From 1d65b9b3c99b7a821485bdb9206a10112a358108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Matej=C3=A1k?= Date: Tue, 3 Oct 2023 00:10:43 +0200 Subject: [PATCH] Osmotic water flow between red cells and plasma. Dynamic chloride shift. --- Physiolibrary/Fluid.mo | 277 +++++++++++++------------- Physiolibrary/Media.mo | 433 ++++++++++++++++------------------------- 2 files changed, 303 insertions(+), 407 deletions(-) diff --git a/Physiolibrary/Fluid.mo b/Physiolibrary/Fluid.mo index 789db76..737cd3e 100644 --- a/Physiolibrary/Fluid.mo +++ b/Physiolibrary/Fluid.mo @@ -557,8 +557,8 @@ package Fluid "Physiological fluids with static and dynamic properties" package Interfaces extends Modelica.Icons.InterfacesPackage; - connector FluidPort = Modelica.Fluid.Interfaces.FluidPort(redeclare - replaceable package Medium = + connector FluidPort = Modelica.Fluid.Interfaces.FluidPort(redeclare replaceable package + Medium = Physiolibrary.Media.Water); connector FluidPort_a "Hydraulical inflow connector" @@ -1314,14 +1314,13 @@ The sensor is ideal, i.e., it does not influence the fluid. Placement(transformation(extent = {{50, 50}, {30, 70}}))); Physiolibrary.Fluid.Sensors.pH pH_measure(redeclare package Medium = Medium) annotation ( Placement(transformation(extent = {{-24, -70}, {-44, -50}}))); - Physiolibrary.Fluid.Sensors.PartialPressure pCO2_measure(redeclare - package + Physiolibrary.Fluid.Sensors.PartialPressure pCO2_measure(redeclare package stateOfMatter = Chemical.Interfaces.IdealGas, substanceData = Chemical.Substances.CarbonDioxide_gas(), redeclare package Medium = Medium) annotation ( Placement(transformation(extent = {{12, -10}, {-8, 10}}))); - Physiolibrary.Fluid.Sensors.PressureMeasure pressureMeasureSystemicCapillaries(redeclare - package Medium = Medium) annotation ( + Physiolibrary.Fluid.Sensors.PressureMeasure pressureMeasureSystemicCapillaries(redeclare package + Medium = Medium) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 0, origin = {78, -76}))); Physiolibrary.Types.RealIO.PressureOutput pressure annotation ( Placement(transformation(extent = {{100, -90}, {120, -70}}), iconTransformation(extent = {{100, -90}, {120, -70}}))); @@ -1560,8 +1559,8 @@ The sensor is ideal, i.e., it does not influence the fluid. model Concentration "Ideal one port concentration sensor" extends Modelica.Icons.RoundSensor; - extends Physiolibrary.Fluid.Interfaces.PartialAbsoluteSensor(redeclare - replaceable package Medium = + extends Physiolibrary.Fluid.Interfaces.PartialAbsoluteSensor(redeclare replaceable package + Medium = Physiolibrary.Media.Blood); Physiolibrary.Types.RealIO.ConcentrationOutput C "Concentration in port medium" annotation ( @@ -1591,8 +1590,8 @@ The sensor is ideal, i.e., it does not influence the fluid. model MassConcentration "Ideal one port mass concentration sensor" extends Modelica.Icons.RoundSensor; - extends Physiolibrary.Fluid.Interfaces.PartialAbsoluteSensor(redeclare - replaceable package Medium = + extends Physiolibrary.Fluid.Interfaces.PartialAbsoluteSensor(redeclare replaceable package + Medium = Physiolibrary.Media.Blood); Physiolibrary.Types.RealIO.MassConcentrationOutput R "Mass concentration in port medium" annotation ( @@ -1621,8 +1620,8 @@ The sensor is ideal, i.e., it does not influence the fluid. model Fraction "Ideal one port fraction sensor" extends Modelica.Icons.RoundSensor; - extends Physiolibrary.Fluid.Interfaces.PartialAbsoluteSensor(redeclare - replaceable package Medium = + extends Physiolibrary.Fluid.Interfaces.PartialAbsoluteSensor(redeclare replaceable package + Medium = Physiolibrary.Media.Blood); Physiolibrary.Types.RealIO.FractionOutput F "Fraction in port medium" annotation ( @@ -1651,8 +1650,8 @@ The sensor is ideal, i.e., it does not influence the fluid. model Activity "Ideal one port activity sensor" extends Modelica.Icons.RoundSensor; - extends Physiolibrary.Fluid.Interfaces.PartialAbsoluteSensor(redeclare - replaceable package Medium = + extends Physiolibrary.Fluid.Interfaces.PartialAbsoluteSensor(redeclare replaceable package + Medium = Physiolibrary.Media.Blood); Modelica.Blocks.Interfaces.RealOutput A "Substance activity in port medium" annotation ( @@ -1682,8 +1681,7 @@ The sensor is ideal, i.e., it does not influence the fluid. model Density "Ideal one port density sensor" extends Modelica.Icons.RoundSensor; - extends Physiolibrary.Fluid.Interfaces.PartialAbsoluteSensor(redeclare - replaceable package + extends Physiolibrary.Fluid.Interfaces.PartialAbsoluteSensor(redeclare replaceable package Medium = Physiolibrary.Media.Blood); @@ -3012,23 +3010,18 @@ The sensor is ideal, i.e., it does not influence the fluid. Physiolibrary.Fluid.Interfaces.FluidPort_b blood_out(redeclare package Medium = BloodPlasma) annotation ( Placement(transformation(extent = {{-70, 110}, {-50, 90}}))); - Physiolibrary.Fluid.Interfaces.FluidPort_a dialysate_in(redeclare - package - Medium = Dialysate) - annotation ( + Physiolibrary.Fluid.Interfaces.FluidPort_a dialysate_in(redeclare package + Medium = Dialysate) annotation ( Placement(transformation(extent = {{50, 110}, {70, 90}}))); - Physiolibrary.Fluid.Interfaces.FluidPort_b dialysate_out(redeclare - package - Medium = Dialysate) - annotation ( + Physiolibrary.Fluid.Interfaces.FluidPort_b dialysate_out(redeclare package + Medium = Dialysate) annotation ( Placement(transformation(extent = {{50, -110}, {70, -90}}))); - Physiolibrary.Fluid.Components.ElasticVessel bloodVessel(redeclare - package + Physiolibrary.Fluid.Components.ElasticVessel bloodVessel(redeclare package Medium = BloodPlasma, useSubstances = true, volume_start = InitialBloodPressure * Compliance, massFractions_start = InitialPlasma, Compliance(displayUnit = "ml/mmHg") = Compliance, ZeroPressureVolume(displayUnit = "m3"), nPorts = 2) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 180, origin = {-68, -4}))); - Physiolibrary.Fluid.Components.ElasticVessel dialysateVessel(redeclare - package Medium = Dialysate, useSubstances = true, onElectricGround = true, volume_start = InitialDialysatePressure * Compliance, massFractions_start = InitialDialysate, Compliance(displayUnit = "ml/mmHg") = Compliance, nPorts = 2) annotation ( + Physiolibrary.Fluid.Components.ElasticVessel dialysateVessel(redeclare package + Medium = Dialysate, useSubstances = true, onElectricGround = true, volume_start = InitialDialysatePressure * Compliance, massFractions_start = InitialDialysate, Compliance(displayUnit = "ml/mmHg") = Compliance, nPorts = 2) annotation ( Placement(transformation(extent = {{66, -14}, {86, 6}}))); Physiolibrary.Fluid.Components.BodyFluidMembrane bodyFluidMembrane( @@ -3088,19 +3081,18 @@ The sensor is ideal, i.e., it does not influence the fluid. Placement(transformation(extent = {{-50, -76}, {-30, -56}}))); Modelica.Blocks.Sources.Sine sine_dialysate_pressure_input(f(displayUnit = "1/min") = 0.41666666666667, amplitude = 2000, offset = InitialDialysatePressure + 101325) annotation ( Placement(transformation(extent = {{94, 60}, {74, 80}}))); - Physiolibrary.Fluid.Sources.PressureSource blood_output(redeclare - package Medium = + Physiolibrary.Fluid.Sources.PressureSource blood_output(redeclare package + Medium = BloodPlasma) annotation ( Placement(transformation(extent = {{-74, 60}, {-54, 80}}))); - Physiolibrary.Fluid.Sources.PressureSource blood_input(redeclare - package Medium = + Physiolibrary.Fluid.Sources.PressureSource blood_input(redeclare package + Medium = BloodPlasma, usePressureInput = true, massFractions_start = PlasmaSubstances) annotation ( Placement(transformation(extent = {{-16, -84}, {4, -64}}))); Sources.PressureSource dialysate_input(redeclare package Medium = Dialysate, usePressureInput = true, massFractions_start = DialysateSubstances) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 180, origin = {48, 70}))); - Physiolibrary.Fluid.Sources.PressureSource dialysate_output(redeclare - package Medium = Dialysate) - annotation ( + Physiolibrary.Fluid.Sources.PressureSource dialysate_output(redeclare package + Medium = Dialysate) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 180, origin = {86, -74}))); Physiolibrary.Fluid.Components.Resistor resistorB(redeclare package Medium = @@ -3178,26 +3170,26 @@ The sensor is ideal, i.e., it does not influence the fluid. Physiolibrary.Fluid.Sensors.FlowMeasure flowMeasure(redeclare package Medium = Air) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 270, origin = {-318, 66}))); - Physiolibrary.Fluid.Components.ElasticVessel upperRespiratoryTract(redeclare - package Medium = Air, useSubstances = true, + Physiolibrary.Fluid.Components.ElasticVessel upperRespiratoryTract(redeclare package + Medium = Air, useSubstances = true, volume_start=0.0001, massFractions_start = Air.reference_X[1:Air.nS - 1], useThermalPort = true, Compliance = TotalCompliance / 100, ZeroPressureVolume(displayUnit = "ml") = 0.0001, ResidualVolume(displayUnit = "ml") = 0.0001, nPorts = 3) annotation ( Placement(transformation(extent = {{-328, -10}, {-308, 10}}))); - Physiolibrary.Fluid.Components.Resistor upperRespiratoryTractResistance(redeclare - package Medium = Air, Resistance = 0.5 * TracheaResistance) annotation ( + Physiolibrary.Fluid.Components.Resistor upperRespiratoryTractResistance(redeclare package + Medium = Air, Resistance = 0.5 * TracheaResistance) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin={-318,34}))); Chemical.Sources.PureSubstance water(redeclare package stateOfMatter = Chemical.Interfaces.Incompressible, substanceData = Chemical.Substances.Water_liquid()) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 180, origin = {-314, -68}))); - Physiolibrary.Fluid.Sensors.PartialPressure pH2O_upperRespiratory(redeclare - package stateOfMatter = + Physiolibrary.Fluid.Sensors.PartialPressure pH2O_upperRespiratory(redeclare package + stateOfMatter = Chemical.Interfaces.IdealGas, substanceData = Chemical.Substances.Water_gas(), redeclare package Medium = Air) annotation ( Placement(transformation(extent = {{-364, 34}, {-344, 14}}))); - Physiolibrary.Fluid.Sensors.Temperature Temperature_upperRespiratory(redeclare - package Medium = Air) annotation ( + Physiolibrary.Fluid.Sensors.Temperature Temperature_upperRespiratory(redeclare package + Medium = Air) annotation ( Placement(transformation(extent = {{-298, 30}, {-278, 50}}))); - Physiolibrary.Fluid.Sensors.Temperature Temperature_mouth(redeclare - package Medium = Air) annotation ( + Physiolibrary.Fluid.Sensors.Temperature Temperature_mouth(redeclare package + Medium = Air) annotation ( Placement(transformation(extent = {{-296, 72}, {-276, 92}}))); Physiolibrary.Thermal.Components.Conductor cooling(Conductance( displayUnit="W/K") = 10) @@ -3255,19 +3247,18 @@ The sensor is ideal, i.e., it does not influence the fluid. replaceable package Blood = Physiolibrary.Media.Blood; inner Modelica.Fluid.System system(T_ambient = 310.15) "Human body system setting" annotation ( Placement(transformation(extent = {{60, 66}, {80, 86}}))); - Physiolibrary.Fluid.Components.ElasticVessel blood(redeclare package - Medium = Blood, - Compliance(displayUnit="ml/mmHg") = 7.5006157584566e-09, massFractions_start = Blood.ArterialDefault, mass_start = 1, nPorts=3, useSubstances = true, use_mass_start = true) annotation ( + Physiolibrary.Fluid.Components.ElasticVessel blood(redeclare package Medium = Blood, + Compliance(displayUnit="ml/mmHg") = 7.5006157584566e-09, massFractions_start = Blood.ArterialDefault, mass_start = 1, nPorts=4, useSubstances = true, use_mass_start = true) annotation ( Placement(transformation(extent={{-6,-52},{14,-32}}))); // massFractions_start=zeros(Blood.nS - 1), // massPartition_start=zeros(Blood.nS), // amountPartition_start=zeros(Blood.nS), - Chemical.Components.GasSolubility O2_GasSolubility(KC = 1e-6) annotation ( + Chemical.Components.GasSolubility O2_GasSolubility(KC=1e-8) annotation ( Placement(transformation(extent = {{-58, -20}, {-38, 0}}))); - Chemical.Components.GasSolubility CO2_GasSolubility(KC = 1e-6) annotation ( + Chemical.Components.GasSolubility CO2_GasSolubility(KC=1e-4) annotation ( Placement(transformation(extent = {{-40, -20}, {-20, 0}}))); - Chemical.Components.GasSolubility CO_GasSolubility(KC = 1e-7) annotation ( + Chemical.Components.GasSolubility CO_GasSolubility(KC=1e-9) annotation ( Placement(transformation(extent = {{-22, -20}, {-2, 0}}))); Chemical.Sources.ExternalIdealGasSubstance O2(substanceData = Chemical.Substances.Oxygen_gas(), usePartialPressureInput = false, PartialPressure(displayUnit = "mmHg") = 133.322387415) annotation ( Placement(transformation(extent={{-96,16},{-76,36}}))); @@ -3286,6 +3277,10 @@ The sensor is ideal, i.e., it does not influence the fluid. redeclare function GetFraction = Physiolibrary.Media.Blood.sO2) annotation (Placement(transformation(extent={{44,-20},{64,0}}))); + Sensors.PartialPressure pCO2( + redeclare package stateOfMatter = Chemical.Interfaces.IdealGas, + substanceData=Chemical.Substances.CarbonDioxide_gas(), + redeclare package Medium = Media.Blood) "Partial pressure of CO2 in blood" annotation (Placement(transformation(extent={{-64,-104},{-44,-84}}))); equation connect(O2.port_a, O2_GasSolubility.gas_port) annotation ( Line(points={{-76,26},{-48,26},{-48,0}}, color = {158, 66, 200})); @@ -3294,13 +3289,12 @@ The sensor is ideal, i.e., it does not influence the fluid. connect(CO.port_a, CO_GasSolubility.gas_port) annotation ( Line(points = {{18, 34}, {-12, 34}, {-12, 0}}, color = {158, 66, 200})); connect(pH.port, blood.q_in[1]) annotation (Line( - points={{64,-74},{64,-78},{6,-78},{6,-46},{3.9,-46},{3.9,-42.8667}}, + points={{64,-74},{64,-78},{6,-78},{6,-46},{3.9,-46},{3.9,-42.975}}, color={127,0,0}, thickness=0.5)); connect(pO2.port, blood.q_in[2]) annotation (Line( - points={{-68,-70},{-32,-70},{-32,-60},{4,-60},{4,-46},{3.9,-46},{3.9, - -42}}, + points={{-68,-70},{-32,-70},{-32,-60},{4,-60},{4,-46},{3.9,-46},{3.9,-42.325}}, color={127,0,0}, thickness=0.5)); connect(CO2_GasSolubility.liquid_port, blood.substances.CO2) annotation ( @@ -3314,13 +3308,23 @@ The sensor is ideal, i.e., it does not influence the fluid. connect(pH.port_a, blood.substances.H) annotation ( Line(points={{74,-64},{82,-64},{82,-28},{-22,-28},{-22,-42},{-6,-42}}, color = {158, 66, 200})); connect(blood.q_in[3], sO2.port) annotation (Line( - points={{3.9,-41.1333},{54,-41.1333},{54,-20}}, + points={{3.9,-41.675},{54,-41.675},{54,-20}}, + color={127,0,0}, + thickness=0.5)); + connect(blood.q_in[4], pCO2.port) + annotation (Line( + points={{3.9,-41.025},{2,-41.025},{2,-104},{-54,-104},{-54,-104}}, color={127,0,0}, thickness=0.5)); + connect(pCO2.port_a, blood.substances.CO2) annotation ( + Line(points={{-44,-94},{-34,-94},{-34,-42},{-6,-42}}, color = {158, 66, 200})); annotation ( Icon(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}})), Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}})), - experiment(StopTime = 1, __Dymola_fixedstepsize = 0.1, __Dymola_Algorithm = "Dassl"), + experiment( + StopTime=100, + __Dymola_fixedstepsize=0.1, + __Dymola_Algorithm="Dassl"), Documentation(info = "

References:


Mecklenburgh, J. S., and W. W. Mapleson. "Ventilatory assistance and respiratory muscle activity. 1: Interaction in healthy volunteers." British journal of anaesthesia 80.4 (1998): 422-433.

@@ -3347,8 +3351,8 @@ The sensor is ideal, i.e., it does not influence the fluid. volume_start = LungsAirVolume_initial, massFractions_start = Air.reference_X, ZeroPressureVolume = FunctionalResidualCapacity, Compliance = TotalCompliance, useExternalPressureInput = true, nPorts = 2) "Lungs" annotation ( Placement(transformation(extent = {{36, -28}, {56, -8}}))); - Physiolibrary.Fluid.Sensors.PressureMeasure lungsPressureMeasure(redeclare - package Medium = Air) "Lungs pressure" annotation ( + Physiolibrary.Fluid.Sensors.PressureMeasure lungsPressureMeasure(redeclare package + Medium = Air) "Lungs pressure" annotation ( Placement(transformation(extent = {{70, -20}, {90, 0}}))); inner Modelica.Fluid.System system(T_ambient = 310.15) "Human body system setting" annotation ( Placement(transformation(extent = {{-76, 8}, {-56, 28}}))); @@ -3404,14 +3408,14 @@ The sensor is ideal, i.e., it does not influence the fluid. parameter Types.HydraulicConductance TotalSystemicConductance = 1.250102626409427e-07 * (1 / 20) "Total systemic blood circulation conductance"; parameter Integer NA = 1 "Number of pulmonary alveolar units"; parameter Integer NT = 1 "Number of systemic tissue units"; - Physiolibrary.Fluid.Components.VolumePump deadSpaceVentilation(redeclare - package Medium = Air, useSolutionFlowInput = false, SolutionFlow = DV * RR) annotation ( + Physiolibrary.Fluid.Components.VolumePump deadSpaceVentilation(redeclare package + Medium = Air, useSolutionFlowInput = false, SolutionFlow = DV * RR) annotation ( Placement(transformation(extent = {{-6, 6}, {14, 26}}))); - Physiolibrary.Fluid.Sources.PressureSource pressureSource(redeclare - package Medium = Air) annotation ( + Physiolibrary.Fluid.Sources.PressureSource pressureSource(redeclare package + Medium = Air) annotation ( Placement(transformation(extent = {{-90, 6}, {-70, 26}}))); - Physiolibrary.Fluid.Sources.VolumeOutflowSource ventilation(useSolutionFlowInput = false, SolutionFlow = TV * RR, redeclare - package Medium = Air) annotation ( + Physiolibrary.Fluid.Sources.VolumeOutflowSource ventilation(useSolutionFlowInput = false, SolutionFlow = TV * RR, redeclare package + Medium = Air) annotation ( Placement(transformation(extent = {{70, 6}, {90, 26}}))); inner Modelica.Fluid.System system(T_ambient = 310.15) annotation ( Placement(transformation(extent = {{-44, 46}, {-24, 66}}))); @@ -3481,33 +3485,33 @@ The sensor is ideal, i.e., it does not influence the fluid. parameter Types.Fraction AirN2 = 1 - AirO2 - AirCO2 - AirH2O "N2 content in inspired air"; Types.Pressure Air_pO2 = AirO2 * system.p_ambient "O2 content in inspired air"; Types.Pressure Air_pCO2 = AirCO2 * system.p_ambient "CO2 content in inspired air"; - Physiolibrary.Fluid.Components.VolumePump deadSpaceVentilation(redeclare - package Medium = Air, useSolutionFlowInput = true, SolutionFlow = DV * RR, + Physiolibrary.Fluid.Components.VolumePump deadSpaceVentilation(redeclare package + Medium = Air, useSolutionFlowInput = true, SolutionFlow = DV * RR, density(start=1.1300953420756321, displayUnit="g/cm3"), q_in(m_flow(start=5.759563136974551E-05)), q_out(p(start=101335.86111397855, displayUnit="bar"))) annotation ( Placement(transformation(extent = {{-14, -52}, {6, -32}}))); - Physiolibrary.Fluid.Sources.PressureSource pressureSource(pressure_start(displayUnit = "Pa"), redeclare - package Medium = Air, massFractions_start = Air.X(AirO2, AirCO2, AirH2O, AirN2)) annotation ( + Physiolibrary.Fluid.Sources.PressureSource pressureSource(pressure_start(displayUnit = "Pa"), redeclare package + Medium = Air, massFractions_start = Air.X(AirO2, AirCO2, AirH2O, AirN2)) annotation ( Placement(transformation(extent = {{-96, -52}, {-76, -32}}))); - Physiolibrary.Fluid.Sources.VolumeOutflowSource volumeOutflow(useSolutionFlowInput = true, SolutionFlow = TV * RR, redeclare - package Medium = Air, + Physiolibrary.Fluid.Sources.VolumeOutflowSource volumeOutflow(useSolutionFlowInput = true, SolutionFlow = TV * RR, redeclare package + Medium = Air, density(start=1.1300953420756321)) annotation ( Placement(transformation(extent = {{64, -52}, {84, -32}}))); - Physiolibrary.Fluid.Components.VolumePump leftHeartPump(redeclare - package Medium = Blood, useSolutionFlowInput = true, SolutionFlow(displayUnit = "l/min") = 8.3333333333333e-05) annotation ( + Physiolibrary.Fluid.Components.VolumePump leftHeartPump(redeclare package + Medium = Blood, useSolutionFlowInput = true, SolutionFlow(displayUnit = "l/min") = 8.3333333333333e-05) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 270, origin = {42, -150}))); - Physiolibrary.Fluid.Components.VolumePump rightHeartPump(redeclare - package Medium = Blood, useSolutionFlowInput = true, SolutionFlow(displayUnit = "l/min") = 8.3333333333333e-05) annotation ( + Physiolibrary.Fluid.Components.VolumePump rightHeartPump(redeclare package + Medium = Blood, useSolutionFlowInput = true, SolutionFlow(displayUnit = "l/min") = 8.3333333333333e-05) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {-50, -150}))); - Physiolibrary.Fluid.Components.ElasticVessel pulmonaryArteries(redeclare - package Medium = Blood, massFractions_start = VenousBloodComposition, volume_start(displayUnit = "l") = 0.00038, Compliance(displayUnit = "ml/mmHg") = 3.6002955640592e-08, ZeroPressureVolume(displayUnit = "l") = 0.0003, nPorts = 4) annotation ( + Physiolibrary.Fluid.Components.ElasticVessel pulmonaryArteries(redeclare package + Medium = Blood, massFractions_start = VenousBloodComposition, volume_start(displayUnit = "l") = 0.00038, Compliance(displayUnit = "ml/mmHg") = 3.6002955640592e-08, ZeroPressureVolume(displayUnit = "l") = 0.0003, nPorts = 4) annotation ( Placement(transformation(extent = {{-60, -112}, {-40, -92}}))); - Physiolibrary.Fluid.Components.ElasticVessel pulmonaryVeins(redeclare - package Medium = Blood, massFractions_start = ArterialBloodComposition, volume_start(displayUnit = "l") = 0.0004, Compliance(displayUnit = "ml/mmHg") = 7.5006157584566e-08, ZeroPressureVolume(displayUnit = "l") = 0.0004, nPorts = 4) annotation ( + Physiolibrary.Fluid.Components.ElasticVessel pulmonaryVeins(redeclare package + Medium = Blood, massFractions_start = ArterialBloodComposition, volume_start(displayUnit = "l") = 0.0004, Compliance(displayUnit = "ml/mmHg") = 7.5006157584566e-08, ZeroPressureVolume(displayUnit = "l") = 0.0004, nPorts = 4) annotation ( Placement(transformation(extent = {{32, -112}, {52, -92}}))); - Physiolibrary.Fluid.Components.ElasticVessel systemicArteries(redeclare - package Medium = Blood, + Physiolibrary.Fluid.Components.ElasticVessel systemicArteries(redeclare package + Medium = Blood, massFractions_start = ArterialBloodComposition, useSubstances = true, volume_start(displayUnit = "l") = 0.00085, @@ -3521,8 +3525,8 @@ The sensor is ideal, i.e., it does not influence the fluid. pO2(start=11608.744631309959, displayUnit="bar"), sO2CO(start=0.9627613894820818, displayUnit="%")))) annotation ( Placement(transformation(extent = {{46, -206}, {26, -186}}))); - Physiolibrary.Fluid.Components.ElasticVessel systemicVeins(redeclare - package Medium = + Physiolibrary.Fluid.Components.ElasticVessel systemicVeins(redeclare package + Medium = Blood, massFractions_start = VenousBloodComposition, useSubstances = true, volume_start(displayUnit = "l") = 0.00325, @@ -3537,14 +3541,14 @@ The sensor is ideal, i.e., it does not influence the fluid. sCO(start=1.808984022893137E-07, displayUnit="%"), sO2CO(start=0.649370212847236, displayUnit="%")))) annotation ( Placement(transformation(extent = {{-60, -206}, {-40, -186}}))); - Physiolibrary.Fluid.Sensors.PressureMeasure pressureMeasureVeins(redeclare - package Medium = Blood) annotation ( + Physiolibrary.Fluid.Sensors.PressureMeasure pressureMeasureVeins(redeclare package + Medium = Blood) annotation ( Placement(transformation(extent = {{10, -10}, {-10, 10}}, rotation = 0, origin = {-80, -204}))); - Physiolibrary.Fluid.Sensors.PressureMeasure pressureMeasurePulmArteries(redeclare - package Medium = Blood) annotation ( + Physiolibrary.Fluid.Sensors.PressureMeasure pressureMeasurePulmArteries(redeclare package + Medium = Blood) annotation ( Placement(transformation(extent = {{-60, -108}, {-80, -88}}))); - Physiolibrary.Fluid.Sensors.PressureMeasure pressureMeasurePulmVeins(redeclare - package Medium = Blood) annotation ( + Physiolibrary.Fluid.Sensors.PressureMeasure pressureMeasurePulmVeins(redeclare package + Medium = Blood) annotation ( Placement(transformation(extent = {{52, -108}, {72, -88}}))); Types.Constants.VolumeFlowRateConst leftCardiacOutput(k = CO) annotation ( Placement(transformation(extent = {{-4, -4}, {4, 4}}, rotation = 180, origin = {76, -150}))); @@ -3552,8 +3556,8 @@ The sensor is ideal, i.e., it does not influence the fluid. Placement(transformation(extent = {{-6, -6}, {6, 6}}, rotation = 0, origin = {-70, -150}))); Physiolibrary.Types.Constants.HydraulicConductanceConst hydraulicConductance1(k = 1.250102626409427e-07 * (5 / 4)) annotation ( Placement(transformation(extent = {{-4, -4}, {4, 4}}, rotation = 270, origin = {-80, -132}))); - Physiolibrary.Fluid.Components.Conductor pulmonaryShunt(redeclare - package Medium = Blood, Conductance(displayUnit = "l/(cmH2O.s)") = cShunt) annotation ( + Physiolibrary.Fluid.Components.Conductor pulmonaryShunt(redeclare package + Medium = Blood, Conductance(displayUnit = "l/(cmH2O.s)") = cShunt) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 0, origin = {-4, -104}))); Organs.Lungs.Components.RespiratoryUnit respiratoryUnit [NA]( @@ -3589,8 +3593,8 @@ The sensor is ideal, i.e., it does not influence the fluid. bloodVolume_start = fill(tissueBloodVolume_start / NT, NT), bloodV0 = fill(tissueV0 / NT, NT), BloodComposition = fill(VenousBloodComposition, NT), - Compliance=fill(CapillariesCompliance/NT, NT), redeclare - package Blood = Blood, + Compliance=fill(CapillariesCompliance/NT, NT), redeclare package + Blood = Blood, systemicCapillaries(chemicalSolution(bloodGases( cHCO3(start=fill(26.674314102391666,NT), each displayUnit="mmol/l"), pCO(start=fill(6.39728383892192E-06,NT), each displayUnit="bar"), @@ -3666,8 +3670,7 @@ The sensor is ideal, i.e., it does not influence the fluid. Line(points = {{49, -150}, {71, -150}}, color = {0, 0, 127})); for i in 1:NT loop connect(tissueUnit[i].q_in, systemicArteries.q_in[i+1]) annotation ( - Line(points={{13.6611,-195.21},{28,-195.21},{28,-196},{36.1,-196},{ - 36.1,-196}}, color = {127, 0, 0}, thickness = 0.5)); + Line(points={{13.6611,-195.21},{28,-195.21},{28,-196},{36.1,-196},{36.1,-196}}, color = {127, 0, 0}, thickness = 0.5)); connect(tissueUnit[i].q_out, systemicVeins.q_in[i+2]) annotation ( Line(points={{-15.2278,-194.93},{-50.1,-194.93},{-50.1,-196}}, color = {127, 0, 0}, thickness = 0.5)); end for; @@ -3729,8 +3732,8 @@ The sensor is ideal, i.e., it does not influence the fluid. Placement(transformation(extent = {{10, -10}, {-10, 10}}, rotation = 0, origin = {-2, -14}))); Chemical.Sources.SubstanceOutflow O2_left(SubstanceFlow(displayUnit = "mmol/min") = O2_consumption) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 180, origin = {-70, -38}))); - Chemical.Sources.SubstanceInflowT CO2_left(SubstanceFlow(displayUnit = "mmol/min") = CO2_production, redeclare - package stateOfMatter = + Chemical.Sources.SubstanceInflowT CO2_left(SubstanceFlow(displayUnit = "mmol/min") = CO2_production, redeclare package + stateOfMatter = Chemical.Interfaces.IdealGas, substanceData = Chemical.Substances.CarbonDioxide_gas()) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 180, origin = {70, -38}))); Sensors.BloodGasesMeasurement tissue annotation ( @@ -3963,8 +3966,8 @@ The sensor is ideal, i.e., it does not influence the fluid. extent={{-10,-10},{10,10}}, rotation=180, origin={-136,-2}))); - Physiolibrary.Fluid.Sensors.PressureMeasure alveolarPressure(redeclare - package Medium = Air) "Alveolar pressure" + Physiolibrary.Fluid.Sensors.PressureMeasure alveolarPressure(redeclare package + Medium = Air) "Alveolar pressure" annotation (Placement(transformation(extent={{-170,-26},{-150,-6}}))); Physiolibrary.Fluid.Components.Resistor lungsPathways( redeclare package Medium = Air, @@ -4121,8 +4124,8 @@ The sensor is ideal, i.e., it does not influence the fluid. Physiolibrary.Blocks.Source.PeriodicCurveSource respiratoryMusclePressureCycle(data = RespiratoryMusclePressureCycle) "Relative position in respiratory cycle (0,1) to absolute external lungs pressure" annotation ( Placement(transformation(extent = {{-34, 72}, {-14, 92}}))); - Physiolibrary.Fluid.Components.ElasticVessel leftAlveoli(redeclare - package Medium = Air, + Physiolibrary.Fluid.Components.ElasticVessel leftAlveoli(redeclare package + Medium = Air, volume_start=LungsAirVolume_initial*LeftLungsSizeFraction, massFractions_start = Air.X(100, 40, 47, 760 - 187), useThermalPort = true, ZeroPressureVolume=FunctionalResidualCapacity*LeftLungsSizeFraction, ResidualVolume=ResidualVolume*LeftLungsSizeFraction, @@ -4133,8 +4136,8 @@ The sensor is ideal, i.e., it does not influence the fluid. each displayUnit="bar"))) "Left alveolar space" annotation ( Placement(transformation(extent = {{-162, 16}, {-142, 36}}))); //0.0133, - Physiolibrary.Fluid.Sensors.PressureMeasure leftPleauralPressure(redeclare - package Medium = + Physiolibrary.Fluid.Sensors.PressureMeasure leftPleauralPressure(redeclare package + Medium = PleuralFluid, GetAbsolutePressure=false) "Left Pleaural pressure" annotation ( Placement(transformation(extent = {{10, -10}, {-10, 10}}, rotation = 0, origin = {-70, 64}))); inner Modelica.Fluid.System system(T_ambient = CoreTemperature) "Human body system setting" annotation ( @@ -4152,20 +4155,20 @@ The sensor is ideal, i.e., it does not influence the fluid. Placement(transformation(extent={{-54,76},{-46,84}}))); Chemical.Sources.SubstanceOutflow O2_left(SubstanceFlow(displayUnit = "mmol/min") = 0.0001285) annotation ( Placement(transformation(extent={{-164,-14},{-144,6}}))); - Chemical.Sources.SubstanceInflowT CO2_left(SubstanceFlow(displayUnit = "mmol/min") = 0.00010283333333333, redeclare - package stateOfMatter = + Chemical.Sources.SubstanceInflowT CO2_left(SubstanceFlow(displayUnit = "mmol/min") = 0.00010283333333333, redeclare package + stateOfMatter = Chemical.Interfaces.IdealGas, substanceData = Chemical.Substances.CarbonDioxide_gas()) annotation ( Placement(transformation(extent={{-200,-14},{-180,6}}))); - Physiolibrary.Fluid.Sensors.PressureMeasure leftAlveolarPressure(redeclare - package Medium = Air) "Left Alveolar pressure" annotation ( + Physiolibrary.Fluid.Sensors.PressureMeasure leftAlveolarPressure(redeclare package + Medium = Air) "Left Alveolar pressure" annotation ( Placement(transformation(extent = {{-124, 22}, {-104, 42}}))); Physiolibrary.Fluid.Components.Resistor rightBronchi(redeclare package Medium = Air, Resistance = RightBronchiResistance, q_in(m_flow(start=0.028225848485321524)), q_out(p(start=102073.43154792248, displayUnit="bar"))) annotation ( Placement(transformation(extent = {{-252, -54}, {-232, -34}}))); - Physiolibrary.Fluid.Components.ElasticVessel rightAlveoli(redeclare - package Medium = Air, + Physiolibrary.Fluid.Components.ElasticVessel rightAlveoli(redeclare package + Medium = Air, massFractions_start=Air.X( 100, 40, @@ -4180,14 +4183,14 @@ The sensor is ideal, i.e., it does not influence the fluid. q_in(p(start={101344.01141127005,101344.0078125,101344.0078125,101344.0078125, 101344.0078125,101344.0078125}, each displayUnit="bar"))) "Right alveolar space" annotation ( Placement(transformation(extent = {{-156, -58}, {-136, -38}}))); - Chemical.Sources.SubstanceInflowT CO2_right(SubstanceFlow(displayUnit = "mmol/min") = 0.00010283333333333, redeclare - package stateOfMatter = + Chemical.Sources.SubstanceInflowT CO2_right(SubstanceFlow(displayUnit = "mmol/min") = 0.00010283333333333, redeclare package + stateOfMatter = Chemical.Interfaces.IdealGas, substanceData = Chemical.Substances.CarbonDioxide_gas()) annotation ( Placement(transformation(extent = {{-220, -96}, {-200, -76}}))); Chemical.Sources.SubstanceOutflow O2_right(SubstanceFlow(displayUnit = "mmol/min") = 0.0001285) annotation ( Placement(transformation(extent = {{-158, -96}, {-138, -76}}))); - Physiolibrary.Fluid.Components.ElasticVessel leftPleuralSpace(redeclare - package Medium = + Physiolibrary.Fluid.Components.ElasticVessel leftPleuralSpace(redeclare package + Medium = PleuralFluid, volume_start=pleuralVolume_initial*LeftPleuralSizeFraction, useThermalPort = false, ZeroPressureVolume=RelaxedLungsCavitySpace*LeftLungsSizeFraction, @@ -4196,12 +4199,12 @@ The sensor is ideal, i.e., it does not influence the fluid. InternalSpace=RelaxedLungsCavitySpace*LeftLungsSizeFraction, nPorts = 1) "Left Pleural space" annotation ( Placement(transformation(extent={{-56,18},{-76,38}}))); - Physiolibrary.Fluid.Sensors.PressureMeasure rightPleauralPressure(redeclare - package Medium = + Physiolibrary.Fluid.Sensors.PressureMeasure rightPleauralPressure(redeclare package + Medium = PleuralFluid, GetAbsolutePressure=false) "Right pleaural pressure" annotation ( Placement(transformation(extent = {{10, -10}, {-10, 10}}, rotation = 0, origin = {-70, -12}))); - Physiolibrary.Fluid.Components.ElasticVessel rightPleuralSpace(redeclare - package Medium = + Physiolibrary.Fluid.Components.ElasticVessel rightPleuralSpace(redeclare package + Medium = PleuralFluid, volume_start=pleuralVolume_initial*RightPleuralSizeFraction, ZeroPressureVolume=RelaxedLungsCavitySpace*RightLungsSizeFraction, @@ -4209,34 +4212,34 @@ The sensor is ideal, i.e., it does not influence the fluid. useInternalSpaceInput=true, InternalSpace=RelaxedLungsCavitySpace*RightLungsSizeFraction, nPorts = 1) "Right Plearal space" annotation ( Placement(transformation(extent={{-56,-58},{-76,-38}}))); - Physiolibrary.Fluid.Sensors.PressureMeasure rightAlveolarPressure(redeclare - package Medium = Air) "Right Alveolar pressure" annotation ( + Physiolibrary.Fluid.Sensors.PressureMeasure rightAlveolarPressure(redeclare package + Medium = Air) "Right Alveolar pressure" annotation ( Placement(transformation(extent = {{-134, -38}, {-114, -18}}))); Physiolibrary.Fluid.Components.Resistor trachea(redeclare package Medium = Air, Resistance = 0.5 * TracheaResistance, q_in(m_flow(start=0.056451696970642506), p(start=105795.1786534674, displayUnit="bar"))) annotation ( Placement(transformation(extent={{-298,-12},{-278,8}}))); - Physiolibrary.Fluid.Components.Resistor leftAlveolarDuct(redeclare - package Medium = + Physiolibrary.Fluid.Components.Resistor leftAlveolarDuct(redeclare package + Medium = Air, Resistance = LeftAlveoliResistance) annotation ( Placement(transformation(extent={{-210,22},{-190,42}}))); Physiolibrary.Fluid.Sensors.FlowMeasure flowMeasure(redeclare package Medium = Air) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 270, origin = {-318, 66}))); - Physiolibrary.Fluid.Components.Resistor rightAlveolarDuct(redeclare - package Medium = + Physiolibrary.Fluid.Components.Resistor rightAlveolarDuct(redeclare package + Medium = Air, Resistance = RightAlveoliResistance) annotation ( Placement(transformation(extent = {{-212, -54}, {-192, -34}}))); - Physiolibrary.Fluid.Components.ElasticVessel upperRespiratoryTract(redeclare - package Medium = Air, useSubstances = true, + Physiolibrary.Fluid.Components.ElasticVessel upperRespiratoryTract(redeclare package + Medium = Air, useSubstances = true, volume_start=9.98e-05, massFractions_start = Air.X(100, 40, 47, 760 - 187), useThermalPort = true, Compliance = TotalCompliance / 100, ZeroPressureVolume(displayUnit = "ml") = 0.0001, ResidualVolume(displayUnit="ml"), InternalSpace=5e-05, nPorts = 4) annotation ( Placement(transformation(extent = {{-328, -10}, {-308, 10}}))); - Physiolibrary.Fluid.Components.Resistor upperRespiratoryTractResistance(redeclare - package Medium = Air, Resistance = 0.5 * TracheaResistance) annotation ( + Physiolibrary.Fluid.Components.Resistor upperRespiratoryTractResistance(redeclare package + Medium = Air, Resistance = 0.5 * TracheaResistance) annotation ( Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin={-318,30}))); Chemical.Sources.PureSubstance water(redeclare package stateOfMatter = Chemical.Interfaces.Incompressible, substanceData = Chemical.Substances.Water_liquid()) annotation ( @@ -4251,23 +4254,23 @@ The sensor is ideal, i.e., it does not influence the fluid. stateOfMatter = Chemical.Interfaces.IdealGas, substanceData = Chemical.Substances.Oxygen_gas(), redeclare package Medium = Air) annotation ( Placement(transformation(extent = {{-138, -64}, {-158, -84}}))); - Physiolibrary.Fluid.Sensors.Temperature Temperature_alveolar(redeclare - package Medium = Air) annotation ( + Physiolibrary.Fluid.Sensors.Temperature Temperature_alveolar(redeclare package + Medium = Air) annotation ( Placement(transformation(extent = {{-110, -40}, {-90, -20}}))); - Physiolibrary.Fluid.Sensors.PartialPressure pH2O_alveolar(redeclare - package stateOfMatter = + Physiolibrary.Fluid.Sensors.PartialPressure pH2O_alveolar(redeclare package + stateOfMatter = Chemical.Interfaces.IdealGas, substanceData = Chemical.Substances.Water_gas(), redeclare package Medium = Air) annotation ( Placement(transformation(extent = {{-122, -66}, {-102, -86}}))); - Physiolibrary.Fluid.Sensors.PartialPressure pH2O_upperRespiratory(redeclare - package stateOfMatter = Chemical.Interfaces.IdealGas, substanceData = Chemical.Substances.Water_gas(), redeclare + Physiolibrary.Fluid.Sensors.PartialPressure pH2O_upperRespiratory(redeclare package + stateOfMatter = Chemical.Interfaces.IdealGas, substanceData = Chemical.Substances.Water_gas(), redeclare package Medium = Air) annotation ( Placement(transformation(extent = {{-364, 34}, {-344, 14}}))); - Physiolibrary.Fluid.Sensors.Temperature Temperature_upperRespiratory(redeclare - package Medium = Air) annotation ( + Physiolibrary.Fluid.Sensors.Temperature Temperature_upperRespiratory(redeclare package + Medium = Air) annotation ( Placement(transformation(extent = {{-298, 30}, {-278, 50}}))); - Physiolibrary.Fluid.Sensors.Temperature Temperature_mouth(redeclare - package Medium = Air) annotation ( + Physiolibrary.Fluid.Sensors.Temperature Temperature_mouth(redeclare package + Medium = Air) annotation ( Placement(transformation(extent = {{-296, 72}, {-276, 92}}))); Physiolibrary.Thermal.Components.Conductor conductor(Conductance(displayUnit = "W/K") = 10) annotation ( Placement(transformation(extent = {{-302, -44}, {-322, -24}}))); @@ -4401,7 +4404,7 @@ The sensor is ideal, i.e., it does not influence the fluid. replaceable package Blood = Physiolibrary.Media.Blood; Components.ElasticVessel Artys( redeclare package Medium = Blood, - massFractions_start=Blood.X(epinephrine=40e-7), + massFractions_start=Blood.ArterialDefault, useSubstances=true, Compliance=7.5006157584566e-08, nPorts=14) diff --git a/Physiolibrary/Media.mo b/Physiolibrary/Media.mo index e05d612..aed0a49 100644 --- a/Physiolibrary/Media.mo +++ b/Physiolibrary/Media.mo @@ -1,5 +1,5 @@ within Physiolibrary; -package Media +package Media "Models of physiological fluids" extends Modelica.Icons.Package; package Blood "Blood" @@ -10,7 +10,7 @@ package Media mediumName = "Blood", substanceNames={"H2O_E","O2","CO2","CO","Hb","MetHb","HbF","Alb","Glb","PO4","DPG", "Glucose","Lactate","Urea","AminoAcids","Lipids","KetoAcids", - "Na_P","K_P","Na_E","K_E","Cl", + "Na_P","K_P","Na_E","K_E","Cl_P","Cl_E", "Epinephrine", "Norepinephrine","Vasopressin", "Insulin","Glucagon","Thyrotropin","Thyroxine","Leptin", "Desglymidodrine","AlphaBlockers","BetaBlockers", @@ -33,13 +33,15 @@ package Media start=310.15, nominal=310.15)); - constant Types.MassFraction ArterialDefault[nS]=X(tO2=D_Arterial_O2,tCO2=D_Arterial_CO2); + constant Types.MassFraction ArterialDefault[nS]={ + 0.24006872,0.00024730066,0.00088532415,4.0067286e-11,0.13012053,0.0006506026,0.0006506026,0.023240043,0.0148344375,7.7006625e-06,0.0005979338,0.00058174727,4.9633483e-05,0.00021128391,0.00026331126,0.0005255277,2.637139e-06,0.0016869484,8.2860926e-05,6.699073e-05,0.0015625204,0.0018235744,0.0008487089,2.1192053e-11,1.2715232e-10,1.0567206e-12,3.675887e-10,3.6916557e-11,5.978278e-11,4.2172186e-08,4.2172186e-09,5.298013e-15,1e-20,1e-20,1e-06,1.0596027e-11,7.12053e-15,6.301733e-11,0.4941722,0.07920542}; - constant Types.MassFraction VenousDefault[nS]=X(tO2=D_Venous_O2,tCO2=D_Venous_CO2); + constant Types.MassFraction VenousDefault[nS]={ + 0.24047989,0.0001659035, 0.0009894797, 4.0067286e-11,0.13012053,0.0006506026,0.0006506026,0.023240043,0.0148344375,7.7006625e-06,0.0005979338,0.00058174727,4.9633483e-05,0.00021128391,0.00026331126,0.0005255277,2.637139e-06,0.0016869484,8.2860926e-05,6.699073e-05,0.0015625204,0.0017914142,0.00088086916,2.1192053e-11,1.2715232e-10,1.0567206e-12,3.675887e-10,3.6916557e-11,5.978278e-11,4.2172186e-08,4.2172186e-09,5.298013e-15,1e-20,1e-20,1e-06,1.0596027e-11,7.12053e-15,6.301733e-11,0.493761,0.078535914}; public - redeclare connector extends SubstancesPort + redeclare connector extends SubstancesPort "Blood chemical substances interface" Chemical.Interfaces.SubstancePort_a CO2 "Free carbon dioxide molecule"; Chemical.Interfaces.SubstancePort_a O2 "Free oxygen molecule"; Chemical.Interfaces.SubstancePort_a CO "Free carbon monoxide moelcule"; @@ -53,6 +55,9 @@ package Media Chemical.Interfaces.SubstancePort_a Insulin,Glucagon,Thyrotropin,Thyroxine,Leptin; Chemical.Interfaces.SubstancePort_a Desglymidodrine; Chemical.Interfaces.SubstancePort_a Angiotensin2,Renin,Aldosterone; + annotation (Documentation(info=" +

Electrochemical connections lead via free base substance forms. For example, the total mass fraction of carbon dioxide is represented as part of the composition of blood in fluid connector, but free dissolved carbon dioxide in blood plasma or bicarbonate in blood plasma are its electrochemical connectors proposed to model the electrochemical CO2 fluxes. Since the selected forms are precisely determined by the composition of the blood, it is not necessary to store them and pass them through the fluid connector. They are only expressed and calculated when needed.

+")); end SubstancesPort; redeclare replaceable record extends ThermodynamicState @@ -62,7 +67,6 @@ package Media SpecificEnthalpy h "Specific enthalpy"; MassFraction X[nS] "Mass fractions of substances"; Types.ElectricPotential v "Electric potential of the substance"; - Types.MoleFraction I "Ionic strengh (mole fraction based)"; annotation (Documentation(info="

Thermodynamic state of blood is represented by pressure, temperature, base substances composition, electrical potential and ionic strengh.

")); @@ -88,6 +92,10 @@ package Media "Mole fraction of Cl- in blood plasma"; Modelica.Units.SI.MoleFraction aCl_E(start = 0.050) "Mole fraction of Cl- in blood red cell"; + Modelica.Units.SI.MoleFraction aH2O_E,aH2O_P; + Types.MolarFlowRate Cl_Ery2Plasma,H2O_Ery2Plasma; + parameter Real KC_Cl = 1e-5 "Rate of chloride shift equilibration"; + parameter Real KC_H2O = 1e-2 "Rate of osmolarity equilibration"; Modelica.Units.SI.MoleFraction aCO "Gaseous CO activity"; @@ -110,7 +118,7 @@ package Media Modelica.Units.SI.Molality bHCO3_P = (aHCO3*x_P) "Molality of bicarbonate in blood plasma [mol/kg]"; Modelica.Units.SI.Molality bHCO3_E = (aHCO3_E*x_E) "Molality of bicarbonate in blood red cells [mol/kg]"; - + Types.MassFraction expected_XCl_E,expected_XH2O_E; equation @@ -127,12 +135,21 @@ package Media aHCO3 = bloodGases.cHCO3 / (x_P*plasmaDensity(state)); aHCO3_E = bloodGases.cHCO3_E / (x_E*formedElementsDensity(state)); - aHCO3*aCl_E = aCl_P*aHCO3_E "Chloride shift"; - state.X[i("Cl")] = (aCl_P*x_P)*Cl.MolarWeight*pct + (aCl_E*x_E)*Cl.MolarWeight*hct "Mass fraction of Cl- in blood"; + state.X[i("Cl_P")] = (aCl_P*x_P)*Cl.MolarWeight*pct "Mass fraction of Cl- in blood"; + state.X[i("Cl_E")] = (aCl_E*x_E)*Cl.MolarWeight*hct "Mass fraction of Cl- in blood"; + Cl_Ery2Plasma = KC_Cl*(Modelica.Constants.R*T*log((aCl_E/aCl_P)*(aHCO3/aHCO3_E))) "Chloride shift"; + expected_XCl_E = (aCl_P*(aHCO3_E/aHCO3)*x_E)*Cl.MolarWeight*hct "Debug of chloride shift rate"; + pct = plasmaMassFraction(state); hct = formedElementsMassFraction(state); + state.X[i("H2O_P")] = aH2O_P*pct*x_P/Chemical.Interfaces.Incompressible.specificAmountOfParticles(Substances.Water,T,p,v,I); + state.X[i("H2O_E")] = aH2O_E*hct*x_E/Chemical.Interfaces.Incompressible.specificAmountOfParticles(Substances.Water,T,p,v,I); + H2O_Ery2Plasma = KC_H2O*(Modelica.Constants.R*T*log(aH2O_E/aH2O_P)) "Osmolarity equilibration rate"; + expected_XH2O_E = aH2O_P*hct*x_E/Chemical.Interfaces.Incompressible.specificAmountOfParticles(Substances.Water,T,p,v,I) "Debug of osmolarity equilibration"; + + fH2O_P = state.X[i("H2O_P")]*Chemical.Interfaces.Incompressible.specificAmountOfParticles(Substances.Water,T,p,v,I)/pct "Amount of free H2O particles in 1 kg of blood plasma [mol/kg]"; x_P = @@ -332,7 +349,7 @@ package Media substances.KetoAcids.q * actualStream(substances.KetoAcids.h_outflow) "enthalpy from substances"; - massFlows[i("H2O_E")]= 0; + massFlows[i("H2O_E")]= -H2O_Ery2Plasma * Substances.Water.MolarWeight; massFlows[i("O2")]= substances.O2.q * Substances.O2.MolarWeight; massFlows[i("CO2")]= substances.CO2.q * Substances.CO2.MolarWeight + substances.HCO3.q .* Substances.CO2.MolarWeight; massFlows[i("CO")]= substances.CO.q * Substances.CO.MolarWeight; @@ -351,9 +368,10 @@ package Media massFlows[i("KetoAcids")]= substances.KetoAcids.q * Constants.MM_KetoAcids; massFlows[i("Na_P")]= 0; massFlows[i("K_P")]= 0; + massFlows[i("Cl_P")]= Cl_Ery2Plasma * Cl.MolarWeight; massFlows[i("Na_E")]= 0; massFlows[i("K_E")]= 0; - massFlows[i("Cl")]= 0; + massFlows[i("Cl_E")]= -Cl_Ery2Plasma * Cl.MolarWeight; massFlows[i("Epinephrine")]= substances.Epinephrine.q * Constants.MM_Epinephrine; massFlows[i("Norepinephrine")]= substances.Norepinephrine.q * Constants.MM_Norepinephrine; massFlows[i("Vasopressin")]= substances.Vasopressin.q * Constants.MM_Vasopressin; @@ -369,7 +387,7 @@ package Media massFlows[i("Angiotensin2")]= substances.Angiotensin2.q * Constants.MM_Angiotensin2; massFlows[i("Renin")]= substances.Renin.q * Constants.MM_Renin; massFlows[i("Aldosterone")]= substances.Aldosterone.q * Constants.MM_Aldosterone; - massFlows[i("H2O_P")]= substances.H2O.q * Substances.Water.MolarWeight; + massFlows[i("H2O_P")]= substances.H2O.q * Substances.Water.MolarWeight + H2O_Ery2Plasma * Substances.Water.MolarWeight; massFlows[i("Other_E")]= 0; @@ -382,35 +400,35 @@ package Media replaceable model BloodGases "Hydrogen Ion, Carbon Dioxide, and Oxygen in the Blood" input Physiolibrary.Media.Blood.ThermodynamicState state(p=101325,h=ArterialDefault*specificEnthalpies_TpvI(T,101325),X=ArterialDefault) "blood"; input Modelica.Units.SI.Temperature T=310.15 "Temperature"; - output Modelica.Units.SI.Pressure pO2(start=101325*87/760) + output Modelica.Units.SI.Pressure pO2(start=101325*87/760,min=1e-11) "Oxygen partial pressure"; output Modelica.Units.SI.Pressure pCO2(start=101325*40/760) "Carbon dioxide partial pressure"; - output Modelica.Units.SI.Pressure pCO(start=1e-5) + output Modelica.Units.SI.Pressure pCO(start=1e-5, min=1e-11) "Carbon monoxide partial pressure"; output Physiolibrary.Types.pH pH(start=7.4) "Blood plasma acidity"; // protected - Physiolibrary.Types.VolumeFraction Hct=hematocrit(state) "haematocrit"; - Types.Concentration _tO2=tO2(state) "oxygen content per volume of blood"; - Types.Concentration _tCO2=tCO2(state) + input Physiolibrary.Types.VolumeFraction Hct=hematocrit(state) "haematocrit"; + input Types.Concentration _tO2=tO2(state) "oxygen content per volume of blood"; + input Types.Concentration _tCO2=tCO2(state) "carbon dioxide content per volume of blood"; - Types.Concentration _tCO=tCO(state) + input Types.Concentration _tCO=tCO(state) "carbon monoxide content per volume of blood"; - Types.Concentration _tHb=tHb(state) + input Types.Concentration _tHb=tHb(state) "hemoglobin content per volume of blood"; - Types.MoleFraction _FMetHb=FMetHb(state) "fraction of methemoglobin"; - Types.MoleFraction _FHbF=FHbF(state) "fraction of foetalhemoglobin"; - Types.Concentration _ctHb_ery=ctHb_ery(state) + input Types.MoleFraction _FMetHb(start=0.005)=FMetHb(state) "fraction of methemoglobin"; + input Types.MoleFraction _FHbF(start=0.005)=FHbF(state) "fraction of foetalhemoglobin"; + input Types.Concentration _ctHb_ery=ctHb_ery(state) "hemoglobin concentration in red cells"; - Types.Concentration _tAlb=tAlb(state) + input Types.Concentration _tAlb=tAlb(state) "albumin concentration in blood plasma"; - Types.MassConcentration _tGlb=tGlb(state) + input Types.MassConcentration _tGlb=tGlb(state) "globulin concentration in blood plasma"; - Types.Concentration _tPO4=tPO4(state) + input Types.Concentration _tPO4=tPO4(state) "inorganic phosphates concentration in blood plasma"; - Types.Concentration _cDPG=cDPG(state) "DPG concentration in blood plasma"; - Types.Concentration _SID=SID(state) "strong ion difference of blood"; + input Types.Concentration _cDPG=cDPG(state) "DPG concentration in blood plasma"; + input Types.Concentration _SID=SID(state) "strong ion difference of blood"; constant Physiolibrary.Types.Temperature T0=273.15 + 37 "normal temperature"; constant Physiolibrary.Types.pH pH0=7.4 "normal pH"; @@ -426,19 +444,19 @@ package Media Physiolibrary.Types.pH pH_ery; - Physiolibrary.Types.GasSolubilityPa aCO2N=0.00023 + input Physiolibrary.Types.GasSolubilityPa aCO2N=0.00023 "solubility of CO2 in blood plasma at 37 degC"; - Physiolibrary.Types.GasSolubilityPa aCO2=0.00023*(10^(-0.0092*(T - 310.15))) + input Physiolibrary.Types.GasSolubilityPa aCO2=0.00023*(10^(-0.0092*(T - 310.15))) "solubility of CO2 in blood plasma"; - Physiolibrary.Types.GasSolubilityPa aCO2_ery(displayUnit="mmol/l/mmHg") = 0.000195 + input Physiolibrary.Types.GasSolubilityPa aCO2_ery(displayUnit="mmol/l/mmHg") = 0.000195 "solubility 0.23 (mmol/l)/kPa at 25degC"; - Physiolibrary.Types.GasSolubilityPa aO2=exp(log(0.0105) + (-0.0115*(T - T0)) + 0.5* + input Physiolibrary.Types.GasSolubilityPa aO2=exp(log(0.0105) + (-0.0115*(T - T0)) + 0.5* 0.00042*((T - T0)^2))/1000 "oxygen solubility in blood"; - Physiolibrary.Types.GasSolubilityPa aCO=(0.00099/0.0013)*aO2 + input Physiolibrary.Types.GasSolubilityPa aCO=(0.00099/0.0013)*aO2 "carbon monoxide solubility in blood"; - Real pK=6.1 + (-0.0026)*(T - 310.15) "Henderson-Hasselbalch"; - Real pK_ery=6.125 - log10(1 + 10^(pH_ery - 7.84 - 0.06*sO2)); + input Real pK=6.1 + (-0.0026)*(T - 310.15) "Henderson-Hasselbalch"; + input Real pK_ery=6.125 - log10(1 + 10^(pH_ery - 7.84 - 0.06*sO2)); parameter Real pKa1=2.1 "HPO4^2- dissociation"; parameter Real pKa2=6.8 "H2PO4^- dissociation"; @@ -558,14 +576,13 @@ package Media state.h = h; state.X = X; state.v = v; - state.I = I; annotation (Documentation(info="

Simplification of blood:

Constant density and constant heat capacity

")); end BaseProperties; - redeclare function extends specificEnthalpies_TpvI + redeclare function extends specificEnthalpies_TpvI "Specific enthalpies of blood substances" algorithm specificEnthalpy[i("H2O_E")]:=Chemical.Interfaces.Incompressible.specificEnthalpy(Substances.Water,T,p,v,I); specificEnthalpy[i("O2")]:=Chemical.Interfaces.IdealGas.specificEnthalpy(Substances.O2_g,T,p,v,I); @@ -588,7 +605,8 @@ package Media specificEnthalpy[i("Na_E")]:=Chemical.Interfaces.Incompressible.specificEnthalpy(Substances.Na,T,p,v,I); specificEnthalpy[i("K_P")]:=Chemical.Interfaces.Incompressible.specificEnthalpy(Substances.K,T,p,v,I); specificEnthalpy[i("K_E")]:=Chemical.Interfaces.Incompressible.specificEnthalpy(Substances.K,T,p,v,I); - specificEnthalpy[i("Cl")]:=Chemical.Interfaces.Incompressible.specificEnthalpy(Substances.Cl,T,p,v,I); + specificEnthalpy[i("Cl_P")]:=Chemical.Interfaces.Incompressible.specificEnthalpy(Substances.Cl,T,p,v,I); + specificEnthalpy[i("Cl_E")]:=Chemical.Interfaces.Incompressible.specificEnthalpy(Substances.Cl,T,p,v,I); specificEnthalpy[i("Epinephrine")]:=0; specificEnthalpy[i("Norepinephrine")]:=0; specificEnthalpy[i("Vasopressin")]:=0; @@ -761,7 +779,6 @@ package Media state.p := p; state.X := X; state.v := v; - state.I := I; annotation (Documentation(info="

Set thermodynamic state

")); @@ -775,7 +792,7 @@ package Media state.h := h; state.X := X; state.v := v; - state.I := I; + annotation (Documentation(info="

Set thermodynamic state based on constant heat capacity

")); @@ -900,7 +917,8 @@ package Media state.X[i("Na_E")]/Na.MolarWeight + state.X[i("K_P")]/K.MolarWeight + state.X[i("K_E")]/K.MolarWeight - - state.X[i("Cl")]/Cl.MolarWeight); + state.X[i("Cl_P")]/Cl.MolarWeight - + state.X[i("Cl_E")]/Cl.MolarWeight); end SID; function glucose "Total glucose in blood plasma" @@ -1045,144 +1063,6 @@ package Media plasmaMassFraction(state) "conversion factor from PRA (ng/mL/h) to DRC (mU/L) is 11.2, μIU/mL (mIU/L) * 0.6 = pg/mL"; end renin; - function X "To set mass fractions in blood" - - input Types.VolumeFraction hematocrit = D_Hct "Hematocrit [ml/ml]"; - input Types.Concentration tO2 = D_Arterial_O2 "Total oxygen in blood", - tCO2 = D_Arterial_CO2 "Total carbon dioxide in blood", - tCO = D_CO "Total carbon monoxide in blood", - tHb = D_Hb "Total hemoglobin in blood"; - input Types.Fraction FMetHb=D_MetHb/D_Hb "Methemoglobin fraction", - FHbF=D_HbF/D_Hb "Foetal hemoglobin fraction"; - input Types.Concentration tAlb = D_Alb "Total albumin in blood plasma"; - input Types.MassConcentration tGlb = D_Glb "Total globulin in blood plasma"; - - input Types.Concentration tPO4 = D_PO4 "Total inorganic phosphate in blood plasma", - cDPG = D_DPG "Diphosphoglycerate in red cells", - glucose = D_Glucose "Glucose in blood plasma", - lactate = D_Lactate "Lactate in blood plasma", - urea = D_Urea "Urea in blood plasma", - aminoAcids = D_AminoAcids "Amino acids in blood plasma", - lipids = D_Lipids "Fatty acids in blood plasma", - ketoacids = D_Ketoacids "Keto acids in blood plasma", - BEox = D_BEox "Base excess of oxygenated blood"; - - input Types.MassConcentration - epinephrine(displayUnit="ng/L")=D_Epinephrine_MC "Epinephrine in blood plasma", - norepinephrine(displayUnit="ng/L")=D_Norepinephrine_MC "Norepinephrine in blood plasma"; - input Types.Concentration - vasopressin(displayUnit="pmol/L")=D_Vasopressin "ADH in blood plasma"; - input Real - insulin(displayUnit="mU/L")=D_Insulin_A "Insulin in blood plasma"; - input Types.MassConcentration - glucagon(displayUnit="ng/L")=D_Glucagon_MC "Glucagon in blood plasma"; - input Types.Concentration - thyrotropin(displayUnit="pmol/L")=D_Thyrotropin "Thyrotropin in blood plasma"; - input Types.MassConcentration - thyroxine(displayUnit="ug/L")=D_Thyroxine_MC "Thyroxine blood plasma", - leptin(displayUnit="ug/L")=D_Leptin_MC "Leptin in blood plasma", - desglymidodrine(displayUnit="ug/L")=D_Desglymidodrine_MC "Desglymidodrine in blood plasma"; - input Types.Fraction - alphaBlockers = D_AlphaBlockers_f "Alpha blockers efffect", - betaBlockers = D_BetaBlockers_f "Beta blockers efffect", - anesthesiaVascularConductance = D_AnesthesiaVascularConductance_f "Anesthesia vasodilatation efffect"; - input Types.MassConcentration - angiotensin2(displayUnit="ng/L")=D_Angiotensin2_MC "A2 in blood plasma"; - input Real renin(displayUnit="ng/mL/h")=D_Renin_PRA "Renin in blood plasma"; - input Types.Concentration - aldosterone(displayUnit="nmol/L")=D_Aldosterone "Aldosterone in blood plasma"; - input Types.MassConcentration H2O_plasma = D_BloodPlasmaWater "Water in blood plasma"; - input Types.MassConcentration H2O_ery = D_BloodFormedElementsWater "Water in blood red cells"; - - input Types.Concentration cNa_P = D_Na "Sodium in blood plasma"; - input Types.Concentration cK_P = D_K "Potassium in blood plasma"; - input Types.Concentration cNa_E = D_Na_RBC "Sodium in erythrocytes"; - input Types.Concentration cK_E = D_K_RBC "Potassium in erythrocytes"; - - output Types.MassFraction X[nS]; - - protected - Types.Density density,plasmaDensity; - Types.Fraction plasmacrit; - Types.Concentration NSID; - Types.Fraction XE,XP,PMF; - algorithm - density := D_BloodDensity; - plasmaDensity := D_BloodPlasmaDensity; - plasmacrit := 1-hematocrit; - NSID := (1 - hematocrit) * (zAlbNAP * tAlb + zGlbNAP * tGlb + zPO4NAP * tPO4 + ztCO2NAP) + hematocrit * (zHbNAE * (tHb / hematocrit) + ztCO2NAE + zDPG*cDPG + zOtherE); - - X[i("H2O_P")] := (plasmacrit*H2O_plasma)/density; - X[i("H2O_E")] := (hematocrit*H2O_ery)/density; - X[i("O2")] := (tO2*O2.MolarWeight)/density; - X[i("CO2")] := (tCO2*CO2.MolarWeight)/density; - X[i("CO")] := (tCO*CO.MolarWeight)/density; - X[i("Hb")] := (tHb*Constants.MM_Hb)/density; - X[i("MetHb")] := FMetHb*X[ - i("Hb")]; - X[i("HbF")] := FHbF*X[i("Hb")]; - X[i("Alb")] := plasmacrit*(tAlb*Constants.MM_Alb)/ - density; - X[i("Glb")] := plasmacrit*tGlb/density; - X[i("PO4")] := plasmacrit*(tPO4*PO4.MolarWeight)/ - density; - X[i("DPG")] := hematocrit*(cDPG*Constants.MM_DPG)/ - density; - X[i("Glucose")] := plasmacrit*(glucose*Constants.MM_Glucose) - /density; - X[i("Lactate")] := plasmacrit*(lactate*Constants.MM_Lactate) - /density; - X[i("Urea")] := plasmacrit*(urea*Constants.MM_Urea) - /density; - X[i("AminoAcids")] := plasmacrit*(aminoAcids* - Constants.MM_AminoAcids)/density; - X[i("Lipids")] := plasmacrit*(lipids*Constants.MM_Lipids) - /density; - X[i("KetoAcids")] := plasmacrit*(ketoacids* - Constants.MM_KetoAcids)/density; - X[i("Na_P")] := plasmacrit*(cNa_P*Na.MolarWeight)/density; - X[i("K_P")] := plasmacrit*(cK_P*K.MolarWeight)/density; - X[i("Na_E")] := hematocrit*(cNa_E*Na.MolarWeight)/density; - X[i("K_E")] := hematocrit*(cK_E*K.MolarWeight)/density; - X[i("Cl")] := -((NSID - BEox)-plasmacrit*(cNa_P+cK_P)-hematocrit*(cNa_E+cK_E))*Cl.MolarWeight/density "where blood SID = NSID - BEox"; - X[i("Epinephrine")] := plasmacrit*(epinephrine)/ - density; - X[i("Norepinephrine")] := plasmacrit*( - norepinephrine)/density; - X[i("Vasopressin")] := plasmacrit*(vasopressin* - Constants.MM_Vasopressin)/density; - X[i("Insulin")] := plasmacrit*(6e-9*insulin* - Constants.MM_Insulin)/density - "conversion factor for human insulin is 1 mU/L = 6.00 pmol/L"; - X[i("Glucagon")] := plasmacrit*(glucagon)/density; - X[i("Thyrotropin")] := plasmacrit*(thyrotropin* - Constants.MM_Thyrotropin)/density; - X[i("Thyroxine")] := plasmacrit*(thyroxine)/ - density; - X[i("Leptin")] := plasmacrit*(leptin)/density; - X[i("Desglymidodrine")] := plasmacrit*( - desglymidodrine)/density; - X[i("AlphaBlockers")] := 1e-6 * alphaBlockers; - X[i("BetaBlockers")] := 1e-6 * betaBlockers; - X[i("AnesthesiaVascularConductance")] := - 1e-6 * anesthesiaVascularConductance; - X[i("Angiotensin2")] := plasmacrit*(angiotensin2)/ - density; - X[i("Renin")] := plasmacrit*(1e-12*0.6*11.2*renin)/ - density - "conversion factor from PRA (ng/mL/h) to DRC (mU/L) is 11.2, μIU/mL (mIU/L) * 0.6 = pg/mL"; - X[i("Aldosterone")] := plasmacrit*(aldosterone* - Constants.MM_Aldosterone)/density; - - PMF := plasmacrit * plasmaDensity/density; - XP := X[i("H2O_P")] + X[i("CO2")] + X[i("Alb")] + X[i("Glb")] + X[i("Glucose")] + - X[i("PO4")] + X[i("Lactate")] + X[i("Urea")] + X[i("AminoAcids")] + X[i("Lipids")] + X[i("KetoAcids")]; - XE := XP*(1-PMF)/PMF; - X[i("Other_E")] := XE - (X[i("H2O_E")] + X[i("Hb")] + X[i("DPG")]); - - - end X; - function plasmacrit "Blood plasmacrit [mL/mL]" extends GetFraction; algorithm @@ -1231,24 +1111,24 @@ package Media F := XE/ (XE + XP); end formedElementsMassFraction; - model InitalComposition "To set mass fractions in blood" + model ArterialComposition "To set mass fractions in blood" - input Types.Temperature T = 310.15; - input Types.Pressure p = 101325; - input Types.ElectricPotential v = 0; - input Real I=0; + Types.Temperature T = 310.15; + Types.Pressure p = 101325; + Types.ElectricPotential v = 0; + Real I=0; - input Types.VolumeFraction hematocrit = D_Hct "Hematocrit [ml/ml]"; - input Types.Concentration tO2 = D_Arterial_O2 "Total oxygen in blood", + Types.VolumeFraction hematocrit = D_Hct "Hematocrit [ml/ml]"; + Types.Concentration tO2 = D_Arterial_O2 "Total oxygen in blood", tCO2 = D_Arterial_CO2 "Total carbon dioxide in blood", tCO = D_CO "Total carbon monoxide in blood", tHb = D_Hb "Total hemoglobin in blood"; - input Types.Fraction FMetHb=D_MetHb/D_Hb "Methemoglobin fraction", + Types.Fraction FMetHb=D_MetHb/D_Hb "Methemoglobin fraction", FHbF=D_HbF/D_Hb "Foetal hemoglobin fraction"; - input Types.Concentration tAlb = D_Alb "Total albumin in blood plasma"; - input Types.MassConcentration tGlb = D_Glb "Total globulin in blood plasma"; + Types.Concentration tAlb = D_Alb "Total albumin in blood plasma"; + Types.MassConcentration tGlb = D_Glb "Total globulin in blood plasma"; - input Types.Concentration tPO4 = D_PO4 "Total inorganic phosphate in blood plasma", + Types.Concentration tPO4 = D_PO4 "Total inorganic phosphate in blood plasma", cDPG = D_DPG "Diphosphoglycerate in red cells", glucose = D_Glucose "Glucose in blood plasma", lactate = D_Lactate "Lactate in blood plasma", @@ -1258,55 +1138,54 @@ package Media ketoacids = D_Ketoacids "Keto acids in blood plasma", BEox = D_BEox "Base excess of oxygenated blood"; - input Types.MassConcentration + Types.MassConcentration epinephrine(displayUnit="ng/L")=D_Epinephrine_MC "Epinephrine in blood plasma", norepinephrine(displayUnit="ng/L")=D_Norepinephrine_MC "Norepinephrine in blood plasma"; - input Types.Concentration + Types.Concentration vasopressin(displayUnit="pmol/L")=D_Vasopressin "ADH in blood plasma"; - input Real - insulin(displayUnit="mU/L")=D_Insulin_A "Insulin in blood plasma"; - input Types.MassConcentration + Real insulin(displayUnit="mU/L")=D_Insulin_A "Insulin in blood plasma"; + Types.MassConcentration glucagon(displayUnit="ng/L")=D_Glucagon_MC "Glucagon in blood plasma"; - input Types.Concentration + Types.Concentration thyrotropin(displayUnit="pmol/L")=D_Thyrotropin "Thyrotropin in blood plasma"; - input Types.MassConcentration + Types.MassConcentration thyroxine(displayUnit="ug/L")=D_Thyroxine_MC "Thyroxine blood plasma", leptin(displayUnit="ug/L")=D_Leptin_MC "Leptin in blood plasma", desglymidodrine(displayUnit="ug/L")=D_Desglymidodrine_MC "Desglymidodrine in blood plasma"; - input Types.Fraction + Types.Fraction alphaBlockers = D_AlphaBlockers_f "Alpha blockers efffect", betaBlockers = D_BetaBlockers_f "Beta blockers efffect", anesthesiaVascularConductance = D_AnesthesiaVascularConductance_f "Anesthesia vasodilatation efffect"; - input Types.MassConcentration + Types.MassConcentration angiotensin2(displayUnit="ng/L")=D_Angiotensin2_MC "A2 in blood plasma"; - input Real renin(displayUnit="ng/mL/h")=D_Renin_PRA "Renin in blood plasma"; - input Types.Concentration + Real renin(displayUnit="ng/mL/h")=D_Renin_PRA "Renin in blood plasma"; + Types.Concentration aldosterone(displayUnit="nmol/L")=D_Aldosterone "Aldosterone in blood plasma"; - input Types.MassFraction XH2O = D_H2O_B "Water in blood"; - //input Types.MassConcentration H2O_plasma = D_BloodPlasmaWater "Water in blood plasma"; - //input Types.MassConcentration H2O_ery = D_BloodFormedElementsWater "Water in blood red cells"; + Types.MassFraction XH2O = D_H2O_B "Water in blood"; + //Types.MassConcentration H2O_plasma = D_BloodPlasmaWater "Water in blood plasma"; + //Types.MassConcentration H2O_ery = D_BloodFormedElementsWater "Water in blood red cells"; - input Types.Concentration cNa_P = D_Na "Sodium in blood plasma"; - input Types.Concentration cK_P = D_K "Potassium in blood plasma"; - input Types.Concentration cNa_E = D_Na_RBC "Sodium in erythrocytes"; - input Types.Concentration cK_E = D_K_RBC "Potassium in erythrocytes"; + Types.Concentration cNa_P = D_Na "Sodium in blood plasma"; + Types.Concentration cK_P = D_K "Potassium in blood plasma"; + Types.Concentration cNa_E = D_Na_RBC "Sodium in erythrocytes"; + Types.Concentration cK_E = D_K_RBC "Potassium in erythrocytes"; output Types.MassFraction X[nS]; // output Types.MassFraction XH2O; - protected + //protected Types.Density density,plasmaDensity; Types.Fraction plasmacrit; Types.Concentration NSID; Types.Fraction XE,XP,PMF; - + //(start=ArterialDefault*Physiolibrary.Media.Blood.specificEnthalpies_TpvI(310,p)) Types.SpecificEnthalpy h = X*Physiolibrary.Media.Blood.specificEnthalpies_TpvI(T,p); ThermodynamicState state = setState_phX(p, h, X) "State of blood"; Physiolibrary.Media.Blood.BloodGases bloodGases( T=T, - state=state); + state=state,pO2(start=11608.745),pCO(start=1.000545e-05)); Types.MassFraction pct "Plasmacrit [kg/kg]"; Types.MassFraction hct "Hematocrit [kg/kg]"; @@ -1316,8 +1195,8 @@ package Media Modelica.Units.SI.Molality x_E(start=0.86) "Amount of free particles in 1 kg of blood erythrocytes [mol/kg]"; Types.MoleFraction aH2O_P,aH2O_E, aCl_P, aCl_E, aHCO3, aHCO3_E; - Types.MassConcentration H2O_plasma(start=D_BloodPlasmaWater) "Water in blood plasma"; - Types.MassConcentration H2O_ery(start=D_BloodFormedElementsWater) "Water in blood red cells"; + Types.Concentration H2O_plasma(start=D_BloodPlasmaWater) "Water in blood plasma"; + Types.Concentration H2O_ery(start=D_BloodFormedElementsWater) "Water in blood red cells"; // debug of chloride shift: Modelica.Units.SI.Concentration cCl_P = (aCl_P*x_P)*plasmaDensity "Chloride in blood plasma"; @@ -1325,81 +1204,79 @@ package Media Modelica.Units.SI.Concentration cHCO3_P = (aHCO3*x_P)*plasmaDensity "Bicarbonate in blood plasma"; Modelica.Units.SI.Concentration cHCO3_E = (aHCO3_E*x_E)*formedElementsDensity(state) "Bicarbonate in blood red cells"; - algorithm - density := D_BloodDensity; - plasmaDensity := D_BloodPlasmaDensity; - plasmacrit := 1-hematocrit; - NSID := (1 - hematocrit) * (zAlbNAP * tAlb + zGlbNAP * tGlb + zPO4NAP * tPO4 + ztCO2NAP) + hematocrit * (zHbNAE * (tHb / hematocrit) + ztCO2NAE + zDPG*cDPG + zOtherE); - - X[i("H2O_P")] := (plasmacrit*H2O_plasma)/density; - X[i("H2O_E")] := (hematocrit*H2O_ery)/density; - X[i("O2")] := (tO2*O2.MolarWeight)/density; - X[i("CO2")] := (tCO2*CO2.MolarWeight)/density; - X[i("CO")] := (tCO*CO.MolarWeight)/density; - X[i("Hb")] := (tHb*Constants.MM_Hb)/density; - X[i("MetHb")] := FMetHb*X[ + equation + density = D_BloodDensity; + plasmaDensity = D_BloodPlasmaDensity; + plasmacrit = 1-hematocrit; + NSID = (1 - hematocrit) * (zAlbNAP * tAlb + zGlbNAP * tGlb + zPO4NAP * tPO4 + ztCO2NAP) + hematocrit * (zHbNAE * (tHb / hematocrit) + ztCO2NAE + zDPG*cDPG + zOtherE); + + X[i("H2O_P")] = (plasmacrit*H2O_plasma)/density; + X[i("H2O_E")] = (hematocrit*H2O_ery)/density; + X[i("O2")] = (tO2*O2.MolarWeight)/density; + X[i("CO2")] = (tCO2*CO2.MolarWeight)/density; + X[i("CO")] = (tCO*CO.MolarWeight)/density; + X[i("Hb")] = (tHb*Constants.MM_Hb)/density; + X[i("MetHb")] = FMetHb*X[ i("Hb")]; - X[i("HbF")] := FHbF*X[i("Hb")]; - X[i("Alb")] := plasmacrit*(tAlb*Constants.MM_Alb)/ + X[i("HbF")] = FHbF*X[i("Hb")]; + X[i("Alb")] = plasmacrit*(tAlb*Constants.MM_Alb)/ density; - X[i("Glb")] := plasmacrit*tGlb/density; - X[i("PO4")] := plasmacrit*(tPO4*PO4.MolarWeight)/ + X[i("Glb")] = plasmacrit*tGlb/density; + X[i("PO4")] = plasmacrit*(tPO4*PO4.MolarWeight)/ density; - X[i("DPG")] := hematocrit*(cDPG*Constants.MM_DPG)/ + X[i("DPG")] = hematocrit*(cDPG*Constants.MM_DPG)/ density; - X[i("Glucose")] := plasmacrit*(glucose*Constants.MM_Glucose) + X[i("Glucose")] = plasmacrit*(glucose*Constants.MM_Glucose) /density; - X[i("Lactate")] := plasmacrit*(lactate*Constants.MM_Lactate) + X[i("Lactate")] = plasmacrit*(lactate*Constants.MM_Lactate) /density; - X[i("Urea")] := plasmacrit*(urea*Constants.MM_Urea) + X[i("Urea")] = plasmacrit*(urea*Constants.MM_Urea) /density; - X[i("AminoAcids")] := plasmacrit*(aminoAcids* + X[i("AminoAcids")] = plasmacrit*(aminoAcids* Constants.MM_AminoAcids)/density; - X[i("Lipids")] := plasmacrit*(lipids*Constants.MM_Lipids) + X[i("Lipids")] = plasmacrit*(lipids*Constants.MM_Lipids) /density; - X[i("KetoAcids")] := plasmacrit*(ketoacids* + X[i("KetoAcids")] = plasmacrit*(ketoacids* Constants.MM_KetoAcids)/density; - X[i("Na_P")] := plasmacrit*(cNa_P*Na.MolarWeight)/density; - X[i("K_P")] := plasmacrit*(cK_P*K.MolarWeight)/density; - X[i("Na_E")] := hematocrit*(cNa_E*Na.MolarWeight)/density; - X[i("K_E")] := hematocrit*(cK_E*K.MolarWeight)/density; - X[i("Cl")] := -((NSID - BEox)-plasmacrit*(cNa_P+cK_P)-hematocrit*(cNa_E+cK_E))*Cl.MolarWeight/density "where blood SID = NSID - BEox"; - X[i("Epinephrine")] := plasmacrit*(epinephrine)/ + X[i("Na_P")] = plasmacrit*(cNa_P*Na.MolarWeight)/density; + X[i("K_P")] = plasmacrit*(cK_P*K.MolarWeight)/density; + X[i("Na_E")] = hematocrit*(cNa_E*Na.MolarWeight)/density; + X[i("K_E")] = hematocrit*(cK_E*K.MolarWeight)/density; + X[i("Epinephrine")] = plasmacrit*(epinephrine)/ density; - X[i("Norepinephrine")] := plasmacrit*( + X[i("Norepinephrine")] = plasmacrit*( norepinephrine)/density; - X[i("Vasopressin")] := plasmacrit*(vasopressin* + X[i("Vasopressin")] = plasmacrit*(vasopressin* Constants.MM_Vasopressin)/density; - X[i("Insulin")] := plasmacrit*(6e-9*insulin* + X[i("Insulin")] = plasmacrit*(6e-9*insulin* Constants.MM_Insulin)/density "conversion factor for human insulin is 1 mU/L = 6.00 pmol/L"; - X[i("Glucagon")] := plasmacrit*(glucagon)/density; - X[i("Thyrotropin")] := plasmacrit*(thyrotropin* + X[i("Glucagon")] = plasmacrit*(glucagon)/density; + X[i("Thyrotropin")] = plasmacrit*(thyrotropin* Constants.MM_Thyrotropin)/density; - X[i("Thyroxine")] := plasmacrit*(thyroxine)/ + X[i("Thyroxine")] = plasmacrit*(thyroxine)/ density; - X[i("Leptin")] := plasmacrit*(leptin)/density; - X[i("Desglymidodrine")] := plasmacrit*( + X[i("Leptin")] = plasmacrit*(leptin)/density; + X[i("Desglymidodrine")] = plasmacrit*( desglymidodrine)/density; - X[i("AlphaBlockers")] := 1e-6 * alphaBlockers; - X[i("BetaBlockers")] := 1e-6 * betaBlockers; - X[i("AnesthesiaVascularConductance")] := + X[i("AlphaBlockers")] = 1e-6 * alphaBlockers; + X[i("BetaBlockers")] = 1e-6 * betaBlockers; + X[i("AnesthesiaVascularConductance")] = 1e-6 * anesthesiaVascularConductance; - X[i("Angiotensin2")] := plasmacrit*(angiotensin2)/ + X[i("Angiotensin2")] = plasmacrit*(angiotensin2)/ density; - X[i("Renin")] := plasmacrit*(1e-12*0.6*11.2*renin)/ + X[i("Renin")] = plasmacrit*(1e-12*0.6*11.2*renin)/ density "conversion factor from PRA (ng/mL/h) to DRC (mU/L) is 11.2, μIU/mL (mIU/L) * 0.6 = pg/mL"; - X[i("Aldosterone")] := plasmacrit*(aldosterone* + X[i("Aldosterone")] = plasmacrit*(aldosterone* Constants.MM_Aldosterone)/density; - PMF := plasmacrit * plasmaDensity/density; - XP := X[i("H2O_P")] + X[i("CO2")] + X[i("Alb")] + X[i("Glb")] + X[i("Glucose")] + + PMF = plasmacrit * plasmaDensity/density; + XP = X[i("H2O_P")] + X[i("CO2")] + X[i("Alb")] + X[i("Glb")] + X[i("Glucose")] + X[i("PO4")] + X[i("Lactate")] + X[i("Urea")] + X[i("AminoAcids")] + X[i("Lipids")] + X[i("KetoAcids")]; - XE := XP*(1-PMF)/PMF; - X[i("Other_E")] := XE - (X[i("H2O_E")] + X[i("Hb")] + X[i("DPG")]); + XE = XP*(1-PMF)/PMF; + X[i("Other_E")] = XE - (X[i("H2O_E")] + X[i("Hb")] + X[i("DPG")]); - equation XH2O = X[i("H2O_P")] + X[i("H2O_E")]; aH2O_P = aH2O_E "osmolarity"; @@ -1441,9 +1318,24 @@ package Media aHCO3_E = bloodGases.cHCO3_E / (x_E*formedElementsDensity(state)); aHCO3*aCl_E = aCl_P*aHCO3_E "Chloride shift"; - state.X[i("Cl")] = (aCl_P*x_P)*Cl.MolarWeight*pct + (aCl_E*x_E)*Cl.MolarWeight*hct "Mass fraction of Cl- in blood"; + X[i("Cl_P")] = (aCl_P*x_P)*Cl.MolarWeight*pct "Mass fraction of plasma Cl- in blood"; + X[i("Cl_E")] = (aCl_E*x_E)*Cl.MolarWeight*hct "Mass fraction of erythrocyte's Cl- in blood"; + X[i("Cl_P")]+X[i("Cl_E")] = -((NSID - BEox)-plasmacrit*(cNa_P+cK_P)-hematocrit*(cNa_E+cK_E))*Cl.MolarWeight/density "where blood SID = NSID - BEox"; + + annotation (experiment(StopTime=1, __Dymola_Algorithm="Dassl")); + end ArterialComposition; - end InitalComposition; + model VenousComposition + extends ArterialComposition(tO2=D_Venous_O2,tCO2=D_Venous_CO2); + end VenousComposition; + + annotation (Documentation(info=" +

Adding new substance to blood model:

+


- add to Blood.substanceNames

+

- modify functions: Blood.specificEnthalpies_TpvI

+

- modify model: Blood.ArterialComposition, run it and resuled X set as ArterialDefault (and from VenousComposition -> VenousDefault)

+

- modify model: Blood.ChemicalSolution,

+")); end Blood; package Water "Incompressible water with constant heat capacity" @@ -2312,15 +2204,10 @@ Modelica source. Physiolibrary.Types.RealIO.ElectricPotentialOutput v "electric potential"; - Real logm[nS] "natutal logarithm of medium substance masses (as state variables)"; initial equation - logm = log(startSubstanceMasses); + substanceMasses = startSubstanceMasses; equation - - //The main accumulation equation is "der(substanceMasses)= substanceMassFlowsFromStream + massFlows" - // However, the numerical solvers can handle it in form of log(m) much better. :-) - der(logm) = ((substanceMassFlowsFromStream + massFlows)./substanceMasses) "accumulation of substances=exp(logm) [kg]"; - substanceMasses = exp(logm); + der(substanceMasses) = substanceMassFlowsFromStream + massFlows; end ChemicalSolution; function i "Find index of substance" @@ -2599,4 +2486,10 @@ Modelica source. constant Types.MassFraction D_H2O_B = 0.7342409 "Mass fraction of water in blood"; end InitialValues; + annotation (Documentation(info=" +

Water – as pure incompressible water with constant heat capacity without any substance inside

+

Air – as an ideal gas model with oxygen, carbon dioxide, nitrogen and water

+

Blood – as an incompressible fluid containing many physiological substances such as blood gases, electrolytes, red cells, nutrients, proteins and hormones. Thanks to the shift of numerical tolerances with predefined nominal values for each substance, the calculation is numerically stable, even if the ratio between the mass fractions of substances is 10^9 (e.g. mass fraction of water / mass fraction of thyrotropin). Blood contains equations for haemoglobin oxygen saturation, acid-base balance, and carbon dioxide transfers to achieve physiological conditions in the transport of blood gases under variable conditions (Mateják, Kulhánek, and Matoušek 2015).

+

BodyFluid – as an incompressible fluid that simplifies other physiological fluids such as interstitial fluid, intracellular fluid, cerebrospinal fluid, or urine. In Physiolibrary 3.0 this medium represents only a homogeneous chemical solution without special transfers or binding of substances inside.

+")); end Media;