Creating cardiovascular and respiratory models using Physiolibrary 3.0

The free open-source Physiolibrary version 3.0


Introduction
Earlier versions of Physiolibrary (Mateják et al. 2014) mainly contain components for individual domains, e.g., hydraulic, osmotic, chemical, and thermal resistances.These components were defined to implement large integrative models such as Physiomodel (Mateják and Kofránek 2015).The hydraulic domain was not suitable for gas transport.The osmotic domain was inaccurate and difficult to connect with the chemical domain of protein distributions and electrolytes.The first version of the chemical domain was controlled by concentration gradients instead of electrochemical potentials (Mateják 2015).It was difficult for the user to implement obvious interactions between the domains.We addressed all these problems and proposed solutions.The result is that version 3.0 of Physiolibrary allows the use of standard Modelica Fluid Connectors (Casella et al. 2006) and electrochemical connectors for cross-compartment transport of substances (Mateják et al. 2015).Fluid connectors transport media such as blood, air, interstitial fluid, intracellular fluid.Drag-and-drop connections of these connectors define equations for pressures, mass flows, heat flows and mass fractions of substances between components.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.

SI units
In medicine, many obscure units are still in use such as mmHg (millimeters of mercury), cmH2O (centimeters of water) for pressure, calories for energy, chemical equivalents for electric charge, degrees Celsius for temperature, and so on.Modelica allows you to define these as display units.This means that it is possible to output graphs in the selected units or even set values in parametric dialogs in these selected units.However, the variables within the model in SI units explain the compatibility between all components and models.Also, the selection of zero offset is better for use within connectors and state variables, since, for example, absolute pressure is well defined, as opposed to relative pressure in circuits with heterogeneous environments that have different pressures.To see nice pressure values, it is necessary to use a pressure sensor instead of looking at the variables of the connector "p".Even if the user wants to create a small physiological model, it is much better to achieve these interfaces because they allow others to easily reuse it without modifications or adapters.

State and connector variables
For gaseous substances, volume changes with pressure and temperature, so it is always better to use mass and mass flows instead of volume and volume flows.And, of course, volumes can always be evaluated by including pressures, temperatures, and the composition of the medium with known masses.For the same reason, it is better to use mass fractions of substances instead of volume fractions, concentrations, molalities, molarities, or even mole fractions for the compositional state of the medium.The molar quantities may change due to chemical binding (e.g., to a transporter protein), but the mass of the substance change only with external flows.If the state of the medium is known, all these quantities can be evaluated for output or parametric purposes.

Elastic vessels
One of the most important components in Physiolibrary 3.0 is Fluid.ElasticVessel.It accumulates the mass of the medium, e.g.blood, air, lymph, interstitial fluid, intracellular fluid.From the accumulated mass, heat and substances, volume, pressure, temperature, concentrations and other properties of the accumulated medium are expressed.In addition if the user use chemical substances connectors, special equations are included as Medium.ChemicalSolution model.In this case, electrochemical potentials and enthalpies are expressed to allow passive and active transport, for example, through the alveolar membrane, the capillary membrane, the cell membrane or the CSF membrane.Electrochemical processes and their calculation (Mateják 2015) are from the chemical library (Mateják et al. 2015).Here osmotic transport is the result of balancing the chemical potential of water.Similarly, Donnan's equilibrium (Donnan 1911) is the result of balancing the electrochemical potentials of electrolytes (Atkins and De Paula 2011) at a semipermeable membrane.And also, active transport or signal transduction can be modeled as electrochemical reactions involving membrane proteins.

Medium
Physiolibrary 3.0 defines examples for the following media: Wateras pure incompressible water with constant heat capacity without any substance inside Airas an ideal gas model with oxygen, carbon dioxide, nitrogen and water Bloodas 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).BodyFluidas 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.

Blood gases interface
The library has prepared a blood medium containing the dissociation model of common gasses such as oxygen, carbon dioxide, and carbon monoxide (Siggaard-Andersen 1971; Siggaard-Andersen and Siggaard-Andersen 1990; SIGGAARD-ANDERSEN and SIGGAARD-ANDERSEN 1995).With this model, we can build a gas transport between air and blood.First, we add a component ElasticVessel from the Fluid.Components package.ElasticVessel is a container for the medium in which blood accumulates oxygen and carbon dioxide.It contains dynamic calculation of blood volume, blood temperature, blood pressure, blood composition and other blood properties.In the parameter dialog we set blood from the Media package as the medium in this component.This will link the equations and properties of the medium to the model of this component.As initialization we can set normal predefined arterial blood by setting the massFractions_start parameter to predefined values Blood.ArterialDefault.Then we check the useSubstances checkbox to enable the connectors with free blood substances and the complex model of these substances in them.The bundle of substance connectors is located on the left side of the icon.Now we can handle a freely dissolved basic chemical substance defined in the medium."Free dissolved" means that the substance connector contains chemical potential and flows only for unbound molecules.And "basic" means that this molecule is not connected in a cluster with other molecules.For example, H2O molecules are connected by hydrogen bonds, so water in these chemical compounds is represented only by the chemical potential and molar flux of the free, unbound H2O molecules.The clusters and bonds can nevertheless be calculated internally if needed (Mateják and Kofránek 2020).The next component type we use in this model is "GasSolubility" from the "Chemical.Components" package.It represents the chemical processes of gasliquid solubility for the selected gas molecule.To define the air source of gas substances, we can use ExternalIdealGasSubstance from the Chemical.Sources package.Here in the listbox of the parameter dialog we should be able to set "O2(g)" or "CO2(g)" or "CO(g)".
Then we can define a very small partial pressure of oxygen (1 mmHg) together with a typical partial pressure of carbon dioxide (40 mmHg) and a very small partial pressure for carbon monoxide (1e-6 mmHg).This settings cause that the blood is losing the oxygen during simulation.

