Content uploaded by Marek Matejak
Author content
All content in this area was uploaded by Marek Matejak on Oct 11, 2023
Content may be subject to copyright.
Creating cardiovascular and respiratory
models using Physiolibrary 3.0
Marek Mateják1,2
1Institute for Clinical and Experimental Medicine, Czech,
marek.matejak@ikem.cz
2First medical faculty, Charles University in Prague, Czech,
marek.matejak@lf1.cuni.cz
Abstract
The free open-source Physiolibrary version 3.0
(https://github.com/MarekMatejak/Physiolibrary) has
transformed components from physiological domains
such as hydraulic (cardiovascular), thermal, osmotic, and
chemical into the Modelica Standard Library (MSL)
concept of Fluid/Media and Chemical library.
Components are extended to include gas transports, acids-
bases, electrolytes, nutrient delivery, and endocrines by
simply selecting pre-made media. They can be connected
directly (same medium) or across membranes (different
media), allowing small physiological models to be
integrated into more quantitative models with minimal
effort.
Keywords: physiology modelling, physiological
simulation, quantitative physiology, physiological model,
cardiovascular, respiratory, physiolib, physiolibrary,
physiomodel, systems biology, medical simulation
1 Introduction
Earlier versions of Physiolibrary (Mateják et al. 2014)
mainly contain components for individual domains, e.g.,
hydraulic, osmotic, chemical, and thermal resistances.
These components were defined to implement large
integrative models such as Physiomodel (Mateják and
Kofránek 2015). The hydraulic domain was not suitable
for gas transport. The osmotic domain was inaccurate and
difficult to connect with the chemical domain of protein
distributions and electrolytes. The first version of the
chemical domain was controlled by concentration
gradients instead of electrochemical potentials (Mateják
2015). It was difficult for the user to implement obvious
interactions between the domains. We addressed all these
problems and proposed solutions. The result is that
version 3.0 of Physiolibrary allows the use of standard
Modelica Fluid Connectors (Casella et al. 2006) and
electrochemical connectors for cross-compartment
transport of substances (Mateják et al. 2015). Fluid
connectors transport media such as blood, air, interstitial
fluid, intracellular fluid. Drag-and-drop connections of
these connectors define equations for pressures, mass
flows, heat flows and mass fractions of substances
between components. Electrochemical connections lead
via free base substance forms. For example, the total mass
fraction of carbon dioxide is represented as part of the
composition of blood in fluid connector, but free dissolved
carbon dioxide in blood plasma or bicarbonate in blood
plasma are its electrochemical connectors proposed to
model the electrochemical CO2 fluxes. Since the selected
forms are precisely determined by the composition of the
blood, it is not necessary to store them and pass them
through the fluid connector. They are only expressed and
calculated when needed.
2 Methods
2.1 SI units
In medicine, many obscure units are still in use such as
mmHg (millimeters of mercury), cmH2O (centimeters of
water) for pressure, calories for energy, chemical
equivalents for electric charge, degrees Celsius for
temperature, and so on. Modelica allows you to define
these as display units. This means that it is possible to
output graphs in the selected units or even set values in
parametric dialogs in these selected units. However, the
variables within the model in SI units explain the
compatibility between all components and models. Also,
the selection of zero offset is better for use within
connectors and state variables, since, for example,
absolute pressure is well defined, as opposed to relative
pressure in circuits with heterogeneous environments that
have different pressures. To see nice pressure values, it is
necessary to use a pressure sensor instead of looking at
the variables of the connector “p”. Even if the user wants
to create a small physiological model, it is much better to
achieve these interfaces because they allow others to
easily reuse it without modifications or adapters.
2.2 State and connector variables
For gaseous substances, volume changes with pressure
and temperature, so it is always better to use mass and
mass flows instead of volume and volume flows. And, of
course, volumes can always be evaluated by including
pressures, temperatures, and the composition of the
medium with known masses. For the same reason, it is
better to use mass fractions of substances instead of
volume fractions, concentrations, molalities, molarities,
or even mole fractions for the compositional state of the
medium. The molar quantities may change due to
chemical binding (e.g., to a transporter protein), but the
mass of the substance change only with external flows. If
the state of the medium is known, all these quantities can
be evaluated for output or parametric purposes.
2.3 Elastic vessels
One of the most important components in Physiolibrary
3.0 is Fluid.ElasticVessel. It accumulates the mass of the
medium, e.g. blood, air, lymph, interstitial fluid,
intracellular fluid. From the accumulated mass, heat and
substances, volume, pressure, temperature, concentrations
and other properties of the accumulated medium are
expressed. In addition if the user use chemical substances
connectors, special equations are included as
Medium.ChemicalSolution model. In this case,
electrochemical potentials and enthalpies are expressed to
allow passive and active transport, for example, through
the alveolar membrane, the capillary membrane, the cell
membrane or the CSF membrane. Electrochemical
processes and their calculation (Mateják 2015) are from
the chemical library (Mateják et al. 2015). Here osmotic
transport is the result of balancing the chemical potential
of water. Similarly, Donnan’s equilibrium (Donnan 1911)
is the result of balancing the electrochemical potentials of
electrolytes (Atkins and De Paula 2011) at a
semipermeable membrane. And also, active transport or
signal transduction can be modeled as electrochemical
reactions involving membrane proteins.
2.4 Medium
Physiolibrary 3.0 defines examples for the following
media:
Water – as pure incompressible water with constant heat
capacity without any substance inside
Air – as an ideal gas model with oxygen, carbon dioxide,
nitrogen and water
Blood – as an incompressible fluid containing many
physiological substances such as blood gases,
electrolytes, red cells, nutrients, proteins and hormones.
Thanks to the shift of numerical tolerances with
predefined nominal values for each substance, the
calculation is numerically stable, even if the ratio between
the mass fractions of substances is 10^9 (e.g. mass
fraction of water / mass fraction of thyrotropin). Blood
contains equations for haemoglobin oxygen saturation,
acid-base balance, and carbon dioxide transfers to achieve
physiological conditions in the transport of blood gases
under variable conditions (Mateják, Kulhánek, and
Matoušek 2015).
BodyFluid – as an incompressible fluid that simplifies
other physiological fluids such as interstitial fluid,
intracellular fluid, cerebrospinal fluid, or urine. In
Physiolibrary 3.0 this medium represents only a
homogeneous chemical solution without special transfers
or binding of substances inside.
3 Results
3.1 Blood gases interface
The library has prepared a blood medium containing the
dissociation model of common gasses such as oxygen,
carbon dioxide, and carbon monoxide (Siggaard-
Andersen 1971; Siggaard-Andersen and Siggaard-
Andersen 1990; SIGGAARD-ANDERSEN and
SIGGAARD-ANDERSEN 1995). With this model, we
can build a gas transport between air and blood. First, we
add a component ElasticVessel from the
Fluid.Components package. ElasticVessel is a container
for the medium in which blood accumulates oxygen and
carbon dioxide. It contains dynamic calculation of blood
volume, blood temperature, blood pressure, blood
composition and other blood properties. In the parameter
dialog we set blood from the Media package as the
medium in this component. This will link the equations
and properties of the medium to the model of this
component. As initialization we can set normal predefined
arterial blood by setting the massFractions_start
parameter to predefined values Blood.ArterialDefault.
Then we check the useSubstances checkbox to enable the
connectors with free blood substances and the complex
model of these substances in them. The bundle of
substance connectors is located on the left side of the icon.
Now we can handle a freely dissolved basic chemical
substance defined in the medium. “Free dissolved” means
that the substance connector contains chemical potential
and flows only for unbound molecules. And “basic"
means that this molecule is not connected in a cluster with
other molecules. For example, H2O molecules are
connected by hydrogen bonds, so water in these chemical
compounds is represented only by the chemical potential
and molar flux of the free, unbound H2O molecules. The
clusters and bonds can nevertheless be calculated
internally if needed (Mateják and Kofránek 2020).
The next component type we use in this model is
“GasSolubility” from the “Chemical.Components”
package. It represents the chemical processes of gas-
liquid solubility for the selected gas molecule.
To define the air source of gas substances, we can use
ExternalIdealGasSubstance from the Chemical.Sources
package. Here in the listbox of the parameter dialog we
should be able to set „O2(g)“ or "CO2(g)“ or “CO(g)”.
Then we can define a very small partial pressure of
oxygen (1 mmHg) together with a typical partial pressure
of carbon dioxide (40 mmHg) and a very small partial
pressure for carbon monoxide (1e-6 mmHg). This settings
cause that the blood is losing the oxygen during
simulation.
Figure 1. Selected Physiolibrary components: ElasticVesel,
GasSolubility, ExternalGasSubstance, System
The standard Modelica.Fluid.System component is used
to pass on ambient pressure, temperature (37°C), and
gravity acceleration. The parameters of this component
are accessible throughout the model.
After we have defined all the components of the model,
we can connect them.
Figure 2. Model of blood gases
To see the current values of the model, it is a good practice
to use sensors. These components do not affect other
values of the model here, but they represent the initial
values in the expected form. To measure the oxygen
saturation in blood, we can use the Fraction sensor from
the Fluid.Sensors package. As parameterization of this
component, we need to specify the media model and the
name of the predefined fraction function in the medium.
Figure 3. Fraction sensor parameterized for measurement of
oxygen saturation in blood
We can define a similar measurement for blood oxygen
partial pressure by using the PartialPressure component
from the Fluid.Sensors package. During parameterization
we have to select the state of matter and the substance
definition in the similar way.
The entire model with all source codes is accessible in one
of the examples within the library as
Fluid.Examples.BloodGasesEquilibrium.
If we run a simulation of this model, we can see the
dynamic oxygen-haemoglobin dissociation
(Severinghaus 1979) as a relationship between oxygen
saturation and oxygen patrial pressure in blood.
Figure 4. Result of the simulation as oxygen saturation curve
3.2 Respiratory unit
Physiolibrary has some predefined models of organs or
their functional units composed of components of the base
library. One of these components is RespiratoryUnit in the
Organs.Lungs.Components package. For gas transport
between the air and the blood, the same basic components
are used as in the previous model.
Figure 5. RespiratoryUnit component
The parameterization of the RespiratoryUnit is divided
into ventilation, blood perfusion and diffusion of gases
through the capillary and alveolar membrane.
Ventilation parameters are based on the physiological
characteristics of the lungs, such as functional residual
capacity (the volume of air remaining after a normal
passive expiration), residual volume (the volume of air
remaining after full expiration), total capacity (the volume
of air remaining after full inspiration), base tidal volume
(inhaled/exhaled volume during a normal breath), total
compliance, initial air volume, and initial air composition.
Perfusion settings are based on blood and vessel
parameters such as blood model, initial blood volume,
initial blood composition, ZeroPressureVolume
(maximum blood volume in vessels that does not generate
pressure), vessel compliance, and vessel conductance.
The RespiratoryUnit can be connected to the respiratory
muscles via chest, where a negative or even a positive
external pressure is generated by respiratory muscles. The
medium of this compartment can be chosen as pleural
fluid. This compartment should have a non-zero internal
space (lung volume) that can collapse below the relaxed
volume. Thus, the current volume of respiratory units can
be related to the internal space of the chest, and the
external pressure is transmitted from the muscles to the
lungs through the pleural cavity (where it is displaced by
the internal space). This pattern is illustrated by the
examples SimpleRespiration and Respiration in the
package Fluid.Examples.
3.3 Tissue unit
To demonstrate oxygen consumption and carbon dioxide
production in body tissue metabolism, we can define a
TissueUnit. This unit does not solve hypoxic situations,
but it can be used for normal body conditions. Here,
oxygen consumption (e.g., 15mmol/min) and carbon
dioxide production (e.g., 12mmol/min) are constant
parameters during simulations propagated by
SubstanceOutflow and SubstanceInflow components
from the Chemical.Sources package. Blood is connected
from systemic arteries to systemic veins via tissue
capillaries, using typical connections for modeling the
cardiovascular system (Kulhánek, Kofránek, and Mateják
2014).
Figure 7. Diagram of simple tissue unit
3.4 Simple respiratory-cardiovascular model
If you combine all these principles, you can create a model
of respiration, blood circulation and blood-gas transport.
Non-medical users usually focus on oscillatory models, as
presented in the examples
MeursModel2011.HemodynamicsMeurs_flatNorm or
Respiration in the Fluid.Examples package. However,
precise non-oscillatory models can also be defined for
long-term physiological simulations. Oscillation from
breath to breath or even from heartbeat to heartbeat does
not affect the calculated mean values that are
physiologically significant (e.g. mean pressure, cardiac
output, heart rate, respiratory volume, respiratory rate,
etc.). Therefore, it is good practice in medical physiology
to define non-oscillatory long-term cardiovascular and
respiratory models (Hester et al. 2011).
A non-oscillatory respiratory model can be defined by the
same RespiratoryUnit as the oscillatory one. However, the
connection of the respiratory tract must be defined by a
separate air inflow and outflow. And the dead space
should be defined in parallel connection. Similarly, the
pulmonary shunt (where the blood of the pulmonary
circulation does not flow through the ventilated alveoli)
should be defined in parallel connection with the blood
perfusion in the RespiratoryUnits.
The non-oscillating cardiovascular model is based on non-
oscillating pumps representing the right and left heart
delivering cardiac output to the bloodstream.
Figure 6. Parameterization of ventilation in dialog of the RespiratoryUnit component
Figure 8. Respiratory-cardiovascular example
Figure 9. Results of respiratory-cardiovascular example
4 Discussion
The models presented are only examples of the use of the
library. The components of the Physiolibrary are general
enough to be included in more specific or/and more
complex models. Today version of the blood medium is
designed for the transport of blood gases, but our goal is
to make it general for the transport of physiological
substances. Using the nominals, even hormones and
endocrines (physiologically active substances in very low
concentrations) can be solved numerically in the same
way. With chemical processes such as passive and active
transport or signal transmission, more complex models of
tissues and organs can be defined. If we connect tissues
and organs, we can easily create a model of the whole
body (Mateják and Kofránek 2015). With specific bodies,
we can virtually transplant organs from one body to
another and so on. With the non-oscillation approach, we
can even simulate years of life or perhaps one day even
the whole life of an organism.
This kind of mathematical modelling leads to virtual
experiments that could improve experiments before using
animals or humans. This minimalizes number of iteration
and changes in experimental conditions, which can
improve the quality of research and shorten research time.
And it could also be a platform for sharing results in the
form of well-defined and structured models.
-
Acknowledgements
The author would like to thank Jiří Kofránek for phone
consultation and all the sponsors of
https://github.com/sponsors/MarekMatejak for additional
support.
References
Atkins, Peter, and Julio De Paula. 2011. Physical
Chemistry for the Life Sciences. Oxford University
Press, USA.
Donnan, F. G. 1911. “Theorie Der
Membrangleichgewichte Und
Membranpotentiale Bei Vorhandensein von
Nicht Dialysierenden Elektrolyten. Ein Beitrag
Zur Physikalisch-Chemischen Physiologie.”
Zeitschrift Für Elektrochemie Und Angewandte
Physikalische Chemie 17: 572–81.
https://doi.org/10.1002/bbpc.19110171405.
Hester, Robert L., Alison J. Brown, Leland Husband, Radu
Iliescu, Drew Pruett, Richard Summers, and
Thomas G. Coleman. 2011. “HumMod: A
Modeling Environment for the Simulation of
Integrative Human Physiology.” Frontiers in
Physiology 2.
Kulhánek, Tomáš, Jiří Kofránek, and Marek Mateják.
2014. “Modeling of Short-Term Mechanism of
0
10
20
30
40
80
120
Ti me [mi n]
venous.pO2
arteria l.pO2
respiratoryUni t[1].alve olar.pO2
0
10
20
30
60
80
100
Ti me [mi n]
venou s.sO2
arterial .sO2
respiratoryUnit [1].alveo lar.sO2
0
10
20
30
40
50
Ti me [mi n]
venou s.pCO2
arteria l.pCO2
respiratoryUni t[1].alve olar.pCO2
0
10
20
30
7.32
7.36
7.40
Ti me [mi n]
venou s.pH
arterial .pH
respiratoryUnit [1].alveo lar.pH
Arterial Pressure Control in the Cardiovascular
System: Object-Oriented and Acausal
Approach.” Computers in Biology and Medicine
54: 137–44.
Mateják, Marek. 2015. “Formalization of Integrative
Physiology.” Dissertation Thesis, Charles
University in Prague.
Mateják, Marek, and Jiří Kofránek. 2015. “Physiomodel-
an Integrative Physiology in Modelica.” In 2015
37th Annual International Conference of the IEEE
Engineering in Medicine and Biology Society
(EMBC), 1464–67. IEEE.
Mateják, Marek, and Jiří Kofránek. 2020. “Molar Amount
of Water.” Medsoft 32 (1): 59.
Mateják, Marek, Tomáš Kulhánek, and Stanislav
Matoušek. 2015. “Adair-Based Hemoglobin
Equilibrium with Oxygen, Carbon Dioxide and
Hydrogen Ion Activity.” Scandinavian Journal of
Clinical & Laboratory Investigation 75 (2): 113–
20.
https://doi.org/10.3109/00365513.2014.98432
0.
Mateják, Marek, Martin Tribula, Filip Ježek, and Jiří
Kofránek. 2015. “Free Modelica Library of
Chemical and Electrochemical Processes.” In
11th International Modelica Conference,
Versailles, France, 118:359–66. Linköping
University Electronic Press, Linköpings
universitet.
SIGGAARD-ANDERSEN, MADS, and Ole SIGGAARD-
ANDERSEN. 1995. “Oxygen Status Algorithm,
Version 3, with Some Applications.” Acta
Anaesthesiologica Scandinavica 39: 13–20.
Siggaard-Andersen, O. 1971. “Oxygen-Linked Hydrogen
Ion Binding of Human Hemoglobin. Effects of
Carbon Dioxide and 2, 3-Diphosphoglycerate I.
Studies on Erythrolysate.” Scandinavian Journal
of Clinical & Laboratory Investigation 27 (4):
351–60.
Siggaard-Andersen, O., and M. Siggaard-Andersen. 1990.
“The Oxygen Status Algorithm: A Computer
Program for Calculating and Displaying PH and
Blood Gas Data.” Scandinavian Journal of Clinical
& Laboratory Investigation 50 (S203): 29–45.