OpenModelica-based virtual simulator for the cardiovascular and respiratory physiology of a neonate

Abstract There is a lack of medical simulation tools that can be understood and used, at the same time, by researchers, teachers, clinicians and students. Regarding this issue, in this work we report a virtual simulator (developed in OpenModelica) that allow to experiment with the fundamental variables of the cardiovascular and respiratory system of a neonate. We extended a long-tested lumped parameter model that represents the cardiovascular and respiratory physiology of a neonate. From this model, we implemented a physiological simulator using Modelica. The fidelity and versatility of the reported simulator were evaluated by simulating seven physiological scenarios: two of them representing a healthy infant (newborn and 6-months old) and five representing newborns affected by different heart diseases. The simulator properly and consistently represented the quantitative and qualitative behaviour of the seven physiological scenarios when compared with existing clinical data. Results allow us to consider the simulator reported here as a reliable tool for researching, training and learning. The advanced modelling features of Modelica and the friendly graphical user interface of OpenModelica make the simulator suitable to be used by a broad community of users. Furthermore, it can be easily extended to simulate many clinical scenarios.


Introduction
Studies like that of Donaldson et al. [1] point out that around 100,000 deaths per year in the US are due to medical errors. Regarding this issue, the use of medical simulators contributes to reduce human error (or even the ethical conflict that arise in many clinical situations) and to improve professional training [2]. These facts have given rise to pedagogical strategies such as simulation-based medical education [3] and competency-based education [4] that foster simulation as an essential pedagogical tool.
In considering virtual medical simulators, it is important to stress that their fidelity (the extent in which they represent a patient in a realistic way) depends on the iterative assessment by experienced clinicians and on the availability of real clinical data for tuning the parameters of their underlying mathematical models [5]. Virtual simulators have limitations due to reductionism inherent to mathematical modelling and the lack of interaction with complex and unpredictable environmental factors. For these reasons, one should keep in mind that virtual medical simulators are by no means an exact representation of the physiological behaviour of a patient in a complex clinical scenario. However, despite their limitations, they can provide a profound insight into the complexity of physiological phenomena that occur in a patient under diverse conditions. The development of virtual medical simulators depends on the advance of the mathematical models of the human physiology. Currently, there exists a considerable progress in the modelling of the cardiovascular and respiratory systems by means of lumped parameter models. In the following, we will present representative contributions in this field.
In the case of the cardiovascular system, Goodwin et al. [6], Lankhaar et al. [7] and Yigit et al. [8] proposed models based on hydraulic analogy; Myers and Capper [9] proposed models based on electrical analogy; and Pennati et al. [10] proposed a model that combine electrical, hydraulic and chemical analogies.
The works of Riley [11] and Ellwein et al. [12] report, respectively, complete simulations of cardiac pathologies and simulation of patients with congestive heart failure. S a-Couto et al. developed an educational model of a neonate's cardiovascular system (which is an extension of the model of Goodwin et al. [6]) to simulate cardiac pathologies [13] and the hemodynamics transitions at birth [14]. This model has been recognised as a remarkable achievement in terms of clarity, simplicity and fidelity [5].
Considering the respiratory system, Ben-Tal [15] proposes models of electrical analogy; Riedlinger et al.,  propose models of hydraulic analogy; and, the work of S a-Couto et al. [19] introduces a model (with hydraulic analogy) tailored for educational simulation of the mother-to-fetus transport of oxygen through placenta.
It is fair to comment that the models developed by Albanese et al. [20] and Yigit et al. [8] integrate both the cardiovascular and the respiratory system. These models are quite complete, but nevertheless lack the pedagogical and computational simplicity of that proposed by S a-Couto et al. [13,14]. The latter does not include a model of the respiratory system of a neonate.
In reviewing literature of models in physiology and virtual simulators, one can realise the need for a common software environment that can be used at the same time by researchers (for developing their physiological models) and by clinicians and students (for understanding the human physiology). For instance, the models presented in references [14,20] were implemented using a proprietary engineering software, which only can be used by licenced users. Moreover, the specialised interfaces of these engineering programs also hinder their use by clinicians or medical students. On the other hand, there exists commercial simulators as PhysioExTM [21], which provide an easy-to-use interface and are high quality educational tools specifically intended for healthcare personnel. Nevertheless, these kind of simulation tools cannot be used neither for developing new models nor for carry out specialised research experiments.
Keeping the aforementioned facts in view, in this work we report a novel virtual simulator of the cardiovascular and the respiratory system of a neonate. This virtual simulator is a continuation of the work of S a-Couto et al. [13,14] with the following contributions: (i) it integrates the uptake and supply of gases, according with the model of Hoppensteadt and Peskin [22]; (ii) it integrates the transport and consumption of gases according with the model proposed by S a-Couto et al. [19]; (iii) it was developed in the open source platform called OpenModelica [23]; and, (iv) it is intended to be used and understood by researchers, teachers, clinicians and undergraduate students of different disciplines.
In brief, the virtual simulator we report here allows to experiment with several physiological variables including pressure, volume, blood flow, changes in elastance, pressure-volume ratio (PV) and oxygen saturation. The user can also visualise the effects on the physiology caused both by cardiac anomalies or by changes in the vascular resistances.
This paper is structured as follows: in the section of materials and methods, we describe the mathematical model that underlies the simulator, the components of this model and the fundamental concepts for designing and implementing the neonatal simulator. In the section of results, we use the simulator for studying five cases of neonatal heart diseases. In the section of discussion, we present the conclusions, potential and limitations of this simulator. Finally, we present a general conclusion and the future work.

