Content uploaded by Marek Matejak
Author content
All content in this area was uploaded by Marek Matejak on Jan 27, 2014
Content may be subject to copyright.
Physiolibrary - Modelica library for Physiology
Marek Mateják*, Tomáš Kulhánek*, Jan Šilar*, Pavol Privitzer*, Filip Ježek**, Jiří Kofránek*
*Institute of Pathological Physiology, 1st Faculty of Medicine, Charles University in Prague
U nemocnice 5, Prague 2, 128 53, Czech Republic
**Department of Cybernetics, Faculty of Electrical Engineering, Czech Technical University in
Prague, Technicka 2, Praha 6
marek@matfyz.cz
Abstract
Physiolibrary is a free open-source Modelica library
designed for modeling human physiology. It is ac-
cessible on the Modelica Libraries web page at
https://www.modelica.org/libraries. This library con-
tains basic physical laws governing human physiolo-
gy, usable for cardiovascular circulation, metabolic
processes, nutrient distribution, thermoregulation,
gases transport, electrolyte regulation, water distribu-
tion, hormonal regulation and pharmacological
regulation.
Keywords: Physiolibrary; HumMod; Modelica li-
brary; Physiology; Integrative physiology; System
biology
1 Introduction
Our laboratory have a long tradition building
physiological libraries, starting with the
Matlab/Simulink environment [2]. The origin of this
Modelica Physiolibrary was in the first version of
our HumMod Golem Edition model implementation
[3-6], where it was called HumMod.Library. As the
successors of Guyton's Medical Physiology School
write, the original HumMod model [7] is “The best,
most complete, mathematical model of human phys-
iology ever created” [8].
We are also developing many types of smaller
physiological models for use in medical education
[9-11], so it was essential to separate this library
from our HumMod Modelica implementation. Some
other Modelica models and libraries covering the
biological domain already existed, e.g. [12-17],
which are useful in the process of system modeling
and parameter identification. Especially BioChem
Modelica library, that implements large part of
SBML library in Modelica language [14-18].
Our Physiolibrary contains only carefully-chosen
elementary physiological laws, which are the basis of
more complex physiological processes. For example
from only three type of blocks (ChemicalReaction,
Substance and MolarConservationMass) it is possi-
ble to compose the allosteric transitions [19] or the
Michaelis-Menten equation.
2 Physiology
Physiology is a very progressive discipline, that
examines how the living body works. And it is no
surprise that all processes in the human body are
driven by physical laws of nature. The great chal-
lenge is to marry old empirical experiments with the
“new” physical principles. Many teams and projects
in the word deal with this formalization of physiolo-
gy, for example: Physiome[20], SBML[17, 18],
EuroPhysiome[21], VPH[22], CellML[23] etc. It is
our hope that this library helps this unflagging effort
of physiologists to exactly describe the processes.
2.1 Display units in physiology
Energy in medicine and chemistry has a very long
tradition. One must not be confused by its different
units and definitions. The researcher must be aware
of multiple definitions of calorie, such as the interna-
tional calorie, the 15°C calorie, the thermal calorie or
the Calorie with a capital "C". The origin of this unit
is in the thermal energy needed to heat one gram of
water by one degree Celsius. But because the meas-
urement conditions may differ, these alternative def-
initions are necessary. In physiology it is recom-
mended to use only international calorie as defined
in Table 1. The flow of heat/energy is usually calcu-
lated in kcal/min, but in physics this is called power
and is expressed in the SI unit watts.
Pressure units in medicine are also mainly based
on historical measurements. For many years blood
pressure was measured by the mercury sphygmoma-
nometer, where the pressure is represented by the
change of mercury hydrostatic column height. And
because the scale of units on the column is in milli-
metres the pressure unit is called millimetre of mer-
cury 'mmHg'. There also exists a very small differ-
ence between this unit and torrs. It is caused again by
variance in measurement conditions.
Figure 1, Example parameter dialog for non-SI physio-
logical units. The Dymola environment automatically
converts this user’s non-SI-values to SI-values to en-
sure compatibility with any other Modelica library.
Many physiological processes are based on elec-
trical principles in the human body. The main cause
of this is that each cell has a nonconductive mem-
brane with molecular structures called channels,
through which the fluxes of electrolytes can be pre-
cisely regulated. Even more, the cells use energy
from metabolism to retain a small electric potential
between inside and outside. This view leads to a unit
called equivalents or “eq”. A charge of 1eq, for ex-
ample, has 1mol of sodium cations (Na+). The fluxes
of electrically charged ions can be in meq/min, but in
physics the SI unit ampere is more generally used.
Unit conversion table
(for Modelica environment display-unit setting)
x kcal
=
4186.8*x
J
x kcal/min
=
69.78*x
W
x mmHg
=
133.322387415*x
Pa
x degC
=
273.15 + x
K
x meq
=
96.4853365*x
C
x meq/min
=
1.60808894*x
A
x mosm
=
0.001*x
mol
x litreSTP
=
0.044031617*x
mol
x litreSATP
=
0.040339548*x
mol
x litreNIST
=
0.041571200*x
mol
Table 1, Selected Non-SI units in physiology
Another strange unit describing the amount of
substance is the osmol (“osm”), which has the same
value as the mol, but which highlights the property
that this substance cannot cross the membrane to-
gether with the flux of its solvent.
For gases, it is common to measure the amount as
volume, which for specific measurement conditions
is equivalent to the number of molecules.
The International Union of Pure and Applied Chem-
istry (IUPAC) set this standard condition for temper-
ature and pressure (STP) precisely at 0°C and
100kPa. But other standards exist. For example,
SATP is measured at 25°C and 100kPa, or the stand-
ard measurement condition at the National Institute
of Standards and Technology (NIST), which is 20°C
and 101.325kPa.
2.2 Chemical domains in physiology
In physiology books, chapters about chemical
substances are organized by their types. The main
reason for this is that each substance in the human
body is regulated in a different way. For example the
regulation of sodium is different from the regulation
of potassium, and from the regulation of glucose, and
so on. This view leads to the idea of having separate
models of each substance. The origin of different
flows and regulations is the (cellular) membrane.
Water and solutions can cross it in different direc-
tions at the same time. Crossings occur for different
reasons: water is driven mostly by osmotic gradients,
electrolytes are driven by charge to reach Donnan's
equilibrium, and some solutes can even be actively
transported against their concentration or electrical
gradients. And all this is specifically driven from the
higher levels by neural and hormonal responses.
In Physiolibrary flows and fluxes of solutes are
supported mostly by the Chemical package. All parts
inside this Physiolibrary.Chemical package use the
connector ChemicalPort, which defines the molar
concentration and molar flow/flux rate of one solute.
This is the supporting infrastructure for modeling
membrane diffusion, accumulations of substances,
reversal chemical reactions, Henry's law of gas solu-
bility, dilution with additional solvent flow, mem-
brane reabsorption, chemical degradation and physi-
ological clearance.
For usage examples, please open the Chemi-
cal.Examples package, where the chemical reaction
shown in Fig. 2 is implemented, along with many
other chemical processes.
Figure 2, Example of a chemical reaction: A <-> B + C.
Purple beakers (Substance) accumulate one type of
substance and generate its concentration in port. Block
for chemical reaction (ChemicalReaction) can have
any number of substrates or products with any stoi-
chiometric numbers. In this case there is only one sub-
strate and two products. Purple lines represent chemi-
cal connectors, are composed of molar concentration
and the molar flow of substance.
The graphically-created diagram shown in Fig. 2
generates this Modelica code:
model SimpleReaction2
import Physiolibrary.Chemical.Components.*;
Substance A(solute_start=0.9);
ChemicalReaction reaction(K=1, nP=2);
Substance B(solute_start=0.1);
Substance C(solute_start=0.1);
equation
connect(A.q_out, reaction.substrates[1]);
connect(reaction.products[1], B.q_out);
connect(reaction.products[2], C.q_out);
end SimpleReaction2;
This means that before the numerical simulation
begins, each Substance.solute_start parameter must
be set to some initial amount of substance.
ChemicalReaction.nP must also be configured for
the number of products, and parameter
ChemicalReaction.K must be configured for the dis-
sociation constant of reaction in SI-units (please note
that concentration of 1 mol/m3 = 1 mmol/L). As
mentioned before, the values in text code are in SI-
units, but the Dymola environment support non-SI
units in the parameter dialog of each component.
2.3 Hydraulic domain in physiology
The main usage of the hydraulic domain in hu-
man physiology is modeling of the cardio-vascular
system. And because there are no extreme thermo-
dynamic conditions, the system can be really simple
—it is only necessary to model conditions for in-
compressible water, at normal liquid-water tempera-
tures and with relative pressure 5-20kPa. This boring
thermodynamic state leads to using very simple
blocks of hydraulic resistance, hydrostatic pressure,
volumetric flow, inertia and finally a block repre-
senting blood accumulation in elastic vessels.
2.4 Thermal domain in physiology
For the human body to function optimally, it is
critical to hold the core temperature at 35–39°C. A
fever of 41°C for more than a short period of time
causes brain damage. If the core temperature falls
below 10°C, the heart stops. As in the hydraulic do-
main, the thermal domain is simplified to these con-
ditions.
The Physiolibrary.Thermal package extends the
package Modelica.Thermal.HeatTransfer from
Figure 3, Hydraulic example: the cardiovascular sub-
system of the famous Guyton-Coleman-Granger model
[1]. Yellow circles (ElasticVessel) represent blood ac-
cumulation and pressure generation, rectangles be-
tween them are hydraulic resistances (Resistance) of
blood vessels, blue triangles (Pump) represent a heart
pump driven by the Frank-Starling law. Heart-filling
pressures are determined by the block with the blue
tube icon (PressureMeassure) and a block-rectangle
(Blocks.Factors.Spline) converts filling pressure to
their effect on cardiac output. Black lines connect the
hydraulic connectors (HydraulicPort), which contains
pressure and volumetric flow variables.
Modelica Standard Library 3.2 (MSL), where the
connector is composed of temperature and heat flow.
The main blocks in Physiolibrary.Thermal are: Con-
ductor, IdealRadiator and HeatAccumulation. The
heat conductor conducts the heat from the source,
such us muscles or metabolically active tissue, to its
surrounding. IdealRadiator delivers heat to tissues by
blood circulation. HeatAccumulation plays a role in
accumulating thermal energy in each tissue mass
driven by its heat capacity. We recommend using
this block instead of Modelica.Thermal.HeatTransfer
.HeatCapacitor to allow the possibility of variable
mass amounts, and to have support for calculating
steady state, described in section 2.7.
Figure 4, Example of heat flow from a working muscle.
The muscle is represented by a red beaker
(HeatAccumulation), where heat energy is accumulat-
ed in a mass with defined weight and specific heat.
Heat transfer is processed by blood circulation
(IdealRadiator) with blood flow as its internal parame-
ter. The temperature of blood is set to a fixed value of
37°C to simulate well-regulated core body tempera-
ture.
Figure 5, Basic heat flow model of human body. Heat
production occurs in each tissue via metabolism, or
from warm (to cool) eaten food using the MSL block
with two red arrows (Modelica.Thermal.HeatTransfer.
Sources.FixedHeatFlow). This heat is stored in tissues
(HeatAccumulation) and transferred out by blood
(IdealRadiator) or together with mass (Stream,
HeatOutstream), where the model also integrates va-
porization heat loss. Heat radiation and conduction to
the environment is simplified using an MSL block for
heat conductor (Modelica.Thermal.HeatTransfer.
Components.ThermalConductor).
2.5 Osmotic domain in physiology
One of the basic phenomenon of biological sys-
tems is the osmotically-driven flow of water. This is
always connected with semipermeable membranes.
The different concentrations of impermeable solutes
on both sides of the membrane causes the hydrostatic
pressure at the concentrated side to rise[24]. This
pressure difference is called osmotic pressure. Os-
motic pressure is linearly proportional to the concen-
tration gradient of impermeable solutes. The
osmolarity (osmotic concentration) is also one of the
main indexes of human body balance, called homeo-
stasis. Its value should not significantly deviate for a
long period of time from a value of 285-295mosm/l.
In Physiolibrary the osmotic connector
OsmoticPort is composed of the osmotic concentra-
tion and the volumetric flux of permeable liquid. The
two main blocks are called Membrane and
OsmoticCell. Here, inside the membrane blocks, it is
of course possible to also define hydraulic pressure
and temperatures effects on both sides of membrane.
Figure 6, Osmotic example simulating water transfer
between intracellular and interstitial compartments in
hypertonic or hypotonic conditions.
2.6 Types and units
The most common errors in HumMod Golem
Edition were caused by using bad physical units. The
main problem of medical research, articles, and ex-
periments is using obscure units from medicine,
pharmacology, biology and non-physics disciplines.
The Physiolibrary fulfills the Modelica ideal of
using SI units as the main unit for each variable, and
the previously described physiological units are also
implemented as the displayUnits for each variable.
Using these displayUnits the user sets and sees the
"physiological" values. The implementation can also
be joined to any unit-correct Modelica models and
physical equations without crashing due to unit in-
compatibilities. The unit support of Physiolibrary is
so strong that one can even chose the right unit-typed
“input real”/”output real” from the library package
Types.RealIO or one can use unit-typed constants
(Types.Constants). As can be expected, only the non-
specific package Blocks in the Physiolibrary has var-
iables without units.
2.7 Steady states
One of the main questions in clinical medicine is
how to stabilize the patient. In modeling the oscillat-
ing heart, breathing, circadian rhythm or menstrua-
tion cycle the model can be designed as non-
oscillating, using variables such as period times, am-
plitudes, frequencies, mean values and other phase
space variables. This type of model has better nu-
merical stability for long simulation times, and even
more importantly, it can be "stabilized". This stabili-
zation we call a steady state.
To be mathematically exact, we define a steady
state system (SSS) as a non-differential system de-
rived from an original differential system (DS) by
using zero derivations and by adding additional
steady state equations (ASSE). The number of the
ASSE must be the same as the number of algebrai-
cally dependent equations in the non-differential sys-
tem derived from DS by setting zero derivations. The
ASSE describes the system mostly from the top
view, such as the equations of mass conservation
laws or the boundary equation of environment
sources.
To define a model as an SSS, the user must
switch each Simulation parameter in each block to
the value Types.SimulationType.SteadyState and
must have correctly defined all necessary ASSE.
This setting causes the system to ignore any start
values for any state and add zero derivation equa-
tions instead. There does not currently exist a
Modelica environment which can automatically find
and remove generated dependent equations by this
solution. So the correct number of states must be
marked as dependent (parameter isDependent) and
the same number of ASSE must be inserted. Howev-
er, despite the fact that a model in this steady-state
setting will not be locally balanced, it must be glob-
ally balanced and without any dependent equation.
Figure 7, Steady state system example: equilibrium of
chemical reaction A<->B+C is calculated with two
ASSE. Zero change of reactant A is automatically
propagated through a reaction to both products. So
both products must be marked as dependent (parame-
ter isDependent), and two mass conservation laws
must be added as green square blocks to the right
(MolarConservationLaw). Please note that conserva-
tion laws must be included only after designing the rest
of the system, because they are global properties, not
properties of individual substances or reactions.
Adding an ASSE is possible by inserting and
connecting the energy or mass conservation law
block from package SteadyState.Components. An-
other possibility is using environment sources
blocks, where setting the isIsolatedInSteadyState
parameter adds the equation of the zero
mass/volume/energy flow from or to environment.
The steady state model often changes to one big
nonlinear strong component, but without solver stiff
or convergence problems. Especially in quick chem-
ical kinetics, it is not necessary to have very rapid
molar fluxes, when it always reach equilibrium in the
end. This design is also useful in creating steady-
stated parts in a dynamical model without huge re-
building. It also brings other benefits. To see these
possibilities, one has to realize that conservation
laws could be invariances in a dynamical simulation.
This is really useful for debugging.
For example see the model
SteadyStates.Examples.SimpleReaction2_in_Equilib
rium (Fig.7), which implements the equilibrium of
the closed system from Fig.2 as a solution of three
chemical substances with a simple reversible reac-
tion between them extended by two conservation
laws. Each of these laws describes the total possible
amount of one product in its free form and in its as-
sociated form.
It is always a big challenge to nicely solve initial
values of differential system. However, it should be
possible to solve the SSS in its initial phase. And this
is the idea behind the
Types.SimulationType.InitSteadyState option for
models already extended with ASSE.
2.8 File utilities—input/output manipulations
During the creation and debugging of huge inte-
grated models it is necessary to easily define con-
sistent input, output and test sets of all output varia-
bles for some subsystems. Let's imagine that we have
a model composed only of subsystems that converge
from some constant inputs to constant outputs. It
should be possible to substitute each main subsystem
for its chosen constant output values as parameters.
Comparing the model with these parametric values
and the original subsystem can show the wrong part
of the simulation.
For example in the huge HumMod model it is
necessary to debug smaller parts separately. These
tools could be use, because HumMod is the type of
constant-converged model. Each subsystem in the
first level has the constant input values set for its
output variables. Simulating, for example, the cardi-
ovascular subsystem is possible by creating the high-
level system with the original cardiovascular subsys-
tem, but with a constant metabolic, constant ther-
moregulation, constant hormonal, constant water,
constant proteins, constant gases, constant electro-
lytes and constant status subsystem.
Because the number of output variables for each
subsytem changes during development, it is a good
idea to have only one list for each subsystem. And
generating consistent sets to store, restore, compare
initial and final values is possible by the same pat-
tern as presented in the package Types.Example. In
this package it is also possible to define a customized
way to save and load the variables that connect sub-
systems together. For this purpose, one has to
redeclare the package Types.Utilities with simple
functions for reading and writing values, such as is
done in the default package FileUtilities.
The typical code of a parameter set could be:
model MyParameterSet
replaceable package T = Physiolibrary.Types.RealTypes
constrainedby Physiolibrary.Types.RealTypes;
T.Pressure v1(varName="Bone-Flow.PO2");
T.VolumeFlowRate v2(varName="Bone-Flow.BloodFlow");
T.MolarFlowRate v3(varName="Bone-Metabolism.O2-Need");
T.Volume v4(varName="Bone-Tissue.LiquidVol");
BusConnector busConnector;
equation
connect(v1.y, busConnector.Bone_PO2);
connect(v2.y, busConnector.Bone_BloodFlow);
connect(v3.y, busConnector.Bone_O2Need);
connect(v4.y, busConnector.Bone_LiquidVol);
end MyParameterSet;
To redefine these sets of values to use inputs from
a file is simple. The user just redeclares the type of
the values to type InputParameter and redirects read-
ing functions to FileUtilities:
model InputParameterSet
extends MyParameterSet( T(redeclare block Variable =
Physiolibrary.Types.RealExtension.InputParameter (
redeclare package Utilities = Physiolibrary.Types.FileUtilities)));
end InputParameterSet;
And the same set of values can also be redefined
to file output at the end of the simulation:
model OutputFinalSet
extends MyParameterSet( T(redeclare block Variable =
Physiolibrary.Types.RealExtension.OutputFinal (
redeclare package Utilities = Physiolibrary.Types.FileUtilities)));
end OutputFinalSet;
3 Conclusion
In our opinion the best way to understand this li-
brary is to download it from the Modelica web pages
at www.modelica.org/libraries and examine the ex-
amples. We recommend examining the package
Hydraulica.Examples, which provides an example of
a simplified cardiovascular system; the package
Chemical.Examples, which provides an example of
allosteric hemoglobin oxygen binding; the package
Osmotic.Examples, which simulates cell volume in
hypertonic and hypotonic environments; and finally
the package Thermal.Examples, which simulates the
heating of circulated blood inside active muscles.
Acknowledgements
This paper describes the outcome of research that has
been accomplished as part of a research program
funded by the Ministry of Industry and Trade of the
Czech Republic by the grant FR—TI3/869 and by
The Ministry of Education, Youth and Sports by the
grant SVV-2013-266509.
In addition, the main author wants to thank Jan
Obdržálek for consultations about physical units, and
Austin Schaefer for English language editing.
References
[1] Guyton, A.C., T.G. Coleman, and H.J. Granger,
Circulation: overall regulation. Annual review
of physiology, 1972. 34(1): p. 13-44.
[2] Teaching, L.o.B.a.C.A. Physiolibrary in Matlab
and Simuling. 2008; Available from:
http://www.physiome.cz/simchips.
[3] Marek Mateják and J. Kofránek, HUMMOD–
GOLEM EDITION–ROZSÁHLÝ MODEL
FYZIOLOGICKÝCH SYSTÉMŮ Medsoft,
2011: p. 182-196.
[4] Marek Mateják and J. Kofránek, Rozsáhlý model
fyziologických regulací v Modelice. Medsoft,
2010: p. 126-146.
[5] Kofránek, J., M. Mateják, and P. Privitzer.
HumMod - large scale physiological model in
Modelica. in 8th. International Modelica
conference. 2011. Dresden, Germany.
[6] Kofránek, J., Mateják, M., Privitzer, P., Tribula,
M., Kulhánek, T., Šilar, J., Pecinovský, R.
HumMod-Golem Edition: large scale model of
integrative physiology for virtual patient
simulators. in World Congress in Computer
Science 2013 (WORLDCOMP'13), International
Conference on Modeling, Simulation and
Visualisation Methods (MSV'13). 2013.
[7] Hester, R.L., et al., HumMod: a modeling
environment for the simulation of integrative
human physiology. Frontiers in physiology, 2011.
2.
[8] Center, L.b.U.o.M.M., HumMod. 2012: p.
http://hummod.org/.
[9] Kofránek, J., M. Mateják, and P. Privitzer.
Leaving toil to machines - building simulation
kernel of educational software in modern
software environments. in Mefanet 2009. 2009.
Masaryk University, Brno.
[10] Kofránek, J., M. Mateják, and P. Privitzer, Web
simulator creation technology. MEFANET
report, 2010. 3: p. 52-97.
[11] Kofranek, J., et al., The Atlas of Physiology and
Pathophysiology: Web-based multimedia enabled
interactive simulations. Computer methods and
programs in biomedicine, 2011. 104(2): p. 143-
153.
[12] Proß, S. and B. Bachmann, An Advanced
Environment for Hybrid Modeling and
Parameter Identification of Biological Systems.
[13] Cellier, F.E. and A. Nebot. Object-oriented
Modeling in the Service of Medicine. in Proc. 6th
Asia Simulation Conference. 2005.
[14] Larsdotter Nilsson, E. and P. Fritzson. BioChem-
A Biological and Chemical Library for Modelica.
in Proceedings of the 3rd International Modelica
Conference (November 3-4, Linköping, Sweden).
2003. Modelica Assocation.
[15] Nilsson, E.L. and P. Fritzson, Biochemical and
metabolic modeling and simulation with
Modelica. BioMedSim. Linköping, Sweden,
2005.
[16] Nilsson, E.L. and P. Fritzson. A Metabolic
Specialization of a General Purpose Modelica
Library for Biological and Biochemical Systems.
in Paper presented at the 4th International
Modelica Conference. 2005.
[17] Brugård, J., et al. Creating a Bridge between
Modelica and the Systems Biology Community. in
7th International Modelica Conference, Como,
Italy. 2009.
[18] Hucka, M., et al., The systems biology markup
language (SBML): a medium for representation
and exchange of biochemical network models.
Bioinformatics, 2003. 19(4): p. 524-531.
[19] Monod, J., J. Wyman, and J.-P. Changeux, On
the nature of allosteric transitions: a plausible
model. Journal of Molecular Biology, 1965.
12(1): p. 88-118.
[20] Bassingthwaighte, J.B., Strategies for the
physiome project. Annals of Biomedical
Engineering, 2000. 28(8): p. 1043-1058.
[21] Fenner, J.W., et al., The EuroPhysiome, STEP
and a roadmap for the virtual physiological
human. Philosophical Transactions of the Royal
Society A: Mathematical, Physical and
Engineering Sciences, 2008. 366(1878): p. 2979-
2999.
[22] Hunter, P.J. and M. Viceconti, The VPH-
physiome project: standards and tools for
multiscale modeling in clinical applications.
Biomedical Engineering, IEEE Reviews in, 2009.
2: p. 40-53.
[23] Smith, L., et al., SBML and CellML translation in
Antimony and JSim. Bioinformatics, 2013: p.
btt641.
[24] Mortimer, R.G., Mathematics for physical
chemistry. 1999: Access Online via Elsevier.