forked from MarekMatejak/Physiolibrary
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Chemical.mo
2478 lines (2229 loc) · 109 KB
/
Chemical.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
within Physiolibrary;
package Chemical "Domain with Molar Concentration and Molar Flow"
extends Modelica.Icons.Package;
package Examples
"Examples that demonstrate usage of the Pressure flow components"
extends Modelica.Icons.ExamplesPackage;
model SimpleReaction
extends Modelica.Icons.Example;
import Physiolibrary.Chemical.Components.*;
Substance A(solute_start=0.9)
annotation (Placement(transformation(extent={{-56,-8},{-36,12}})));
ChemicalReaction reaction(K=1)
annotation (Placement(transformation(extent={{-10,-8},{10,12}})));
Substance B(solute_start=0.1)
annotation (Placement(transformation(extent={{42,-8},{62,12}})));
equation
connect(B.q_out, reaction.products[1]) annotation (Line(
points={{52,2},{10,2}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(A.q_out, reaction.substrates[1]) annotation (Line(
points={{-46,2},{-10,2}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
annotation ( Documentation(revisions="<html>
<p><i>2013</i></p>
<p>Marek Matejak, Charles University, Prague, Czech Republic </p>
</html>"),
experiment(StopTime=1e-007));
end SimpleReaction;
model SimpleReaction2
extends Modelica.Icons.Example;
import Physiolibrary.Chemical.Components.*;
Substance A(solute_start=0.9)
annotation (Placement(transformation(extent={{-40,-8},{-20,12}})));
ChemicalReaction reaction(K=1, nP=2)
annotation (Placement(transformation(extent={{-6,-8},{14,12}})));
Substance B(solute_start=0.1)
annotation (Placement(transformation(extent={{36,-8},{56,12}})));
Substance C(solute_start=0.1)
annotation (Placement(transformation(extent={{36,16},{56,36}})));
equation
connect(A.q_out, reaction.substrates[1]) annotation (Line(
points={{-30,2},{-6,2}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(reaction.products[1], B.q_out) annotation (Line(
points={{14,1.5},{24,1.5},{24,2},{46,2}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(reaction.products[2], C.q_out) annotation (Line(
points={{14,2.5},{24,2.5},{24,26},{46,26}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
annotation ( Documentation(revisions="<html>
<p><i>2013</i></p>
<p>Marek Matejak, Charles University, Prague, Czech Republic </p>
</html>"),
experiment(StopTime=1e-009));
end SimpleReaction2;
model ExothermicReaction
extends Modelica.Icons.Example;
import Physiolibrary.Chemical;
Components.Substance A(solute_start=0.9)
annotation (Placement(transformation(extent={{-56,-8},{-36,12}})));
Components.ChemicalReaction
reaction(K=1,
useHeatPort=true,
dH=-1000,
kf=1)
annotation (Placement(transformation(extent={{-10,-8},{10,12}})));
Components.Substance B(solute_start=0.1)
annotation (Placement(transformation(extent={{44,-8},{64,12}})));
Modelica.Thermal.HeatTransfer.Sensors.HeatFlowSensor heatFlowSensor
annotation (Placement(transformation(extent={{12,-58},{32,-38}})));
Physiolibrary.Thermal.Sources.UnlimitedHeat unlimitedHeat(T=310.15)
annotation (Placement(transformation(extent={{74,-58},{54,-38}})));
equation
connect(B.q_out, reaction.products[1]) annotation (Line(
points={{54,2},{10,2}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(A.q_out, reaction.substrates[1]) annotation (Line(
points={{-46,2},{-10,2}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(reaction.heatPort, heatFlowSensor.port_a) annotation (Line(
points={{0,2},{0,-48},{12,-48}},
color={191,0,0},
thickness=1,
smooth=Smooth.None));
connect(unlimitedHeat.port, heatFlowSensor.port_b) annotation (Line(
points={{54,-48},{32,-48}},
color={191,0,0},
thickness=1,
smooth=Smooth.None));
annotation ( Documentation(revisions="<html>
<p><i>2013</i></p>
<p>Marek Matejak, Charles University, Prague, Czech Republic </p>
</html>"),
experiment(StopTime=5));
end ExothermicReaction;
model MichaelisMenten "Basic enzyme kinetics"
import Physiolibrary;
extends Modelica.Icons.Example;
extends Physiolibrary.SteadyStates.Interfaces.SteadyStateSystem(
Simulation=Types.SimulationType.SteadyState);
import Physiolibrary.Types.*;
Physiolibrary.Chemical.Sources.UnlimitedSolutionStorage
P(Conc=0)
annotation (Placement(transformation(extent={{92,-12},{72,8}})));
Physiolibrary.Chemical.Sources.UnlimitedSolutionStorage
S(Conc=0.1)
annotation (Placement(transformation(extent={{-94,-12},{-74,8}})));
parameter AmountOfSubstance tE=0.01 "total amount of enzyme";
parameter Real k_cat(unit="1/s", displayUnit="1/min")= 1
"forward rate of second reaction";
parameter Physiolibrary.Types.Concentration Km = 0.1
"Michaelis constant = substrate concentration at rate of half Vmax";
Physiolibrary.Chemical.Components.Substance
ES( solute_start=0,
Simulation=SimulationType.SteadyState)
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
Physiolibrary.Chemical.Components.Substance
E( solute_start=tE,
isDependent=true,
Simulation=SimulationType.SteadyState)
annotation (Placement(transformation(extent={{-10,38},{10,58}})));
Components.ChemicalReaction
chemicalReaction(nS=2,
K=2/Km,
kf=2*k_cat/Km)
annotation (Placement(transformation(extent={{-42,-10},{-22,10}})));
Components.ChemicalReaction
chemicalReaction1(nP=2,
K=Modelica.Constants.inf,
kf=k_cat)
annotation (Placement(transformation(extent={{24,-10},{44,10}})));
// Real v(unit="mol/s", displayUnit="mmol/min") "test of MM equation";
equation
normalizedState[1]*tE = E.solute + ES.solute;
//Michaelis-Menton: v=((E.q_out.conc + ES.q_out.conc)*k_cat)*S.concentration/(Km+S.concentration);
connect(S.q_out, chemicalReaction.substrates[1]) annotation (Line(
points={{-74,-2},{-60,-2},{-60,-0.5},{-42,-0.5}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(chemicalReaction1.products[1], P.q_out) annotation (Line(
points={{44,-0.5},{54,-0.5},{54,-2},{72,-2}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(E.q_out, chemicalReaction.substrates[2]) annotation (Line(
points={{0,48},{-50,48},{-50,0.5},{-42,0.5}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(E.q_out, chemicalReaction1.products[2]) annotation (Line(
points={{0,48},{50,48},{50,0.5},{44,0.5}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(chemicalReaction.products[1], ES.q_out) annotation (Line(
points={{-22,0},{0,0}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(ES.q_out, chemicalReaction1.substrates[1]) annotation (Line(
points={{0,0},{24,0}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
annotation ( Documentation(revisions="<html>
<p><i>2013</i></p>
<p>Marek Matejak, Charles University, Prague, Czech Republic </p>
</html>"),
experiment(StopTime=1));
end MichaelisMenten;
model HendersonHaselbalch
extends Modelica.Icons.Example;
Components.Substance HCO3(isDependent=true, Simulation=Physiolibrary.Types.SimulationType.SteadyState)
annotation (Placement(transformation(extent={{-18,46},{2,66}})));
Components.ChemicalReaction HendersonHasselbalch(
nP=2,
K=10^(-6.103 + 3),
dH=15.13)
annotation (Placement(transformation(extent={{-58,22},{-38,42}})));
Sources.UnlimitedGasStorage CO2_gas(PartialPressure=5332.8954966,
Simulation=Physiolibrary.Types.SimulationType.SteadyState)
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
rotation=270,
origin={-80,82})));
Sources.UnlimitedSolutionStorage pH(
q_out(conc(nominal=10^(-7.4 + 3))),
Conc=10^(-7.4 + 3),
isIsolatedInSteadyState=false,
Simulation=Physiolibrary.Types.SimulationType.SteadyState) annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={-8,12})));
Components.GasSolubility gasSolubility(C=2400, kH_T0(displayUnit="(mmol/l)/kPa at 25degC")=
0.81805576878885)
annotation (Placement(transformation(extent={{-90,46},{-70,66}})));
Components.Substance CO2_liquid(Simulation=Physiolibrary.Types.SimulationType.SteadyState)
annotation (Placement(transformation(extent={{-90,22},{-70,42}})));
equation
connect(HendersonHasselbalch.products[1], HCO3.q_out) annotation (Line(
points={{-38,31.5},{-26,31.5},{-26,56},{-8,56}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(pH.q_out, HendersonHasselbalch.products[2]) annotation (Line(
points={{-18,12},{-26,12},{-26,32.5},{-38,32.5}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(CO2_liquid.q_out, HendersonHasselbalch.substrates[1]) annotation (
Line(
points={{-80,32},{-58,32}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(gasSolubility.q_in, CO2_liquid.q_out) annotation (Line(
points={{-80,48},{-80,32}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(CO2_gas.q_out, gasSolubility.q_out) annotation (Line(
points={{-80,72},{-80,66}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
annotation ( Documentation(info="<html>
<p>Henderson-Hasselbalch equation in ideal buffered solution, where pH remains constant.</p>
<p>The partial pressure of CO2 in gas are input parameter. Outputs are an amount of free disolved CO2 in liquid and an amount of HCO3-.</p>
</html>", revisions="<html>
<p><i>2014</i></p>
<p>Marek Matejak, Charles University, Prague, Czech Republic </p>
</html>"),
experiment(StopTime=1));
end HendersonHaselbalch;
package Hemoglobin "Hemoglobin blood gases binding"
model Allosteric_Hemoglobin_MWC "Monod,Wyman,Changeux (1965)"
extends Modelica.Icons.Example;
import Physiolibrary.Chemical.*;
import Physiolibrary.Types.*;
//extends Physiolibrary.SteadyStates.Interfaces.SteadyStateSystem(
// Simulation=SimulationType.SteadyState);
parameter Temperature T=310.15 "Temperature";
// parameter GasSolubility alpha = Modelica.Constants.R*298.15 * 0.0105 * 1e-3
// "oxygen solubility in plasma";
// by Siggaard Andersen: 0.0105 (mmol/l)/kPa
parameter Fraction L = 7.0529*10^6
"=[T0]/[R0] .. dissociation constant of relaxed <-> tensed change of deoxyhemoglobin tetramer";
parameter Fraction c = 0.00431555
"=KR/KT .. ration between oxygen affinities of relaxed vs. tensed subunit";
parameter Concentration KR = 0.000671946
"oxygen dissociation on relaxed(R) hemoglobin subunit"; //*7.875647668393782383419689119171e-5
//10.500001495896 7.8756465463794e-05
parameter Concentration KT=KR/c
"oxygen dissociation on tensed(T) hemoglobin subunit";
// Fraction sO2 "hemoglobin oxygen saturation";
parameter AmountOfSubstance totalAmountOfHemoglobin=1;
// AmountOfSubstance totalAmountOfRforms;
// AmountOfSubstance totalAmountOfTforms;
Components.Substance T0(stateName="T0",Simulation=SimulationType.SteadyState,
solute_start=1)
annotation (Placement(transformation(extent={{32,78},{52,98}})));
Components.Substance T1(stateName="T1",Simulation=SimulationType.SteadyState,
solute_start=0)
annotation (Placement(transformation(extent={{34,36},{54,56}})));
Components.Substance R1(stateName="R1",Simulation=SimulationType.SteadyState,
solute_start=0,
isDependent=true)
annotation (Placement(transformation(extent={{-20,36},{0,56}})));
Components.Substance T2(stateName="T2",Simulation=SimulationType.SteadyState,
solute_start=0)
annotation (Placement(transformation(extent={{34,-10},{54,10}})));
Components.Substance R2(stateName="R2",Simulation=SimulationType.SteadyState,
solute_start=0)
annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
Components.Substance T3(stateName="T3",Simulation=SimulationType.SteadyState,
solute_start=0)
annotation (Placement(transformation(extent={{34,-54},{54,-34}})));
Components.Substance R3(stateName="R3",Simulation=SimulationType.SteadyState,
solute_start=0)
annotation (Placement(transformation(extent={{-20,-54},{0,-34}})));
Components.Substance T4(stateName="T4",Simulation=SimulationType.SteadyState,
solute_start=0,
isDependent=true)
annotation (Placement(transformation(extent={{34,-92},{54,-72}})));
Components.Substance R4(stateName="R4",Simulation=SimulationType.SteadyState,
solute_start=0)
annotation (Placement(transformation(extent={{-20,-92},{0,-72}})));
Components.Substance R0(stateName="R0",Simulation=SimulationType.SteadyState,
solute_start=0)
annotation (Placement(transformation(extent={{-20,78},{0,98}})));
Components.ChemicalReaction quaternaryForm(K=L)
annotation (Placement(transformation(extent={{4,78},{24,98}})));
Components.ChemicalReaction oxyR1(nP=2, K=KR/4)
annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
rotation=90,
origin={-10,64})));
Components.ChemicalReaction oxyT1(nP=2, K=KT/4)
annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=90,
origin={44,64})));
Components.ChemicalReaction oxyR2(nP=2, K=KR/(3/2))
annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
rotation=90,
origin={-10,22})));
Components.ChemicalReaction oxyR3(nP=2, K=KR/(2/3))
annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
rotation=90,
origin={-10,-24})));
Components.ChemicalReaction oxyR4(nP=2, K=KR*4)
annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
rotation=90,
origin={-10,-66})));
Components.ChemicalReaction oxyT2(nP=2, K=KT/(3/2))
annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=90,
origin={44,22})));
Components.ChemicalReaction oxyT3(nP=2, K=KT/(2/3))
annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=90,
origin={44,-24})));
Components.ChemicalReaction oxyT4(nP=2, K=KT*4)
annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=90,
origin={44,-66})));
Components.ChemicalReaction quaternaryForm1(K=c*L)
annotation (Placement(transformation(extent={{8,36},{28,56}})));
Components.ChemicalReaction quaternaryForm2(K=(c^2)*L)
annotation (Placement(transformation(extent={{8,-10},{28,10}})));
Components.ChemicalReaction quaternaryForm3(K=(c^3)*L)
annotation (Placement(transformation(extent={{8,-54},{28,-34}})));
Components.ChemicalReaction quaternaryForm4(K=(c^4)*L)
annotation (Placement(transformation(extent={{10,-92},{30,-72}})));
SteadyStates.Components.MolarConservationLaw hemoglobinConservationLaw(
n=10, Total(displayUnit="mol") = 1,
Simulation=Physiolibrary.Types.SimulationType.SteadyState)
annotation (Placement(transformation(extent={{72,-2},{92,18}})));
Modelica.Blocks.Math.Sum oxygen_bound(k={1,1,2,2,3,3,4,4}, nin=8)
annotation (Placement(transformation(extent={{72,-56},{82,-46}})));
Modelica.Blocks.Math.Division sO2_ "hemoglobin oxygen saturation"
annotation (Placement(transformation(extent={{86,-60},{96,-50}})));
Modelica.Blocks.Math.Sum tHb(nin=10, k=4*ones(10))
annotation (Placement(transformation(extent={{72,-70},{82,-60}})));
Components.Substance oxygen_unbound(solute_start=0.000001*
7.875647668393782383419689119171e-5, Simulation=SimulationType.SteadyState)
annotation (Placement(transformation(extent={{-56,-44},{-36,-24}})));
Modelica.Blocks.Sources.Clock clock(offset=60)
annotation (Placement(transformation(extent={{-94,44},{-74,64}})));
Sources.UnlimitedGasStorage O2_in_air(Simulation=Physiolibrary.Types.SimulationType.SteadyState,
usePartialPressureInput=true,
T=310.15) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-66,24})));
Components.GasSolubility gasSolubility(
useHeatPort=false, kH_T0=
0.026029047188736)
annotation (Placement(transformation(extent={{-76,-14},{-56,6}})));
equation
// sO2 = (R1.solute + 2*R2.solute + 3*R3.solute + 4*R4.solute + T1.solute + 2*T2.solute + 3*T3.solute + 4*T4.solute)/(4*totalAmountOfHemoglobin);
// totalAmountOfRforms = R0.solute + R1.solute + R2.solute + R3.solute + R4.solute;
// totalAmountOfTforms = T0.solute + T1.solute + T2.solute + T3.solute + T4.solute;
// totalAmountOfHemoglobin*normalizedState[1] = totalAmountOfRforms + totalAmountOfTforms;
connect(quaternaryForm.products[1],T0. q_out) annotation (Line(
points={{24,88},{42,88}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyR1.substrates[1],R1. q_out) annotation (Line(
points={{-10,54},{-10,46}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(R1.q_out,oxyR2. products[1]) annotation (Line(
points={{-10,46},{-10,32},{-10.5,32}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyR2.substrates[1],R2. q_out) annotation (Line(
points={{-10,12},{-10,0}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyR3.substrates[1],R3. q_out) annotation (Line(
points={{-10,-34},{-10,-44}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyR3.products[1],R2. q_out) annotation (Line(
points={{-10.5,-14},{-10.5,-7},{-10,-7},{-10,0}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(R3.q_out,oxyR4. products[1]) annotation (Line(
points={{-10,-44},{-10,-56},{-10.5,-56}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyR4.substrates[1],R4. q_out) annotation (Line(
points={{-10,-76},{-10,-82}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyT1.products[1],T0. q_out) annotation (Line(
points={{44.5,74},{44.5,88},{42,88}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyT1.substrates[1],T1. q_out) annotation (Line(
points={{44,54},{44,46}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(T1.q_out,oxyT2. products[1]) annotation (Line(
points={{44,46},{44,32},{44.5,32}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyT2.substrates[1],T2. q_out) annotation (Line(
points={{44,12},{44,0}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(T2.q_out,oxyT3. products[1]) annotation (Line(
points={{44,0},{44,-14},{44.5,-14}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyT3.substrates[1],T3. q_out) annotation (Line(
points={{44,-34},{44,-44}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(T3.q_out,oxyT4. products[1]) annotation (Line(
points={{44,-44},{44,-56},{44.5,-56}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyT4.substrates[1],T4. q_out) annotation (Line(
points={{44,-76},{44,-82}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(R0.q_out,quaternaryForm. substrates[1]) annotation (Line(
points={{-10,88},{4,88}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(R0.q_out,oxyR1. products[1]) annotation (Line(
points={{-10,88},{-10,74},{-10.5,74}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(R1.q_out,quaternaryForm1. substrates[1]) annotation (Line(
points={{-10,46},{8,46}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(quaternaryForm1.products[1],T1. q_out) annotation (Line(
points={{28,46},{44,46}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(R2.q_out,quaternaryForm2. substrates[1]) annotation (Line(
points={{-10,0},{8,0}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(quaternaryForm2.products[1],T2. q_out) annotation (Line(
points={{28,0},{44,0}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(R3.q_out,quaternaryForm3. substrates[1]) annotation (Line(
points={{-10,-44},{8,-44}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(quaternaryForm3.products[1],T3. q_out) annotation (Line(
points={{28,-44},{44,-44}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(R4.q_out,quaternaryForm4. substrates[1]) annotation (Line(
points={{-10,-82},{10,-82}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(quaternaryForm4.products[1],T4. q_out) annotation (Line(
points={{30,-82},{44,-82}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(R4.solute,hemoglobinConservationLaw. fragment[1]) annotation (
Line(
points={{-10,-92},{-10,-98},{64,-98},{64,2.2},{72,2.2}},
color={0,0,127},
smooth=Smooth.None));
connect(T4.solute,hemoglobinConservationLaw. fragment[2]) annotation (
Line(
points={{44,-92},{44,-98},{64,-98},{64,2.6},{72,2.6}},
color={0,0,127},
smooth=Smooth.None));
connect(R3.solute,hemoglobinConservationLaw. fragment[3]) annotation (
Line(
points={{-10,-54},{64,-54},{64,3},{72,3}},
color={0,0,127},
smooth=Smooth.None));
connect(T3.solute,hemoglobinConservationLaw. fragment[4]) annotation (
Line(
points={{44,-54},{64,-54},{64,3.4},{72,3.4}},
color={0,0,127},
smooth=Smooth.None));
connect(R2.solute,hemoglobinConservationLaw. fragment[5]) annotation (
Line(
points={{-10,-10},{64,-10},{64,3.8},{72,3.8}},
color={0,0,127},
smooth=Smooth.None));
connect(T2.solute,hemoglobinConservationLaw. fragment[6]) annotation (
Line(
points={{44,-10},{64,-10},{64,4.2},{72,4.2}},
color={0,0,127},
smooth=Smooth.None));
connect(R1.solute,hemoglobinConservationLaw. fragment[7]) annotation (
Line(
points={{-10,36},{64,36},{64,4.6},{72,4.6}},
color={0,0,127},
smooth=Smooth.None));
connect(T1.solute,hemoglobinConservationLaw. fragment[8]) annotation (
Line(
points={{44,36},{64,36},{64,5},{72,5}},
color={0,0,127},
smooth=Smooth.None));
connect(R0.solute,hemoglobinConservationLaw. fragment[9]) annotation (
Line(
points={{-10,78},{64,78},{64,5.4},{72,5.4}},
color={0,0,127},
smooth=Smooth.None));
connect(T0.solute,hemoglobinConservationLaw. fragment[10]) annotation (
Line(
points={{42,78},{64,78},{64,5.8},{72,5.8}},
color={0,0,127},
smooth=Smooth.None));
connect(R1.solute,oxygen_bound. u[1]) annotation (Line(
points={{-10,36},{64,36},{64,-51.875},{71,-51.875}},
color={0,0,127},
smooth=Smooth.None));
connect(T1.solute,oxygen_bound. u[2]) annotation (Line(
points={{44,36},{64,36},{64,-51.625},{71,-51.625}},
color={0,0,127},
smooth=Smooth.None));
connect(R2.solute,oxygen_bound. u[3]) annotation (Line(
points={{-10,-10},{64,-10},{64,-51.375},{71,-51.375}},
color={0,0,127},
smooth=Smooth.None));
connect(T2.solute,oxygen_bound. u[4]) annotation (Line(
points={{44,-10},{64,-10},{64,-51.125},{71,-51.125}},
color={0,0,127},
smooth=Smooth.None));
connect(R3.solute,oxygen_bound. u[5]) annotation (Line(
points={{-10,-54},{64,-54},{64,-50.875},{71,-50.875}},
color={0,0,127},
smooth=Smooth.None));
connect(T3.solute,oxygen_bound. u[6]) annotation (Line(
points={{44,-54},{64,-54},{64,-50.625},{71,-50.625}},
color={0,0,127},
smooth=Smooth.None));
connect(R4.solute,oxygen_bound. u[7]) annotation (Line(
points={{-10,-92},{-10,-98},{64,-98},{64,-50.375},{71,-50.375}},
color={0,0,127},
smooth=Smooth.None));
connect(T4.solute,oxygen_bound. u[8]) annotation (Line(
points={{44,-92},{44,-98},{64,-98},{64,-50.125},{71,-50.125}},
color={0,0,127},
smooth=Smooth.None));
connect(oxygen_bound.y,sO2_. u1) annotation (Line(
points={{82.5,-51},{84,-51},{84,-52},{85,-52}},
color={0,0,127},
smooth=Smooth.None));
connect(sO2_.u2,tHb. y) annotation (Line(
points={{85,-58},{84,-58},{84,-65},{82.5,-65}},
color={0,0,127},
smooth=Smooth.None));
connect(R0.solute,tHb. u[1]) annotation (Line(
points={{-10,78},{64,78},{64,-65.9},{71,-65.9}},
color={0,0,127},
smooth=Smooth.None));
connect(T0.solute,tHb. u[2]) annotation (Line(
points={{42,78},{64,78},{64,-65.7},{71,-65.7}},
color={0,0,127},
smooth=Smooth.None));
connect(R1.solute,tHb. u[3]) annotation (Line(
points={{-10,36},{64,36},{64,-65.5},{71,-65.5}},
color={0,0,127},
smooth=Smooth.None));
connect(T1.solute,tHb. u[4]) annotation (Line(
points={{44,36},{64,36},{64,-65.3},{71,-65.3}},
color={0,0,127},
smooth=Smooth.None));
connect(R2.solute,tHb. u[5]) annotation (Line(
points={{-10,-10},{64,-10},{64,-65.1},{71,-65.1}},
color={0,0,127},
smooth=Smooth.None));
connect(T2.solute,tHb. u[6]) annotation (Line(
points={{44,-10},{64,-10},{64,-64.9},{71,-64.9}},
color={0,0,127},
smooth=Smooth.None));
connect(R3.solute,tHb. u[7]) annotation (Line(
points={{-10,-54},{64,-54},{64,-64.7},{71,-64.7}},
color={0,0,127},
smooth=Smooth.None));
connect(T3.solute,tHb. u[8]) annotation (Line(
points={{44,-54},{64,-54},{64,-64.5},{71,-64.5}},
color={0,0,127},
smooth=Smooth.None));
connect(R4.solute,tHb. u[9]) annotation (Line(
points={{-10,-92},{-10,-98},{64,-98},{64,-64.3},{71,-64.3}},
color={0,0,127},
smooth=Smooth.None));
connect(T4.solute,tHb. u[10]) annotation (Line(
points={{44,-92},{44,-98},{64,-98},{64,-64.1},{71,-64.1}},
color={0,0,127},
smooth=Smooth.None));
connect(oxyR1.products[2],oxygen_unbound. q_out)
annotation (Line(
points={{-9.5,74},{-46,74},{-46,-34}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyR2.products[2],oxygen_unbound. q_out)
annotation (Line(
points={{-9.5,32},{-46,32},{-46,-34}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyR3.products[2],oxygen_unbound. q_out)
annotation (Line(
points={{-9.5,-14},{-46,-14},{-46,-34}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxyR4.products[2],oxygen_unbound. q_out)
annotation (Line(
points={{-9.5,-56},{-46,-56},{-46,-34}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygen_unbound.q_out, oxyT1.products[2])
annotation (Line(
points={{-46,-34},{-46,74},{43.5,74}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygen_unbound.q_out, oxyT2.products[2])
annotation (Line(
points={{-46,-34},{-46,32},{43.5,32}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygen_unbound.q_out, oxyT3.products[2])
annotation (Line(
points={{-46,-34},{-46,-14},{43.5,-14}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygen_unbound.q_out, oxyT4.products[2])
annotation (Line(
points={{-46,-34},{-46,-56},{43.5,-56}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygen_unbound.q_out,gasSolubility. q_in) annotation (Line(
points={{-46,-34},{-66,-34},{-66,-12}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(O2_in_air.q_out,gasSolubility. q_out) annotation (Line(
points={{-66,14},{-66,6}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(clock.y,O2_in_air. partialPressure) annotation (Line(
points={{-73,54},{-66,54},{-66,34}},
color={0,0,127},
smooth=Smooth.None));
annotation ( experiment(StopTime=10000), Documentation(info=
"<html>
<p>To understand the model is necessary to study the principles of MWC allosteric transitions first published by </p>
<p>Monod,Wyman,Changeux (1965). "On the nature of allosteric transitions: a plausible model." Journal of molecular biology 12(1): 88-118.</p>
<p><br/>In short it is about binding oxygen to hemoglobin.</p>
<p>Oxgen are driven by its partial pressure using clock source - from very little pressure to pressure of 10kPa.</p>
<p>(Partial pressure of oxygen in air is the air pressure multiplied by the fraction of the oxygen in air.)</p>
<p>Hemoglobin was observed (by Perutz) in two structuraly different forms R and T.</p>
<p>These forms are represented by blocks T0..T4 and R0..R4, where the suffexed index means the number of oxygen bounded to the form.</p>
<p><br/>In equilibrated model can be four chemical reactions removed and the results will be the same, but dynamics will change a lot. ;)</p>
<p>If you remove the quaternaryForm1,quaternaryForm2,quaternaryForm3,quaternaryForm4 then the model in equilibrium will be exactly the same as in MWC article.</p>
<p><br/>Parameters was fitted to data of Severinghaus article from 1979. (For example at pO2=26mmHg is oxygen saturation sO2 = 48.27 %).</p>
</html>", revisions="<html>
<p><i>2013</i></p>
<p>Marek Matejak, Charles University, Prague, Czech Republic </p>
</html>"));
end Allosteric_Hemoglobin_MWC;
model Allosteric_Hemoglobin2_MWC
"Monod,Wyman,Changeux (1965) - The same allosteric hemoglobin model as Allosteric_Hemoglobin_MWC implemented by Speciation blocks"
import Physiolibrary.Types.*;
extends Modelica.Icons.Example;
// extends Physiolibrary.SteadyStates.Interfaces.SteadyStateSystem(
// Simulation=SimulationType.SteadyState);
// parameter GasSolubility alpha = 0.0105 * 1e-3 "oxygen solubility in plasma"; // by Siggaard Andersen: 0.0105 (mmol/l)/kPa
parameter Fraction L = 7.0529*10^6
"=[T0]/[R0] .. dissociation constant of relaxed <-> tensed change of deoxyhemoglobin tetramer";
parameter Fraction c = 0.00431555
"=KR/KT .. ration between oxygen affinities of relaxed vs. tensed subunit";
parameter Concentration KR = 0.000671946
"oxygen dissociation on relaxed(R) hemoglobin subunit"; //*7.875647668393782383419689119171e-5
//10.500001495896 7.8756465463794e-05
parameter Concentration KT=KR/c
"oxygen dissociation on tensed(T) hemoglobin subunit";
// Fraction sO2 "hemoglobin oxygen saturation";
parameter AmountOfSubstance totalAmountOfHemoglobin=0.001;
Physiolibrary.Chemical.Components.ChemicalReaction
quaternaryForm(K=L)
annotation (Placement(transformation(extent={{-4,-84},{16,-64}})));
Components.Speciation
R0_in_R(NumberOfSubunitTypes=4)
annotation (Placement(transformation(extent={{-32,-76},{-52,-56}})));
Components.Speciation
T0_in_T(NumberOfSubunitTypes=4)
annotation (Placement(transformation(extent={{68,-74},{48,-54}})));
Physiolibrary.Chemical.Components.Substance OxyRHm[4](
each Simulation=SimulationType.SteadyState,
each isDependent=true,
each solute_start=4e-19)
"Oxygenated subunit in R structure of hemoglobin tetramer"
annotation (Placement(transformation(extent={{-98,-36},{-78,-16}})));
Physiolibrary.Chemical.Components.ChemicalReaction oxygenation_R[4](each K=KR, each nP=2)
annotation (Placement(transformation(extent={{-70,-36},{-50,-16}})));
Physiolibrary.Chemical.Components.Substance DeoxyRHm[4](each Simulation=
SimulationType.SteadyState, each solute_start=4e-11)
"Deoxygenated subunit in R structure of hemoglobin tetramer"
annotation (Placement(transformation(extent={{-42,-36},{-22,-16}})));
Physiolibrary.Chemical.Components.Substance OxyTHm[4](
each Simulation=SimulationType.SteadyState,
each isDependent=true,
each solute_start=1e-14)
"Oxygenated subunit in T structure of hemoglobin tetramer"
annotation (Placement(transformation(extent={{14,-36},{34,-16}})));
Physiolibrary.Chemical.Components.ChemicalReaction oxygenation_T[4](each K=KT, each nP=2)
annotation (Placement(transformation(extent={{42,-36},{62,-16}})));
Physiolibrary.Chemical.Components.Substance DeoxyTHm[4](
each Simulation=SimulationType.SteadyState,
each solute_start=0.00025)
"Deoxygenated subunit in T structure of hemoglobin tetramer"
annotation (Placement(transformation(extent={{70,-36},{90,-16}})));
Physiolibrary.Chemical.Components.Substance
oxygen_unbound(Simulation=SimulationType.SteadyState, solute_start=0.000001
*7.875647668393782383419689119171e-5)
annotation (Placement(transformation(extent={{-4,-2},{16,18}})));
Modelica.Blocks.Sources.Clock clock(offset=60)
annotation (Placement(transformation(extent={{-40,74},{-20,94}})));
Modelica.Blocks.Math.Add add[4] annotation (Placement(transformation(
extent={{-4,-4},{4,4}},
rotation=270,
origin={-66,-54})));
Modelica.Blocks.Math.Add add1[4] annotation (Placement(transformation(
extent={{-4,-4},{4,4}},
rotation=270,
origin={44,-54})));
Sources.UnlimitedGasStorage oxygen_in_air(
Simulation=Physiolibrary.Types.SimulationType.SteadyState,
usePartialPressureInput=true,
T=310.15) annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={6,60})));
Components.GasSolubility
partialPressure1( kH_T0(displayUnit="(mmol/l)/kPa at 25degC")=
0.026029047188736, T=310.15) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
origin={6,32})));
SteadyStates.Components.MolarConservationLaw totalHb(
Simulation=Physiolibrary.Types.SimulationType.SteadyState,
Total(displayUnit="mol") = totalAmountOfHemoglobin,
n=2)
annotation (Placement(transformation(extent={{70,-92},{90,-72}})));
Modelica.Blocks.Math.Sum sum1(nin=8, k=(1/4)*ones(8))
annotation (Placement(transformation(
extent={{-4,-4},{4,4}},
rotation=270,
origin={-74,-82})));
Modelica.Blocks.Math.Division sO2_ "hemoglobin oxygen saturation"
annotation (Placement(transformation(extent={{-64,-96},{-54,-86}})));
equation
// totalAmountOfHemoglobin*normalizedState[1] = sum(OxyRHm.solute) + sum(DeoxyRHm.solute) + sum(OxyTHm.solute) + sum(DeoxyTHm.solute);
// sO2 = (sum(OxyRHm.solute) + sum(OxyTHm.solute))/totalAmountOfHemoglobin;
connect(R0_in_R.species, quaternaryForm.substrates[1])
annotation (Line(
points={{-52,-74},{-4,-74}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(quaternaryForm.products[1], T0_in_T.species)
annotation (Line(
points={{16,-74},{32,-74},{32,-72},{48,-72}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(OxyTHm.q_out, oxygenation_T.substrates[1])
annotation (Line(
points={{24,-26},{42,-26}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygenation_T.products[1], DeoxyTHm.q_out)
annotation (Line(
points={{62,-26.5},{72,-26.5},{72,-26},{80,-26}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(OxyTHm.solute, add1.u2) annotation (Line(
points={{24,-36},{24,-42},{41.6,-42},{41.6,-49.2}},
color={0,0,127},
smooth=Smooth.Bezier));
connect(add1.u1, DeoxyTHm.solute) annotation (Line(
points={{46.4,-49.2},{46.4,-42},{80,-42},{80,-36}},
color={0,0,127},
smooth=Smooth.Bezier));
connect(partialPressure1.q_out, oxygen_in_air.q_out)
annotation (Line(
points={{6,42},{6,50}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(partialPressure1.q_in, oxygen_unbound.q_out) annotation (Line(
points={{6,24},{6,8}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(clock.y, oxygen_in_air.partialPressure) annotation (Line(
points={{-19,84},{6,84},{6,70}},
color={0,0,127},
smooth=Smooth.None));
connect(add.y, R0_in_R.totalSubunitAmount) annotation (Line(
points={{-66,-58.4},{-66,-66},{-50,-66}},
color={0,0,127},
smooth=Smooth.Bezier));
connect(OxyRHm.solute, add.u2) annotation (Line(
points={{-88,-36},{-88,-44},{-68.4,-44},{-68.4,-49.2}},
color={0,0,127},
smooth=Smooth.Bezier));
connect(DeoxyRHm.solute, add.u1) annotation (Line(
points={{-32,-36},{-32,-36},{-32,-44},{-63.6,-44},{-63.6,-50},{
-63.6,-49.2}},
color={0,0,127},
smooth=Smooth.Bezier));
connect(OxyRHm.q_out, oxygenation_R.substrates[1]) annotation (Line(
points={{-88,-26},{-70,-26}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(DeoxyRHm.q_out, R0_in_R.subunitSpecies) annotation (Line(
points={{-32,-26},{-42,-26},{-42,-56}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygenation_R.products[1], DeoxyRHm.q_out) annotation (Line(
points={{-50,-26.5},{-42,-26.5},{-42,-26},{-32,-26}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygenation_R[1].products[2], oxygen_unbound.q_out) annotation (Line(
points={{-50,-25.5},{-36,-25.5},{-36,12},{6,12},{6,8}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygenation_R[2].products[2], oxygen_unbound.q_out) annotation (Line(
points={{-50,-25.5},{-36,-25.5},{-36,12},{6,12},{6,8}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygenation_R[3].products[2], oxygen_unbound.q_out) annotation (Line(
points={{-50,-25.5},{-36,-25.5},{-36,12},{6,12},{6,8}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygenation_R[4].products[2], oxygen_unbound.q_out) annotation (Line(
points={{-50,-25.5},{-36,-25.5},{-36,12},{6,12},{6,8}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygenation_T[1].products[2], oxygen_unbound.q_out) annotation (Line(
points={{62,-25.5},{78,-25.5},{78,8},{6,8}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygenation_T[2].products[2], oxygen_unbound.q_out) annotation (Line(
points={{62,-25.5},{78,-25.5},{78,8},{6,8}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygenation_T[3].products[2], oxygen_unbound.q_out) annotation (Line(
points={{62,-25.5},{78,-25.5},{78,8},{6,8}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(oxygenation_T[4].products[2], oxygen_unbound.q_out) annotation (Line(
points={{62,-25.5},{78,-25.5},{78,8},{6,8}},
color={107,45,134},
thickness=1,
smooth=Smooth.None));
connect(T0_in_T.subunitSpecies, DeoxyTHm.q_out)
annotation (Line(
points={{58,-54},{84,-54},{84,-26},{80,-26}},