Skip to content

Commit 6433127

Browse files
committed
switch to Chemical 1.4.1
1 parent 15dd529 commit 6433127

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

Physiolibrary/Media.mo

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ package Media "Models of physiological fluids"
313313

314314
aH2O_P = aH2O_E "osmolarity";
315315

316-
aH2O_P = state.X[i("H2O_P")]*Chemical.Interfaces.Incompressible.specificAmountOfFreeBaseMolecule((state.X[i("H2O_P")]/pct)*1,x_P*1,Substances.Water,T,p,v) / (pct*x_P);
317-
aH2O_E = state.X[i("H2O_E")]*Chemical.Interfaces.Incompressible.specificAmountOfFreeBaseMolecule((state.X[i("H2O_E")]/hct)*1,x_E*1,Substances.Water,T,p,v) / (hct*x_E);
316+
aH2O_P = state.X[i("H2O_P")]*Chemical.Interfaces.Incompressible.specificAmountOfFreeBaseMolecule(Substances.Water,T,p,v,0,(state.X[i("H2O_P")]/pct)*1,x_P*1) / (pct*x_P);
317+
aH2O_E = state.X[i("H2O_E")]*Chemical.Interfaces.Incompressible.specificAmountOfFreeBaseMolecule(Substances.Water,T,p,v,0,(state.X[i("H2O_E")]/hct)*1,x_E*1) / (hct*x_E);
318318

319319
pct = plasmaMassFraction(state);
320320
hct = formedElementsMassFraction(state);
@@ -499,10 +499,10 @@ package Media "Models of physiological fluids"
499499
nSolution_E = x_E;
500500

501501

502-
state.X[i("H2O_P")] = aH2O_P*pct*x_P/Chemical.Interfaces.Incompressible.specificAmountOfFreeBaseMolecule(massH2O_P,nSolution_P,Substances.Water,T,p,v);
503-
state.X[i("H2O_E")] = aH2O_E*hct*x_E/Chemical.Interfaces.Incompressible.specificAmountOfFreeBaseMolecule(massH2O_E,nSolution_E,Substances.Water,T,p,v);
502+
state.X[i("H2O_P")] = aH2O_P*pct*x_P/Chemical.Interfaces.Incompressible.specificAmountOfFreeBaseMolecule(Substances.Water,T,p,v,0,massH2O_P,nSolution_P);
503+
state.X[i("H2O_E")] = aH2O_E*hct*x_E/Chemical.Interfaces.Incompressible.specificAmountOfFreeBaseMolecule(Substances.Water,T,p,v,0,massH2O_E,nSolution_E);
504504
H2O_Ery2Plasma = KC_H2O*(Modelica.Constants.R*T*log(aH2O_E/aH2O_P)) "Osmolarity equilibration rate";
505-
expected_XH2O_E = aH2O_P*hct*x_E/Chemical.Interfaces.Incompressible.specificAmountOfFreeBaseMolecule(massH2O_E,nSolution_E,Substances.Water,T,p,v) "Debug of osmolarity equilibration";
505+
expected_XH2O_E = aH2O_P*hct*x_E/Chemical.Interfaces.Incompressible.specificAmountOfFreeBaseMolecule(Substances.Water,T,p,v,0,massH2O_E,nSolution_E) "Debug of osmolarity equilibration";
506506

507507