Materials and methods
In the following, we will present the mathematical model underlying the simulator, the components of the model and the software considerations in implementing the neonatal simulator.

Mathematical model
The mathematical model proposed in this work is depicted in Figure 1. It is an extension of the educational model of the cardiovascular system of an infant proposed by Goodwin et al. [6] and later extended and tuned by S a-Couto et al. [13,14]. It is worth to say that Goodwin's model underlies the Human Patient Simulator HPSTM [24] developed at the University of Florida. Therefore, this model has been tested and tuned for a long time.
In the model of Figure 1, we integrate two physiological functions that are not included in the models of references [6,13,14]: (a) the uptake and supply of gases in accordance to the equations formulated by Hoppensteadt and Peskin [22] for the mechanical diffusion of gases between alveolus and capillary; and, (b) the transport and consumption of gases according with the mass balance equations for gas transport proposed by S a-Couto et al. [19]. To represent the uptake of gases, we introduce the component S1 (see green block labelled as ½O 2 in Figure 1), therefore modifying the original structure of the model of Goodwin et al. [6].
For representing the transport and consumption of gases, we integrated two coupled differential equations to all components of the hemodynamic system (vascular resistances, cardiac valves, elastic components and inertias). Therefore, at mathematical level, these modifications imply that the original set of equations representing the hemodynamic system proposed by Goodwin et al. [6] was coupled to a new set of equations describing the respiratory system.
The mathematical model represented in Figure 1 contains the following hemodynamic and respiratory variables:

Components of the model
In the following, we will qualitatively describe the six types of components in the model of Figure 1.

Type Itime invariant elastances
Components denoted by E 1 to E 6 represent the elastic properties of tissues composing veins and arteries, i.e., they expand when accumulating blood and can recover their shape when the strain stress is suppressed. Specifically, E 1 denotes the component representing pulmonary arteries, E 2 pulmonary veins, E 3 intrathoracic arteries, E 4 extrathoracic arteries, E 5 extrathoracic veins and E 6 e intrathoracic veins. Table 1 presents the mathematical relationships describing the behaviour of Type I components. Equation (1) is a piecewise linear function for determining the transmural pressure pðtÞ: It depends on parameters vðtÞ (current volume of component), V u (the stress-free volume 1 ), E (constant elastance), and pint (the intrathoracic pressure that must be added in to obtain the absolute pressure). Equation (2) defines the constant value of elastance for this type of components.
Equation (3) is a mass conservation equation describing the volume vðtÞ of the component. It depends on the input blood flow f in ðtÞ and the output blood flow f out ðtÞ: Equation (4) represents the oxygen saturation SO 2 : This is a percentage indicator representing the amount of oxygen available in the blood. Under normal conditions, each gram of haemoglobin ½Hb combines, at a peak level, with 1:34 ml of oxygen (see reference [26] for more information). Equation (5) describes the gas transportation in the cardiovascular system. It is a mass conservation equation of a gas with an oxygen concentration ½O 2 in a homogeneous compartment i with a constant blood volume v, a rate of metabolic consumption _ M, perfused with a flow rate _ vðtÞ (which is defined by Equation (3)) that transports the O 2 with a concentration ½O 2 in from the component j to the input component i:

