12
HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology, First Faculty of Medicine, Charles University U nemocnice 5, 128 53 Praha 2, Czech Republic [email protected] [email protected] [email protected] Abstract Modelica is being used more and more in industrial applications, but Modelica is still not used as much in biomedical applications. For a long time we have mostly been using Matlab/Simulink models, made by Mathworks, for the development of models of physio- logical systems. Recently, we have been using a simu- lation environment based on the Modelica language. In this language, we implemented a large scale model of interconnected physiological subsystems contai- ning thousands of variables. Model is a richly hierar- chically structured, easily modifiable, and “self-docu- menting”. Modelica allows a much clearer than other simulation environments, to express the physiological nature of the modeled reality. Keywords: simulation; physiology; large-scale model 1 Introduction It is simply amazing how fast the Modelica simulation language adopted various commercial development environments. Modelica is being used more and more in industrial applications. However, Modelica is still not used as much in biomedical applications. The vast majority of biomedical simulation applica- tions are still done in casual, block-oriented environ- ments. These include referencing database develop- ment environments for biomedical models (such as the JSIM language - http://physiome.org/model/doku. php or CellML language - http://www.cellml.org/). A frequently used environment in biology and medi- cine is Matlab/Simulink – monographs dedicated to biomedicine models are usually equipped with additi- onal software used in this environment, but so far wi- thout the use of new acasual or non-casual Simulink libraries, such as [24, 28, 32]. However, already in 2006, Cellier and Nebot [5] poin- ted out the benefits of Modelica, when used for clear implementation of physiological systems descriptions and interpretations. The classic McLeod‘s circulation system model was implemented by PHYSBE (PHYS- iological Simulation Benchmark Experiment) [25, 26, 27]. The difference is clearly seen, if we compare the Cellier model implementation [5] with the freely downloadable version of the PHYSBE model imple- mentation in Simulink http://www.mathworks.com/ products/demos/simulink/physbe/. Haas and Burnhan, in their recently published mono- graph, pointed out the benefits and large potential of the Modelica language used for modeling medically adaptive regulatory systems [9]. The most recent, Brugård [4] talks about work on the implementation of the SBML language (http://sbml.org/) in the Mode- lica language. This would enable us in the future, to simply run models, whose structure is described in the SBML language, on development platforms, based on the Modelica language. 2 Web of physiological regulations Thirty-nine years ago, in 1972 Guyton, Coleman and Granger published an article in the Annual Review of Physiology [9] which at a glance was entirely diffe- rent from the usual physiological articles of that time. It was introduced by a large diagram on an insertion. Full of lines and interconnected elements, the drawing vaguely resembled an electrical wiring diagram at first sight (Fig. 1). However, instead of vacuum tubes or other electrical components, it showed interconnec- ted computation blocks (multipliers, dividers, adders, integrators and functional blocks) that symbolized mathematical operations performed on physiological variables. In this entirely new manner, using graphi- cally represented mathematical symbols; the authors described the physiological regulations of the circu- latory system and its broader physiological relations and links with the other subsystems in the body – the kidneys, volumetric and electrolyte balance control, etc. Instead of an extensive set of mathematical equa- tions, the article used a graphical representation of mathematical relations. This syntax allowed depicting relations between individual physiological variables graphically in the form of interconnected blocks re- presenting mathematical operations. The whole dia-

HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

HumMod - Large Scale Physiological Models in ModelicaJiri Kofranek Marek Matejak Pavol Privitzer

Institute of Pathophysiology, First Faculty of Medicine, Charles University U nemocnice 5, 128 53 Praha 2, Czech Republic

[email protected] [email protected] [email protected]

Abstract

Modelica is being used more and more in industrial applications, but Modelica is still not used as much in biomedical applications. For a long time we have mostly been using Matlab/Simulink models, made by Mathworks, for the development of models of physio-logical systems. Recently, we have been using a simu-lation environment based on the Modelica language. In this language, we implemented a large scale model of interconnected physiological subsystems contai-ning thousands of variables. Model is a richly hierar-chically structured, easily modifiable, and “self-docu-menting”. Modelica allows a much clearer than other simulation environments, to express the physiological nature of the modeled reality. Keywords: simulation; physiology; large-scale model

1 Introduction

It is simply amazing how fast the Modelica simulation language adopted various commercial development environments. Modelica is being used more and more in industrial applications. However, Modelica is still not used as much in biomedical applications. The vast majority of biomedical simulation applica-tions are still done in casual, block-oriented environ-ments. These include referencing database develop-ment environments for biomedical models (such as the JSIM language - http://physiome.org/model/doku.php or CellML language - http://www.cellml.org/). A frequently used environment in biology and medi-cine is Matlab/Simulink – monographs dedicated to biomedicine models are usually equipped with additi-onal software used in this environment, but so far wi-thout the use of new acasual or non-casual Simulink libraries, such as [24, 28, 32]. However, already in 2006, Cellier and Nebot [5] poin-ted out the benefits of Modelica, when used for clear implementation of physiological systems descriptions and interpretations. The classic McLeod‘s circulation system model was implemented by PHYSBE (PHYS-

iological Simulation Benchmark Experiment) [25, 26, 27]. The difference is clearly seen, if we compare the Cellier model implementation [5] with the freely downloadable version of the PHYSBE model imple-mentation in Simulink http://www.mathworks.com/products/demos/simulink/physbe/. Haas and Burnhan, in their recently published mono-graph, pointed out the benefits and large potential of the Modelica language used for modeling medically adaptive regulatory systems [9]. The most recent, Brugård [4] talks about work on the implementation of the SBML language (http://sbml.org/) in the Mode-lica language. This would enable us in the future, to simply run models, whose structure is described in the SBML language, on development platforms, based on the Modelica language.

2 Web of physiological regulations

Thirty-nine years ago, in 1972 Guyton, Coleman and Granger published an article in the Annual Review of Physiology [9] which at a glance was entirely diffe-rent from the usual physiological articles of that time. It was introduced by a large diagram on an insertion. Full of lines and interconnected elements, the drawing vaguely resembled an electrical wiring diagram at first sight (Fig. 1). However, instead of vacuum tubes or other electrical components, it showed interconnec-ted computation blocks (multipliers, dividers, adders, integrators and functional blocks) that symbolized mathematical operations performed on physiological variables. In this entirely new manner, using graphi-cally represented mathematical symbols; the authors described the physiological regulations of the circu-latory system and its broader physiological relations and links with the other subsystems in the body – the kidneys, volumetric and electrolyte balance control, etc. Instead of an extensive set of mathematical equa-tions, the article used a graphical representation of mathematical relations. This syntax allowed depicting relations between individual physiological variables graphically in the form of interconnected blocks re-presenting mathematical operations. The whole dia-

Page 2: HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

gram thus featured a formalized description of phys-iological relations in the circulatory system using a graphically represented mathematical model. Guyton’s model was the first extensive mathematical description of the physiological functions of interco-nnected body subsystems and launched the field of physiological research that is sometimes described as “integrative physiology” today. Just as theoretical physics tries to describe physical reality and explain the results of experimental research using formal me-ans, “integrative physiology” strives to create a for-malized description of the interconnection of phys-iological controls based on experimental results and explain their function in the development of various diseases. From this point of view, Guyton’s model was a mi-lestone, trying to adopt a systematic view of physio-logical controls to capture the dynamics of relations between the regulation of the circulation, kidneys, the respiration and the volume and ionic composition of body fluids by means of a graphically represented ne-twork. Guyton’s graphical notation was soon adopted by

other authors – such as Ikeda et al. (1979) in Japan [13] and Amosov et al. (1977) in the former USSR [2]. However, the graphical notation of the mathematical model using a network of interconnected blocks was only a graphical representation – Guyton’s model and later modifications (as well as the models of other authors that adopted Guyton’s representative notati-on) were originally implemented in Fortran and later in C++. Today the situation is different. Now, 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 de-velopment environment by Mathworks, which allows building a simulation model gradually from individual components – types of software simulation elements that are interconnected using a computer mouse to form simulation networks. Simulink blocks are very similar to the elements used by Guyton for the formalized representation of

Figure 1: Guyton’s blood circulation regulation diagram from 1972.

Page 3: HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

physiological relations. The only difference is in their graphical form. This similarity inspired us to use Si-mulink to revive Guyton’s good, classic diagram and transform it into a working simulation model. When implementing the model in Simulink, we used swit-ches that allow us to connect and disconnect indivi-dual subsystems and control loops while the model is running. We strove to keep the appearance of the Simulink model identical to the original graphic dia-gram – the arrangement, wire location, variable na-mes and block numbers are the same. The simulation visualization of the old diagram was not without difficulties – there are errors in the origi-nal graphic diagram of the model! It does not matter in the hand-drawn illustration but if we try to bring it to life in Simulink, the model as a whole collapses immediately. A detailed description of the errors and their corrections is in [23]. Our Simulink implementation of Guyton’s (correc-ted) model (Figs. 2 and 3) is available for download at www.physiome.cz/guyton. Also available at that ad-dress is our Simulink implementation of a much more complex, later model from Guyton et al. There is also

a very detailed description of all applied mathemati-cal relations with an explanation.

3 Block-oriented simulation networks for physiology

Block-oriented simulation languages, of which Simu-link is a typical example, allow assembling computer models from individual blocks with defined inputs and outputs. The blocks are grouped in libraries; when building a model, a computer mouse is used to crea-te individual block instances, with inputs and outputs connected through wires that “conduct” information. A Simulink network can be arranged hierarchically. Blocks can be grouped into subsystems that commu-nicate with their ambient environment through defined input and output “pins”, making “simulation chips” of a sort. A simulation chip hides the simulation network structure from the user, much like an electronic chip hiding the interconnection of transistors and other electronic elements. Then the user can be concerned

Figure 2: The implementation of Guyton’s model in Simulink preserves the original arrangement of elements in Guyton’s graphic diagram.

NON-MUSCLE OXYGEN DELIVERY

269

268

261

260

270

262

263

264

271

272

265

266

267

259

258

257

256

255

POV

OSV

POT

RDO

MO2

DOB

QO2POTP1O

P4O

02M

AOM

271

NON-MUSCLE LOCAL BLOOD FLOW CONTROL

if (POD<0) {POJ=PODx3.3}

278 277 276 275 274 273

285 282 281 280 279

290

284

283284b286287

288

289

AR1

AK1

POB

POK

POD

POV

ARM

AR1AR3

PON

POA

A2K

AR2

POJ

POZ

POC

A3K

AR3

POR

VASCULAR STRESS

RELAXATION

65

64

63

6261

VV7

VV7

VV1

VV2

VVE

SRK

VV6

195

196

197

198

199

200

201

202

203

205206

207

208

209

210

211

212

213 214

215

216

217

218

219

220

221

222

KIDNEY DYNAMICS AND EXCRETIONTHIRST AND DRINKING

192 193 194

190 191

Z10 Z11

STH

TVD

POT

ANTIDIURECTIC HORMONE CONTROL

181

180179178177

175 176 182183

184

185

158A

186

187

188189

AHM AH4

AH2 AH1

AHC

AH

CNZ

CN8

CNR

CNA

PRAAHZ

AH7

AHY

AH8AU

CIRCULATORY DYNAMICS

VIM

AUM

AUM

VIM

AUM

BFN12

3

4

36

35

31

3233

PGS

RSM

38

34

37

RVS

43

42 41A

41

40

39

VBD

VVE

5 6

7 8 9

DAS

QAO30

QLO

LVM

HPLHMD

QLN

2959

58

28

50

16

PA2

60

PLA

24

25

26

27

VVS

QLO

AUH

HMD

QRO

QRO

AUH

VPEPPA

PL1

PPA

RPV

RPT

RPT

PP1

5453

5556

57

52

51

2322 21

2019 18

4849

4645

47

44

10

11

12

13

1415

LVM

CAPILLARY MEMBRANE DYNAMICS66

67

68

69

70 71

7473

6261

80

79

7877

75

74

72

RVS

BFNPVG

PVS

VB

VP

VRC

PTC

PPCPIF

CFC

VPDVUD

DFP

TVD

VP

CPKCPI

CP1

CPP

CPP PRP

VP

CPRLPK

DLP

PPD

DP0

DPL

DPP

DPC

ANGIOTENSIN CONTROL

154 155 156 157 158

159

160161

162163

153b153a

CNA CNEANM

AN1

ANT

ANC

AN2AN3

AN5ANM

REK

RFN

TISSUE FLUIDS, PRESSURES AND GEL

105PTC

108

107

106

109

104

110

103102

112

113

98

97

96

99

92919089

9394 95

100

101

86

85

84

8387

88

111

DPL

VTL

CPI

PIF

PLD

PTT

GP1

GPD

GPR

VG

VIF PTS

PIF

GPD

DPL

VTC

VTL

VID

VTS

VTD

PTT

DPIVIF

IFP

GP2

VGD

VG

V2D

PG2PGC

PTC

PIF

PIFPTS

PRMCHY

HYL

VG

PGR

PGP

PGH

ALDOSTERONE CONTROL

165 166

167

164

168

169

170

171

172173174AM AM5

AM3AM2

AMC

AMT

AM1AMP

KN1CKE

CNA

ANM

AMR

ELECTROLYTES AND CELL WATER

114 115

116

117 118119

120

121

126

125

122123 124

127

128129130

131

135134133

132CKI CCD

CNAVIC

VIDVIC

KI

KCD KIE KIR

KE1

AM

CKEKEKED

KCD

KID

KOD

REK

NEDNAE

CNA

VTW

VIC

VEC

STHNID

VP

VPF

VTS

HEART HYPERTROPHY OR DETERIORATION

340

341

342

343

344 349

348

347

346

345

350

351

352

PA

PPA4

HPLHPR

PP3

PPAHSL HSR

POT

DHM

HMD

RED CELLS AND VISCOSITY

329

330

331

332

333334

335

336

337

338

339POT

PO1

POY

PO2

RC1

RCD

VRC

RKC

RC2VRC

VB

HM

HM2

VIE

VIM

336c

336b

PULMONARY DYNAMICS AND FLUIDS

PLA

136

137

138

139

140

141

142

143

144

145152

146

147

148

149

150

151

PPA

PCP

PPC

POS

PPI

CPF

PFI

PLF

DFP VPF

PPI

PLF

PLF

PPO

POS

CPN

VPFPPR

PPD

PPN

PPC

CPP

AUTONOMIC CONTROL

292291

294293

296297298

295

307303302

301

305

304308

309

310311

312

313

315

314

316317

318319

320

POQPOT

PA

EXE

POQP2O

Z12EXC

AUCPA1

A1B

AUB

AUN

AU8

AUK AU2

AU6

DAU

Z8

AUJ

AULVV9

VVR

AUH

AUM

AVE

AUY

AUD

AUVAU9

AU

HEART RATE AND STROKE VOLUME

328327 323

322

321324325326

SVO

QLO

HR

PRA

AUHMD

MUSCLE BLOOD FLOW CONTROL AND PO2

227

226

225

224

223

228

229

230

231

232

233

234

235

238236

237239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

OSA

OVA

BFM

RMO

BFM

PK1

PK2

DVS

PVO

PMO

PM5

RMO

QOM

PMO

PM3

PK3

PM4

P2O

P3O

EXC

AOM

02A

AUAMM

POE

POM

PDO

PVO

POV

POT

ARM

OVA

P2O

AOM

AMM

AMM

VVE

VV7

VUD

RBF

RFN

NOD

AU

VVR

AUH

AUM

AVE

SVO

HM

BFN

VPFHM

OVA

PPCREK

CNEAUM AHM

AM

AHM

PA

NOD

DPC

AUZ

ARM

VIM

AUM

ANMAVE

RBF

PC

VVR

VV7

AUH

HMD

HSR

HPR

STH

TVD

VTL

AHM

ANM

CNE

AM

VID

CKE

CNA

VTW

PCVB

VP

DPC

CPP

VTC

VTL

DPL

PTC

CPI

VTS

PIF

HPR

HPL

HMD

VIM

HM

VRC

DFP

VPF

PPD

BFN

BFM

RVS

PVS

PRA

QLOPLA

PPA

PA

HSL

PPCVTC

PC

GP3APD

algebraic loop

breaking

algebraic loop

breaking

upper limit 8

upper limit 8lower limit 4

upper limit 8

upper limit 15.0lower limit 0.4

upper limit 1

lower_limit_0

lower limit 6

lower limit 50

lower limit 5

lower limit 4

lower limit 3

lower limit 0.95

lower limit 0.7lower limit 0.5

lower limit 0.3

lower limit 0.2375

lower limit 0.2

lower limit 0.0003

lower limit 0.0001

lower limit 0

lower limit 0

lower limit .005

lower limit .001

12

12

171

3

210

1

0

2

2400

1600

1

1

1

75

25

2130

3550

1

11.4

0.7

0

1

0.7

1

1

2400Xo

00

1.4

50RVM = f(PP2)

30.5

RAR

96.3

RAM

0-4

15

20

QRN = f(PRA)

0.6

QRF

0-4

15

20

QLN = f(PLA)

(u/12)^2PTT = (VTS/12)^2

00

20

10PTS = f(VIF)

2-(0.15/u) PPI = 2 - (0.15/VPF)

u^0.625 PP3^0.1

u^3 POT^3

0.33

u^2PM1^2

u^3

PC^3

u^0.625 PA4^0.625

u^3 P40^3

u^3P3O^3

10u

10u

sqrt

10u

00

1.4

260LVM = f(PA2)

1sxo

1sxo

1sxo

1s

xo

1s

xo

1s

xo

1sxo

1s

xo

1s xo

1s

xo

1s

xo

1s

xo1s

xo

1s xo

1sxo

1s xo

1s xo

1s xo

1s xo

1s

xo

1s xo

1s

1s

1sxo

1sxo

1s

xo

1s

xo

1s xo

1s

5

GF4

0.01095

0.3229

0.9898

2.86

99.95

1

15.22

0.022555.085

0.09914

3.781

2.782

1.014

2.86

6.822e-008

0.01252

40

-3.994e-010

2

40

0.9897

1

1

1.001

-6.328

11.99

20.17

7.987

5.043

0.038250.001896

0.001897

16.8169.78

0.03838

3.004

5.00416.81

198.7

40

142

5

1.115e-006

1.003

10

1.004

0.9999

0.001001

1.002

0.9456

0.0704

1

1.001

1

2.949

1.001

0.1003

1.211

1.211

0.001007

7.999

0.0005

4.0

3.3

0.042

150.1152

1.6379

0.00047

85

512

0.007

1.6283e-007

0.007 0.4

0.1

1.79

0.4

0.4

0.003550.495

5

2.738

1

0.026

1

0.035720

0.85

0.00480.30625

3.25

5

1717

1

0.38

0.0050.1

0.1

100

1

0.0007

0.00333

2

1

139

0.3333

0.0785

6

0.14

6

8.25 4

57.14

0.009

0.01

1

1

1

0.125

0.00781

1851.66

31.67

8.0001

0.0250.001

1000

0.8

1

33

0.5

11

15

0

5

100

1

2.8

0

0.301

0.3

2.9

3.7

28

517

0.002

0.04

70

3

0.3

1

1

2.95

1

1

1

0

0

0.0125

40

0.1

2688

1

2

1 1

1

20

-6.3

0.04

0.002

5

1

12

142

5

0

1

10

1

1

0

1

20

1.2

1.2

0.1

0.001

0

1

0.04

20

0

0.002

1

0.001

0

5

-6.3

2

3.72.8

2.9

0.001

1

0.06

1

51

1

1

1

0

2.95

17

1.2

40

1

1

1

1

1

1.6

40

1

1

8

1

8

100

5

0

1

1

70

28

0

15

1

5

8

8

8

200

15100

0.04

0

0.002

1

12

3

0.0125

1

0.1

8

1

142

5

100

11520

1

1.2

142

401

8

142

0

1

1

1

168

1

1

10

1

128

100

0.3

1

1

1

1

400.0125

200

2.8

40

1

800

2500

122

1

57.14

5

0.5

1

840

0.08

51

0.25

0.15

1

32

0.5 1

40

2

0.21

6

0.0005

1

1

1.24

1

8

3

1

0.5

1

0.85

0.15

0.7

60

0.3

3.159

8

0.4

0.375

0.000225

0.0003

11

0.0003

0.4667

1

0.0125

0.55

40

0.3331.5

0.00092

8.25

100

0.0000058

464e-7

512

0.0025

6

57600

15

57600

100

2850

0.01

140

0.013

8.0001

0.0028

0.00014

0.00042

0.1

0.00352

20.039

19.8

-0.017

60

9

-1

0.25

24.2

-5.9

57

0.4

0.1

0.0047.8

0.25

0.013332

51

0.0825

CV

6

CNY

2.5

CNX

0.2

CN7

0.0212

CN2

u^2 CHY^2

PA1 AUN

AUN CALCULATION

when PA1<50: AUN=6 when 20>PA1<50: AUN=0.2*(50-PA1)

when PA1>=50: AUC=0

AUN calculation

uv

AUJ^AUZ

PA1 AUC

AUC CALCULATION

when PA1<40: AUC=1.2 when 40>PA1<80: AUC=0.03*(80-PA1)

when PA1>=80: AUC=0

AUC calculation

u^3 AUB^3

PA1 AUB

AUB CALCULATION

when PA1<40: AUB=1.85718 when 40>PA1<170: AUB=0.014286*(170-PA1)

when PA1>=170: AUB=0

AUB calculation

1.5

ARF

0 0

4

200AMP = f(PA)

1

(1.2/u)^3

(1.2/RFN)^3

1s

xo

VVS

1s

xo

VRA

1s

xo

VPA

1s

xo

VLA

1sxo

1s

xo

1s

xo

VAS31sxo

1s xo

1s xo

lower limit 0.35

lower limit 0

VIM

VIM

AAR

AAR

AAR

RR

RFN

GLP

PPC

PFL

GFN

GFR

TRR

VUD

AHM

AM

AM

NOD

EVR

RBF

ANU

ANU

RAR

VAS

VAS VAE

PA

PA

PAMPAM

RAM

PGSRSN

BFM

QAO

RV1

RV1

VVS VV8

PVS

PVS

PVS

PVS

QVO

QVO

QVO

DVS

QLO

QLN

QLN

DLA

VLA

VLA

VLE

PLA

PLA

PLA

VB

RVM

RVM

QRN

RVG

DRA

VRA

VRA

PRA

PRA

PR1

PR1

PP2

VPA

VPAPGL

QPO

QPO

RPA

CPA

RFN

GF3

GF3

Page 4: HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

just with the behavior of the chip and does not have to bother about the internal structure and calculation algorithm. The behavior of a simulation chip can be tested by monitoring its outputs using virtual displays or vir-tual oscilloscopes connected to it. This is very useful especially for testing the behaviour of a model and expressing the mutual relations of variables. Simulation chips can be stored in libraries and users can create their instances for use in their models. For example, we created a Physiolibrary for modelling physiological regulations. Hierarchical, block-oriented simulation tools are thus used advantageously in the description of the com-plex regulation systems that we have in physiology. A formalized description of physiological systems is the subject matter of PHYSIOME, an international project that is a successor to the GENOME project. The output of the GENOME project was a detailed description of the human genome; the goal of the PHYSIOME project is a formalized description of physiological functions. It uses computer models as its methodological tool [3, 12]. Several block-oriented simulation tools developed under 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) and CellML (http://www.cellml.org).

4 From Simulink to Modelica in mo-deling of large-scale physiological systems

We have been using Matlab and Simulink for years to create and develop models of physiological systems [16, 17, 23] and have also been developing the rele-vant application Simulink library – the Physiolibrary (http://www.physiome.cz/simchips). We have also developed the relevant software tools that simplify the transfer of models implemented in Simulink over to development environments (Contro-lWeb and Microsoft .NET), where we create tutorial and education simulators [18, 22]. Our development team gained invaluable experience in previous years working with the Matlab/Simulink development en-vironment made by the renown company MathWorks. On the other hand, we were also attracted by the acau-sal development environments using the Modelica language. In the Modelica language environment the essence of physiological regulation is much clearer than in Simulink causal network (see Figures 3 and 4). We were facing a decision whether to continue with the development process of physiological system models in Simulink (using new acasual libraries), or to make a radical decision and switch to the new Modelica lan-guage platform. Our decision was affected by our efforts to imple-

Figure 3: Circulatory dymamics - more detailed cent-ral structures of the Simulink implementation of Gu-yton’s model, representing flows through aggregated parts of the circulatory system and the activity of the heart as a pump.

Figure 4: The same model structure as is shown in figure 3 implemented in Modelica. The structure of the model in Simulink corresponds to the structure of computational steps, while the Structure of Modelica model reflects the structure of the modeled physiolo-gical reality.

Page 5: HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

ment a large model made by Guyton’s disciples and followers. Their Quantitative Human Physiology model is an extension of a tutorial simulator called the Quantitative Circulatory Physiology (QCP) [1]. Quantitative Human Physiology (QHP) simulator [10], which is now distributed as “HumMod” [11], represents today’s most comprehensive and largest model of physiological functions.

The HumMod model contains more than 4000 vari-ables and at the present time, it probably represents the largest and most extensive model of physiologi-cal regulations. It enables the user to simulate a wide range of pathological stages and statuses, including the effects of the relevant applied therapy. The authors developed a special block-oriented simulation system to represent the complex model structure. Compared

Figure 5: All necessary files of the Quantitative Human Physiology tutorial simulator (called the HumMod by the authors in the last version). This simulator has been designed for the Windows operating system and does not require special installation. Only zip files must be unzipped into a selected folder. After you click the Hummod.exe icon, the translator translates the source text embedded within hundreds of directories and more than two thousand files and initiate its own simulator. Even though the source text of the simulator and the entire mathematical model on the background is offered as an open source (and in theory, the user may modify the model), the navigation through thousands of mathematical relations and viewing thousands of XML and interconnected files is rather difficult.

simulátor Hummod

fragment of XML source code

Compiler and launcher of Hummod simulator

Source code files of HumMod simulator

RunningHumMod simulator

Page 6: HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

with the previous QCP simulator, whose mathemati-cal background is hidden from the user in its source code written in C++, the HumMod simulator uses a different approach. The HumMod authors decided to separate the simulator implementation and descrip-tion of the model quotations, in order to make the structure of the model more clear and apparent for the larger scientific community. In 1985 the architect of this model, Thomas Coleman, had already created a special language used to write the model structure, as well as the element definiti-ons into the simulator user interface. The language is based on modified XML notation. The model is then written by using XML files. A special converter/de-coder (DESolver) converts XML files into executable simulator code. A detailed description of this language and DESolver converter, as well as the relevant educational tutorial, is freely accessible on the web page of the University of Mississippi (http://physiology.umc.edu/themode-lingworkshop). The new HumMod model is written

in the XML language as well. Its structure with all de-tails may be found at (http://HumMod.org), published as an open source. Therefore, the user can modify this model as he wishes. However, the model description has been divided into more than three thousand XML files in more than thousand directories, from which the spe-cial solver creates and executes the simulator (Figure 5). The entire structure of the model and following links and references are not easily identifiable. That is why the international research and development team in its SAPHIR project (System Approach for Physiological Integration of Renal, cardiac and respiratory control) decided to use the old Guyton models from 1972 [9] and the Ikeda model from 1979 [13] for the creation of its new and extensive model of physiological func-tions instead of the freely available QHP model. The source codes of the QHP model appeared unclear or hard-to-understand to those involved in this project [31].

VascularCompartments QHPViewSpla

nchn

icVein

s

Equations

Figure 6: Visualization tool QHPView, created by us, simplifies viewing of the QHP/HumMod simulator structure, containing more than two thousand XML files, scattered in thousands of directories, where quotati-ons and links between them may not be apparent.

Page 7: HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

We have been able to create a special software tool called QHPView (Figure 6), which is able to create a clear and legible overview of mathematical relations and connections from thousands of source codes. We are offering this tool as an open source on the web page at (http://physiome.cz/HumMod). First, we tried to implement the QHP/HumMod model in the Simu-link environment. The model contains a wide range of relations that of-fer solutions for implicit equations. That is why the implementation of this block-oriented model (outputs from one block are used as inputs for the next blocks) is very difficult and as the implementation got more and more complex, the transparency of this model went down quickly. The use of new acasual Simulink libraries in this complex model proved to be proble-matic and the transparency of the model improved only a little bit. Therefore, we decided to stop using the Simulink implementation and began to implement in Modeli-ca language (using the Dymola environment). Very quickly we discovered that the implementation of a large and extensive model in Modelica is much more effective than using acasual libraries in Simulink. When we compared the Simulink and Modelica im-plementations we also discovered a significant diffe-rence. Mainly due to the fact that the new acasual lib-raries are only acasual superstructure of Simulink and not an objectively oriented modeling language based on equatations, as the Modelica language is. Therefore, if we compare the development environ-ments based on the simulation language Modelica with the Matlab/Simulink development environments made by Mathworks, we may say the following: • contrary to Simulink, the model implemented in

Modelica much better reflects the essentials and base of the modeled reality and the simulation models are more clear, readable and less error prone;

• the object architecture in Modelica enables the user to build and tweak models with an hierar-chical structure gradually, while using reusable element libraries;

• contrary to Simulink (which is the industrial stan-dard from Mathworks), Modelica is a non pro-prietary programming language and therefore, it may contain various commercial and non-co-mmercial developing environments competing between each other. This language is used for specific problem solutions originating in various application fields (for commercial and non-co-

mmercial specialized libraries); • in Modelica it is possible to combine causal

(mostly signals) and acasual links; and unlike in Simulink, it is also possible, (within interconne-cted blocks) to create algebraic loops - Modelica compiler uses symbolic manipulations to resolve the loops automatically (when possible) and the-refore the disconnection of algebraic loops is the task for the development environment and not for the programmer.

The above specified reasons led us to use, as the main implementation tool for the model creation, the Mo-delica language and we also gradually stopped using the Matlab/Simulink environment [20].

5 HumMod in Modelica

The implementation of the HumMod model clearly shows the benefits of the model creation process when done in the Modelica language. If we compare the complex structure of the HumMod model by using the visualization option in QHPView (Figure 5) with examples of implementations done in the simulation language Modelica, shown in Figures 7-13, we can see that the acasual implementation done in Modelica creates a transparent and legible model structure and

Figure 7: Structure of Hummod model. Model con-sist of cardiovascular component (CVS), nutritient and metabolism component, water and osmolarity component, proteins component, O2, CO2 and acid--base regulation component, electrolyte component, nervous regulation component, hormone regulation component, status of virtual pateint component and setup component. All components ar connected wtih bus connectors.

Page 8: HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

therefore offers easier model modifications. The HumMod model implemented in Modelica is be-ing currently modified and extended. Modifications and extensions of HumMod were par-tially taken from our original model Golem [16, 17] and further modified according to newest findings and experiences. Our modifications are mainly extensions, which improve the usability of the model during the modeling of difficult disorders in acid-base, ionic, vo-lume and osmotic homeostasis of inner environments, which is very important for urgent medicinal statuses. Our modification of the HumMod model is based mainly on the process of re-modeling the subsystem of acid-base balance, which is based in the original QHP on the so-called Stewart acid-base balance theo-

ry. Simply put, the so-called “modern approach“ of Stewart [30] and his followers (e.g. Fencl et al. [8], Sirker et al. [29] ) explaining disorders in the acid--base balance, uses mathematical relations calculating the concentration of hydrogen ions [H+] from partial pressure CO2 in plasma (pCO2), total concentration ([Buftot]), weak (partially dissociated) acids ([HBuf]) and their base ([Buf-]), where:

[Buftot]=[Buf-]+[HBuf] and from the difference between the concentration of fully dissociated cations and fully dissociated anions in SID (strong ion difference):

[H+]=Function (pCO2, SID, Buftot ) The problem of this approach is that the precision of acid-base calculations in the model depends on the

Figure 11: Structure of splanchnic circulation compo-nent (SplanchnicCirculation class).

Figure 9: Structure of systemic circulation component (SystemicCirculation class).

Figure 10: Structure of systemic peripheral circulati-on component (Peripheral class).

Figure 8: Structure of cardiovascular component (CVS class).

Page 9: HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

precision of the SID calculation, that is the difference between the concentration of fully dissociated cations (that is mainly sodium and potassium) and fully di-ssociated anions (mostly chlorides). Imprecision that is created during the modeling of sodium, potassium and chlorides intake and excretion are transferred and reflected by the imprecision in the modeling process of the acid-base status. Even though Hester et al. [11], significantly improved the modeling of reception and excretion of sodium, potassium and chlorides in kidneys in his HumMod model, if we model a long-term status (when nothing is happening with the virtual patient), the virtual pa-tient (in the current model version) has a tendency to fall into slight and steady metabolic acidosis after one

month of the simulated time. Our evaluative approach towards the modeling and evaluation of disorders in acid-basic balance [14, 15, 21] is based on the modeling and evaluation of two flows – the creation and excretion of CO2 and the creation and excretion of strong acids, connec-ted through the purification systems of each part of the bodily fluids. This approach, according to our opinion, better explains the physiological causality of acid-base regulations, rather than direct mode-ling of acid-base disorders through the balancing of accompanying electrolytes. Besides, the fidelity and truthfulness of the modeling process is getting better; mainly in mixed (acid-base and electrolyte) disorders in inner environments. Another important modification of the HumMod, is the fact that the model was extended by adding the dependency of the potassium flow on the intake of glucose as a result of insulin, which enables us to model (besides other things), the influence of pota-ssium solution infusions with insulin and glucoses, which are distributed in acute medicine for treating potassium depletions. We have been using this “balancing and evaluation” approach [18] towards the modeling of acid-base ba-lance in our old “Golem” simulator [17]. The exten-ded HumMod model serves as the base for the educa-tional simulator „eGolem“, used in medical tutoring in clinical physiology of urgent statuses which is be-ing currently developed. On the webpage http://physiome.cz/HumMod you may find the updated and current structure of our implementation of the HumMod model („HumMod--Golem edition“). In collaboration with M. Tiller we are preparing a detailed description of this model with extensive descriptions of the various physiological regulatory circuits.

6 From a model to the simulator

A simulation model, implemented in a sophistica-ted development environment, cannot be used for education as is alone. It is the implementation of the formalized description of the modeled reality that enables testing of the behavior of the mathematic model during various input values and the search for model quotations and parameters, which within the established precision range, can ensure the sufficient compatibility of the behavior of the model with the modeled system (model identification). Even after this goal is reached, there is still a long

Figure 12: Structure of gastrointestinal vascular resi-stance component (GITract class).

Figure 13: Structure of component calculating influ-ence of alpha receptors stimulation on gatrointestinal vascular resistance (AlphaReceptors class).

Page 10: HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

road ahead from the identified model to the educatio-nal or tutorial simulator. It is a very demanding deve-lopment work, which requires the combination of ide-as and experiences of teachers who create the script of the tutorial application, the creativity of art designers who create the multimedia components interconnec-ted with the simulation model in the background, as

well as the efforts of programmers who finally “sew up” the final masterpiece into its final shape. We have used a special web simulator creation technology for creation of educational simulators [20]. To automate the model debugging transfer from the simulation development environment (previously using Simulink and nowadays using Modelica) into

Figure 15: Our new solution of creative interconne-ction of tools and applications, used for the creation of simulators and tutorial programmes using simu-lation games. The base of an e-learning program is still a high-quality script, created by an experienced pedagogue. The creation of animated figures is done by artists who create interactive animations in Expre-ssion Blend. To create and test animations that will be controlled by the simulation model, art designers use the Animtester software tool, developed by us. The core of simulators is the simulation model, created in the Modelica simulation language environment. Wi-thin the project Open Modelica Source Consortium, we are in the process of creating a tool which is able to generate the source code from Modelica to C# lan-guage. This enables us to generate a component from .NET used in the final application on the Silverlight platform, which enables to distribute the simulator as a web application, running in the internet browser (even on computers with various operating systems).

Figure 14: The original solution of creative interco-nnection of tools and applications, used for the crea-tion of simulators and tutorial programmes using si-mulation games. The base of an e-learning program is a high-quality script, created by an experienced pedagogue. The creation of animated pictures is done by artists who create interactive animations in Adobe Flash. The core of simulators is the simula-tion model, created with special development tools, designed for the creation of simulation models. For a long time, we have been using Matlab/Simulink made by Mathworks for the development of models. The simulator development process is a demanding pro-gramming work. To make this task easier, we have developed special programmes that simplify the au-tomatic transfer process of simulation models created in Matlab/Simulink over to ControlWeb or over to the Microsoft .NET environment.

Page 11: HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

the development environment where the development application is programmed, specialized software tools (developed by us) are used. We have been creating tu-torial simulators in Microsoft .NET and Adobe Flash environments (Figure 14). Recently, we began using the Microsoft Silverlight platform (Figure 15), which enables distribution of simulators over the internet and may be executed directly into the internet brow-ser environment (even on computers running various operating systems).

7 Conclusions

Nowadays, the old Comenius motto – “schola ludus,“ or “playful school” [6], has found a modern use in interactive educational programs that use simulation games. Connection of the multimedia environment, serving as an audio-visual user interface, with simula-tion models, gives the studied problem a much more tangible feeling. A simulation game offers the possi-bility to test, without any risk, the simulated object’s behavior. The behavior of individual physiological subsystems can be appreciated in a simulation game, both under normal conditions and in the presence of a disorder. Complex integrative simulators of human physiolo-gy can be of large importance when teaching patho-physiology or studying pathogenesis of varied medi-cal conditions and syndromes using virtual patients. Such simulators include models of not only individual physiological subsystems but also of their mutual co-nnection into more complex units. Modelica is a very convenient developing tool for design of those com-plex hierarchical models.

References

[1] Abram, S.R., Hodnett, B.L., Summers, R.L., Coleman, T.G., Hester R.L., Quantitative Circu-latory Physiology: An Integrative Mathematical Model of Human Physiology for medical educa-tion. Advannced Physiology Education, 31 (2), pp.202 - 210, 2007.

[2] Amosov, N.M, Palec, B.L., Agapov, G.T., Er-makova, I.I., Ljabach, E.G., Packina, S.A., So-loviev, V.P.. Theoretical research of physiologi-cal systems (in Russian). Naukova Dumaka, Kiev, 1977.

[3] Bassingthwaighte J. B., Strategies for the Physi-ome Project“, Annals of Biomedical Engeneer-

ing 28, pp. 1043-1058, 2000.[4] Brugård, J., Hedberg, D., Cascante, M., Geder-

sund, G., Gómez-Garrido, A., Maier, D., Nyman, E., Selivanov, V., Stralfors, P., Creating a Bridge between Modelica and the Systems Biology Community, Proceedings 7th Modelica Confer-ence, Como, Italy, Sep. 20-22, 2009., pp. 473-479, The Modelica Association., Como, 2009. Available http://www.ep.liu.se/ecp/043/052/ecp09430016.pdf.

[5] Cellier, F. E., Nebot, A., Object-oreiented mod-eling in the service of medicine, Proceedings of the 6tha Asia Conference, Bejing, China 2006. 1, pp 33-40. International Academic Publishers, Bejing, 2006.

[6] Comenius, J. A., Schola ludus seu Encyclo-paedea Viva., Sarospartak, 1656.

[7] Fencl, J., Jabor, A., Kazda, A., Figge, J., Diagno-sis of metabolic acid-base disturbances in criti-cally ill patients, Am. J. Respir. Crit. Care., 162, pp. 2246-2251, 2000.

[8] Guyton A. C., Coleman T. A., Granger H. J., Circulation: Overall Regulation, Ann. Rev. Physiol., 41, 13-41, 1972.

[9] Haas, O. C., Burnham, K. J., Systems Modeling and Control Applied to Medicine, in O. C. Haas, K. J. Burnham, Intelligent and Adaptive Systems in Medicine, pp. 17-52, CRC Press, Boca Raton Fl , 2008.

[10] Hester R. L., Coleman T., Summers, R., A multilevel open source model of human physiology.“The FASEB Journal, 22, p. 756, 2008

[11] Hester, R.L, Ilescu, R., Summers R. L , Cole-man T. G., Systems biology and integrative physiological modeling, Journal of Physiology, Published online before print December 6, 2010, doi: 10.1113/jphysiol.2010.201558, Availabe: http://jp.physoc.org/content/early/2010/12/01/jphysiol.2010.201558.full.pdf+html.

[12] Hunter P.J., Robins, P., Noble D., The IUPS Physiome Project, Pflugers Archive-European Journal of Physiology, 445, pp. 1–9, 2002.

[13] Ikeda N., Marumo F., Shirsataka M. A., Model of overall regulation of body fluids, Ann. Bi-omed. Eng. 7, pp. 135-166, 1979.

[14] Kofránek, J., Modelling of blood acid base bal-ance, Ph,D, Thesis, Charles University, Faculty od General Medicine, Prague, 1980.

[15] Kofránek, J., Complex model of acid-base bal-ance (in Czech)., in M. Zeithamlová (Editor), MEDSOFT 2009, Praha: Agentura Action M., pp. 23-60. English translation of the paper is

Page 12: HumMod - Large Scale Physiological Models in Modelica · HumMod - Large Scale Physiological Models in Modelica Jiri Kofranek Marek Matejak Pavol Privitzer Institute of Pathophysiology,

available at http://www.physiome.cz/references/medsoft2009acidbase.pdf, model is available at http://www.physiome.cz/acidbase.

[16] Kofránek, J., Andrlík, M., Kripner, T., Mašek, J., Simulation chips for GOLEM – multimedia simulator of physiological functions, in J. G. Anderson, M. Kapzer (Editor), Simulation in the Health and Medical Sciences 2002. pp. 159-163, Society for Computer Simulation International, Simulation Councils, San Diego, 2002. Available: http://www.physiome.cz/references/simchips2002.pdf.

[17] Kofránek J. Anh Vu L. D., Snášelová H., Kerekeš R. and Velan T., GOLEM – Multimedia simulator for medical education, in MEDINFO 2001, Proceedings of the 10th World Congress on Medical Informatics. (London, UK, 2001), Patel, L., Rogers, R., Haux R. Eds., pp. 1042-1046, IOS Press, London, Available: http://www.physiome.cz/references/medinfo2001.pdf.

[18] Kofránek, J., Mateják, M., Matoušek, S., Privitzer, P., Tribula, M., & Vacek, O., School as a (multimedia simulation) play: use of multimedia applications in teaching of pathological physiology. MEFANET 2008. CD ROM Proceedings, (ISBN 978-80-7392-065-4), kofranek.pdf: pp. 1-26, Masarykova Univerzita, Brno, 2008. Available: http://www.physiome.cz/references/mefanet2008.pdf.

[19] Kofránek, J., Mateják, M. Privitzer, P., Tribula, M., Causal or acausal modeling: labour for hu-mans or labour for machines, in V C. Moler, A. Procházka, R. Bartko, M. Folin, J. Houška, P. Byron (Editor), Technical Computing Prague 2008, 16th Annual Conference Proceedings, CD ROM, 058_kofranek.pdf: pp. 1-16. Humusoft s.r.o., Praha, 2008, Available: http://www.physi-ome.cz/references/tcp2008.pdf.

[20] Kofránek, J. Mateják, M., Privitzer, P.:Web sim-ulator creation technology. MEFANET report, 3, pp. 32-97. Available: http://www.physiome.cz/references/mefanetreport3.pdf.

[21] Kofránek, J., Matoušek, S., Andrlík, M., Border flux ballance approach towards modelling acid-base chemistry and blood gases transport, in V B. Zupanic, S. Karba, S. Blažič (Editor), Proceedings of the 6th EUROSIM Congress on Modeling and Simulation, Full Papers (CD) (TU-1-P7-4, pp. 1-9), University of Ljubljana, Ljubljana 2007. Available: http://www.physiome.cz/references/ljubljana2007.pdf.

[22] Kofránek, J., Matoušek, S., Rusz, J., Privitzer, P., Mateják, M, Tribula, M., The Atlas of physiol-

ogy and pathophysiology: web-based multime-dia enabled interactive simulations, Computer Methods and Programs in Biomedicine, Article in Press, doi:10.1016/j.cmpb.2010.12.007, 11 pp., 2011, Available: http://www.physiome.cz/references/CMPB2011.pdf.

[23] Kofránek, J, Rusz, J., Restoration of Guyton dia-gram for regulation of the circulation as a basis for quantitative physiological model develop-ment Physiological Research, 59, pp 897-908, 2010, Available: http://www.biomed.cas.cz/physiolres/pdf/59/59_897.pdf.

[24] Logan, J. D., Wolesensky, J. D., Mathematical methods in biology. John Wiley & Sons,,Inc., Hoboken, NJ, 2009.

[25] McLeod, J., PHYSBE: A ophysiological simula-tion benchmark experiment, Simulation, 15: pp. 324-329, 1966.

[26] McLeod, J., PHYSBE...a year later, Simulation, 10, pp. 37-45, 1967.

[27] McLeod, J., Toward uniform documentation-PHYSBE and CSMP, Simulation, 14, pp. 215-220, 1970.

[28] Oomnes, C., Breklemans, M., Baaijens, F., Bio-mechanics: concepts and computation. Cam-bridge University Press, Cambridge, 2009.

[29] Sirker, A. A., Rhodes, A., Grounds, R. M.,Acid-base physiology: the ‚traditional‘ and ‚modern‘ approaches, Anesthesia, 57, pp. 348-356, 2001.

[30] Stewart, P. A., Modern quantitative acid-base chemistry. Can. J. Physiol. Pharmacol., 61, 1444-1461, 1983.

[31] Thomas, R. S., Baconnier, P., Fontecave, J., Francoise, J., Guillaud, F., Hannaert, P., Her-mandéz, A., Le Rolle, V., Maziére, P, Tahi, F., White R. J., SAPHIR: a physiome core model of body fluid homeostasis and blood pressure regu-lation, Philosophical Transactions of the Royal Society, 366, pp. 3175-3197, 2008.

[32] Wallish, P., Lusignan, M., Benayoun, M., Baker, T. I., Dickey, A. S., Hatsopoulos, N. G., MAT-LAB for Neuroscientists: An Introduction to Sci-entific Computing in MATLAB. Academic Press, Burlington, MA, 2008.

AcknowledgementWork on the development of medical simulators has been supported by the grants MPO FR-TI3/869, MSM 0021620806 and by Creative Connections s.r.o.