Respiratory unit
Physiolibrary has some predefined models of organs or their functional units composed of components of the base library.One of these components is RespiratoryUnit in the Organs.Lungs.Components package.For gas transport between the air and the blood, the same basic components are used as in the previous model.Perfusion settings are based on blood and vessel parameters such as blood model, initial blood volume, initial blood composition, ZeroPressureVolume (maximum blood volume in vessels that does not generate pressure), vessel compliance, and vessel conductance.
The RespiratoryUnit can be connected to the respiratory muscles via chest, where a negative or even a positive external pressure is generated by respiratory muscles.The medium of this compartment can be chosen as pleural fluid.This compartment should have a non-zero internal space (lung volume) that can collapse below the relaxed volume.Thus, the current volume of respiratory units can be related to the internal space of the chest, and the external pressure is transmitted from the muscles to the lungs through the pleural cavity (where it is displaced by the internal space).This pattern is illustrated by the examples SimpleRespiration and Respiration in the package Fluid.Examples.

Tissue unit
To demonstrate oxygen consumption and carbon dioxide production in body tissue metabolism, we can define a TissueUnit.This unit does not solve hypoxic situations, but it can be used for normal body conditions.Here, oxygen consumption (e.g., 15mmol/min) and carbon dioxide production (e.g., 12mmol/min) are constant parameters during simulations propagated by SubstanceOutflow and SubstanceInflow components from the Chemical.Sources package.Blood is connected from systemic arteries to systemic veins via tissue capillaries, using typical connections for modeling the cardiovascular system (Kulhánek, Kofránek, and Mateják 2014).

Simple respiratory-cardiovascular model
If you combine all these principles, you can create a model of respiration, blood circulation and blood-gas transport.Non-medical users usually focus on oscillatory models, as presented in the examples MeursModel2011.HemodynamicsMeurs_flatNorm or Respiration in the Fluid.Examples package.However, precise non-oscillatory models can also be defined for long-term physiological simulations.Oscillation from breath to breath or even from heartbeat to heartbeat does not affect the calculated mean values that are physiologically significant (e.g.mean pressure, cardiac output, heart rate, respiratory volume, respiratory rate, etc.).Therefore, it is good practice in medical physiology to define non-oscillatory long-term cardiovascular and respiratory models (Hester et al. 2011).A non-oscillatory respiratory model can be defined by the same RespiratoryUnit as the oscillatory one.However, the connection of the respiratory tract must be defined by a separate air inflow and outflow.And the dead space should be defined in parallel connection.Similarly, the pulmonary shunt (where the blood of the pulmonary circulation does not flow through the ventilated alveoli) should be defined in parallel connection with the blood perfusion in the RespiratoryUnits.The non-oscillating cardiovascular model is based on nonoscillating pumps representing the right and left heart delivering cardiac output to the bloodstream.

Discussion
The models presented are only examples of the use of the library.The components of the Physiolibrary are general enough to be included in more specific or/and more complex models.Today version of the blood medium is designed for the transport of blood gases, but our goal is to make it general for the transport of physiological substances.Using the nominals, even hormones and endocrines (physiologically active substances in very low concentrations) can be solved numerically in the same way.With chemical processes such as passive and active transport or signal transmission, more complex models of tissues and organs can be defined.If we connect tissues and organs, we can easily create a model of the whole body (Mateják and Kofránek 2015).With specific bodies, we can virtually transplant organs from one body to another and so on.With the non-oscillation approach, we can even simulate years of life or perhaps one day even the whole life of an organism.This kind of mathematical modelling leads to virtual experiments that could improve experiments before using animals or humans.This minimalizes number of iteration and changes in experimental conditions, which can improve the quality of research and shorten research time.And it could also be a platform for sharing results in the form of well-defined and structured models. -

Figure 2 .
Figure 2. Model of blood gases

Figure 3 .
Figure 3. Fraction sensor parameterized for measurement of oxygen saturation in blood

Figure 4 .
Figure 4. Result of the simulation as oxygen saturation curve

Figure 7 .
Figure 7. Diagram of simple tissue unit