Type II -Time variant elastances
The time variant elastances characterising these components simulate the muscular distension and contraction produced by the cardiac function (i.e., the diastole and systole of ventricles and atria). Particularly, components E RV and E LV in Figure 1 represent, respectively, right ventricle and left ventricle. In turn, components E RA and E LA represent, respectively, right atrium and left atrium.
Type II components are also described by Equations (1) to (5) but the term eðtÞ of Equation (1) has a different definition for components representing atria than for components representing ventricles. In the following, we present the five equations that describe the mathematical behaviour of time variant elastances. Table 2 presents the mathematical relationships describing the behaviour of Type-II components.
Regarding components E RV and E LV representing ventricles, their elastance is defined according to the Equation (6). The terms E min and E max , correspond to the elastance of systole and diastole respectively. Regarding components E RA and E LA representing atria, their elastance is defined according to the Equation (9). Notice that variant time elastances defined by Equations (6) and (9) set the pulsatile behaviour of the hemodynamic model. Term HP corresponds to the cardiac period.
Type III -Vascular resistances Components denoted as R 1 and R 10 in Figure 1 represent the vascular resistance associated with all the blood vessels. For instance, component represent the vascular resistance associated with pulmonary arteries. Type III components possesses two fundamental properties: they do not accumulate blood and they can receive an external supply of oxygen concentration. Table 3 presents the mathematical relationships describing the behaviour of Type-III components. Equation (11) establish a linear relationship between the blood flow of component j to component i, denoted as f ji ðtÞ, and the difference of pressures P j -P i existing in the components j and i between which the vascular resistance R ji is connected.