508508
x_P =plasmaSpecificAmountOfParticles(state);
@@ -581,7 +581,7 @@ package Media "Models of physiological fluids"
581581
pK_WaterSelfIonization = -log10(exp((Chemical.Interfaces.Incompressible.electroChemicalPotentialPure(
582582
Substances.Water, T, p, v)
583583
+ Modelica.Constants.R*T*log(
584-
(Chemical.Interfaces.Incompressible.specificAmountOfFreeBaseMolecule(massH2O_P,nSolution_P,Substances.Water, T, p, v)
584+
(Chemical.Interfaces.Incompressible.specificAmountOfFreeBaseMolecule(Substances.Water, T, p, v, 0, massH2O_P, nSolution_P)
585585
* massH2O_P)/nSolution_P)
586586
- Chemical.Interfaces.Incompressible.electroChemicalPotentialPure(Substances.OH, T, p, v)
587587
- Chemical.Interfaces.Incompressible.electroChemicalPotentialPure(Substances.H, T, p, v))/(Modelica.Constants.R*T)))
@@ -843,6 +843,8 @@ package Media "Models of physiological fluids"
843843
"inorganic phosphates concentration in blood plasma";
844844
input Types.Concentration _cDPG=cDPG(state) "DPG concentration in blood plasma";
845845
input Types.Concentration _SID=SID(state) "strong ion difference of blood";
846+
input Types.Concentration _SID_P=plasmaSID(state) "strong ion difference of blood plasma";
847+
input Types.Concentration _SID_E=formedElementsSID(state) "strong ion difference of blood formed elements";
846848

847849
constant Physiolibrary.Types.Temperature T0=273.15 + 37 "normal temperature";
848850
constant Physiolibrary.Types.pH pH0=7.4 "normal pH";
@@ -853,7 +855,7 @@ package Media "Models of physiological fluids"
853855
Physiolibrary.Types.Concentration NSIDP;
854856
Physiolibrary.Types.Concentration NSIDE;
855857
Physiolibrary.Types.Concentration NSID;
856-
Physiolibrary.Types.Concentration BEox;
858+
Physiolibrary.Types.Concentration BEox, BEox_P, BEox_E;
857859
Physiolibrary.Types.Concentration cdCO2;
858860

859861
Physiolibrary.Types.pH pH_ery;
@@ -1007,12 +1009,11 @@ package Media "Models of physiological fluids"
10071009
"Bohr's protons = number of protons released during deoxygenation of one hemoglobin subunit";
10081010
dTH = sO2*dH + sCO2D*(1+1/(1+10^(pH-pKzD)))
10091011
"Total titration shift with Bohr protons and carbamination";
1010-
/*
1011-
sHO =
1012-
"H+ saturation of oxy-hemoglobin";
1013-
sHD =
1014-
"H+ saturation of deoxy-hemoglobin";
1015-
*/
1012+
1013+
BEox_P = _SID_P - NSIDP;
1014+
BEox_E = _SID_E + dTH*ceHb - NSIDE;
1015+
1016+
10161017
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
10171018
coordinateSystem(preserveAspectRatio=false)),
10181019
Documentation(info="<html>
@@ -1628,6 +1629,24 @@ package Media "Models of physiological fluids"
16281629
end plasmaMassFractionWithoutOther;
16291630

16301631

1632+
replaceable function plasmaSID "Strong ion difference of blood plasma"
1633+
extends GetConcentration;
1634+
algorithm
1635+
C := plasmaDensity(state) * (
1636+
state.X[i("Na_P")]/Na.MolarWeight +
1637+
state.X[i("K_P")]/K.MolarWeight -
1638+
state.X[i("Cl_P")]/Cl.MolarWeight -
1639+
SO4.z*state.X[i("SO4_P")]/SO4.MolarWeight) / plasmacrit(state);
1640+
end plasmaSID;
1641+
1642+
replaceable function formedElementsSID "Strong ion difference of blood formed elements"
1643+
extends GetConcentration;
1644+
algorithm
1645+
C := density(state) * (
1646+
state.X[i("Na_E")]/Na.MolarWeight +
1647+
state.X[i("K_E")]/K.MolarWeight -
1648+
state.X[i("Cl_E")]/Cl.MolarWeight) / hematocrit(state);
1649+
end formedElementsSID;
16311650
annotation (Documentation(info="<html>
16321651
<p>Adding new substance to blood model:</p>
16331652
<p><br>- add to Blood.substanceNames</p>
@@ -1886,7 +1905,7 @@ Modelica source.
18861905

18871906
NpM = stateOfMatter.specificAmountOfParticles(substanceData,T=T,p=p);
18881907

1889-
x_baseMolecule = X.*stateOfMatter.specificAmountOfFreeBaseMolecule(0,0,substanceData,T=T,p=p)./(X*NpM);
1908+
x_baseMolecule = X.*stateOfMatter.specificAmountOfFreeBaseMolecule(substanceData,T=T,p=p)./(X*NpM);
18901909

18911910
T = stateOfMatter.solution_temperature(
18921911
substanceData,
@@ -2156,8 +2175,8 @@ Modelica source.
21562175
equation
21572176
NpM = stateOfMatter.specificAmountOfParticles(substanceData,T=T,p=p);
21582177

2159-
nSolution = X*NpM;
2160-
x_baseMolecule = X.*stateOfMatter.specificAmountOfFreeBaseMolecule(X,nSolution,substanceData,T=T,p=p)./(X*NpM);
2178+
nSolution = X*NpM*1;
2179+
x_baseMolecule = X.*stateOfMatter.specificAmountOfFreeBaseMolecule(substanceData,T=T,p=p,v=0,I=0,massH2O=X,nSolution=nSolution)./(X*NpM);
21612180

21622181
T = stateOfMatter.solution_temperature(
21632182
substanceData,

Physiolibrary/package.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package Physiolibrary "System biology, integrative physiology and pathophysiolog
1616
versionDate = "2023-10-10",
1717
dateModified = "2023-10-10 1:00:00Z",
1818
uses(Modelica(version = "4.0.0"), Complex(version = "4.0.0"),
19-
Chemical(version="1.5.0-alpha")),
19+
Chemical(version="1.4.1")),
2020
conversion(
2121
from(version = "BioChem-1.0.1", script = "modelica://Physiolibrary/Resources/Scripts/Dymola/ConvertBioChem_1.0.1_to_Physiolibrary_2.3.mos", to = "3.0.0"),
2222
from(version = "0.4980", script = "modelica://Physiolibrary/Resources/Scripts/Dymola/ConvertPhysiolibrary_from_0.4980_to_2.3.mos", to = "3.0.0"),

0 commit comments

Comments
 (0)