modelica – a language for integrative and system ...physiome.cz/modelica.pdf · in 1972, arthur...
TRANSCRIPT
Modelica – a language for integrative and system physiology modelling
Jiří Kofránek1,*, Marek Mateják1, Filip Ježek1, Jan Šilar1
1Institute of Pathophysiology, First Faculty of Medicine, Charles University, Prague, U Nemocnice 5, 128 53 Praha 2, Czech Republic
*Correspondence to: Jiří Kofránek; email: [email protected]
ABSTRACTThe integrative model of human physiology connects individual physiological subsystems into a single unit. They are enormous (contain thousands of variables) and represent a formalized description of in-terconnected physiological regulations. The issue of formalization of physiological systems became part of a series of international projects (e.g. the worldwide program PHYSIOME, or the European program VIRTUAL PHYSIOLOGICAL HUMAN). The development of large-scale models of human physiolo-gy was facilitated by a new (i.e. equation-based) generation of simulation environments, especially by the Modelica language. Fundamental innovation is the possibility to describe individual parts of the mo-del as a system of equations directly describing the behavior of that part and not the algorithm of solving of these equations. The connection of these equation-based principles with object-oriented principles makes Modelica a great language for the huge systems that are typical in integrative and system physio-logy. Unlike block-oriented causal modelling languages (e.g. Simulink) where the structure of connec-tions among hierarchical blocks represents rather the computation process instead of the modelled re-ality, the structure of models in Modelica shows the structure of the modelled reality. These advantages are demonstrated in practice by our implementation of the large integrative model of human physiology “HumMod”, which we reimplemented (modified and expanded) in the acausal environment of the Mo-delica language. Our implementation of this model in Modelica has brought a much clearer description of the simulated complex physiological relationships than the original block oriented implementation.
KEYWORDSsimulation; integrative physiology; system physiology; modelling languages; block-oriented modelling; causal modelling; acausal modelling; Modelica
1 Introduction – a web of physiological regulations
In 1972, Arthur Guyton with two coauthors published an article 1 in the journal Annual Review of Physiology, whose form quite surpassed the usual forms of physiolog-ical articles of those times at the very first sight. An exten-sive diagram, slightly resembling some kind of a complex electronic circuit, enclosed as an attachment, was used as an introduction, showing interconnection of essential subsystems that have an effect on circulation, by means of special symbols expressing mathematical operations (addi-tion, subtraction, multiplication, division, integration and functional dependencies). The connections of the elements thus represented mathematical equations (Fig. 1). The actual description of the model in the article was mostly
represented by the elementary (but fully illustrative) draw-ing. Comments on and reasons for the formulation of the mathematical relations were very brief. In this entirely new manner, using graphically represented mathematical sym-bols, the authors described the physiological regulations of the circulatory system and its broader physiological relations and links with the other subsystems in the body (Fig. 2). This graphic scheme of Guyton was thus one of the first mathematical descriptions of mutually connect-ed physiological systems in the organism and it initiated development of physiological research, described today as “integrative physiology”.
Guyton’s model also served as inspiration and a re-source for the development of complex models of physio-logical regulation systems used to explain causal chains of reactions in the organism to various stimuli and to under-stand the development of various pathological conditions. Guyton’s disciples and followers have expanded the model
Multiplier
Divider
Functional block
Integrator
PCP
PPA PLA
PCP=0.55 PLA+0.45 PPA
++
-
Summator
-40
20
50
Figure 1. Individual elements in the block diagram of Guyton’s model represent mathematical operations, the interconnection of elements represents equations in a graphically expressed mathematical model
Circulatorydynamics
kidney
thirst
ADH control
vascularstress
relaxation
muscleblood flowand PO2
non-musclesoxygen delivery
non-musclesblood flow
autonomiccontrol
heart rate, strokevolume
pulmonarydynamics
red cells, viscosity
hearthypertrophy
tissuefluids,
pressures, gel
electrolytes& cell water
aldosteronecontrol
angiotensincontrol
capillarymembranedynamics
Figure 2. Individual interconnected subsystems in Guyton’s model.
1
with an integrated connection of all important physiolog-ical systems 2. The latest result called HumMod represents today’s most comprehensive and largest model of integrat-ed physiological functions. Modelling is closely related to formalization – i.e. re-placement of verbal description of physiological sys-tems with the exact language of mathematics in the form of a mathematical model. Given the complexity of biological systems, the process of formalization is delayed in biological and medical sciences compared to physics, chemistry or technical sciences.
Currently, the international project “PHYSIOME” (http://www.physiome.org) is focused on the formalized description of physiological systems; this project is the successor of the “GENOME” project, which resulted in a detailed description of the human genome. The aim of the “PHYSIOME” project is to develop a formalized descrip-tion of physiological functions. Computer models are used as the methodical tool 3–7. “VIRTUAL PHYSIOLOGICAL HUMAN” (http://www.vph-institute.org) is a European
initiative in this field, focused on applications of the for-malized approach to human physiology in clinical medi-cine, among other things 8.
Current situation is different.Today, there are specialized software simulation envi-
ronments available for the development, debugging and verification of simulation models, which allow creating a model in graphical form and then testing its behavior. One of these is the Matlab/Simulink development environment by Mathworks, which allows building a simulation mod-el gradually from individual components – types of soft-ware simulation elements that are interconnected using a computer mouse to form simulation networks 9. Simulink blocks are very similar to the elements used by Guyton for the formalized representation of physiological relations. The only difference is in their graphical form (see Fig. 3).
This similarity inspired us to use Simulink to revive Guyton’s classic graphics diagram and transform it into a working simulation model. However, this scheme was not flawless 10 – these easily detectable “graphic typing errors“ (switched signs, shifted connectors) had an effect on the model functionality because the entire scheme was created only as an illustration and not as the source code of the model (programmed in Fortran). The picture itself was a part of the PhD thesis of a co-author of the Guyton’s ar-ticle, Thomas Coleman, and today, it can be find as a cer-tain scientific relic in a display case of the Guyton’s research center at the University of Mississippi.
2 Methods - development tools for integrative models
2.1 Simulation chips in block-oriented languages
Simulink belongs to so called block-oriented simulation languages, which utilize connected blocks. Signals “flow“ through the connecting lines between individual blocks and transfer the values of individual variables from an out-put of one block to inputs of other blocks. Input informa-
MultiplierDivider
Summator Integrator
Guyton
Simulink
Functional block
s1
Guyton
Simulink
Guyton
Simulink
GuytonSimulink-4
0
20
50-40
20
50
Simulink
++ -
++ -
Guyton
Figure 3. Appearance of blocks in Guyton’s original graphical nota-tion and in Simulink.
BEINV
ee°" . e ... E><oo•"":;:�;::;;:�.�:;:,g
�::1
���:�•d
SOZ37-oxyt,omoglobinH!ur<llion [o,q:,, .... o., ••hofo,mOto 11
PC0237- pC02 �ON! In blood •137 "C
.>.Hb -oooffioionlldorindfrom homogloblnoonconb•tlon
8E·blood euoe-.,(mmoLII)
�C03<t-<l•nda<d blo•rbot,<fto oonoonh<ltion(mmoLIII
�-------------+-�=---+lPCOlJ7 oon:i;:i,�h°:':�:�:·:o:���1:0
1 ::%00
AHb·«>tffiolontdt<hlodl,om oonoont,nionofhomoglobin in blood
SOW SOZ11-0><JhomoglobinHtur.tion37"C (oxp ,..,.d.,,.tioto,m0to1)
POZ37-p02(t,>r�ln blood •137 "C
02-blood02oon1on! lt><PIUstd ln lC02 STPO}'I]
PCOZ11 · pC02 �o,� In blood .t37 "C S0237-oxytiomoglobl••.t•••hon
��;·�::::;i.i;,,,1
:-:;�,i-.,;1
����---+i,pHJ7 C02-bloodC020<>nton1 (.xi,,.,...dinlC02STPM)
SIMULATION CHIP: BLOOD ACID BASE BALANCE
Figure 4. An example of a “simulation chip” (here representing the simulation model that is the basis for the GOLEM simulator (Kofránek et al., 2001)). Its behavior can be tested easily in the Simulink environment – input values (or value patterns) can be fed to the “input pins” and outputs or the time behavior of outputs can be read out from the “output pins” by means of virtual displays or oscilloscopes. Simulation chips are arranged hierarchically. Each chip is usually dynamically linked with the appropriate documentation page including a factual description of chip’s function, including a description of the mathematical relations that constitute its basis.
2
tion is processed in the blocks to obtain output informa-tion. The connections among individual blocks show how the values of individual variables are calculated – i.e. the algorithm of the computation.
A Simulink network can be arranged hierarchically. Blocks can be grouped into subsystems that communicate with their ambient environment through defined input and output “pins”, making “simulation chips” of a sort. A sim-ulation chip hides the simulation network structure from the user, comparable to an electronic chip hiding the in-terconnection of transistors and other electronic elements. Then the user can be concerned only with the behavior of the chip and does not have to bother about the inter-nal structure and calculation algorithm. The behaviour of a simulation chip can be tested by monitoring its outputs using virtual displays or virtual oscilloscopes connected to it. This is very useful especially for testing the behavior of
a model and expressing the mutual relations of variables.The entire complex model can be then visualized as in-
terconnected simulation chips and the structure of their interconnection clearly shows what effects are taken into account in the model, and how (Figs. 4).
This is very useful for interdisciplinary collaboration – especially in borderline fields such as biomedical system modelling 11. An experimental physiologist does not have to examine the details of mathematical relations hidden “inside” a simulation chip; however, from the mutual in-terconnection of simulation chips they will understand the model structure and will be able to check its behavior in the appropriate simulation visualization environment.
Simulation chips can be stored in libraries and users can create their instances for use in their models. In the past, we used Simulink to create a freely available library of blocks for the modelling of physiological systems (http://www.physiome.cz/simchips), which also includes the source code of an integrated model of physiological systems used as a source for our teaching simulator Golem 11,12.
Block-oriented simulation languages provided a con-siderable simplification of implementation of simulation models. Hierarchical, block-oriented simulation tools are thus used advantageously in the description of the complex regulation systems that we have in physiology.
Several block-oriented simulation tools developed un-der the PHYSIOME project have been used as a reference database for a formalized description of the structure of complex physiological models. These include JSIM (http://www.physiome.org/model/doku.php) 13 and CEllML (http://www.cellml.org) 14–17.
2.2 Disadvantages of block-oriented simulation languages
Blocks in block-oriented languages have a hierarchical structure. On the lowest level, the blocks are created as a network of interconnected numeric blocks that use input values to calculate output values (Fig. 5). The connections among the numeric blocks represent a solution of math-ematical equations of the model designed so that output values are calculated from input values.
However, the connection of blocks in the network of re-lationships cannot be arbitrary. No algebraic loops may oc-cur in the connected elements – i.e. cyclic structures where an input value brought to the input of a computing block depends in the same time step (through several intermedi-ators) on the output value of the same block.
Development environments of block-oriented languag-es provide tools to avoid algebraic loops; however, their use often results in transformations that may the model struc-ture less clear.
However, the main problem of block-oriented languag-es is that the simulation network composed of hierarchi-cally connected blocks shows a graphic representation of a chain of transformations of input values to output values, meaning that when the model is designed, an exact com-putational algorithm must be defined from input to output values of the model.
ano XCO3
1Outputs
vTW
yURI
GFR
yMNI
vEC
ZUR 0
ZMNE 0
zUR
xURE
yURU
zMNE
xMNE
yMNU
UREA AND MANNITOL BALANCE
INPUTS: vTW - total body fluid volume [l]
yURI - intake rate of urea [mEq/min] GFR - glomerular filtration rate [l/min]
yMNI - intake rate of mannitol [mEq/min] vEC - ECF volume [l]
OUTPUTS: zUR - total body-fluid urea content [mEq] xURE - ECF urea concentration [mEq/l]
yURU - renal excretion rate of urea [mEq/min] zMNE - ECF mannitol content [mEq]
xMNE - ECF mannitol concentration [mEq] yMNU - renal excretion rate of mannitol [mEq/min]
21.8.2001
Urea and Mannitol Balance
UU(E)
Selector
Scope9Scope8
Scope7
Scope6
Scope5 Scope4
Scope3
Scope2
Scope18Scope17
Scope16
Scope15
Scope14Scope13
Scope12
Scope11Scope10
Scope1
Scope
VA0
pO2A
pCO2A
pHA
AH
VA
RESPIRATION CONTROL
INPUTS: VA0 - normal value of alveolar ventilation [l BTPS/min]
pO2A - O2 partial pressure in alveoli [Torr] pCO2A - CO2 partial pressure in alveoli Torr]
pHA - arterial blood pH AH - concentration of hydrogen ions in arterial blood [nM/l]
OUTPUTS: VA - alveolar ventilation [l BTPS/min]
4.10.2001
Respiration Control
TPHA1
PHA
yORG
yPO4
yTA0
ALD
TPHU2
TPHU1
yNH40
qWU
pCO2A
GFR
xCO3
PHA 0
PHU2 0
PHU1 0
STPG
yTA
yTA1
PHU
yNH4
yCO3
yCO3R
RENAL ACID BASE CONTROL
INPUTS: TPHA1 - Time constant of titratable acid [1/min]
PHA - arterial pH yORG - Renal excretion rate of organic acid [mEq/min] yPO4 - Renal excretion rate of phosphate [mEq/min]
yTA0 - Normal value of renal excretion rate of titratable acid [mmol/min] ALD - Aldosterone effect [x normal]
TPHU1 - Time constant of ammonium secretion [1/min] TPHU2 - Time constant of titratable acids secretion [1/min]
yNH40 - Normal value of ammonium renal excretion rate [mmol/min] qWU - Urine output [l/min]
pCO2A - Alveolar pCO2 [torr] GFR - Glomerular filtration rate [l/min]
xCO3 - Actual bicarbonate concentration [mmol/l]
OUTPUT VARIABLES: STPG - summary renal excretion rate of titratable acids, phosphate and org. acids [mmol/mi
yTA - renal excretion rate of titratable acids [mmol/min] yTA1 - on arterial pH dependent portion of titratable acid secretion rate [mmol/min]
PHU - urine pH YNH4 - Ammonium renal excretion rate [mmol/min]
YCO3 - Bicarbonate excretion rate [mmol/min] YCO3R - Bicarbonate reabsorption rate [mmol/min]
24.7.2001
Renal Acid Base Control
vIF
qLF
pC
YPLIN
vP
ZPG 0
ZPIF 0
ZPP 0
ZPLG 0
pICO
xPIF
zPIF
zPP
xPP
pPCO
PROTEIN BALANCE
INPUTS: vIF interstitial fluid volume [l] qLF - lymph flow rate [l/min] pC - capillary pressure [torr]
YPLIN - rate of intravenous plasma protein input [g/min] vP -plasma volume [l]
OUTPUTS: pICO - interstitial colloid osmotic pressure [torr]
xPIF - interstitial protein concentration [g/l] zPIF - interstitial protein content[g] zPP - plasma protein content [g]
xPP - plasma protein concentration [g/l] pPCO - plasma colloid osmotic pressure [torr]
10.7.2001
Protein Balance
xMNE
xURE
xGLE
xNE
xKE
OSMP
P L A S M A O S M O L A R I T Y
INPUTS : XMNE - ECF mannitol concentration [mmol/l]
XURE - ECF urea concentration [mmol/l XGLE - ECF glucose concentration [mmol/l] XNE - ECF sodium concentration [mmol/l]
XKE - ECF potassium concentration [mmol/l]
OUTPUT : OSMP - plasma osmolarity
Plasma osmolarity calculation
vEC
yPO4I
ySO4I
yORGI
GFR
ZPO4E 0
ZSO4E 0
ZORGE 0
zPO4E
xPO4
yPO4
zSO4E
xSO4
ySO4
zORGE
xORGE
yORG
PHOSPHATE, SULPHATE AND ORGANIC ACIDS BALANCE
INPUTS: vEC - ECF volume [l]
yPO4I - phosphate intake [mEq/min] ySO4I - sulphate intake [mEq/min]
yORGI - organic acids intake [mEq/min] GFR - Glomerular filtration rate [l/min]
OUTPUTS: zPO4E - ECF phosphate content [mEq]
xPO4 - ECF phosphate contentration [mEq/l] yPO4 - Phosphate renal excretion rate [mEq/min]
zSO4E - ECF sulphate content [mEq] xSO4 - ECF sulphate contentration [mEq/l]
ySO4 - sulphate renal excretion rate [mEq/min] zORGE - ECF organic acids content [mEq]
xORGE - ECF organic acids contentration [mEq/l] yORG - organic acids renal excretion rate [mEq/min]
30.7.2001
Phosphate, Sulphate and Organic Acids Balance
mrCO2
uCO2A
VTW
mrO2
uO2A
QCO
PBA
fCO2i
VAL
VA
fO2i
UCO2V 0
UO2V 0
FCO2A 0
FO2A 0
uCO2V
uO2V
pCO2A
fCO2A
pO2A
fO2A
O2 and CO2 EXCHANGE
INPUTS: mrCO2 - (*Metabolic production rate of CO2 [l STPD/min]*) uCO2A - (*Content of CO2 in arterial blood [l STPD/l]*)
VTW - (*Total body fluid volume [l]*) mrO2 - (*Metabolic consumption rate of O2 [l STPD/min]*) uO2A - (*Content of CO2 in arterial blood [l STPD/l]*)
QCO - (*Cardiac output [l/min]*) PBA - (*Barometric pressure*)
fCO2i - (*Volume fraction of CO2 in dry inspired gas*) VAL - (*Total alveolar volume (BTPS)*)
VA - (*Alveolar ventilation [l BTPS/min]*) fO2i - (*Volume fraction of O2 in dry inspired gas*)
OUTPUTS: uCO2V - (** Content of CO2 in venous blood [l STPD/l]*) uO2V - (** Content of O2 in venous blood [l STPD / l*)
pCO2A - (*CO2 tension alveoli [Torr]*) fCO2A - (*Volume fraction of CO2 in dry alveoli gas*)
pO2A - (*O2 tension in alveoli [Torr]*) fO2A - (*Volume fraction of O2 in dry alveoli gas*)
8.10.2001
O2 and CO2 Exchange
yTA1
yNH4
yCO3
ALD
GFR
CPR
THDF
yNIN
PHA
CBFI
CHEI
yKGLI
zKI0
CKEI
yKIN
vEC
ZNE 0
ZKE 0
ZHI 0
yNU
yNH
yND
xNE
zNE
yNHI
yKHI
zKI
zKE
yKU
yKD
xKE
SODIUM AND POTASSIUM BALANCE
INPUTS: yTA1 - Arterial pH dependent portion of titrable acid excretion rate
yNH4 - ammonium renal excretion rate [mEq/min] yCO3R - bicarbonate reabsorption rate [mEq/min]
ALD - aldostrone effect [x normal] GFR - glomerular filtration rate [l/min]
CPR - excretion ratio of filterd load after proximal tubule THDF - effect of 3rd factor (natriuretic horm.) [x normal]
yNIN - sodium intake [mEq/min] PHA - Arterial blood pH
CBFI - Parameter of intracellular buffer capacity CHEI - Transfer coeff. of H ions from ECF to ICF
yKGLI - K flow rate from ECF to ICF accompanying secretion of insulin [mEq/min] zKI0 - normal ICF K content [mEq]
CKEI - Transfer coeff. of K ions from ECF into ICF (exchanged with H ions) yKIN - K intake [mEq/min]
vEC - ECF volume [l]
OUTPUTS: yNU - Na renal excretion rate [mEq/min]
yNH - Na excretion in Henle loop [mEq/min] yND - Na excretion rate in distal tubule [mEq/min]
xNE - ECF Na concentration [mEq/l] zNE - ECF Na content[mEq]
yNHI - H ions flow rate from ECF to ICF (exchanged w. Na) [mEq/min] yKHI - K flow rate from ECF to ICF (exchanged w. H) [mEq/min]
zKI - ICF K content [mEq] zKE - ECF K content [mEq]
yKU - K renal excretion rate [mEq/min] yKD - K excretion rate in distal tubule [mEq/min]
xKE - ECF K concentration [mEq/l]
27.7.2001
Na & K Balance
VIF0
VIF
QLF0
PIF
QLF
INTERSTITIAL PRESSURE AND
LYMPH FLOW RATE
INPUTS: vIF0 - normal interstitial fluid volume [l]
vIF - interstitial fluid volume [l] qLF - normal lymph flow rate [l/min]
OUTPUTS: pIF - interstitial pressure [torr] qLF - lymph flow rate [l/min]
16.8.2001
Interstitial Pressure and Lymph Flow Rate
ADH
OSMP
yND
yKD
yGLU
yURU
yMNU
yNU
yKU
qWD
qWU
OSMU
DIURESIS AND URINE OSMOLARITY
INPUTS: ADH - effect of antidiuretic hormone [x normal]
OSMP - plasma osmolality [mOsm/l] yND - sodium excretion rate in distal tubule [mEq/min]
yKD - potassium excretion rate in distal tubule [mEq/min] yGLU - renal excretion rate of glucose [mEq/min]
yURU - renal excretion rate of urea [mEq/min] yMNU - renal excretion rate of mannitol [mEq/min]
yNU - sodium renal excretion rate [mEq/min] yKU - potassium renal excretion rate [mEq/min]
OUTPUTS: qWD - rate of urinary excretion in distal tubule [l/min]
qWU - urine output [l/min] OSMU - urine osmolality [mOsm/l]
17.8.2001
Diuresis and Urine Osmolarity
vEC
pAS
xKE
yNH
pVP
OSMP
pPCO
GFR
ALD
ADH
THDF
CONTROLLER OF RENAL FUNCTION
INPUTS: vEC - ECF volume [l]
pAS - systemic arterial pressure [torr] xKE - ECF K concentration [mEq/l]
yNH - Na excretion in Henle loop [mEq/min] pVP - pulmonary venous pressure [torr]
OSMP - plasma osmolality [mOsm/l] pPCO - plasma colloid osmotic pressure [torr]
OUTPUTS: GFR - glomerular filtration rate [l/min] ALD - aldosterone effect [x normal]
ADH - effect of antidiuretic hormone [x normal] THDF - effect of 3rd factor (natriuretic horm.) [x normal]
HIDDEN CONSTANTS: vEC0 - normal ECF volume [l]
GFR0 - normal glomerular filtration rate [l/min] ___
17.8.2001
Controller of Renal Function
vEC
yCLI
yNU
yKU
yNH4
yCa
yMg
ySO4
yCO3
STPG
ZCLE 0
zCLE
xCLE
yCLU
CHLORIDE BALANCE
INPUTS: vEC - ECF volume [l]
yCLI - chloride intake [mEq/min] yNU - Na renal excretion rate [mEq/min] yKU - K renal excretion rate [mEq/min]
yNH4 - ammonium renal excretion rate [mEq/min] yCa - calcium renal excretion rate [mEq/min]
yMg - magnesium renal excretion rate [mEq/min] ySO4 - sulphate renal excretion rate [mEq/min] yCO3 - bicarbonate excretion rate [mEq/min]
STPG - summary renal excretion rate of phosphates and org. acids related to arterial pH [mEq/min]
OUTPUTS: zCLE - ECF chloride content [mEq]
xCLE - ECF chloride concentration [mEq/l] yCLU - chloride renal excretion rate [mEq/min]
30.7.2001
Chloride Balance
VB
RTOT
RTOP
KL
KR
DEN
KRAN
QCO
PAP
PAS
pC
PVS
PVP
CARDIOVASCULAR BLOCK
INPUTS: VB - Blood volume [l]
RTOT - Total resistance in systemic circulation [Torr * Min / l] (norm.=20) RTOP - Total resistance in pulmonary circulation [Torr * Min /l] (norm. =3)
KL - Parameter of the left heart performance [l/min/torr] (norm.=0.2) KR - Parameter of the right heart performance [l/min/torr] (norm.=0.3) DEN - Proportional constant between QCO AND VB [1/min] (norm.=1)
KRAN - Parameter of capillary pressure (norm.=5.93)
OUTPUTS: QCO - Cardiac output [l/min]
PAP - Pulmonary arterial pressure [torr] PAS - Systemic arterial pressure [torr]
pC - Capillary pressure [Torr] PVS - Central venous pressure [torr]
PVP - Pulmonary venous pressure [torr]
24.8.2001 edited by Tom Kripner
Cardiovascular Block
vEC
yCaI
GFR
yMgI
zCaE0
zMgE0
zCaE
xCaE
yCa
zMgE
xMgE
yMg
CALCIUM AND MAGNESIUM BALANCE
INPUTS: vEC - ECF volume [l]
yCaI - calcium intake [mEq/min] yMgI -magnesium intake [mEq/min]
GFR - glomerular filtration rate [l/min]
OUTPUTS: zCaE - ECF calcium content [mEq]
xCaE - ECF calcium contentration [mEq/l] yCa - calcium renal excretion rate [mEq/min]
zMgE - ECF magnesium content [mEq] xMgE - ECF magnesium contentration [mEq/l]
yMg - magnesium renal excretion rate [mEq/min]
INITIAL CONDITIONS: zCaE0 - ECF calcium content [mEq]
zMgE0 - ECF magnesium content [mEq]
30.7.2001
Calcium and Magnesium Balance
qIN
qVIN
qIWL
qMWP
qWU
qLF
CFC
pICO
pPCO
pC
pIF
CSM
xNE
xKE
xGLE
zKI
vRBC
xHBER
VIN 0
VP 0
VIF 0
VIC 0
HB
HT
vB
vP
vEC
vIF
vTW
vIC
BODY FLUID VOLUME BALANCE
INPUTS: qIN - drinking rate [l/min]
qVIN - intravenous water input [l/min] qIWL - insensible water loss [l/min]
qMWP - metabolic water production [l/min] qWU - urine output [l/min]
qLF - lymph flow rate [l/min] CFC - capillary filtration coefficient [l/min/torr]
pICO - interstitial colloid osmotic pressure [torr] pPCO - plasma colloid osmotic pressure [torr]
pC - capillary pressure [torr] pIF - interstitial pressure [torr]
CSM - transfer coeff. of water from ECF to ICF xNE - ECF Na concentration [mEq/l] xKE - ECF K concentration [mEq/l] xGLE - ECF glucose conc. [mEq/l]
zKI - ICF K content [mEq] vRBC - volume of red blood cells [l]
xHBER - hemoglobin concentration in the red blood cells [g/100 ml]
OUTPUTS: HB - blood hemoglobin concentration [g/100 ml]
HT - hematocrit vB - blood volume [l] vP -plasma volume [l] vEC - ECF volume [l]
vIF - interstitial fluid volume [l] vTW - total body fluid volume [l]
vIC - ICF volume [l]
24.8.2001
Body Fluid Volume Balance
TYINT
xGL0
CGL1
CGL2
yINS
CGL3
yGLI
vEC
GFR
YINT 0
ZGLE 0
yINT
yGLS
yKGLI
zGLE
xGLE
yGLU
BLOOD GLUCOSE CONTROL
INPUTS: TYINT - time constant of insulin secretion
xGL0 - reference value of ECF glucose concentration CGL1 - parameter of glucose metabolism CGL2 - parameter of glucose metabolism
yINS - intake rate of insulin[unit/min] CGL3 - parameter of glucose metabolism
yGLI - intake rate of glucose [g/min] vEC - ECF volume [l]
GFR - glomerular filtration rate [l/min]
OUTPUTS: yINT - insulin secretion [unit/min]
yGLS - glucose flow rate from ECF into cells [mEq/min] yKGLI - K flow rate from ECF to ICF accompanying secretion of insulin [mEq/min]
zGLE - ECF glucose content [mEq] xGLE - ECF glucose concentration [mEq]
yGLU - renal excretion rate of glucose [mEq/min]
21.8.2001
Blood Glucose Control
BEOX
HB
PCO2A
PO2A
XHB
STBC
BE
AH
PHA
SO2A
XCO3A
UCO2A
UO2A
BLOOD ACID BASE BALANCE
INPUTS: BEOX - Base Excess in fully oxygenated blood [mmol/l]
HB - Hemoglobin concentration [g/dl]PCO2A - CO2 tension in arterial blood [torr]
PO2A - Oxygen tension in arterial blood [torr]
OUTPUTS: XHB - Vector of coefficients derived from hemoglobin concentration
STBC - Standard bicarbonate concentration [mmol/l]BE - Base Excess concentration in arterial blood
AH - Hydrogen ions concentration [nmol/l]PHA - arterial plasma pH
SO2A - Oxygen hemoglobin saturation in arterial blood (expressed as ratio from 0 to 1)XCO3 - Actual bicarbonate concentration in arterial blood
UCO2A - Content of CO2 in arterial blood [l STPD/l] UO2A-Content of O2 in arterial blood [l STPD/l]
Blood Acid Base Balance
TBEox
VB
HB
A
pCO2A
VEC
yTA
yNH4
yCO3
yKHi
yNHi
yCO3in
yHin
MRH
ZBEEC 0
BEOX 0
BEox
BEEC
ACID BASE METABOLIC BALANCE
INPUTS: TBEOX - (*Time constant*)
VB - (*Blood Volume [l]*) HB (fore XHB) - (*Blood hemoglobin concentration [g/100 ml]*) A [11] - (* vector of coeficients, see "Blood Acid Base Balance" *)
pCO2A - (*CO2 tension in arterial blood [Torr]*) VEC - (*Extracelular fluid volume [l]*)
yTA - (*Renal excretion rate of titratable acid [mEq/min]*) yNH4 - (*Renal excretion rate of ammonium [mEq/min]*) yCO3 - (*Renal excretion rate of bicarbonate [mEq/min]*)
yKHi - (*Potassium ions flow rate from ECF into ICF exchanged with hydrogen ions [mEq/min]*)
yNHi - (*Hydrogen ions flow rate from ECF into ICF exchanged with sodium ions [mEq/min]*)
OUTPUTS: BEox - (** Base excess in fully oxygenated blood [mEq/l]*)
BEEC - (*ECF Base excess concentration
Acid Base Metabolic Balance1
1Inputs
XCO3
<TPHA1>
<YTA0>
<ZHI0>
<ZKE0>
<ZNE0>
<VEC>
<YKIN>
<CKEI>
<ZKI0>
<YKGLI>
<CHEI>
<CBFI>
<PHA>
<YNIN>
<THDF>
<CPR>
<GFR>
<ALD>
<YCO3>
<YNH4>
<YTA1>
<YINT0>
<ZMNE0>
<ZUR0>
<VEC>
<YMNI>
<GFR>
<YURI>
<VTW>
<AH>
<PHA>
<PCO2A>
<PO2A>
<VA0>
<PPCO>
<OSMP>
<PVP>
<YNH>
<XKE>
<PAS>
<VEC>
<PHU10>
<PHU20>
<PHA0>
<XCO3>
<GFR>
<PCO2A>
<QWU>
<YNH40>
<TPHU1>
<TPHU2>
<ALD>
<YPO4>
<YORG>
<PHA>
<ZPLG0>
<ZPP0>
<ZPIF0>
<ZPG0>
<VP>
<YPLIN>
<PC>
<QLF>
<VIF>
<ZORGE0>
<ZSO4E0>
<ZPO4E0>
<GFR>
<YORGI>
<YSO4I>
<YPO4I>
<VEC>
<XKE>
<XNE>
<XGLE>
<XURE>
<XMNE>
<FO2A0>
<FCO2A0>
<UO2V0>
<UCO2V0>
<FO2I>
<VA>
<VAL>
<FCO2I>
<PBA>
<QCO>
<UO2A>
<MRO2>
<VTW>
<UCO2A>
<MRCO2>
<QLF0>
<VIF>
<VIF0>
<YKU>
<YNU>
<YMNU>
<YURU>
<YGLU>
<YKD>
<YND>
<OSMP>
<ADH>
<ZCLE0>
<STPG>
<YCO3>
<YSO4>
<YMG>
<YCA>
<YNH4>
<YKU>
<YNU>
<YCLI>
<VEC>
<KRAN>
<DEN>
<KR>
<KL>
<RTOP>
<RTOT>
<VB>
<ZMGE0>
<ZCAE0>
<YMGI>
<GFR>
<YCAI>
<VEC>
<VIC0>
<VIF0>
<VP0>
<VIN0>
<XHBER>
<VRBC>
<ZKI>
<XGLE>
<XKE>
<XNE>
<CSM>
<PIF>
<PC>
<PPCO>
<PICO>
<CFC>
<QLF>
<QWU>
<QMWP>
<QIWL>
<QVIN>
<QIN>
<ZGLE0>
<GFR>
<VEC>
<YGLI>
<CGL3>
<YINS>
<CGL2>
<CGL1>
<XGL0>
<TYINT>
<PO2A>
<PCO2A>
<HB>
<BEOX>
<BEOX0>
<ZBEEC0>
<MRH>
<YHIN>
<YCO3IN>
<YNHI>
<YKHI>
<YCO3>
<YNH4>
<YTA>
<VEC>
<PCO2A>
<A>
<HB>
<VB>
<TBEOX> YINT
YGLS
YKGLI
ZGLE
XGLE
PVP
PVS
PC
PAS
PAP
QCO
YMG
XMGE
ZMGE
YCA
XCAE
ZCAE
VEC
VP
VIC
VTW
VIF
HB
VB
HT
Sodium and potassium balance
YNU
XKE
YKD
YKU
ZKE
ZKI
YKHI
YNHI
ZNE
XNE
YND
YNH
INPUTS
Cardiovascular block
Calcium and magnesium balanceBody fluid volume balance
FO2A
PO2A
FCO2A
PCO2A
UO2V
UCO2V
OSMP
UO2A
UCO2A
Urea and mannitol balance
YMNU
XMNE
ZMNE
YURU
XURE
ZUR
Respiration control
VA
Controller of renal function
GFR
ALD
ADH
THDF
Renal acid base control
STPG
YTA
YTA1
PHU
YNH4
YCO3
YCO3R
Protein balance
PPCO
XPP
ZPP
ZPIF
XPIF
PICO
Phosphate sulphate and organic acids balance
YORG
XORGE
ZORGE
YSO4
XSO4
ZSO4E
YPO4
XPO4
ZPO4E
Plasma osmolarityO2 and CO2 exchange
Interstitial pressure and lymph flow rate
QLF
PIF
Diuresis and urine osmolarity
OSMU
QWU
QWD
Chloride balance
YCLU
XCLE
ZCLE
Blood glucose control
YGLU
Blood acid base balance
STBC
BE
AH
PHA
SO2A
Acid base metabolic balance
BEEC
BEOX
AXHB
SIMULATION CHIP: BLOOD ACID BASE BALANCE
SO2A
SO2A
SO2ASO2A
STBC
SO2A SO2A
SO2A
SO2A
SO2A
SO2A
9UO2A
8UCO2A
7XCO3A
6SO2A
5PHA
4AH
3BE
2STBC
1XHB
XHb
BEox
SO237
PCO237
pH37
BE
pH From Base Excess B E I N V
INPUTS :XHb - coefficients derived from
concentration of hemoglobin in bloodBEox - Base Excess in fully oxygenated blood [mmol/l]
SO237 - oxyhemoglobin saturation[expressed as ratio form 0 to 1]
PCO237 - pCO2 [torr] in blood at 37 °C
OUTPUTS :pH37 - plasma pH at standard temperature (37 °C)BE- current value of blood Base Excess [mmol/l]
pH From BE
XHb
BE
HCO3st
Standard Bicarbonate Concentration S T B C B
INPUTS :
XHb - coefficients derived from hemoglobin concentration
BE -blood Base Excess [mmol/l]
OUTPUT :HCO3st - standard bicarbonate concentration [mmol/l]
ST BCB
PO237
pH37
pCO237
SO237
Oxyhemoglobin Saturation S A T U R
INPUTS :PO237 - pO2 [torr] in blood at 37 °C
PCO237 - pCO2 [torr] in blood at 37 °CpH37 - pH of plasma at 37 °C
OUTPUT :SO237 - oxyhemoglobin saturation (expressed as ratio form 0 to 1)
SATUR
XHb
SO237
PO237
O2
O2 Blood Content O X Y
INPUTS :XHb - coefficient derived from
concentration of hemoglobin in bloodSO237 - oxyhemoglobin saturation 37 °C
(expressed as ratio form 0 to 1)PO237 - pO2 (torr) in blood at 37 °C
OUTPUT :O2 - blood O2 content
[expressed in l CO2 STPD)/l ]
OXY
Memory
10^(9-u);
Fcn
37
Constant
XHb
PCO237
SO237
pH37
CO2
CO2 Blood Content C A R B
INPUTS :XHb - coefficients derived from
conentration of hemoglobin in bloodPCO237 - pCO2 [torr] in blood at 37 °C
SO237 - oxyhemoglobin saturation [expressed as ratio form 0 to 1]pH37 - pH of plasma at 37 °C
OUTPUT :CO2 - blood CO2 content
[expressed in l CO2 STPD/l ]
CARB
pHt
PCO2t
temp
HCO3
Actual Bicarbonate Concentration A C B C B
INPUTS :pHt - plasma pH at patient temperature
PCO2t - PCO2 [torr] at body temperature temp - body temperature [°C]
OUTPUT :HCO3 - actual bicarbonate concentration
at body temperature
AC BCB
Hb XHb
Hemoglobin Coefficients A B C N S T
INPUT : Hb - blood hemoglobin
concentration [g/dl]
OUTPUTS : XHb - coefficients derived from
hemoglobin concentration
c[1]..c[10] a[1]..a[11]
ABCNST
4PO2A
3PCO2A
2HB
1BEOX
PCO2A
PCO2A
PCO2A
PCO2A
PCO2A
PHA
PHA
PHAPHA
XCO3A
PO2A
PO2A
PO2A
Bloodhemoglobinconcentration
SIMULATION CHIP: CARB
X0=7.0388002E-3 ; X1=3.6447450E-4 ; X2=7.9099077 ;
X3=-2.0113444E-1 ; X4=-1.4790526 ;
% if SO237==0 % SO237=1E-13;
% end;
D=X0*(SO237^X1)*(pH37^X2)*exp(X3*SO237+X4*pH37); AH=10^(9-pH37);
CO2 = 0.02226*PCO237*(XHb(1)+(XHb(2)*AH+XHb(3))/(AH*AH)+XHb(4)*D/AH ... +XHb(5)*(1-SO237)/((AH/D)^2+AH*XHb(6)/D+XHb(7)*PCO237) ... +XHb(8)*SO237 /((AH/D)^2+AH*XHb(9)/D+XHb(10)*PCO237));
1
CO2
[7.0388002E-3 3.6447450E-4 7.9099077 -2.0113444E-1 -1.4790526 ]
X0 ... X4
SO2 >= 10^ -13
0.02226
Const
CO2=
u[8]* u[24] / ( (u[26]/u[25])^2 + u[26]*u[9] / u[25] + u[10] * u[23] )CO2 - part5
u[5]* ( 1-u[24] ) / ( (u[26]/u[25])^2 + u[26]*u[6] / u[25] + u[7] * u[23] )CO2 - part4
u[4]*u[25]/u[26]
CO2 - part3
( u[2]*u[26] + u[3] ) / (u[26]*u[26])
CO2 - part2
u[1]
CO2 - part1
10^( 9 - u )
AH=10^(9-pH37);
f(u)
D=X0*(SO237^X1)*(pH37^X2)*exp(X3*SO237+X4*pH37);4
pH37
3
SO237
2
PCO237
1
XHb
D
AH
Figure 5. The whole model of the Golem simulator is created from the hierarchical, interconnected Simulink blocks. The link shows the dependencies and linkages between different physiological sub-systems. Simulink computing network, representing mathematical relationships, it appears only at the lowest hierarchical level. For ex-ample, within a block BLOOD ACID BASE BALANCE one of the linked units - (block CARB), counting the total concentration of carbon dioxide in the blood, already has its own counting blocks.
3
The interconnection of blocks thus reflects the calcula-tion procedure rather than the actual structure of the mod-elled reality. We call this causal modelling.
For example, when the direction of the computation is reversed (by replacing inputs with outputs), the algorithm will be different although the model equations remain the same. Thus, for example, in the model of an electrical RLC circuit (or its hydraulic analogy) it will make a difference if voltage (pressure in the hydraulic domain) or (electrical or hydraulic) current is used as the input for the circuit although the electrical (hydraulic) scheme itself does not change. The Simulink network representing the computa-tional process will be different.
In complex models, it is usually not simple to derive the computation causality (i.e. to derive the algorithm of com-puting output variables from input variables). Apart from that, in complex systems, the physical reality of the mod-elled system becomes somewhat lost under the structure of calculation with this approach.
2.3 Modelica – language for acausal modelling
At the turn of the millennium, a completely new category of so-called modelling tools emerged, which makes it pos-sible to leave the computation aside and describe directly equations in the modelling blocks. The major innovation brought about by this so-called acausal modelling tools is the possibility to describe the individual parts of a model directly as a system of equations rather than an algorithm for solving the equations. The notation of models is declar-ative (we describe the structure and mathematical rela-tions, not the calculation algorithm) – thus the notation is acausal.
Acausal modelling tools work with interconnected com-ponents that are instances of classes in which equations are directly defined.
The components (i.e. instances of classes with equa-tions) can be interconnected by means of precisely defined interfaces – connectors; this defines a system of equations.
The latest version of Simulink provides certain options for using acausal tools as well. Math- works, the producer of the Matlab/Simulink simulation tools, responded to the new trends by creating a special acausal Simulink library – Simscape – and related domain libraries such as SimElec-tronics, SimHydraulics, SimMechanics, etc.
A modern simulation language that is built directly on the acausal notation of models is Modelica 18–21. Modelica, originally developed as an academic project in cooperation with small development companies associated with Lund and Linköping universities 22–26, soon showed to be a very efficient tool for the modelling of complex models applied particularly in mechanical engineering, in the automobile and airline industries. The development of Modelica there-fore gradually gained support of the commercial sector.
The speed at which the new simulation language Mod-elica spread in various industries and at which it was em-braced by various commercial development environments is astonishing. Today, several commercial and noncom-mercial development tools that use this language exist (see
https://www.modelica.org). Modelica works with interconnected components that
are instances of individual classes. Unlike the implementa-tion of classes in other object-oriented languages (such as C# or Java), classes in Modelica have an additional special section in which equations are defined.
The equations do not mean assignment (i.e. storing the result of the calculation of an assigned command in a variable) but rather the definition of relations between variables (as is common in mathematics and physics). For example, the following notations of relations between vari-ables expressing the resistance (R), flow (F) and pressure gradient (P) are equivalent:
F=P/R;P/R=F;P=R*F;R*F=P;R=P/F;P/F=R;
Components (class instances) in Modelica can be inter-connected by means of precisely defined interfaces – con-nectors.
What is important is that the interconnection of com-ponents actually interconnects systems of equations in the individual components with one another. By interconnect-ing Modelica components, we do not define the calculation procedure but rather the modelled reality. The method of solving the equations is then “left to the machines”.
Unlike block-oriented causal modelling languages where the structure of connections among hierarchical blocks represents rather the computation process instead of the modelled reality, the structure of models in Modeli-ca shows the structure of the modelled reality. This is why even complex models are sufficiently transparent and com-prehensible in Modelica 22,23.
The advantage can be demonstrated for example by the comparison of implementation of the classical Guyton model 24 in Simulink (Fig. 6) and in Modelica (Fig. 7).
The central part of Guyton’s model (Circulation dynam-ics) represents circulation modelling of blood pumped by the right and the left heart ventricle. The Simulink model represents a at-first-glance-complex computational net-work. The Modelica implementation provides a clear view of the essence of the modelled reality – it consists of in-stances of two pumps (right and left ventricles), instances of elastic compartments, and resistances of individual parts of the vascular bed, interconnected through acausal con-nectors (that connect the flow and pressure in individual parts of the blood stream). The acausal connector of large veins is moreover connected to a controlled pump used to model blood formation or loss, infusions, and volume transfers from blood and interstitial liquid.
Transparency and clarity is very important precisely for the development of large complex models that are typical in integrative and system physiology. The task of unifying and designing complex models faces another problem due to the complicatedness. Usually, only the authors are able to understand and use complex models. Modelica partial-
4
ly resolves this problem thanks to its characteristics and a complex model of human physiology designed in Modelica may lead to a wider use of the model in the scientific com-munity.
3. Results
3.1 Modelica libraries for physiological modelling
Modelica is designed to be domain neutral and, as a re-sult, is used in a wide variety of applications. The use of Modelica in different domains is facilitated by special do-main-oriented libraries. Until now, various libraries have been created for a wide variety of applications, such as
fluid, thermo-fluid and energy systems modelling (for ex-ample, steam power generation, hydraulics, etc.), automo-tive applications (especially powertrain) and mechanical systems (for example, multi-body systems, mechatronics, etc.). In the automotive sector, many of the major automo-tive OEMs are using Modelica. The OEMs include Ford, General Motors, Toyota, BMW and Daimler.
Modelica facilitates modelling considerably, especially that of extensive and complex systems, which also include biomedical systems, though. Therefore, we have opted for Modelica as the implementation tool for the creation of physiological models, thus abandoning the development of models in the block-oriented environment Simulink/Mat-lab.
To facilitate modelling of physiological processes, we created the special Modelica library - Physiolibrary 30–32. Physiolibrary is a free open-source Modelica library de-signed for modelling human physiology. This library con-tains basic physical laws governing human physiology, usable for cardiovascular circulation, metabolic processes, nutrient distribution, thermoregulation, gases transport, electrolyte regulation, water distribution, hormonal reg-ulation and pharmacological regulation. For modelling chemical processes we have designed Modelica library Chemical 33. These libraries are accessible on the Modelica Libraries web page at https://www.modelica.org/libraries, or at http://www.physiolibrary.org.
Graphical modelling with Physiolibrary and Chemical libraries is very easy and intuitive. Using these physiolog-ical diagrams as a higher-level mathematical language is sufficient for describing the elementary physical processes of physiology.
By graphically connecting instances of Physiolibrary classes, a user can create models of cardiovascular circu-lation, thermoregulation, metabolic processes, nutrient distribution, gas transport, electrolyte regulation, water distribution, hormonal regulation and pharmacological regulation. After a simple setting of the parameters, the models are ready to simulate. After simulation, the user can examine variables as their values change over time. Model representation as a diagram also has great advantages for clarity because the user can better understand physical principles when they are modeled graphically.
The Physiolibrary and Chemical classes are implement-ed to give robust support for many use cases. Each class contains an equation for some physical law. The implemen-tation is open-source, so everybody can see each equation behind each class. The purpose of these libraries is to en-capsulate the equations of elementary physical laws and to allow the user to build complex models. Since Physiolibrary (or Chemical) models these complex equations graphically, a model will be readable by everybody. This graphical style is much more natural than the text-based code representa-tion. These models could even be directly used for teaching students who have never seen Modelica before. The sche-matic model representations describe themselves without a need to reference the underlying code.
Integrative physiology needs exact interfaces and ter-
Figure 6. Circulatory dynamics – the detailed structure of the cen-tral part of Guyton’s model implemented in Simulink, which shows blood flows through aggregated parts of the circulatory system, and function of the heart as a pump.
Figure 7. The same part of the model as in Figure 6, but implemented in Modelica. The model contains connected instances of two pumps (of the right and left heart ventricle), elastic vascular compartments, and resistances. Upon its comparison with Fig. 6, it can be seen that the model structure in Simulink corresponds rather to a computa-tional algorithm, while the model structure in Modelica shows more of the structure itself of the modelled reality.
5
minology to interconnect the parts accurately. Primitive data types must be physical quantities with physical units. Above the quantities, the programmer must define physical connectors, and above the connectors library classes must be built, the classes have to be based on physical laws. From these elementary definitions in libraries, a user can build up more complex processes and regulations; and finally, construct a whole-body physiological model. Because we use Modelica, it is not necessary to deal with the typical algebraic or numerical problems, since models are solved automatically. This allows building large models without a huge effort.
The common errors in physiological models were caused by using bad physical units. The main problem of medical research, articles, and experiments is using obscure units from medicine, pharmacology, biology and non-physics disciplines. In Physiolibrary and Chemical (as in other cor-rectly-defined Modelica libraries), all values are calculated in SI units only. This is really useful for compatibility with other libraries and models in case of integration. However, non-SI units are also integrated in Modelica environments (these units can be selected in parameter dialogs or in plot-ting of results), but internally all units are in SI.
3.2 Modelica implementation of Hummod
Today, the most extensive model of integrated physiolog-ical systems of human physiology is apparently the Hum-Mod model created based on international cooperation of a group of collaborators and disciples of A. Guyton at the Mississippi University Medical Center, USA 34–38.
The authors do not seek to keep its structure a secret; the source text of the model (containing more than 5,000 variables) can be downloaded from the website of the mod-el, http://hummod.org. The source text was written in the special markup language XML. The entire mathematical model is offered as “open source“: users can use the website to download and install on their computer the source code as well as the compiler and run the model on their own machine (Figs. 8 and 9). Users can thus adapt and modify the model. The problem is that the XML source texts of the entire model are written in several thousands of files locat-ed in hundreds of folders, and it is very difficult to orien-tate oneself in the mathematical relationships by studying more than a thousand of mutually connected XML files. Special viewers have been created for better understanding of the HumMod model that enable the user to go through
individual relationships within the model 39–41. Despite that, equations of the model and their relationships still remain difficult to understand for the user.
Due to the lack of clarity, many research teams actually preferred to use older (and more simple) models of complex physiological regulations as a starting point for integrative model development.
For example, this path was taken by the international research team of the SAPHIR (System Approach for Physiological Integration of Re-nal, cardiac and respiratory con-trol) project in 2008 after deciding that the open source mathematical model of integrative human phys-iology containing over 3000 vari-ables from Guyton’s laboratory 2 at that time, seemed very poorly read-able and difficult to understand to the project participants. Therefore two legacy integrated models have served as the starting point for mod-el development (Thomas et al. 2008), namely the classic model of Guyton 1, which focused on blood pressure regulation, and the model of Ike-da 42, based on Guyton’s models but extended to focus on the overall regulation of body fluid. Model of Ikeda was recently reimplemented in modern simulation environment 43. Similarly, in 2011 Mangourova et
Compiler and loader for HumMod model
Source code of HumMod
Figure 8. The HumMod simulator has been distributed with a compiler, loader and the source code written in thousands of XML files.
6
al. 44 implemented in Simulink an older model of Guyton of 1992 writ-ten in C instead of the then most recent (but difficult to understand for them) version of the large inte-grative model - QHP (Quantitative Human Physiology - predecessor of the HumMod model) from Guyton’s laboratory 2.
As it shows, comprehensibility of descriptions of complex integra-tive models is one of their limiting factors for their acceptance by the scientific community. If only the creators understand their models, their potential of factual communi-cation with other departments will be thus hindered. This also limits the possibilities of designing inte-grative models within a broader sci-entific community. This is why the development of methodologies that would make clearer the descriptions of structures of complex hierarchi-cal models in a way so that a wider spectrum of users can understand them has been gaining importance.
One of the ways to facilitate the understanding of complex hierar-chical models consists of using the Figure 9. The user can compile and run the HumMod model. Using a widely branched menu,
hundreds of variables can be monitored during simulation experiments.
VascularCompartments HumMod source
Splanc
hnicV
eins
Equations
Figure 10. Visualization tool QHPView, created by us, simplifies viewing of the QHP/HumMod simulator structure, containing thousands of XML files, scattered in hunderds of directories, where quotations and links between them may not be apparent.
7
Modelica language. Therefore, we have decided to reimple-ment the entire complex model of the American authors in this language.
We were not frightened by the complex structure of the HumMod model (called QHP in the previous version) and established closer cooperation with the American authors. We developed a special software tool called QHPView 45 to create a clear visualization of the used mathematical rela-tionships from the thousands of the source text files (see Fig 10). This enabled us to orientate ourselves in the large model.
Our version of HumMod called PHYSIOMODEL has been developed as an open source model using our Model-ica libraries Physiolibrary and Chemical.
Source texts of the model (i.e. the equations, values of all constants, etc.) representing formalized expressions of physiological relationships are available to the public at http://www.physiomodel.org.
Model reimplementation in Modelica resulted in a sub-stantially better visualization of the model structure (see Fig. 11) and among other things, it also helped to discover some mistakes in the original American implementation of HumMod. We modified and expanded the model, in particular regarding the modelling of the transfer of blood gases and homeostasis of the inner environment, especially the acid-base balance 46–48.
A more detailed description of the libraries and of our implementation of the integrative model of human physi-ology is a subject of a PhD thesis 49.
4. Discussion
4.1 Modelica – a suitable tool of sharing and publishing models
The development of integrative models in physiology ex-hibits an exclusively interdisciplinary nature. The team needs to have broad knowledge of physiology as well as knowledge of computer sciences, mathematics, the theory of control, and cybernetics. In addition, the team members of various professions must dispose of a considerable inter-section of their knowledge.
This is also why there are not many scientific teams that develop large integrative models in physiology.
The developed integrative models should be compre-hensible not only within the development team, but also externally – if a model is comprehensible only to its au-thors, it will hardly receive the necessary feedback and new impulses from specialized scientific community.
Modelica makes it much easier to visualize the structure of the model. It can also be a suitable intermediary for in-terdisciplinary communication, spreading and publishing models.
Reproducibility is the main attribute of any scientific re-sult. Leaving aside certain acts of deception not discovered by reviewers, the principle of reproducibility is a key for the gradual discovery of the secrets of nature. This principle is oftentimes disturbed in the field of scientific publications
related to biomedical models (both small and large). It is not always the fault of the authors – many times the reason is that a sign or an index is omitted in equations while the paper is prepared for printing, which causes a lot of prob-lems to readers who seek not only to understand, but also to implement the described model.
In addition, in many cases biomedical models are so complex that the limited space for the article is sufficient only for fundamental equations of the model (and often not even all of them), while no space remains for more de-tailed information (initial values of state variables, values of all parameters, etc.) necessary to set up the model at a dif-ferent department. Therefore the classical form of publica-tions of models in journals is insufficient. A specialized ar-ticle that describes a model should include, as a minimum, a digital (available through the Internet) appendix giving a detailed description of the model structure including the
Figure 11. An illustration of a part of the source text of our Hum-Mod implementation in Modelica. The source text resembles hierar-chical physiological schemes. The content of the component circu-lation (from the upper figure) shows blood flow through the heart, pulmonary circulation and splanchnic circulation.
8
values of all parameters (preferably in the form designed in some modelling language), sufficient for the reader to be able to reproduce the model (and perhaps follow up in his or her own work). This solution has already been ap-proached by a number of journals that publish specialized articles on computer models.
If the model is published in a modelling language that requires a commercial licence (for example, in MathWorks Matlab&Simulink), a problem arises because the reader needs to have an appropriate licence to be able to run the given model in the licenced development environment.
Considerable efforts were thus developed in the inter-national project PHYSIOME to create databases – reposi-tories of models that, besides storing the source text of the model in the defined format, offer publicly available tools for their simulation. Given that Modelica is a standardized
Figure 12. An illustration of a part of the source text of our HumMod implementation in Modelica. The source text resembles hierarchical physiological schemes. The content of the component of splanch-nic circulation (from the upper figure) shows blood flow through the gastrointestinal tract component, the elastic compartment of the portal vein, and flow through the liver.
Figure 13. An illustration of a part of the source text of our Hum-Mod implementation in Modelica. The source text resembles hierar-chical physiological schemes. The content of the component of the gastrointestinal circulation (from the upper figure) shows blood flow through the gastrointestinal resistance. The resistance value is con-trolled by a number of hormonal and nerve stimuli.
language – and not a corporate proprietary product (such as MathWorks Matlab&Simulink) and given that open source development tools exist today for this language (for example, OpenModelica – see https://openmodelica.org) – Modelica seems to be a highly promising tool for publish-ing and sharing biomedical models.
So far, no other open source alternative besides Mod-elica exists that could be used for publishing extensive models. For example, the Guyton model version of 1992, implemented by Montani in C using the C-MODSIM envi-ronment 50, is divided in the cellML repository in 22 mod-ules in the open source cellML language. However, attempts at running these modules connected in one unit were not successful (https://models.cellml.org/exposure), while the Simulink version of the model works without problems 44
however, it requires the commercial environment of Mat-
9
lab@Simulink. For the sake of completeness, we should note that the-
oretically, also the environment used to publish HumMod is an open source environment for implementation of large models – the source code of the model is saved in a number of XML files. This is sufficient for simple models; however, complex models are difficult to understand by users – the reader can compare for themselves the HumMod model structure in the original form (http://hummod.org) and its implementation in Modelica (http://www.physiomodel.org).
Modelica thus seems to be a promising publication tool for extensive integrated models.
4.2 Prospects of combining commercial and academic development in Modelica
However, international cooperation and openness to the sharing of results are the driving force of scientific develop-ment in today’s globalized world. For example, as shown by experience, a community of users and developers as wide as possible is important for the development of complex software systems, thus a community that can provide feed-back and ensure further innovations of a complex product through cooperative development, while subsequently, fur-ther entrepreneurial opportunities open up in connection with this product – this is why such a great spreading of the development of projects with open source code has been seen in recent years.
In order to ensure the development of complex inte-grated models in physiology, it will probably be suitable to seek such forms that will combine entrepreneurial oppor-tunities and financing by the commercial sector with open scientific development.
One of the possibilities is to utilize a similar form in which the product OpenModelica has been developed in the open community (see https://openmodelica.org). The development of products is ensured by the consortium of 23 universities and 23 companies and institutions as well as a number of individual developers (Open Source Mod-elica Consortium – see https://openmodelica.org/home/consortium). Research is financed using member contri-butions whose amount is determined based on the size of the company and based on the number of sold products in which development OpenModelica licences have been used. OpenModelica has created a circle of a relatively large community of users as well as a high number of co-operating developers; the result is a functional open source product equivalent in terms of functionality to competi-tive expensive commercial implementations of Modelica (such as Dymola from Dassault Systèmes, MapleSim from MapleSoft, Wolfram SystemModeler from Wolfram, etc.). Commercial companies may use and further develop any part of the OpenModelica environment in their own com-mercial applications, also in the development of competi-tive commercial implementations of Modelica (this is why companies such as Wolfram Math Core or MapleSoft are also members of the consortium).Perhaps a consortium of the academic community and
commercial companies built on similar foundations – called e.g. “Physiomodelica Open Source Consortium“ could ensure further development of an integrated model of physiology in the future.
5 Conclusion
Times are changing. Mathematical modelling will no lon-ger require manual numerical solving or the manual alge-braic solving of sets of equations. They can be solved au-tomatically by sophisticated algorithms and tools such as Modelica compilers and solvers. So, the equations can be written in their natural form, just as they appear in physics textbooks. This gives the user a comfortable environment to build the theories and physiological models in very short time. This comfort also guarantees less errors and more physical consistency. Even better, the connection of these equation-based principles with object-oriented principles makes Modelica a great language for the huge systems that are typical in integrative and system physiology.
Disclosure of potential conflict of interest
No potential conflicts of interest were disclosed.
Funding
This works was supported by PRVOUK number P/24/LF1 and trio-MPO number FV20628
Rederences
1. Guyton AC, Coleman TG, Granger HJ. Circulation: overall reg-ulation. Annu Rev Physiol [Internet] 1972; 34:13–46. Availablefrom: http://dx.doi.org/10.1146/annurev.ph.34.030172.000305
2. Hester RL, Coleman T, Summers R. A multilevel open sourceintegrative model of human physiology. The FASEB Journal[Internet] 2008; 22:756.8–756.8. Available from: http://www.fasebj.org/content/22/1_Supplement/756.8.abstract
3. Bassingthwaighte JB. Strategies for the physiome project. AnnBiomed Eng [Internet] 2000; 28:1043–58. Available from:https://www.ncbi.nlm.nih.gov/pubmed/11144666
4. Hunter P, Robbins P, Noble D. The IUPS human PhysiomeProject. Pflugers Arch [Internet] 2002; 445:1–9. Available from:http://dx.doi.org/10.1007/s00424-002-0890-1
5. Hunter PJ, Li WW, McCulloch AD, Noble D. Multiscale mod-eling: physiome project standards, tools, and databases. Com-puter [Internet] 2006; 39:48–54. Available from: http://dx.doi.org/10.1109/MC.2006.392
6. Hunter PJ, Crampin EJ, Nielsen PMF. Bioinformatics, multi-scale modeling and the IUPS Physiome Project. Brief Bioin-form [Internet] 2008; 9:333–43. Available from: http://dx.doi.org/10.1093/bib/bbn024
7. Omholt SW, Hunter PJ. The Human Physiome: a necessary keyfor the creative destruction of medicine. Interface Focus [In-ternet] 2016 [cited 2017 Jan 22]; 6:20160003. Available from:http://rsfs.royalsocietypublishing.org/content/6/2/20160003.abstract
8. Hunter P. The Virtual Physiological Human: The PhysiomeProject Aims to Develop Reproducible, Multiscale Models forClinical Practice. IEEE Pulse [Internet] 2016; 7:36–42. Avail-
10
able from: http://dx.doi.org/10.1109/MPUL.2016.25638419. Dabney JB, Harman TL. Mastering simulink [Internet]. Pear-
son; 2004. Available from: http://cds.cern.ch/record/781806/files/9780131424777_TOC.pdf
10. Kofranek J, Rusz J. Restoration of Guyton’s diagram for regula-tion of the circulation as a basis for quantitative physiologicalmodel development. Physiol Res 2010; 59:897.
11. Kofránek J, Andrlík M, Kripner T, Mašek J, Velan T. Simula-tion chips for GOLEM - multimedia simulator of physiologicalfunctions [Internet]. In: Simulation in Health and Medical Sci-ences. Society for Computer Simulation International, Simula-tion Councils, San Diego; 2002. page 159–63.
12. Kofránek J, Vu LDA, Snaselova H, Kerekes R, Velan T. GO-LEM-multimedia simulator for medical education. Stud HealthTechnol Inform [Internet] 2001; :1042–6. Available from: http://www.physiome.cz/references/MEDINFO2001.pdf
13. Butterworth E, Jardine BE, Raymond GM, Neal ML, Bass-ingthwaighte JB. JSim, an open-source modeling system fordata analysis. F1000Res [Internet] 2013; 2:288. Available from:http://dx.doi.org/10.12688/f1000research.2-288.v1
14. Cuellar AA, Lloyd CM, Nielsen PF, Bullivant DP, NickersonDP, Hunter PJ. An Overview of CellML 1.1, a Biological ModelDescription Language. Simulation [Internet] 2003; 79:740–7.Available from: http://dx.doi.org/10.1177/0037549703040939
15. Garny A, Nickerson DP, Cooper J, Weber dos Santos R, Mill-er AK, McKeever S, Nielsen PMF, Hunter PJ. CellML and as-sociated tools and techniques. Philos Trans A Math Phys EngSci [Internet] 2008; 366:3017–43. Available from: http://dx.doi.org/10.1098/rsta.2008.0094
16. Lloyd CM, Lawson JR, Hunter PJ, Nielsen PF. The CellML Mod-el Repository. Bioinformatics [Internet] 2008; 24:2122–3. Avail-able from: http://dx.doi.org/10.1093/bioinformatics/btn390
17. Cooling MT, Hunter P. The CellML Metadata Framework 2.0Specification. J Integr Bioinform [Internet] 2015; 12:260. Avail-able from: http://dx.doi.org/10.2390/biecoll-jib-2015-260
18. Fritzson P. Principles of object-oriented modeling and simula-tion with Modelica 3.3: A cyber-physical approach. John Wiley& Sons; 2014.
19. Fritzson P. Introduction to modeling and simulation of tech-nical and physical systems with Modelica [Internet]. John Wi-ley & Sons; 2011. Available from: https://www.google.com/books?hl=en&lr=&id=413e_S4DI-IC&oi=fnd&pg=PR5&d-q=Modelica+by+example&ots=4GaaQRhhze&sig=EV-2vKrsAgvwHA0cncsGavAXM4xk
20. Tiller M. Introduction to physical modeling with Modelica[Internet]. Springer Science & Business Media; 2012. Availablefrom: https://www.google.com/books?hl=en&lr=&id=7vcG-CAAAQBAJ&oi=fnd&pg=PR18&dq=Modelica+by+exam-ple&ots=cZ-TZh7G7h&sig=9DeYoyyK56htMLIoJmkVwWX-Z1GA
21. Tiller M. Modelica by Example - electronic interactive book:http://book. xogeny. com. Xogeny.com; 2014.
22. Elmqvist H, Mattsson SE, Otter M. Modelica: The new ob-ject-oriented modeling language [Internet]. In: 12th Europe-an Simulation Multiconference, Manchester, UK. academia.edu; 1998. Available from: http://www.academia.edu/down-load/31411522/esm98mod.pdf
23. Elmqvist H, Mattsson SE, Otter M. Modelica-a language forphysical system modeling, visualization and interaction [In-ternet]. In: Proceedings of the 1999 IEEE International Sym-posium on Computer Aided Control System Design (Cat.No.99TH8404). ieeexplore.ieee.org; 1999. page 630–9.Availablefrom: http://dx.doi.org/10.1109/CACSD.1999.808720
24. Elmqvist H, Mattsson SE. An introduction to the physical mod-
eling language Modelica [Internet]. In: Proceedings of the 9th European Simulation Symposium, ESS. 1997. page 19–23.Avail-able from: https://www.modelica.org/education/publications/papers/ESS97Modelica.pdf
25. Elmqvist H, Mattsson SE, Otter M. Object-Oriented and Hy-brid Modeling in Modelica. Journal Européen des systèmesautomatisés [Internet] 2001 [cited 2017 Aug 16]; 35:395–404.Available from: http://elib.dlr.de/11522/
26. Fritzson P, Engelson V. Modelica—A unified object-orient-ed language for system modeling and simulation [Internet].In: European Conference on Object-Oriented Programming.Springer; 1998. page 67–90.Available from: http://link.springer.com/chapter/10.1007/BFb0054087
27. Kulhánek T, Kofránek J, Mateják M. Modeling of short-termmechanism of arterial pressure control in the cardiovascularsystem: object-oriented and acausal approach. Comput BiolMed [Internet] 2014; 54:137–44. Available from: http://dx.doi.org/10.1016/j.compbiomed.2014.08.025
28. Kofránek J, Kulhánek T, Mateják M, Ježek F, Šilar J. Integra-tive physiology in Modelica. In: Kofránek J, Casella F, editors.Proceedings of the 12th International Modelica Conference.Linköping, Sweden: Modelica Association and Linköping Uni-versity Electronic Press; 2017. page 938.
29. Kofránek J, Mateják M, Privitzer P. Complex model of integrat-ed physiological systems - a theoretical basis for medical train-ing simulators. Mefanet report 2011; 4:22–59.
30. Mateják M, Kulhánek T, Šilar J, Privitzer P, Ježek F, KofránekJ. Physiolibrary-Modelica library for physiology [Internet]. In:Proceedings of the 10 th International Modelica Conference;March 10-12; 2014; Lund; Sweden. Linköping University Elec-tronic Press; 2014. page 499–505.Available from: http://www.ep.liu.se/ecp/article.asp?issue=096&volume=&article=052
31. Mateják M, Ježek F, Tribula M, Kofránek J. Physiolibrary2.3-An Intuitive Tool for Integrative Physiology. IFAC-Pa-persOnLine [Internet] 2015; 48:699–700. Available from:https://www.researchgate.net/profile/Marek_Matejak/publica-tion/281527992_Physiolibrary_23_-_An_Intuitive_Tool_for_Integrative_Physiology/links/55f29ed608ae0af8ee1f906d.pdf
32. Mateják M. Physiology in modelica. MEFANET Journal [In-ternet] 2014; 2:10–4. Available from: http://mj.mefanet.cz/mj-03140307
33. Matejak M, Tribula M, Ježek F, Kofranek J. Free Modelica Li-brary for Chemical and Electrochemical Processes [Internet].In: Proceedings of the 11th International Modelica Conference,Versailles, France, September 21-23, 2015. Linköping Univer-sity Electronic Press; 2015. page 359–66.Available from: http://www.ep.liu.se/ecp/article.asp?issue=118&volume=&article=38
34. Hester RL, Iliescu R, Summers R, Coleman TG. Systems biolo-gy and integrative physiological modelling. J Physiol [Internet]2011; 589:1053–60. Available from: http://dx.doi.org/10.1113/jphysiol.2010.201558
35. Hester R, Brown A, Husband L, Iliescu R. HumMod: a model-ing environment for the simulation of integrative human phys-iology. Frontiers in Physiology [Internet] 2011; Available from:http://journal.frontiersin.org/article/10.3389/fphys.2011.00012
36. Pruett WA, Clemmer JS, Hester RL. Validation of an integrative mathematical model of dehydration and rehydration in virtualhumans. Physiol Rep [Internet] 2016; 4. Available from: http://dx.doi.org/10.14814/phy2.13015
37. Zhang S, Pruett WA, Hester R. Visualization and classificationof physiological failure modes in ensemble hemorrhage simula-tion [Internet]. In: SPIE/IS&T Electronic Imaging. Internation-al Society for Optics and Photonics; 2015 [cited 2017 Jan 22].page 93970O – 93970O – 8.Available from: http://proceedings.
11
spiedigitallibrary.org/proceeding.aspx?articleid=211045038. Lerant AA, Hester RL, Coleman TG, Phillips WJ, Orledge JD,
Murray WB. Preventing and Treating Hypoxia: Using a Physi-ology Simulator to Demonstrate the Value of Pre-Oxygenationand the Futility of Hyperventilation. Int J Med Sci [Internet]2015; 12:625–32. Available from: http://dx.doi.org/10.7150/ijms.12077
39. Xu L, Lyle J, Wu Y, Pan Z, Zhang M, Laidlaw DH, Hester RL,Chen J. HumMod Explorer: A Multi-scale Time-varying Hu-man Modeling Navigator [Internet]. In: SIGGRAPH Asia 2011Posters. New York, NY, USA: ACM; 2011. page 28:1–28:1.Avail-able from: http://doi.acm.org/10.1145/2073304.2073334
40. Wu K, Chen J, Pruett WA, Hester RL. Hummod browser: An ex-ploratory visualization tool for the analysis of whole-body phys-iology simulation data [Internet]. In: 2013 IEEE Symposiumon Biological Data Visualization (BioVis). ieeexplore.ieee.org;2013. page 97–104.Available from: http://dx.doi.org/10.1109/BioVis.2013.6664352
41. Chen J, Wu K, Pruett WA, Hester RL. HumMod browser: Anexploratory visualization tool for model validation of whole-body physiology simulation [Internet]. In: Eurographics Con-ference on Visualization (EuroVis)(short paper). research-gate.net; 2013. Available from: https://www.researchgate.net/profile/Keqin_Wu2/publication/303290077_HumMod_Browser_An_Exploratory_Visualization_Tool_for_Mod-el_Validation_of_Whole-Body_Physiology_Simulation/links/573f6ab108ae298602e8f3cf.pdf
42. Ikeda N, Marumo F, Shirataka M, Sato T. A model of overallregulation of body fluids. Ann Biomed Eng [Internet] 1979;7:135–66. Available from: https://www.ncbi.nlm.nih.gov/pubmed/533022
43. Fontecave-Jallon J, Thomas SR. Implementation of a mod-el of bodily fluids regulation. Acta Biotheor [Internet] 2015;63:269–82. Available from: http://dx.doi.org/10.1007/s10441-015-9250-3
44. Mangourova V, Ringwood J, Van Vliet B. Graphical simula-tion environments for modelling and simulation of integrativephysiology. Comput Methods Programs Biomed [Internet]2011; 102:295–304. Available from: http://dx.doi.org/10.1016/j.cmpb.2010.05.001
45. Kofránek J, Mateják M, Privitzer P. Web simulator creationtechnology. MEFANET report 2010; 3:32–97.
46. Kofranek J, Matejak M, Privitzer P. Hummod-large scale phys-iological models in modelica [Internet]. In: Proceedings of the8th International Modelica Conference; March 20th-22nd;Technical Univeristy; Dresden; Germany. Linköping Universi-ty Electronic Press; 2011. page 713–24.Available from: http://www.ep.liu.se/ecp/article.asp?issue=063&article=079
47. Kofránek J, Mateják M, Privitzer P, Tribula M, Kulhánek T, Silar J, Pecinovsk\`y R. HumMod-Golem Edition: large scale modelof integrative physiology for virtual patient simulators [Inter-net]. In: Proceedings of the International Conference on Mod-eling, Simulation and Visualization Methods (MSV). The Steer-ing Committee of The World Congress in Computer Science,Computer Engineering and Applied Computing (WorldComp); 2013. page 1.Available from: http://search.proquest.com/open-view/b635d0ddadf26eeab45ec30e0ce34fbf/1?pq-origsite=g-scholar&cbl=1976344
48. Mateják M, Kofránek J. Physiomodel - an integrative physiolo-gy in Modelica [Internet]. In: 2015 37th Annual InternationalConference of the IEEE Engineering in Medicine and BiologySociety (EMBC). 2015. page 1464–7.Available from: http://dx.doi.org/10.1109/EMBC.2015.7318646
49. Mateják M. Formalization of Integrative Physiology. CharlesUniversity in Prague [Internet]. 2015; Available from: https://
github.com/MarekMatejak/dissertation/blob/master/thesis.pdf50. Montani JP, Adair TH, Summers RL, Coleman TG, Guyton AC.
A simulation support system for solving large physiologicalmodels on microcomputers. Int J Biomed Comput [Internet]1989; 24:41–54. Available from: https://www.ncbi.nlm.nih.gov/pubmed/2714878
12