Meaning
Constitutive equations Reference Oxygen saturation Oxygen concentration Equation (12) allows to obtain the concentration of oxygen (denoted by ½O 2 in ) carried by the blood flow f ji ðtÞ enters to component i: This concentration results on the sum of the oxygen concentration of compartment j (denoted by ½O 2 j ) and the oxygen inspired from the environment (denoted by ½O 2 ins ) through the alveolar-capillary membrane.
Type IVcardiac valves Components denoted by V 1 and V 4 in Figure 1 represent the operation of the cardiac valves, which only allow an unidirectional the flow of blood without accumulation. Specifically, V 1 represents the mitral valve, V 2 the aortic valve, V 3 the tricuspid valve and V 4 the pulmonary valve. The following two equations describe the mathematical behaviour of cardiac valves: Table 4 presents the mathematical relationships describing the behaviour of Type-IV components.
Equations (13) and (14) represent cardiac valves as ideal diodes in which the auxiliary variable pass determines whether the valve is open or close. Therefore, if pass > 0 the valve is open and allows the flow of blood, otherwise, if pass < 0 the valve is closed and there remains a minimal leakage flow. Notice that in the special case pass ¼ 0, the pressure gradient _ p remains at the threshold level of Pknee: Notice also that the normal flow through cardiac valves is established when derivative _ p is positive. In Equations (13) and (14) the parameter g on with typical values between (1, 25013e À0:7 and 4, 16708e À0:7 [m3/(Pa.s)]) reported in the Huikeshoven's work [28], defines the output flow and the g off parameter with a value of 1, 25e À12 [m3/(Pa.s)] reported by Matej ak [29], defines the flow of return.
Type Vblood inertia Component denoted by I 1 in Figure 1 represents the physiological behaviour in that the blood flow through the aorta attains its maximum value during systole and later decreases during systole. This inertial effect produces a reduction in pressure when the velocity of the blood flow increases. The following two equations describe the mathematical behaviour of blood inertia: Table 5 presents the mathematical relationships describing the behaviour of Type-V components.
Flow of blood [13] Oxygen saturation [13] Oxygen concentration [13] Duration of atrial systole [13]  [19] Equation (15) was originally proposed by Goodwin [9] and express the extent in that an increasing flow of blood causes a drop in the pressure (conversely, a decreasing flow elevates the pressure). Notice that Equation (15) depends of the extrathoracic resistance (denoted as R ext ðtÞ) and of the inertance of the blood (denoted by I sang ). Due to pulsatile flow, if the extrathoracic pressure P ext ðtÞ is greater than the intrathoracic pressure P int ðtÞ (as is the case of the diastole) the flow decreases or even changes its direction. For this case we have simulated the average intrathoracic pressure defined as P int ðtÞ with a value of 0: Type VIsupply of O 2 Component S 1 in Figure 1 represents the uptake and supply of O 2 in the cardiovascular system of the neonate. It models the oxygen present in the environment, the inspiration of air into the lungs and the alveolar-capillary gas exchange. The following two equations describe the mathematical behaviour of Supply of O 2 : Table 6 presents the mathematical relationships describing the behaviour of Type-VI components.
Equation (16) represents oxygen uptake [30]. In this equation, r is the ventilation/perfusion rate with a clinical value observed at 24 h of age of r ¼ 0: 63 6 0: 7 (reported in Koch's work [26]). Equation (17) represents ½O 2 I is the inspired oxygen concentration of the air at a temperature of 25 C. Hð½O 2 Þ is the oxygen-haemoglobin dissociation curve represented by the Hill function given a partial pressure of oxygen PO 2 in the blood. c is the parameter of respiratory efficiency that adjusts the level of equilibrium between the blood and the partial pressure of oxygen in the air at the outlet of the pulmonary capillaries. The blood and the alveolar air are totally in equilibrium when c ¼ 1, when there is no oxygen exchange c ¼ 0 (reported in the work of Yigit et al. [31]). K is the ideal  [27] Flow through the valve [27] Table 5. Constitutive equation for Type V -Blood Inertia.

Constitutive equations Reference
Extrathoracic flow gradient [6] [8] Inspired oxygen concentration [8] Hill function [8] constant of gases and T is the absolute temperature ( K). The computed oxygen saturation is based on the haemoglobin dissociation curve of Equation (18).

Software concepts for implementing the mathematical model
This simulator is intended to be understood and used by a broad community of users (ranging from researchers in physiological models to healthcare and engineering students). In order to achieve this, it was developed in Modelica which, in a nutshell, is an advanced language for modelling and simulation of complex systems [23]. Modelica is a major breakthrough in the so-called field of Object Oriented Modelling of Dynamic Systems [32]. At present, there is a growing trend in developing Modelica libraries for modelling human physiology [26][27][28][29][30][33][34][35][36]. We selected OpenModelica (OpenModelica is an open source programming environment for the language Modelica. See www.openmodelica.org) for developing this project, considering the following desirable features it possesses: (i) it provides both an advanced modelling software for researching in physiology and a user-friendly interface for education and, (ii) it is open source, that is, it is available to any interested user without any licence fee and the software code can be shared without limitations. Figure 2 is graphical view of the Modelica implementation of the simulator. Modelica is an Object Oriented Modelling Language and the diagram shown of Figure 2 is composed by interconnected blocks called objects. Each object of the diagram of Figure 2 represents specifically a component of the mathematical model depicted in Figure 1 (for example, vascular resistances R 1 and R 10 in Figure 1 corresponds to objects R 1 and R 10 of the connection diagram of Figure 2). Most of the icons used in this simulator and some software interfaces were adapted from the project Physiolibrary [33] developed in OpenModelica. The numerical values used for the simulator presented in this work can be consulted in the Supplementary material provided.
The mathematical equations describing the six types of objects (as defined in the previous section) were programmed by using the specific Modelica syntax. It is worth to say that the user does not need to know these technical details to experiment with the simulator. To do so, user only needs to perform two actions common to all graphical-based simulators.

Changing the parameters of an object
The changes of the cardiovascular and respiratory system of an individual after one week of life (time after which the transitions of birth have already been established) are mostly quantitative and not qualitative (for instance, the heart structure remains the same during the life of a human being). Therefore, by a simple change of parameters of some objects, we can represent different physiological conditions as age, effects of non-congenital pathologies or, in general, scenarios that do not involve modifications of the basic structure shown in Figure 2. 2.3.2. Modifying the structure of the model The action or adding or removing graphical objects -therefore changing the connection structure of Figure 2 allow us to represent congenital heart diseases. These pathologies occur due to malformations of the heart (or its associated vessels) during the foetal life.
As a useful complement, users interested in researching can go further and change the mathematical relationships of any object. They also can create new objects to model more complex physiological phenomena. These advanced options require to use the specialised Modelica programming language.
Regarding computational aspects of the simulations, we made the following three assumptions: A1. When the simulation start, the oxygen saturation in Type I and Type II components is at 50 percent. This assumption is made because oxygen saturation levels at birth time are unknown. A2. Type III, Type IV and Type V components (associated, respectively, with vascular resistances, heart valves and blood inertia) do not accumulate blood nor consume oxygen. A3. For the sake of computational convenience, oxygen concentration ½O 2 ins (inspired from the environment) entering into the blood through the alveolarcapillary membrane towards the pulmonary bed (PAB) is assumed to occur in the pulmonary arteries. Figure 3 gives a glance of the hemodynamic and respiratory variables that can be obtained by means of the simulator. It allows to simulate several physiological variables including cardiac cycle (see Figure  3(A)), oxygen saturation (see Figure 3(B)), blood flow (see Figure 3(C)), blood pressure (see Figure 3(D)), volume, time variant elastances, among others.

Using Modelica for modelling human physiology
The object-oriented paradigm of Modelica reduces dramatically the effort required by the modeller to develop a physiological model such as that presented in Figure  1. This is a consequence of its four main features: inheritance, non-causality, connectors and C compilation. The inheritance feature allows to reuse existing models and functions as part of new models. By using the non-causality feature, one can write the equations of the model in their original mathematical form (without concerning about the algorithmic order of calculations), then Modelica determines their order of precedence at compilation time. The connectors define interactions between the components of the model in a very clear way. This fact offers the modeller the possibility of representing new physiological scenarios only by changing the connection between components. The C compilation feature of Modelica produces a fast execution time and allows to deploy stand-alone simulators for running in different platforms, including a web browser (see references [37,38]). Without the advanced features that Modelica possesses, the implementation of a physiological model requires to consider aspects such as numerical methods and the symbolic mathematical transformations required to adapt the model to the specific syntax of the programming language being used. Therefore, the resulting simulation models are less clear and difficult to extent and refine.
In Modelica, each component is defined by a set of equations written in a compact code that closely resembles their mathematical notation. This fact is illustrated in Listing 1, which is the programming code associated with the Time Variant Elastances. Notice that, for computational issues, we implement the compliance C as the inverse of the elastance E (see lines 22 and 23 in Listing 1). Notice also that all the remaining parameters (minimum elastance E min (ELVMIN), maximum elastance E max (ELVMAX), ventricular activation DT (DeltaT), the duration of the ventricular systole T vs (tvs) and the relative time until the start of the cardiac cycle t (tm)) are represented by readable programming variables. In the next section, we will present different clinical scenarios in order to provide the reader a broader perspective about the fidelity, features and potential of the simulator reported here.
Listing 1 Modelica code for Type II -Time Invariant Elastances

Results
Taking as reference the set of simulated experiments performed by S a-Couto et al. [13], in the following we will deploy the simulator to carry out five different case studies of heart diseases: Aortic Stenosis, Persistence of the Ductus Arteriosus, Tetralogy of Fallot, Coarctation of the Aorta and Transposition of the Great Arteries. The simulation scenarios (together with their respective parameters) were taken from Goodwin et al. [6] and S a-Couto et al. [13]. A detailed list of parameters for each case study can be found in the Supplementary material.

Aortic stenosis (as)
This heart disease is a narrowing of the aortic valve opening. It can be represented, as depicted in Figure  4, by changing four parameters in the simulation diagram. Each parameter varies from a healthy reference value to a stenotic reference value. Therefore, parameter VLVU which decreases from 2 to 0 in component E LV , whereas parameters IAR, AVR, and ELV min must be increased in components E LV , V 3 , and V 3 (as represented by blue arrows in Figure 4). This variation of parameters recreates the increase in mass of the cardiac muscle and the reduction in flow from the left ventricle to the aorta produced by Aortic Stenosis. The reference values assumed here (in both healthy a stenotic scenarios) are for a 6-month-old infant with a weight of 8 Kg (taken from Goodwin et al. [6]). Figure 5 shows the change in volume and pressure of the left ventricle in the normal state (red line) and with aortic stenosis (blue line). Notice the severe alteration of the cardiac cycle and the high pressures induced by aortic stenosis. Figure 6 illustrates the oxygen saturation (SO 2 ) in the intrathoracic arteries both in a healthy state and aortic stenosis. The reduction of blood flow affects the amount of oxygen that is transported through the entire organism and, therefore, the oxygen saturation (SO 2 ) in the organs. An individual with this cardiac pathology has a lower oxygen saturation in each individual organ. This occurs due to an imbalance in the ratio of oxygen available in the blood and the oxygen consumption required by each individual organ.

Persistence of the ductus arteriosus (PDA)
The Ductus arteriosus is a large vessel that connects the pulmonary bed with the descending aorta. It usually closes after birth. Therefore, if it remains open, its persistence becomes a cardiac pathology. The PDA decreases the pulmonary vascular resistance, converting the foetal bypass from right to left in left to right derivation. This fact generates excessive pulmonary blood flow and dilatation of the left ventricle. Another important effect of PDA is that about one-half to two-thirds of the aortic blood passes through the ductus arteriosus into the pulmonary circulation [39].
As we can see in Figure 7, for simulating of PDA we need to include vascular resistance R 11 (representing the ductus arteriosus) in series with inertia I 2 (representing a decreased perfusion), which are connected between the pulmonary and the intrathoracic arteries. The augmented dilatation of the left ventricle (E LV ) is simulated by increasing (resp. decreasing) its maximum (resp. its minimum) elastance.
As shown in Figure 8, an effect of PDA is that individuals have a high left ventricular cardiac output that doubles or even triples the normal cardiac output as reported in medical physiology textbooks [40]. Notice that the simulator properly represented the increase in blood volume of the left ventricle due to the excessive pulmonary blood flow and the dilatation of the left ventricle.

Coarctation of the aorta (CA)
This is a vascular obstruction that decreases blood perfusion, generating an overload in pressure of the left ventricle and a dilatation of the right ventricle [13].
As we can see in Figure 9, in order to simulate the CA we add vascular resistance R 12 connected between the left and right atria, which represents the foramen ovale. In addition, we include vascular resistance R 12 and inertia I 2 , which represent the ductus arteriosus. The obstruction of the left ventricle (E LV ) is simulated by increasing the value of the resistance in the mitral valve. The high dilatation of the right ventricle (E RV ) is simulated by increasing (resp. decreasing) its maximum (resp. its minimum) elastance. Figure 10 illustrates the effect of the CA in pressure of the left ventricle, which has a higher value (due to overload in pressure of the left ventricle) and a steeper rise and decay than in a healthy individual.

Tetralogy of fallot (TF)
This cardiac anomaly refers to a combination of four related heart defects that commonly occur together. These defects are: pulmonary stenosis, ventricular septal defect, dominant aorta and hypertrophy of the right ventricle [40].
As depicted in Figure 11, the Tetralogy of Fallot is simulated by including components V 5 , R 13 and R 14 : Therefore, the resistance to blood flow in the ventricular septum and in the upper aorta are represented, respectively, by R 13 and R 14 : Valve V 5 establish a unidirectional flow through the upper aorta. The high dilatation of the right ventricle (E RV ) is represented by increasing (resp. decreasing) its maximum (resp. its minimum) elastance. An increase of the outflow resistance of the right ventricle (E RV ) represents pulmonary stenosis. Figures 12 and 13 show, respectively, the effect of the Tetralogy of Fallot on the flow passing through the right ventricle and on the flow passing through the pulmonary bed. Notice that the former increases whereas the latter decreases.

Transposition of the great arteries (TGA)
In this congenital defect the pulmonary artery and the aorta are transposed. As a result, deoxygenated blood does not pass through the lungs and recirculates throughout the body [11]. Transposition of the great arteries is the most frequent congenital defect in newborns and frequently causes death in patients who have not had surgery [41,42]. It is only compatible with extrauterine life in case of a timely surgery or when there exists a defect of the ventricular septum (or a similar compensating defect) that allow the mixture of oxygenated and deoxygenated blood. Because of the high incoming flow caused by this defect, the right ventricle becomes hypertrophied.
As depicted in Figure 14, for simulating this defect we include vascular resistances R 12 and R 13 and valves V 4 and V 5 , which represent by themselves the transposition of the great arteries. Vascular resistances R 12 and R 13 represent, respectively, the foramen ovale and the ventricular septal defect. We also eliminate components V 1 , R 1 , V 3 and R 5 in the basic diagram of Figure 2 to suppress the flow of blood from the left ventricle to the aorta and from the right ventricle to the pulmonary arteries. The hypertrophy of the right ventricle (E RV ) is simulated by increasing (resp. decreasing) its maximum (resp. its minimum) elastance.
As we can observe in Figure 15, the transposition of the great arteries causes an increase in blood volume because of suppression of the ventricleaortic flow. Figure 16 summarises the effect of the different heart diseases on the oxygen saturation of the extrathoracic arteries. Because of the Persistence of Ductus Arteriosus, the suppression of the ventricular-aortic flow increases the oxygen concentration that is transported to the intrathoracic arteries. In the Coarctation of the Aorta the concentration of oxygen reaching the extrathoracic arteries increases (as a side effect of the persistence of the ductus arteriosus and the recirculation of blood through the foramen oval), therefore, the oxygen saturation curve stabilises faster (as in the case of PDA). In the Tetralogy of Fallot, the connection between the right ventricle and the aorta causes nonoxygenated blood to recirculate without passing through the lungs. Therefore, the concentration of oxygen that arrives to the organs decreases which consequently leads to hypoxaemia and cyanosis [11,40,41]. This effect is roughly represented by the simulator, if we notice that the TF curve stabilises in less than 90% of SO 2 : TF disease also implies an obstruction in the flow of the left ventricle towards the aorta which reduces the blood flow and, therefore, the amount of oxygen transported to the organs. Notice that this behaviour is properly captured in the simulated oxygen saturation curve that stabilises slower than normal. Finally, in the case of the Transpositions of the Great Arteries, the simulated oxygen saturation in the extrathoracic arteries stabilises faster but reaches a value lower than normal.

Results and discussion
In the previous section, we showed that the simulator is versatile enough to represent the behaviour of the cardiovascular and the respiratory systems both in a healthy state or having a heart disease. To do so, we started from a basic simulation structure of a healthy patient (as that presented in Figure 2) and by performing some modifications in structure and parameters, we could represent different heart diseases. Now, to assess the fidelity achieved by the simulator, we compare the reference values obtained in clinical studies with those values obtained by simulation.
In this regard, Table 7 compares the clinical/objective and simulated values of a 6 month old infant with  aortic stenosis and a healthy one (in both cases, the infant's blood volume is 700 ml) . Notice that the simulated values of blood flow and pressure at the end of diastole and systole are very close to the clinical reference values in both clinical scenarios. Let us consider again the cardiac cycle for aortic stenosis depicted in Figure 5, which shows an increase in the left ventricular pressure value from 80 mmHg to 158 mmHg. This result is consistent with the clinical report of Paul and Das [47], which report and increase of approximately 100 mmHg to 200 mmHg in left ventricular pressure as a result of aortic stenosis. Figure 5 also exhibits how the cardiac cycle is displaced to the left by the reduction of the volume without stress (VLVU) of the left ventricle which is in accordance with the effect of aortic stenosis explained by Goodwin et al. [6]. Table 8 compares the clinical/objective and simulated values of a healthy newborn with a blood  volume of 300 ml. Notice that the simulated values of blood flow and pressure at the end of diastole and systole are very close to the clinical reference values for the healthy newborn. Table 9 compares the simulated and the clinical reference values for patent ductus arteriosus (PDA), aortic coarctation (CA), tetralogy of Fallot (TF) and transposition of the great arteries (TGA). For each case, we consider a neonate infant with a blood volume of 300 ml. Notice that there exists a small discrepancy in the simulated diastolic pressure of the left ventricle with respect to real data. However, we do not consider that this discrepancy necessarily reflects a structural limitation of the simulation model, but probably an inconsistency in the parameters assumed in the simulations (which came from rather different sources).
In brief, we can appreciate the simulator capability to represent, in a very approximate way, the qualitative and quantitative behaviours corresponding to each clinical scenario in which it was deployed. In the  following, we will discuss aspects concerning to research, education and training that emerge from this work.
From the research point of view, this work has shown that OpenModelica provides a powerful modelling apparatus to develop and extend models in physiology. In this regard, we particularly conclude that the integration of the uptake and supply of gases [22] and of the transport and consumption of gases [19] to the model of Goodwin [6] and S a-Couto [13,14]    gives results that are consistent with existing physiological knowledge.
Regarding medical education, we consider that this simulator provides physiological descriptions with enough fidelity and detail to be used in teaching. It gives a complete visualisation of how a heart disease   Figure 16. Effect of heart diseases on oxygen saturation of the neonates extrathoracic arteries.
influences the cardiac cycle, allowing to identify the most affected phase and its corresponding effect on blood pressures and volumes and, as well, other important variables from the medical point of view. Therefore, the simulator is tailored to learn about the cardiac-vascular-hemodynamic-respiratory conditions that occur in the neonate under different systemic conditions. In this regard, it is important to highlight that this simulator has been used in the Workshop of Interdisciplinary Projects, a regular course offered by the faculty of engineering of the National University of Colombia. This course is composed by students of Industrial design, Engineering (with engineering students from six different areas) and Medicine. As a result of the interaction promoted in this course, the students of Engineering and Industrial Design were able to quickly appropriate medical terminology and understand the physiological issues associated with cardiac pathologies. They also learned how to work in teamwork with medical students for developing the course project. Regarding training, this simulator can be a very supportive tool to complement the training of healthcare professionals. By minor modifications of the structure and parameters of the basic model presented in Figure 2, it is possible to represent different scenarios for medical training including the physiological differences of an infant and an adult, and may be more important, the specific characteristics that allow to diagnose pathologies faster and more accurately. In addition, it can be extended to evaluate other conditions such as CO 2 , drugs supplied, anaesthetic effect, gas supply as in hyperbaric oxygen therapy, etc.
Medical simulators are very valuable tools in medical research, education and training. However, we stress again that care must be taken in the use of medical simulators. One must not expect from them to provide exact values of physiological variables. Indeed, what they provide is a fundamental approach for a broad understanding of the physiological phenomena that occur in a patient under different conditions of interest.

Conclusion and future work
In this work, we reported a simulator of the cardiovascular and respiratory system of a neonate. Results allow us to consider this simulator as a reliable tool that can be used for research, learning, and training. In addition, it can be easily extended to simulate many clinical scenarios. The advanced modelling features of Modelica and the friendly graphical user interface of OpenModelica make the simulator suitable to be used by a broad community of users.
Currently, we are finishing an extension of this model that incorporates physiological transitions at birth. As future work, we plan to develop an application that executes this simulator on a mobile device. With this, we intend to provide an interactive learning environment for healthcare personnel.