Physiolibrary.Chemical.Components

Information

Extends from Modelica.Icons.Package (Icon for standard packages).

Package Content

Name Description
Physiolibrary.Chemical.Components.Substance Substance Substance accumulation in solution
Physiolibrary.Chemical.Components.ChemicalReaction ChemicalReaction Chemical Reaction
Physiolibrary.Chemical.Components.GasSolubility GasSolubility Henry's law of gas solubility in liquid.
Physiolibrary.Chemical.Components.Diffusion Diffusion Solute diffusion
Physiolibrary.Chemical.Components.Membrane Membrane Donnan's equilibrium of electrolytes usable for glomerular membrane, open/leak membrane channels, pores, ...
Physiolibrary.Chemical.Components.Speciation Speciation Chemical species definition by independent binding sides of macromolecule
Physiolibrary.Chemical.Components.Degradation Degradation Degradation of solute
Physiolibrary.Chemical.Components.Clearance Clearance Clearance with or without solvent outflow
Physiolibrary.Chemical.Components.Stream Stream Flow of whole solution
Physiolibrary.Chemical.Components.SolutePump SolutePump Prescribed solute flow
Physiolibrary.Chemical.Components.Dilution Dilution Adding/removing of the solvent to/from running solution
Physiolibrary.Chemical.Components.Reabsorption Reabsorption Reabsorption as input fraction

Physiolibrary.Chemical.Components.Substance Physiolibrary.Chemical.Components.Substance

Substance accumulation in solution

Physiolibrary.Chemical.Components.Substance

Information

Solute = Concentration · Volume = ∫ MolarFlow

The main class from “Chemical” package is called "Substance". It has one chemical connector, where molar concentration and molar flow is presented as usually. An amount of a substance ("solute") is accumulated by molar flow inside an instance of this class. In the default setting the volume is set to one liter, so in this setting the concentration at “mol/L” has the same value as the variable solute at “mol”. But in the advanced settings the default volume can be changed with external input. The molar flow at the port can be also negative, which means that the solute leaves the Substance instance. 


Having defined amount of all particles in solution as n(solution) and mass of solvent as m(solvent). It can be expressed mole fraction x and molality b as follows:

x = Solute / n(solution) = Concentration · Volume /n(solution)

b = Solute / m(solvent) = Concentration · Volume /m(solvent)


The activity (mole fraction based) can be expressed using mole-fraction-based activity coefficient gamma as:

a = gamma * x

Extends from Icons.Substance, Interfaces.ConditionalVolume (Chemical processes can be modeled with or without(normalized to 1 liter) variable solution volume), SteadyStates.Interfaces.SteadyState (Abstract class for any dynamic state calculation (for any derivation), which is driven by SimulationType option.).

Parameters

TypeNameDefaultDescription
External inputs/outputs
BooleanuseNormalizedVolumetrueNormalized volume of solution is 1 liter
Initialization
AmountOfSubstancesolute_start1e-8Initial solute amount in compartment [mol]
IO
Functions to read or store
replaceable package UtilitiesTypes.FilesUtilities (direct...How to store or load the values
Initialization
Realstate_startsolute_startState start or init value
Value I/O
StringstoreUnit"mmol"Unit in Utilities input/output function
StringstateNamegetInstanceName()Name in Utilities input/output function
BooleanLOAD_STARTSfalseLoad start value of state
BooleanSAVE_RESULTSfalseSave final state values
BooleanSAVE_COMPARISONfalseCompare final state values with original values
Equilibrium
Simulation
SimulationTypeSimulationTypes.SimulationType.NormalI...Dynamic with Initialization or Steady State
BooleanisDependentfalse=true, If zero flow is propagated in eqiulibrium through resistors, impedances, reactions, etc.
Solver
Numerical support of very small concentrations
AmountOfSubstanceNominalSolute0.001Numerical scale. Default is from mmol to mol, but for some substances such as hormones, hydronium or hydroxide ions can be much smaller. [mol]
Energies
MolarEnergydH0Standard Enthalpy Change [J/mol]

Connectors

TypeNameDescription
input VolumeInputsolutionVolumeVolume of solution [m3]
output AmountOfSubstanceOutputsoluteCurrent amount of solute [mol]
ChemicalPort_bq_outConcentration and molar flow from/to compartment
output EnergyOutputinternalHeatInternal heat energy = enthalpy*amountOfSubstance [J]

Modelica definition

model Substance "Substance accumulation in solution" extends Icons.Substance; extends Interfaces.ConditionalVolume; extends SteadyStates.Interfaces.SteadyState( state(nominal=NominalSolute), change(nominal=NominalSolute/60), state_start=solute_start, storeUnit="mmol"); parameter Types.AmountOfSubstance solute_start(nominal=NominalSolute) = 1e-8 "Initial solute amount in compartment"; Types.RealIO.AmountOfSubstanceOutput solute(nominal= NominalSolute) "Current amount of solute"; parameter Types.AmountOfSubstance NominalSolute = 0.001 "Numerical scale. Default is from mmol to mol, but for some substances such as hormones, hydronium or hydroxide ions can be much smaller."; Interfaces.ChemicalPort_b q_out(conc(start=solute_start/NormalVolume)) "Concentration and molar flow from/to compartment"; parameter Types.MolarEnergy dH=0 "Standard Enthalpy Change"; Types.RealIO.EnergyOutput internalHeat "Internal heat energy = enthalpy*amountOfSubstance"; equation q_out.conc = solute/volume; state = solute; // der(solute)=q_out.q change = q_out.q; internalHeat = dH*solute; end Substance;

Physiolibrary.Chemical.Components.ChemicalReaction Physiolibrary.Chemical.Components.ChemicalReaction

Chemical Reaction

Physiolibrary.Chemical.Components.ChemicalReaction

Information

s1·S1 + .. + snS·SnS <-> p1·P1 + .. + pnP·PnP

Relations

kf·volume·product(S.^s)

forward rate

kb·volume·product(P.^p)

backward rate

KaT = kf/kb = product(P.^p) / product(S.^s) 

equilibrium

log(KaT/KBase) = (-ΔH/R)·(1/TheatPort - 1/TK

van't Hoff's equation

ΔrG0= ΔH - T·ΔS = -R·T·log(KaT)

Gibb's energy

ΔS = k·log(ω)

entropy

Notations

Si

molar concentration of i-th substrate

si

stochiometric coefficients of i-th substrate

nS

number of substrates

Pj

molar concentration of j-th product

pj

stochiometric coefficients of j-th product

nP

number of products

KaT

dissociation constant at current temperature T

kf

forward rate coefficient at current temperature T

kb

backward rate coefficient at current temperature T

volume  

solution volume

ΔH

enthalpy of the reaction

TheatPort

current temperature T

KBase

tabulated dissociation constant at base temperature TK

TK

base temperature of tabulated coefficients

ω

change of number of microstates of particles

ΔS

entropy of the reaction

ΔrG0

Gibb's energy of the reaction

Extends from Physiolibrary.Chemical.Interfaces.ConditionalVolume (Chemical processes can be modeled with or without(normalized to 1 liter) variable solution volume), Physiolibrary.Chemical.Interfaces.ConditionalHeatPort (Partial model to include a conditional HeatPort in order to describe the power loss via a thermal network).

Parameters

TypeNameDefaultDescription
RealK1Fixed dissociation constant [SI-unit] if useDissociationConstantInput=false
Realkf10^8Forward reaction rate coefficient [SI unit]
FractionsolventFraction1Free solvent fraction in liquid (i.e. 'mol/mol' ratio between current solution and pure solvent in one liter; e.g. in plasma=0.96, in RBC=0.717) [1]
External inputs/outputs
BooleanuseNormalizedVolumetrueNormalized volume of solution is 1 liter
BooleanuseDissociationConstantInputfalse=true, if external dissociation ratio is used
BooleanuseForwardRateInputfalse=true, if external forward rate is used
BooleanuseHeatPortfalse=true, if HeatPort is enabled
Reaction type
Substrates
IntegernS1Number of substrates types
StoichiometricNumbers[nS]ones(nS)Stoichiometric reaction coefficient for substrates [1]
ActivityCoefficientas[nS]ones(nS)Activity coefficients of substrates [1]
Products
IntegernP1Number of products types
StoichiometricNumberp[nP]ones(nP)Stoichiometric reaction coefficients for products [1]
ActivityCoefficientap[nP]ones(nP)Activity coefficients of products [1]
Temperature dependence
TemperatureT310.15Fixed device temperature if useHeatPort = false [K]
TemperatureTK298.15Base temperature [K]
MolarEnergydH0Standard Enthalpy Change (negative=exothermic) [J/mol]

Connectors

TypeNameDescription
input VolumeInputsolutionVolumeVolume of solution [m3]
input RealInputdissociationConstantDissociation coefficient [SI-unit]
ChemicalPort_bproducts[nP]Products
ChemicalPort_asubstrates[nS]Substrates
HeatPort_aheatPort 
input RealInputforwardRateCoefficientReaction forward rate coefficient [SI-unit]

Modelica definition

model ChemicalReaction "Chemical Reaction" import Physiolibrary; Real KaT "Dissociation constant at current temperature"; Types.MolarFlowRate rr "Reaction molar flow rate"; extends Physiolibrary.Chemical.Interfaces.ConditionalVolume; parameter Boolean useDissociationConstantInput = false "=true, if external dissociation ratio is used"; parameter Boolean useForwardRateInput = false "=true, if external forward rate is used"; Modelica.Blocks.Interfaces.RealInput dissociationConstant(start=K) = KBase if useDissociationConstantInput "Dissociation coefficient [SI-unit]"; Physiolibrary.Chemical.Interfaces.ChemicalPort_b products[nP] "Products"; Physiolibrary.Chemical.Interfaces.ChemicalPort_a substrates[nS] "Substrates"; parameter Real K = 1 "Fixed dissociation constant [SI-unit] if useDissociationConstantInput=false"; parameter Real kf = 10^8 "Forward reaction rate coefficient [SI unit]"; // annotation (Dialog(group="Parameters")); //forward K*(10^rateLevel) at temperature TK parameter Integer nS=1 "Number of substrates types"; parameter Integer nP=1 "Number of products types"; parameter Types.StoichiometricNumber s[nS]=ones(nS) "Stoichiometric reaction coefficient for substrates"; parameter Modelica.SIunits.ActivityCoefficient as[nS]=ones(nS) "Activity coefficients of substrates"; parameter Types.StoichiometricNumber p[nP]=ones(nP) "Stoichiometric reaction coefficients for products"; parameter Modelica.SIunits.ActivityCoefficient ap[nP]=ones(nP) "Activity coefficients of products"; extends Physiolibrary.Chemical.Interfaces.ConditionalHeatPort; parameter Types.Temperature TK=298.15 "Base temperature"; parameter Types.MolarEnergy dH=0 "Standard Enthalpy Change (negative=exothermic)"; parameter Types.Fraction solventFraction=1 "Free solvent fraction in liquid (i.e. 'mol/mol' ratio between current solution and pure solvent in one liter; e.g. in plasma=0.96, in RBC=0.717)"; Real KBase "dissociation constant at TK"; Real forwardRate; protected parameter Types.Fraction fsp=solventFraction^(sum(s)+sum(p)); parameter Types.Fraction fs=solventFraction^(sum(s)); parameter Types.Fraction fp=solventFraction^(sum(p)); public Modelica.Blocks.Interfaces.RealInput forwardRateCoefficient(start=kf)=forwardRate if useForwardRateInput "Reaction forward rate coefficient [SI-unit]"; equation if not useDissociationConstantInput then KBase = K; end if; if not useForwardRateInput then forwardRate = kf; end if; KaT = KBase * Modelica.Math.exp(((-dH)/Modelica.Constants.R)*(1/T_heatPort - 1/TK)); //Hoff's equation //this Hoff's equation is valid in gases reactions with the same number of substrates and products and plus-minus in liquid solutions. //for gaseous reaction with dn!=0 (stoichoimetry difference, i.e. the stoichiometru number of products minus the stoichiometry number of reactants) is the Van't Hoff's energy (dE) different from enthalphy of reaction (DH): dE=dH-dn*R*T (Ref: D. M. Golden, "Standard states for thermochemical and activation parameters," Journal of Chemical Education, vol. 48, p. 235, 1971/04/01 1971.) rr*fsp = forwardRate*volume*(product((as.*substrates.conc).^s)*fp - (1/KaT)*product((ap.*products.conc).^p)*fs); //Elementary first-order rate kinetics - the main equation lossHeat = -dH*rr; //dH<0 => Exothermic => lossHeat>0, Endothermic otherwise rr*s = substrates.q; rr*p = -products.q; end ChemicalReaction;

Physiolibrary.Chemical.Components.GasSolubility Physiolibrary.Chemical.Components.GasSolubility

Henry's law of gas solubility in liquid.

Physiolibrary.Chemical.Components.GasSolubility

Information

ConcentrationLiquid = kH · ConcentrationGas

Henry's law: The concentration of the gas in the liquid is proportional to the partial pressure of the gas during equilibrium.

Relations

kd·A·cgas

dissolution rate

kv·A·cliquid

volatility rate

kH = kd/kv = cliquid/cgas

equilibrium

log(kH/KH0) = (-ΔH/R)·(1/TheatPort - 1/TK

van't Hoff's equation

ΔrG0= ΔH - T·ΔS = -R·T·log(KH)

Gibb's energy

ΔS = k·log(Ω)

entropy

Notations

cgas

gaseous molar concentration of the substance

cliquid

liquid molar concentration of the substance

KH

Henry's coeficient at current temperature T

kd

dissolution rate coefficient in liquid at current temperature T

kv

volatility rate coefficient at current temperature T

A  

surface area between gas and liquid

ΔH

enthalpy of dissolution

TheatPort

current temperature T

KH0

tabulated Henry's constant at base temperature TK

TK

base temperature of tabulated coefficients

Ω

change of number of ways of arranging molecules

ΔS

entropy of the dissolution

ΔsG0

Gibb's energy of the dissolution

Henry's coefficient kH depends on temperature and on the identities of all substances present in solution.

Water fraction (W_solution, plasma 0.94, RBC 0.65 => blood 0.81 ml/ml) in solution can change the solubility of gases in water [1] as c_pure=c_solution/W_solution.

References

[1] Dash RK, Bassingthwaighte JB. Erratum to: Blood HbO2 and HbCO2 dissociation curves at varied O2, CO2, pH, 2, 3-DPG and temperature levels. Ann Biomed Eng 2010;38:1683-701.

Extends from Icons.GasSolubility, Interfaces.ConditionalHeatPort (Partial model to include a conditional HeatPort in order to describe the power loss via a thermal network).

Parameters

TypeNameDefaultDescription
DiffusionPermeabilitysolubilityRateCoef0.01The rate constant of incoming gas to solution (default 10 liter per second) [m3/s]
GasSolubilitykH_T0 Henry's law coefficient at base temperature (i.e. in (mmol/l)/kPa at 25degC: aO2=0.011, aCO2=0.245, ..) [(mol/m3)/(mol/m3)]
FractionsolventFraction1Free solvent fraction in liquid (i.e. 'mol/mol' ratio between current solution and pure solvent in one liter; e.g. in plasma=0.96, in RBC=0.717) [1]
External inputs/outputs
BooleanuseHeatPortfalse=true, if HeatPort is enabled
Temperature dependence
TemperatureT310.15Fixed device temperature if useHeatPort = false [K]
TemperatureT0298.15Base temperature for kH_T0 [K]
TemperatureC Gas-liquid specific constant for Van't Hoff's change of kH (i.e.: O2..1700K,CO2..2400K,N2..1300K,CO..1300K,..) [K]

Connectors

TypeNameDescription
HeatPort_aheatPort 
ChemicalPort_bq_outGaseous solution
ChemicalPort_aq_inDissolved in liquid solution

Modelica definition

model GasSolubility "Henry's law of gas solubility in liquid." //q_in is dissolved in liquid and q_out is in gaseous solution" extends Icons.GasSolubility; extends Interfaces.ConditionalHeatPort; parameter Types.DiffusionPermeability solubilityRateCoef=0.01 "The rate constant of incoming gas to solution (default 10 liter per second)"; Types.GasSolubility kH "Henry's law coefficient such as liquid-gas concentration ratio"; parameter Types.GasSolubility kH_T0 "Henry's law coefficient at base temperature (i.e. in (mmol/l)/kPa at 25degC: aO2=0.011, aCO2=0.245, ..)"; parameter Types.Temperature T0=298.15 "Base temperature for kH_T0"; parameter Types.Temperature C(displayUnit="K") "Gas-liquid specific constant for Van't Hoff's change of kH (i.e.: O2..1700K,CO2..2400K,N2..1300K,CO..1300K,..)"; parameter Types.Fraction solventFraction=1 "Free solvent fraction in liquid (i.e. 'mol/mol' ratio between current solution and pure solvent in one liter; e.g. in plasma=0.96, in RBC=0.717)"; Interfaces.ChemicalPort_b q_out "Gaseous solution"; Interfaces.ChemicalPort_a q_in "Dissolved in liquid solution"; equation q_in.q + q_out.q = 0; kH = kH_T0 * Modelica.Math.exp(C* (1/T_heatPort - 1/T0)); // Van't Hoff equation // equilibrium: liquid.conc = kH * gas.conc; q_out.q = solubilityRateCoef*(kH * q_out.conc - q_in.conc/solventFraction); //negative because of outflow lossHeat = C*Modelica.Constants.R*q_out.q; //negative = heat are comsumed when change from liquid to gas end GasSolubility;

Physiolibrary.Chemical.Components.Diffusion Physiolibrary.Chemical.Components.Diffusion

Solute diffusion

Physiolibrary.Chemical.Components.Diffusion

Information

The diffusion conductance parameter can be estimated using the Fick's laws of diffusion:

J= -D*(dPhi)/dx

where

J is molar flow of solute per area [mol/(m2.s)].

D is diffusion constant [m2/s].

dPhi is concentration gradient [mol/m3].

dx is length of diffusion [m].


The solution on both sides must have the same properties (for example solubilities, chemical activities, osmolarities,...)!

Extends from Icons.Diffusion, Interfaces.OnePort (Partial transfer of solute between two ports without its accumulation).

Parameters

TypeNameDefaultDescription
DiffusionPermeabilityConductance0Diffusion conductance if useConductanceInput=false [m3/s]
External inputs/outputs
BooleanuseConductanceInputfalse=true, if external conductance value is used

Connectors

TypeNameDescription
ChemicalPort_bq_out 
ChemicalPort_aq_in 
input DiffusionPermeabilityInputconductance[m3/s]

Modelica definition

model Diffusion "Solute diffusion" extends Icons.Diffusion; extends Interfaces.OnePort; parameter Boolean useConductanceInput = false "=true, if external conductance value is used"; parameter Types.DiffusionPermeability Conductance=0 "Diffusion conductance if useConductanceInput=false"; protected Types.DiffusionPermeability c; public Types.RealIO.DiffusionPermeabilityInput conductance = c if useConductanceInput; equation if not useConductanceInput then c=Conductance; end if; q_in.q = c * (q_in.conc - q_out.conc); end Diffusion;

Physiolibrary.Chemical.Components.Membrane Physiolibrary.Chemical.Components.Membrane

Donnan's equilibrium of electrolytes usable for glomerular membrane, open/leak membrane channels, pores, ...

Physiolibrary.Chemical.Components.Membrane

Information

Filtration throught semipermeable membrane.

The penetrating particles are driven by electric and chemical gradient to reach Donnan's equilibrium. The permeabilities of particles are used only in dynamic simulation with non-zero fluxes. If zero-flow Donnan's equilibrium is reached, it is independent on the permeabilities.

This class can be used for glomerular membrane, open(leak) channels (pores) of cellular (or any lipid bilayer) membrane, chloride schift, ...


The membrane permeabilities depends on (D/membrameThicknes)*membraneArea, where D is Fick's diffusion coefficient.

................................

Filtration example of tree particles

ALP .. small penetrating anion

P .. nonpenetrating protein with negative charge

C .. small penetrating cation

In outer side of membrane are not protein P (it leaves inside).

In equilibrium 4 concentration are unknown:

ALP_in, ALP_out, C_in, C_out.

Closed system equilibrium equations:

tALP = ALP_in + ALP_out ... total amount of ALP

tC = C_in + C_out ... total amount of C

P + ALP_in = C_in ... electroneutrality inside

ALP_out = C_out ... electroneutrality outside

----------------------------------------------------

It is possible to write these equations also in form of KAdjustment, which connect also more than tree type of particles with Donnan's equilibrium equations:

ALP_in/ALP_out = (1-KAdjustment)

C_in/C_out = (1+KAdjustment)

where KAdjustment = P/(2*C_in-P) and C_out=ALP_out=(2*C_in-P)/2, because ALP_in/ALP_out = (C_in - P)/C_out = (2C_in-2P)/(2C_in-P) = 1 - P/(2C_in-P) = 1-KAdjustment and C_in/C_out = (2C_in)/(2C_in-P) = 1 + P/(2C_in-P) = 1+KAdjustment .


Problem with different solubilities/Henry constants/ (kH1, kH2)

Equilibrated is chemical potential, not concentrations (c1,c2)!

Equality of chemical potential is approximated by equality of partial pressure (p1,p2):

p1=kH1*c1

p2=kH2*c2


c2 = (kH1/kH2) * c1

Henry constant between both side can be defined as kH_T0 = kH1/kH2 at temperature T0, where kH1 is Henry constant in first side of membrane and kH2 is Henry constant in second side of membrane.

Temperature dependence of Henry constants by Van't Hoff

kH1 = kH1_T0 * Modelica.Math.exp(C1* (1/T - 1/T0))

kH2 = kH2_T0 * Modelica.Math.exp(C2* (1/T - 1/T0))

kH1/kH2 = kH_T0 * Modelica.Math.exp(C * (1/T - 1/T0))

Specific constant for Van't Hoff's change of kH_T0 can be defined as C = C1-C2, where C1 is specific constant in first side of membrane and C2 is specific constant in second side of membrane.

Extends from Icons.Membrane, Interfaces.ConditionalHeatPort (Partial model to include a conditional HeatPort in order to describe the power loss via a thermal network).

Parameters

TypeNameDefaultDescription
IntegerNumberOfParticles1Number of penetrating particle types
IntegerCharges[NumberOfParticles]zeros(NumberOfParticles)Elementary charges of particles
DiffusionPermeabilityPermeabilities[NumberOfParticles]zeros(NumberOfParticles)Permeabilities of particles through membrane chanel [m3/s]
FractionsolventFractionInside1Free solvent fraction inside (i.e. 'mol/mol' ratio between current solution and pure solvent in one liter; e.g. in plasma=0.96, in RBC=0.717) [1]
FractionsolventFractionOutside1Free solvent fraction outside (i.e. 'mol/mol' ratio between current solution and pure solvent in one liter; e.g. in plasma=0.96, in RBC=0.717) [1]
External inputs/outputs
BooleanuseHeatPortfalse=true, if HeatPort is enabled
BooleanusePermeabilityInputfalse=true, if external permeability value is used
Temperature dependence
TemperatureT310.15Fixed device temperature if useHeatPort = false [K]
TemperatureT0298.15Base temperature for kH_T0 [K]
TemperatureC[NumberOfParticles]zeros(NumberOfParticles)Specific constant difference (C1-C2) for Van't Hoff's change of kH [K]
Different solubilities
GasSolubilitykH_T0[NumberOfParticles]ones(NumberOfParticles)Equilibrated concentration ratio at temperature T0 - can be estimated by Henry's law coefficient ratios (kH1/kH2) [(mol/m3)/(mol/m3)]

Connectors

TypeNameDescription
HeatPort_aheatPort 
ChemicalPort_aparticlesInside[NumberOfParticles]inner side of membrane, solution
ChemicalPort_bparticlesOutside[NumberOfParticles]outer side of membrane, solution
input DiffusionPermeabilityInputpermeability[NumberOfParticles][m3/s]

Modelica definition

model Membrane "Donnan's equilibrium of electrolytes usable for glomerular membrane, open/leak membrane channels, pores, ..." extends Icons.Membrane; extends Interfaces.ConditionalHeatPort; parameter Integer NumberOfParticles = 1 "Number of penetrating particle types"; parameter Integer Charges[NumberOfParticles] = zeros(NumberOfParticles) "Elementary charges of particles"; parameter Types.DiffusionPermeability Permeabilities[NumberOfParticles] = zeros(NumberOfParticles) "Permeabilities of particles through membrane chanel"; parameter Boolean usePermeabilityInput = false "=true, if external permeability value is used"; Interfaces.ChemicalPort_a particlesInside[NumberOfParticles] "inner side of membrane, solution"; Interfaces.ChemicalPort_b particlesOutside[NumberOfParticles] "outer side of membrane, solution"; Types.RealIO.DiffusionPermeabilityInput permeability[NumberOfParticles] = p if usePermeabilityInput; Types.GasSolubility kH[NumberOfParticles] "Concentration ratio at equilibrium"; parameter Types.GasSolubility kH_T0[NumberOfParticles] = ones( NumberOfParticles) "Equilibrated concentration ratio at temperature T0 - can be estimated by Henry's law coefficient ratios (kH1/kH2)"; parameter Types.Temperature T0=298.15 "Base temperature for kH_T0"; parameter Types.Temperature C[NumberOfParticles](displayUnit="K") = zeros(NumberOfParticles) "Specific constant difference (C1-C2) for Van't Hoff's change of kH"; parameter Types.Fraction solventFractionInside=1 "Free solvent fraction inside (i.e. 'mol/mol' ratio between current solution and pure solvent in one liter; e.g. in plasma=0.96, in RBC=0.717)"; parameter Types.Fraction solventFractionOutside=1 "Free solvent fraction outside (i.e. 'mol/mol' ratio between current solution and pure solvent in one liter; e.g. in plasma=0.96, in RBC=0.717)"; protected Real KAdjustment "=(Cations-AnionLessProteins)/(Cations+AnionLessProteins)"; Types.DiffusionPermeability p[NumberOfParticles]; equation if not usePermeabilityInput then p=Permeabilities; end if; //no accumulation of particles: particlesInside.q + particlesOutside.q = zeros(NumberOfParticles); //nothing lost inside //electroneutrality: if abs(Charges.*Charges*p)<=Modelica.Constants.eps then KAdjustment=0; //no penetrating electrolytes => KAdjustment and electroneutrality of flux is not needed else Charges*particlesInside.q = 0; //electroneutrality of flux through membrane end if; //diffusion, penetration, particle movement: for i in 1:NumberOfParticles loop if Charges[i]==0 then //normal diffusion particlesInside[i].q = p[i] * (particlesInside[i].conc/solventFractionInside - kH[i]*particlesOutside[i].conc/solventFractionOutside); elseif Charges[i]>0 then //cation goes to Donnan's equilibrium particlesInside[i].q = p[i] * (particlesInside[i].conc/solventFractionInside - (1+KAdjustment)*kH[i]*particlesOutside[i].conc/solventFractionOutside); else //anion goes to Donnan's equilibrium particlesInside[i].q = p[i] * (particlesInside[i].conc/solventFractionInside - (1-KAdjustment)*kH[i]*particlesOutside[i].conc/solventFractionOutside); end if; end for; //different solubilities: kH = kH_T0 .* Modelica.Math.exp(C * (1/T_heatPort - 1/T0)); lossHeat = Modelica.Constants.R* C*particlesOutside.q; //negative = heat are comsumed when change from liquid to gas end Membrane;

Physiolibrary.Chemical.Components.Speciation Physiolibrary.Chemical.Components.Speciation

Chemical species definition by independent binding sides of macromolecule

Physiolibrary.Chemical.Components.Speciation

Information

This block identifies one specific chemical form of one macromolecule defined by forms of its subunits (one chosen chemical species - called specie).

Only main connector called species is designed for inflow and outflow of macromolecule to/from system. The concentration in this connector is the concentration of its specific specie.

Connectors subunitSpecies[:] represent specific forms of the macromolecule subunit types. If the subnunit type occures n-times in macromolecule, the inflow is n-time greater than the inflow of macromolecule.


Initial total concentrations of subunits must be set to be right distribution of total macromolecule concentration. So the ratios between subunit concentrations are the ratios of their occurrence in macromolecule. In equilibrium are this proporties fulfilled.


For example: If the macromolecule has four identical independent subunits and each subunit can occur in two form F1 and F2, then the concentration of macromolecule specie composed only from four subunits in form F1 is species.conc=conc*fF1^4.

Where:

conc is totat concentration of macromolecule in system accumulated by species.q,

fF1 = F1/(F1+F2) is fraction of form F1 in subsystem of subunit,

4 is number of subunits (numberOfSubunit).


This block can be connected to chemical reactions such as it was the chosen species with subsystem behind. It is recommended to use this block only as an equilibrated subsystem.

Heat of chemical system.

Enthalpy of each subunit species can be presented as subunitEnthalpies[:]. Then the total enthalpy of the chemical system can be calculated by equation:

systemEnthalpy = sum(subunitEnthalpies[i] * totalSubunitAmount[i]) / totalSubsystemAmount

And the stored heat as enthalpy is systemEnthalpy*totalSubsystemAmount.

Extends from Icons.Speciation, SteadyStates.Interfaces.SteadyStateSystem (Global abstract class, for additional global state equations), Interfaces.ConditionalVolume (Chemical processes can be modeled with or without(normalized to 1 liter) variable solution volume).

Parameters

TypeNameDefaultDescription
IntegerNumberOfSubunits1Number of independent subunits occurring in molecule
EnergyInputsubunitInternalHeat[NumberOfSubunits]internalHeatOfSubunit[J]
External inputs/outputs
BooleanuseNormalizedVolumetrueNormalized volume of solution is 1 liter
Simulation
Simulation type
SimulationTypeSimulationTypes.SimulationType.SteadyS...Dynamic with Initialization or Steady State
Equilibrium
IntegerNumberOfDependentStatesNumberOfSubunits - 1Number of additional steady state equation of the system
Heat
External inputs/outputs
BooleanuseInternalHeatsInputfalse=true, if subunitInternalHeat inputs are used instead of parameter SubunitEnthalpies
MolarEnergySubunitEnthalpies[NumberOfSubunits]zeros(NumberOfSubunits)Enthalpy changes of substances (can relative to one chosen specific form of chemical substance in the system) if useEnthalpiesInput=false [J/mol]

Connectors

TypeNameDescription
input VolumeInputsolutionVolumeVolume of solution [m3]
ChemicalPort_aspecificFormSpecific form composed with subunits form of subunitSpiecies
ChemicalPort_aspecificSubunitForm[NumberOfSubunits]Specific form of subunits of specific molecule form in connector called spieces
input AmountOfSubstanceInputamountOfSubunit[NumberOfSubunits]Total amount of the subunits in all forms [mol]
output AmountOfSubstanceOutputamountTotal amount of macromolecules in this system [mol]
output EnergyOutputinternalHeatRelative internal heat of all chemical forms in this system [J]
input EnergyInputsubunitInternalHeat[NumberOfSubunits][J]

Modelica definition

model Speciation "Chemical species definition by independent binding sides of macromolecule" extends Icons.Speciation; extends SteadyStates.Interfaces.SteadyStateSystem( Simulation=Types.SimulationType.SteadyState, NumberOfDependentStates=NumberOfSubunits-1); extends Interfaces.ConditionalVolume; parameter Integer NumberOfSubunits=1 "Number of independent subunits occurring in molecule"; Interfaces.ChemicalPort_a specificForm "Specific form composed with subunits form of subunitSpiecies"; Interfaces.ChemicalPort_a specificSubunitForm[NumberOfSubunits] "Specific form of subunits of specific molecule form in connector called spieces"; protected Real fractions[NumberOfSubunits]; public Types.RealIO.AmountOfSubstanceInput amountOfSubunit[NumberOfSubunits] "Total amount of the subunits in all forms"; Types.RealIO.AmountOfSubstanceOutput amount "Total amount of macromolecules in this system"; //(start=1e-8) Types.RealIO.EnergyOutput internalHeat "Relative internal heat of all chemical forms in this system"; //system internal heat parameter Boolean useInternalHeatsInput = false "=true, if subunitInternalHeat inputs are used instead of parameter SubunitEnthalpies"; parameter Types.MolarEnergy SubunitEnthalpies[NumberOfSubunits]=zeros(NumberOfSubunits) "Enthalpy changes of substances (can relative to one chosen specific form of chemical substance in the system) if useEnthalpiesInput=false"; Types.RealIO.EnergyInput subunitInternalHeat[NumberOfSubunits](each start=0)=internalHeatOfSubunit if useInternalHeatsInput; Types.Energy internalHeatOfSubunit[NumberOfSubunits] "Internal heat of subunits"; equation amount = amountOfSubunit[1]; fractions = if (amount < Modelica.Constants.eps) then zeros(NumberOfSubunits) else specificSubunitForm.conc ./ (amountOfSubunit/volume); specificForm.conc = (amount/volume)*product(fractions); //chemical speciation for i in 2:NumberOfSubunits loop normalizedState[i-1]*amount = amountOfSubunit[i]; end for; //molar flow: specificSubunitForm.q = -specificForm.q * ones(NumberOfSubunits); //heat: if not useInternalHeatsInput then internalHeatOfSubunit = SubunitEnthalpies.*amountOfSubunit; end if; internalHeat=sum(internalHeatOfSubunit); end Speciation;

Physiolibrary.Chemical.Components.Degradation Physiolibrary.Chemical.Components.Degradation

Degradation of solute

Physiolibrary.Chemical.Components.Degradation

Information

Extends from Interfaces.ConditionalVolume (Chemical processes can be modeled with or without(normalized to 1 liter) variable solution volume).

Parameters

TypeNameDefaultDescription
TimeHalfTime Degradation half time. The time after which will remain half of initial concentration in the defined volume when no other generation nor clearence nor degradation exist. [s]
External inputs/outputs
BooleanuseNormalizedVolumetrueNormalized volume of solution is 1 liter

Connectors

TypeNameDescription
input VolumeInputsolutionVolumeVolume of solution [m3]
ChemicalPort_aq_inDegraded solute outflow

Modelica definition

model Degradation "Degradation of solute" extends Interfaces.ConditionalVolume; Interfaces.ChemicalPort_a q_in "Degraded solute outflow"; parameter Types.Time HalfTime "Degradation half time. The time after which will remain half of initial concentration in the defined volume when no other generation nor clearence nor degradation exist."; protected Types.VolumeFlowRate Clearance; equation Clearance = volume*Modelica.Math.log(2)/HalfTime; q_in.q = Clearance*q_in.conc; end Degradation;

Physiolibrary.Chemical.Components.Clearance Physiolibrary.Chemical.Components.Clearance

Clearance with or without solvent outflow

Physiolibrary.Chemical.Components.Clearance

Information

Extends from Hydraulic.Interfaces.ConditionalSolutionFlow (Input of solution volumetric flow vs. parametric solution volumetric flow).

Parameters

TypeNameDefaultDescription
VolumeFlowRateClearance0Clearance of solute if useSolutionFlowInput=false [m3/s]
RealK1Coefficient such that Clearance = K*solutionFlow [1]
VolumeFlowRateSolutionFlowClearance/KVolumetric flow of solution if useSolutionFlowInput=false [m3/s]
External inputs/outputs
BooleanuseSolutionFlowInputfalse=true, if solution flow input is used instead of parameter SolutionFlow

Connectors

TypeNameDescription
input VolumeFlowRateInputsolutionFlow[m3/s]
ChemicalPort_aq_insolute outflow

Modelica definition

model Clearance "Clearance with or without solvent outflow" parameter Types.VolumeFlowRate Clearance=0 "Clearance of solute if useSolutionFlowInput=false"; parameter Real K(unit="1")=1 "Coefficient such that Clearance = K*solutionFlow"; extends Hydraulic.Interfaces.ConditionalSolutionFlow(SolutionFlow= Clearance/K); Interfaces.ChemicalPort_a q_in "solute outflow"; Types.VolumeFlowRate clearance; equation clearance = q*K; q_in.q = clearance*q_in.conc; // assert(clearance>=-Modelica.Constants.eps, "Clearance can not be negative!"); end Clearance;

Physiolibrary.Chemical.Components.Stream Physiolibrary.Chemical.Components.Stream

Flow of whole solution

Physiolibrary.Chemical.Components.Stream

Information

Bidirectional mass flow by concentration

Possible field values:

forward flow

backward flow

solutionFlow

>=0

<=0

q_in.q

=solutionFlow*q_in.conc

=-q_out.q

q_out.q

=-q_in.q

=solutionFlow*q_out.conc


Extends from Interfaces.OnePort (Partial transfer of solute between two ports without its accumulation), Hydraulic.Interfaces.ConditionalSolutionFlow (Input of solution volumetric flow vs. parametric solution volumetric flow).

Parameters

TypeNameDefaultDescription
VolumeFlowRateSolutionFlow0Volumetric flow of solution if useSolutionFlowInput=false [m3/s]
External inputs/outputs
BooleanuseSolutionFlowInputfalse=true, if solution flow input is used instead of parameter SolutionFlow

Connectors

TypeNameDescription
ChemicalPort_bq_out 
ChemicalPort_aq_in 
input VolumeFlowRateInputsolutionFlow[m3/s]

Modelica definition

model Stream "Flow of whole solution" extends Interfaces.OnePort; extends Hydraulic.Interfaces.ConditionalSolutionFlow; equation q_in.q = if (q>0) then q*q_in.conc else q*q_out.conc; end Stream;

Physiolibrary.Chemical.Components.SolutePump Physiolibrary.Chemical.Components.SolutePump

Prescribed solute flow

Physiolibrary.Chemical.Components.SolutePump

Information

Extends from Interfaces.OnePort (Partial transfer of solute between two ports without its accumulation), Interfaces.ConditionalSoluteFlow (Input of solute molar flow vs. parametric solute molar flow).

Parameters

TypeNameDefaultDescription
MolarFlowRateSoluteFlow0Volumetric flow of solute if useSoluteFlowInput=false [mol/s]
External inputs/outputs
BooleanuseSoluteFlowInputfalse=true, if solute flow input is used instead of parameter SoluteFlow

Connectors

TypeNameDescription
ChemicalPort_bq_out 
ChemicalPort_aq_in 
input MolarFlowRateInputsoluteFlow[mol/s]

Modelica definition

model SolutePump "Prescribed solute flow" extends Interfaces.OnePort; extends Interfaces.ConditionalSoluteFlow; equation q_in.q = q; end SolutePump;

Physiolibrary.Chemical.Components.Dilution Physiolibrary.Chemical.Components.Dilution

Adding/removing of the solvent to/from running solution

Physiolibrary.Chemical.Components.Dilution

Information

Extends from Interfaces.OnePort (Partial transfer of solute between two ports without its accumulation), Icons.Dilution.

Parameters

TypeNameDefaultDescription
FractionDilution1Concentration ratio after per before dilution (0..no solutes, 1..no dilution) if useDilutionInput=false [1]
External inputs/outputs
BooleanuseDilutionInputfalse=true, if dilition input is used

Connectors

TypeNameDescription
ChemicalPort_bq_out 
ChemicalPort_aq_in 
input FractionInputdilutionFraction of final undilutes solution [1]

Modelica definition

model Dilution "Adding/removing of the solvent to/from running solution" extends Interfaces.OnePort; extends Icons.Dilution; parameter Boolean useDilutionInput = false "=true, if dilition input is used"; parameter Types.Fraction Dilution=1 "Concentration ratio after per before dilution (0..no solutes, 1..no dilution) if useDilutionInput=false"; Types.RealIO.FractionInput dilution(start=Dilution)= d if useDilutionInput "Fraction of final undilutes solution"; protected Types.Fraction d; equation if not useDilutionInput then d=Dilution; end if; q_out.conc = d * q_in.conc; end Dilution;

Physiolibrary.Chemical.Components.Reabsorption Physiolibrary.Chemical.Components.Reabsorption

Reabsorption as input fraction

Physiolibrary.Chemical.Components.Reabsorption

Information

Extends from Icons.Reabsorption.

Parameters

TypeNameDefaultDescription
MolarFlowRateMaxReabsorptionModelica.Constants.infMaximal reabsorption molar flow if useMaxReabInput=false [mol/s]
External inputs/outputs
BooleanuseEffectfalse=true, if reabsorption fraction is BaseReabsorption^(1/Effect)
BooleanuseMaxReabInputfalse=true, if external maximum of reabsorption molar flow is used
BooleanuseBaseReabsorptionfalse=false, if BaseReabsorption=1

Connectors

TypeNameDescription
ChemicalPort_aInflowTubular inflow
ChemicalPort_bOutflowTubular outflow
ChemicalPort_bReabsorptionReabsorption from tubules
input FractionInputbaseReabsorptionBase fraction of molar inflow for reabsorption flow [1]
input FractionInputEffectEffects<1 decrease reabsorption, effects>1 increase reabsorption fraction by equation ReabFract=BaseReabsorption^(1/Effect) [1]
input MolarFlowRateInputMaxReabMaximal allowed reabsorption molar flow rate [mol/s]
output FractionOutputReabFractActual reabsorbed fraction from solute inflow rate [1]

Modelica definition

model Reabsorption "Reabsorption as input fraction" extends Icons.Reabsorption; parameter Boolean useEffect = false "=true, if reabsorption fraction is BaseReabsorption^(1/Effect)"; parameter Boolean useMaxReabInput = false "=true, if external maximum of reabsorption molar flow is used"; parameter Boolean useBaseReabsorption = false "=false, if BaseReabsorption=1"; parameter Types.MolarFlowRate MaxReabsorption = Modelica.Constants.inf "Maximal reabsorption molar flow if useMaxReabInput=false"; Interfaces.ChemicalPort_a Inflow "Tubular inflow"; Interfaces.ChemicalPort_b Outflow "Tubular outflow"; Interfaces.ChemicalPort_b Reabsorption "Reabsorption from tubules"; Types.RealIO.FractionInput baseReabsorption=baseReabFract if useBaseReabsorption "Base fraction of molar inflow for reabsorption flow"; Types.RealIO.FractionInput Effect(displayUnit="1")=e if useEffect "Effects<1 decrease reabsorption, effects>1 increase reabsorption fraction by equation ReabFract=BaseReabsorption^(1/Effect)"; Types.RealIO.MolarFlowRateInput MaxReab=mr if useMaxReabInput "Maximal allowed reabsorption molar flow rate"; Types.RealIO.FractionOutput ReabFract=reabFract if useEffect "Actual reabsorbed fraction from solute inflow rate"; Types.Fraction reabFract,baseReabFract,e; Types.MolarFlowRate mr; equation Inflow.conc = Outflow.conc; 0 = Inflow.q + Outflow.q + Reabsorption.q; Reabsorption.q=-min(mr,reabFract*Inflow.q); reabFract = baseReabFract^(1/e); if not useBaseReabsorption then baseReabFract=1; end if; if not useMaxReabInput then mr=MaxReabsorption; end if; if not useEffect then e=1; end if; end Reabsorption;

Automatically generated Tue Sep 15 22:56:34 2015.