Pulmonary ventilation is a critical operation both during surgery and for assisted or replacement ventilation of the patient.

This report proposes the analysis of a lung mechanics model through an electrical analogy with an equivalent circuit consisting of resistors and capacitors. This electrical-mechanical analogy makes it possible to analyze how the variation of lung parameters affects ventilation in the case of pressure-controlled ventilators and therefore to simulate the response of the pulmonary system to ventilation.

A mathematical model is also proposed for the implementation of a pressure control ventilator with square wave, within the Simulink modeling environment, with a graphical interface and user-selectable parameters.

Various pathological conditions are then simulated by going to see how the variation in lung compliance has the predominant effect. Small variations in the capacity values โ€‹โ€‹are reflected in large variations in the volume of incoming air up to dangerous states for the patient himself.

The following report is an extract from a project carried out for the course of Modeling and Simulation of Physiological Systems, held for Medical Engineering at the University of Rome Tor Vergata.


The evaluation of the respiratory system with electrical analogies makes it possible to analyze different distinctive clinical pictures of pulmonary pathophysiology.

There are many models in the literature and several authors attribute to the pulmonary system different inertial and elastic contributions often translatable into an electrical model of an RLC circuit [1]. In this report the inertial contributions are neglected and an RC model is analyzed which allows to describe the pulmonary system with good approximation.

The introduction of these models in simulation software allows you to analyze and model different respiratory behaviors. A model of respiratory mechanics can be integrated with the modeling of a pressure-controlled ventilation system by imposing the waveform of pressure entering the airways. The combination of the two simulation models makes it possible to study the diagnosis, evolution and treatment of particular pathologies and to analyze how the responses of the respiratory system vary when the parameters of the respirator vary.

The need for ventilation support is a frequent cause of patient transfer to the ICU and analyzing complex lung physiology with simplified models would lead to better management of the patient and ventilation devices.

Furthermore, a digital simulation system allows to better analyze the flow curves towards which there is more and more interest in the clinic [2]. These curves contain a lot of information on respiratory mechanics, patient effort and ventilation mode, including parameters. Correctly analyzing these curves allows us to understand if the patient’s breathing pattern is synchronized with the machine or if too much effort is required from the patient which could require prolonged ventilation or lead to serious lung damage.


Correctly simulating the patient requires the choice of a sufficiently accurate respiratory mechanics model and then the fitting of this model to the patient’s peculiarities.

The following section analyzes a model for respiratory mechanics and compares some parameters of resistance and compliance highlighted in the literature as average properties of the population.

This model is implemented in Simulink together with different pressure waveforms. Subsequently, the description of a pulmonary ventilator model in Simulink is also dealt with in order to allow the user to customize the ventilation parameters.

Circuit analogy

The pulmonary circuit can be analyzed by making an analogy with the electrical circuits.

In particular, it is possible to make a parallelism between the flow of air and the electric current (flow of charges) and the pressure as the presence of an electric potential. The mechanical resistance is then reviewed as the ratio between the pressure increase with respect to the flow, analogous to the electrical resistance. Similarly, compliance is nothing more than the relationship between the increase in volume and the increase in pressure, in electrical analogy it is a condenser.

The system in fig. 1a is a model of respiratory mechanics that neglects the presence of inertial contributions (there are no inductances) and considers the presence of two compartments. The upper airways are separated, with their resistive contribution ๐‘…๐ถ from the lower airways ๐‘…๐‘ƒ . The two compartments are in series with each other and in series with the air tanks, i.e. the capacities representing the compliance contribution of the ๐ถ๐‘Š wall and of the lung ๐ถ๐ฟ . These contributions are in series precisely because the throughput is the same.

Added to this is the shunt capacity ๐ถ๐‘† which takes into account various contributions such as anatomical dead space, airway deformability and air compressibility. This capacity is parallel to the pulmonary path, representing the air flow that does not manage to carry out gas exchanges. Normally this volume is very small in physiological respiratory conditions and at low respiratory frequencies, it is negligible.

The pressures in the nodes are also identified. Airway pressure ๐‘ƒ๐‘Ž๐‘ค , pleural pressure ๐‘ƒ๐‘๐‘™ and alveolar pressure ๐‘ƒ๐ด . Clearly, the entrance to the system, given by the mouth and nasal cavities, is represented by the pressure at the opening of the airways ๐‘ƒ๐‘Ž๐‘‚ .

System response

The circuit in fig. 1a can be described by the following equations:

P_{a O}=Q R_{C}+\frac{1}{C_{S}} \int\left(Q-Q_{A}\right) \\
\frac{1}{C_{s}} \int\left(Q-Q_{A}\right)=Q_{A} R_{P}+\left(\frac{1}{C_{L}}+\frac{1}{C_{W}}\right) \int Q_{A}

We then obtain the system transfer function:

H(s) &=\frac{Q(s)}{P_{a O}(s)}=\\
&=\frac{s^{2}+s \frac{1}{R_{P}}\left(\frac{1}{C_{S}}+\frac{1}{C_{e q}}\right)}{s^{2}\left(R_{C}\right)+s\left(\frac{R_{C}+R_{P}+\frac{R_{C} C_{S}}{C_{e q}}}{C_{S} R_{P}}\right)+\frac{1}{C_{e q} C_{S} R_{P}}}

Where series of capacity is expressed as:

\frac{1}{C_{e q}}=\frac{1}{C_{L}}+\frac{1}{C_{W}}

System properties

Clearly, the solution of this problem requires the knowledge of the patient’s own lung mechanics so as to be able to fix the different coefficients of the model.

FIG. 1: Analogia circuitale della meccanica respiratoria [3] (a); Rappresentazione schematica della divisione del circuito polmonare in due contributi resistivi (vie aeree superiori e inferiori) e in due contributi capacitivi (compliance del polmone e della parete toracica), raffigurate anche la pressione alveolare e pleurica.
FIG. 1: Circuit analogy of respiratory mechanics [3]; Schematic representation of the division of the pulmonary circuit into two resistive contributions (upper and lower airways) and two capacitive contributions (lung and chest wall compliance), also depicted the alveolar and pleural pressure.

It is therefore assumed that the patient has normal lung mechanics and the numerical coefficients are selected by Khoo [3] and are reported in Tab. 1.

RC1cmH2O s/L
RP0.5cmH2O s/L
CL0.2cmH2O s/L

System modeling

Solving the system requires solving an ODE and the approach, when the equations become complex, is to transfer the model to a computer. The classic approach is numerical, through the use of a numerical code for solving differential equations.

However, there is the possibility of using Simulink.

Simulink [4] is software developed by MathWorks that provides a graphical approach based on a modeling environment that allows the user to convert the problem into a network of mathematical function blocks. Furthermore it could be integrated with the Matlab language and related programming functions.

A first synthetic approach could be to diagram an input-output system through the transfer function in eq. (2). However, this model would be too synthetic and would not allow access to some internal variables, such as individual flows.

We then choose to model the complete system in eq. (1). This system is modeled in the lungs block. A subsystem is then added to simulate a pulmonary ventilator, i.e. the input as ๐‘ƒ๐‘Ž๐‘‚ , and a block to view and save the data. A general high-level diagram is present in the appendix (fig. 19).

Ventilator subsystem

In the fan subsystem, the goal is to provide a ๐‘ƒ๐‘Ž๐‘‚ with a precise waveform. Different waveforms are considered and the frequency itself, in breaths per minute, can be varied.

To do this Matlab function block can be used to define a Matlab code containing the instructions to generate the pressure waveform as the input time varies. More information can be found in the appendix.

This block also requires two auxiliary variables through which you can choose the respiratory rate and the type of waveform directly from the graphic interface of the block mask (fig. 2b). A callback function is also set through the block mask that allows you to update the name of the output file, as soon as the parameters are changed, with a structure like:

"wave \:form + frequency + .mat"
FIG. 2: Sistema di input rappresentante il ventilatore: schema a blocchi Simulink dove il segnale di ingresso (๐‘ƒ๐‘Ž๐‘‚) viene generato tramite una funzione (fcn) Matlab (a) che prende in ingresso il tempo di simulazione (Clock) e due variabili, legate alla maschera per la GUI, tramite le quali si seleziona il tipo di forma dโ€™onda e la frequenza; GUI tramite la quale รจ possibile selezionare la frequenza respiratoria e selezionare la forma dโ€™onda.
FIG. 2 :Input system representing the fan: Simulink block diagram where the input signal (๐‘ƒ๐‘Ž๐‘‚) is generated through a function (fcn) Matlab (a) which takes the simulation time (Clock) and two variables, linked to the mask, as input the GUI, through which the type of waveform and frequency are selected; GUI through which you can select the respiratory rate and select the waveform.

Lung subsystems

The descriptive equations of the system (eq. (1)) and the related circuit segments can be represented directly in a Simulink model, presented in fig. 3.

By modeling in Simulink it is possible to add the signal contributions (representing segments of the circuit or, equivalently, members of the equation), multiply by a constant by applying a gain to the signal, derive and integrate. Clearly, to go from flow to volume it is sufficient to integrate over time.

There are also 3 scope-type blocks to display the waveforms directly within the simulation, the input block (takes the ๐‘ƒ signal and the 3 output blocks are used to save the data.

FIG. 3: Modello del blocco in Simulink rappresentante il circuito polmonare (in eq. (1), fig. 1a)
FIG. 3: Simulink block model representing the pulmonary circuit (in eq. (1), fig. 1a)


Ideal wave form for ventilation

A simple approach to analyzing lung mechanics is to ventilate with an ideal waveform. A sinusoidal shape with an amplitude of 2.5 cmH2O (peak-to-peak amplitude of 5 cmH2O) with a frequency of 15 breaths per minute [3], similar to resting breathing, is used as the first analysis.

From the graphs in fig. 4 it is possible to see how the volume follows a similar trend, albeit slightly out of phase. This indicates that, at low frequency, the trend is dominated by the contribution of compliance (where there is proportionality with the integral of the flow). The peak volume amplitude reaches 0.5 L and the flow around 0.7 L / s. The flow trend, on the other hand, is significantly out of phase with respect to the input pressure contribution.

FIG. 4: Confronto tra la pressione in ingresso con forma dโ€™onda sinusoidale ideale con lโ€™andamento del flusso
e del volume (a); ingrandimento sullโ€™andamento di flusso e volume (b). Si puรฒ osservare come volume e flusso
presentano uno sfasamento di 90ยฐ. Inoltre, ne flusso ne volume sono in fase con lโ€™andamento della ๐‘ƒ๐‘Ž๐‘‚. Flow and volume
FIG. 4: Comparison between the inlet pressure with an ideal sinusoidal waveform with the flow and volume trend (a); magnification on the flow and volume trend (b). It can be observed how volume and flow have a 90 ยฐ phase shift. Furthermore, neither flow nor volume are in phase with the trend of the ๐‘ƒ๐‘Ž๐‘‚.

Frequency dependence

By increasing the frequency, up to triple the number of breaths per minute (fig. 5), the lung appears more rigid and in fact the amplitude of the volume tends to decrease despite the increase in flow. The peak amplitude of the volume goes from 0.5 L to 0.4 L although the flow has gone from 0.7 L / s to almost 2 L / s. This represents how although the air exchange is greater, the lung is forced to expand less in order to increase the respiratory rate, limiting the overall intake of air.

FIG. 5: Andamento di flusso, volume e ๐‘ƒ๐‘Ž๐‘‚. Lโ€™ampiezza della ๐‘ƒ๐‘Ž๐‘‚ รจ scalata di un fattore 1โˆ•2. Per la curva del flusso si osserva una riduzione delle sfasamento e un aumento dellโ€™ampiezza di picco. Il volume tende a ridursi (rispetto al caso 15 respiri/min) simbolo di un comportamento piรน rigido del polmone.
FIG. 5: Trend of flow, volume and ๐‘ƒ๐‘Ž๐‘‚. The amplitude of the ๐‘ƒ๐‘Ž๐‘‚ is scaled by a factor of 1โˆ•2. For the flow curve, a reduction in phase shift and an increase in the peak amplitude are observed. The volume tends to decrease (compared to the case 15 breaths / min) symbol of a more rigid behavior of the lung.

Furthermore, the volume trend tends to be more out of phase than the pressure trend while the flow seems to be more in phase, a symbol of a greater resistive contribution (direct pressure-flow proportionality).

Therefore, while at low frequency (rest) the contribution is more related to compliance, at high frequency the resistive behavior seems to be more present.

Square wave

An alternative waveform is the square wave. A waveform with a peak amplitude equivalent to the previous one can be set but a different system response is observed. In fig. 6 we see how the flow quickly returns to zero and a volume plateau phase begins. Then begins the inspiratory phase where the flow presents a symmetrical but negative curve with a peak of the same amplitude and the volume gradually increases.

Furthermore, by varying the frequency the behavior of the flow and volume curves does not change but the plateau phase of the volume is reduced. Clearly, these waveforms are analytical models that in real application would present various problems. In clinical practice, negative pressures are never used but a positive pressure gradient is always maintained, so these curves are to be excluded for realistic application cases.

FIG. 6: Andamento di flusso e volume rispetto lโ€™ingresso di ๐‘ƒ๐‘Ž๐‘‚ come onda quadra con una frequenza di 18
respiri/min (a); grafico pressione-volume per ingresso sinusoidale e ad onda quadra)
FIG. 6: Flow and volume trend with respect to the input of ๐‘ƒ๐‘Ž๐‘‚ as a square wave with a frequency of 18 breaths / min (a); pressure-volume graph for sine and square wave input)

Also note how the very presence of a negative volume, in the sinusoidal waveform, is not desirable for a ventilator whose purpose is to help the patient breathe by reducing the lung’s respiratory work or replacing it completely.

The previous analyzes are useful for understanding the mathematical model and for having a basic idea of respiratory mechanics. However, in the clinic, the approach to ventilation is slightly different.

Pressure-controlled ventilation

In order to create a digital simulator of a pulmonary ventilator, a waveform typically diffused in the clinic for pressure-controlled ventilation is considered [5].

FIG. 7: Differenza tra le curve ottenute in ventilazione a controllo di pressione (VCV) e a controllo di pressione (PCV) (a); generica forma dโ€™onda per la ventilazione a controllo di pressione utilizzata per modellare il ventilatore in Simulink (b)
FIG. 7: Difference between the curves obtained in pressure control ventilation (VCV) and pressure control (PCV) (a); generic waveform for pressure-controlled ventilation used to model the fan in Simulink (b)

Assisted pulmonary ventilation is divided into two macro categories: volume control and pressure control. There are several advantages / disadvantages to both and the choice is based on several specific patient considerations. In pressure-controlled ventilation (VCP) you set a specific target, the airway pressure ๐‘ƒ๐‘Ž๐‘‚ and the ventilator must maintain it. Depending on the machinery used, some parameters may be varied such as the percentage of oxygen, the tidal volume or ventilation per minute, the respiratory rate, the inspiratory time, the flow or set limit values โ€‹โ€‹for the pressure [6].

A generic curve, typical of VCP, consists of a square wave with a positive offset which is called PEEP, positive end-expiratory pressure. The period ๐‘‡ is composed of a breathing time, inspiration time and an inspiration time. Optionally, a certain rise time may be present, expressed as a function of the inspiration time [5].

This can be expressed as a piecewise linear curve (fig.7b) of period ๐‘‡ = ๐‘‡๐‘–๐‘›๐‘ ๐‘ + ๐‘‡๐‘’๐‘ ๐‘ , mathematically described as :

P_{a O} \cdot \frac{t}{\tau}+\text { PEEP } & 0 \leq t<\tau \\
P_{a O}+\text{ PEEP } & \tau \leq t \leq T_{in s p} \\
\text { PEEP } & T_{i n s p} \leq t

PEEP generally remains between 5 รท 10 cmH2O keeping the volume in the range of 4 รท 6 mL / kg of body weight. The ๐‘ƒ๐‘Ž๐‘‚ is kept below 35 cm H2O [7, 8].


In this regard, the graphic interface (fig.2b) is also modified in such a way that it allows the selection of a square wave waveform with a rise time and a pressure offset, leaving the user the possibility to choose frequency, inspiration time (as a function of the period), rise time (as a function of inspiration time), ๐‘ƒ๐‘Ž๐‘‚ and PEEP. The complete interface is present in the appendix (fig. 18).

Once set, this simulator allows you to calibrate the ventilation and to train in the use of a real ventilator by going to see how the different ventilation parameters affect the respiratory mechanics and above all how to modify the ventilation according to the patient’s response.

FIG.8: PCVcon๐‘‡๐‘–๐‘›๐‘ ๐‘ =0.4โˆ—๐‘‡,๐‘“ =18respiri/min,๐œ =0.15โˆ—๐‘‡๐‘–๐‘›๐‘ ๐‘,PEEP=5cmH2Oe๐‘ƒ๐‘Ž๐‘‚ =25cmH2O (a); diagramma PV di confronto con differenti tempi di salita, si osserva come varia il primo ramo di salita del volume, riducendo il rise time lโ€™incremento di volume diventa sempre piรน brusco ma il volume massimo raggiunto รจ sempre lo stesso.
FIG.8: PCV with ๐‘‡๐‘–๐‘›๐‘ ๐‘ = 0.4 โˆ— ๐‘‡, ๐‘“ = 18 breaths / min, ๐œ = 0.15 โˆ— ๐‘‡๐‘–๐‘›๐‘ ๐‘, PEEP = 5cmH2O and ๐‘ƒ๐‘Ž๐‘‚ = 25cmH2O (a); Comparison PV diagram with different rise times, it is observed how the first branch of the volume rise varies, reducing the rise time the increase in volume becomes more and more abrupt but the maximum volume reached is always the same.

Physiological breathing

In the following sections the ventilation parameters [9] are set at a rate of 18 breaths / min, an inspiration time of 30% and a rise time of 15%, with a PEEP of 5 cm H2O and a ๐‘ƒ๐‘Ž๐‘‚ = 25 cm H2O These parameters allow to approximate the waveforms typically used in the clinic [5].

In order to satisfy the lung response, in terms of tidal volume in order not to bring the patient into dangerous conditions [10], it is necessary to satisfy an overall lung compliance of approximately:

C_{T}=\left(\frac{1}{C_{W}}+\frac{1}{C_{L}}\right)^{-1} \approx 10 \mathrm{~mL} / \mathrm{cmH} 2 \mathrm{O}

Then follows the analysis considering the average parameters of a lower order of magnitude: ๐ถ๐‘ค = 0.02 L / cmH2O and ๐ถ๐ฟ = 0.02 L / cmH2O. It is then analyzed how the ventilation varies according to the variation of the patient’s parameters.

Airway resistance

There are several pathologies and clinical pictures that result in an increase in resistance of the internal airways. An increase in resistance can be caused by histological alterations, in the alveolar geometry or in the alteration of the air-liquid interface.

The muscular work that must be generated by the respiratory muscles is dependent on the elastic and resistive properties of the respiratory system for the entire range covered by the volume variation. Normally the lung has a compliance of about 200 mL / cmH2O, i.e. when the transpulmonary pressure (difference between the pressure in the alveoli and the pleural one) increases by 1 cmH2O then the lung expands by 0.2 L. Clearly, the smaller the compliance more the slope in the pressure-volume diagram will be large.

FIG. 9: Flusso con variazione della resistenza delle vie aeree superiori ๐‘…๐‘ nel range 0.6 รท 1 [cmH2O s/L]. Flusso nel tempo (a); zoom sul secondo periodo respiratorio sulla zona di influsso (b) ed efflusso (c). Si vede come al ridursi della resistenza aumenta la velocitร  di variazione e il picco massimo.
FIG. 9: Flow with variation of the resistance of the upper airways ๐‘…๐‘ in the range 0.6 รท 1 [cmH2O s / L]. Flow over time (a); zoom on the second respiratory period on the zone of influence (b) and outflow (c). It can be seen that as the resistance decreases, the rate of change and the maximum peak increase.


The elastic force is the greatest contribution (> 2/3 of the total) in causing the lung to collapse due to the surface tension inside the alveoli. Although this is not a problem in the healthy lung, it becomes a problem in cases where the amount of pulmonary surfractant is reduced, such as in acute respiratory distress syndrome (ARDS) [11], where compliance decreases.

Emphysema is characterized by an increase in respiratory resistance and a decrease in lung compliance [11].

FIG. 10: Volume con variazione della resistenza delle vie aeree superiori ๐‘…๐‘ nel range 0.6 รท 1 [cmH2O s/L]. Volume nel tempo (a); zoom sul secondo periodo respiratorio (b). Si vede come il volume risente molto poco della variazione della resistenza.
FIG. 10: Volume with variation of the resistance of the upper airways ๐‘…๐‘ in the range 0.6 รท 1 [cmH2O s / L]. Volume over time (a); zoom on the second respiratory period (b). It can be seen how the volume is very little affected by the variation in resistance.

There are also several factors not related to specific pathologies that tend to increase resistance such as the presence of obstructions in the endotracheal tube, cough, secretions, bronchospasms and accelerated respiratory rhythm [6].

Other influencing factors

Added to this are external factors that can vary both resistance and compliance such as restrictions on the ventilation system, abdominal contraction or increased abdominal pressure or damage or deformation of the chest wall.

FIG. 11: Flusso con variazione della resistenza delle vie aeree inferiori ๐‘…๐‘ nel range 0.1 รท 3.6 [cmH2O s/L]. Flusso nel tempo (a); zoom nel secondo periodo respiratorio sulla zona di influsso (b) ed efflusso (c). Si osserva un comportamento particolare, allโ€™aumentare della resistenza aumenta il picco del flusso.
FIG. 11: Flow with variation of the resistance of the lower airways ๐‘…๐‘ in the range 0.1 รท 3.6 [cmH2O s / L]. Flow over time (a); zoom in the second respiratory period on the zone of influence (b) and outflow (c). A particular behavior is observed, as the resistance increases, the peak of the flow increases.
FIG. 12: Volume con variazione della resistenza delle vie aeree inferiori ๐‘…๐‘ nel range 0.1 รท 3.6 [cmH2O s/L]. Volume nel tempo (a); zoom sul secondo periodo respiratorio (b). Si vede come il volume risente molto poco della variazione della resistenza ๐‘…๐‘.
FIG. 12: Volume with variation of the resistance of the lower airways ๐‘…๐‘ in the range 0.1 รท 3.6 [cmH2O s / L]. Volume over time (a); zoom on the second respiratory period (b). It can be seen that the volume is very little affected by the variation of the resistance ๐‘…๐‘.

It can be seen how, by varying both resistances present, the volume response is almost zero. Instead, the flow varies slightly from the peak reached. From figs. 9 to 12 we see how the flow is more sensitive to the variation of ๐‘…๐‘ .

Remembering that the tests are performed at the same pressure, an increase in resistance will result in a reduction in flow.

Pulmonary compliance

Lung compliance is also affected by some pathologies.

In chronic obstructive pulmonary disease (COPD) there is a reduction of the pulmonary compliance. In the case of cardiogenic (CPE) or non-cardiogenic (ARDS) pulmonary edema there is a reduction in compliance even up to 0.044 L / cmH2 O and 0.035 L / cmH2 O, respectively [11]. To this are added other factors that contribute to reducing lung compliance such as atelectasis, pneumothorax, displacement of the endotracheal tube and pneumonia [6].

FIG. 13: Flusso con variazione della compliance polmonare (serie di ๐ถ๐‘ค e ๐ถ๐ฟ considerati uguali tra loro) nel range 0.005 รท 0.050 [L/cmH2O]. Flusso nel tempo (a); zoom nel secondo periodo respiratorio sulla zona di influsso (b) ed efflusso (c). Si osserva come il flusso รจ fortemente influenzato dalla compliance polmonare. Lโ€™aumento della capacitร ๐ถ๐‘‡ portaadunforteaumentodelpiccodiflusso.
FIG. 13: Flow with variation of lung compliance (series of ๐ถ๐‘ค and ๐ถ๐ฟ considered equal to each other) in the range 0.005 รท 0.050 [L / cmH2O]. Flow over time (a); zoom in the second respiratory period on the zone of influence (b) and outflow (c). It is observed that the flow is strongly influenced by lung compliance. The increase in capacity leads to a sharp increase in the peak flow.

The variation in compliance greatly affects the volume of air entering the lungs. In particular, since ๐ถ๐‘  is typically very small and low, it is possible to neglect this contribution and therefore the quantity of flow that is directed on the shunt portion and does not enter the lungs is very low, it is possible to neglect this contribution and consider the volume entering the lungs as the volume delivered by the ventilator.

FIG. 14: Volume con variazione della compliance polmonare (serie di ๐ถ๐‘ค e ๐ถ๐ฟ considerati uguali tra loro) nel range 0.005 รท 0.050 [L/cmH2O]. Si vede come il volume รจ fortemente influenzato da ๐ถ๐‘‡ ed in particolare come considerare valori troppo alti porta ad un ingresso di volume elevato che puรฒ risultare pericoloso per il polmone.
FIG. 14: Volume with variation of lung compliance (series of ๐ถ๐‘ค and ๐ถ๐ฟ considered equal to each other) in the range 0.005 รท 0.050 [L / cmH2O]. We can see how the volume is strongly influenced by ๐ถ๐‘‡ and in particular how considering too high values leads to a high volume input which can be dangerous for the lung.

Shunt capacity

However, this is not true if ๐ถ๐‘  increases. In fact, as can be seen from fig. 16, the more ๐ถ๐‘  increases, the more the flow on the shunt branch increases and the greater the gap between the total flow (which instead remains almost constant with an average deviation of less than 10โˆ’3 [L / s]) and the alveolar flow.

FIG. 15: Volume con variazione della compliance polmonare (serie di ๐ถ๐‘ค e ๐ถ๐ฟ considerate uguali tra loro) nel range 0.005 รท 0.050 [L/cmH2O]. Zoom sul secondo periodo respiratorio (a) e diagramma PV (b). Si vede come il volume รจ fortemente influenzato da ๐ถ๐‘‡ ed in particolare come considerare valori troppo alti porta ad un ingresso di volume elevato che puรฒ risultare pericoloso per il polmone. Si vede, dal diagramma pressione-volume, come a paritร  di pressione puรฒ entrare un volume nettamente superiore a quanto dovrebbe essere garantito per rispettare i limiti fisiologici.
FIG. 15: Volume with variation of lung compliance (series of ๐ถ๐‘ค and ๐ถ๐ฟ considered equal to each other) in the range 0.005 รท 0.050 [L / cmH2O]. Zoom on the second respiratory period (a) and PV diagram (b). We can see how the volume is strongly influenced by ๐ถ๐‘‡ and in particular how considering too high values leads to a high volume input which can be dangerous for the lung. It can be seen, from the pressure-volume diagram, how, at the same pressure, a volume that is significantly higher than what should be guaranteed to respect the physiological limits can enter.
FIG. 16: Flusso variando ๐ถ๐‘  nel range 0.001 รท 0.01 [L/cmH2O] (a); norma della differenza di flusso tra shunt e alveoli (eq. (6)) rispetto la variazione di ๐ถ๐‘  (b). Si vede come aumentando la capacitร  di shunt un maggior flusso (e quindi volume) passerร  per il ramo di shunt mentre il flusso complessivamente richiesto al ventilatore rimane quasi costante. Inoltre, piรน aumenta la ๐ถ๐‘  piรน aumenta la differenza tra il flusso di shunt e quello alveolare e quindi il volume dโ€™aria che effettivamente entra nel polmone si riduce.
FIG. 16: Flow varying ๐ถ๐‘  in the range 0.001 รท 0.01 L / cmH2O; norm of the flow difference between shunt and alveoli (eq. (6)) with respect to the variation of ๐ถ๐‘  (b). It can be seen how by increasing the shunt capacity, a greater flow (and therefore volume) will pass through the shunt branch while the overall flow required by the fan remains almost constant. Furthermore, the more the ๐ถ๐‘  increases, the more the difference between the shunt flow and the alveolar flow increases and therefore the volume of air that actually enters the lung is reduced.

In the figure fig. 16b shows the norm of the difference between the flow delivered by the respirator and the alveolar flow, normalized with respect to the maximum value.

\Delta \mathrm{Flux}=\frac{\| \text { flusso su } C_{s}-\text { flusso alveolare } \|}{\max \left(\text { flusso su } C_{s}-\text { flusso alveolare }\right)}

Alveolar flow

To be sure of the amount of air actually entering the lungs and capable of gas exchange, it is necessary to read the flow value on the lung branch, or rather on the capacity ๐ถ๐‘‡. Comparing the alveolar flow values fig. 17, as the system parameters vary, with the respective variations of the total flow it is possible to identify how much flow actually enters the lung.

FIG. 17:ย Flusso alveolare rispetto le variazioni diย ๐‘…๐‘ย (a),ย ๐‘…๐‘ย (b) eย ๐ถ๐‘‡ย (c)
FIG. 17: Alveolar flow with respect to the variations of ๐‘…๐‘ (a), ๐‘…๐‘ (b) and ๐ถ๐‘‡ (c)

In the case of the variation of the resistances, the difference between the flows remains very low compared to the variation of the ๐ถ๐‘‡ for which the variations of the flow are seen to correspond almost completely. On the other hand, the shunt capacity is different for which there is a direct increase in the shunt flow to the detriment of the alveolar flow (fig. 16).


The results show that it is essential to correctly set both the ventilation parameters and to estimate the patient’s behavior.

Variations in the circuit parameters can alter the behavior and quantity of air required from the ventilator. In particular, the term with greater importance is given by the series of lung capacities whose increase leads to an excessive increase in the input volumes up to values โ€‹โ€‹that can be dangerous for the patient.

The increase in shunt capacity tends to increase the diverted flow and therefore to remove air from the lung, despite the fact that the fan still introduces more air. Furthermore, the variation of the resistances, in the ranges considered, is not reflected so much on the variation of the overall flow as on the slope of its waveform.

So, the availability of a pulmonary ventilator model coupled to a respiratory mechanics model allows you to simulate the ventilator-pathology interaction and analyze the best method of operating depending on the parameter that is deviated from the pathology.

Code availability

All the code is available in the GitHub repository.


  • [1] Pardis Ghafarian, Hamidreza Jamaati, and Seyed Mohammadreza Hashemian. โ€œA Re- view on Human Respiratory Modelingโ€.
  • [2]  Natsumi Hamahata, Ryota Sato, and Ehab Daoud. โ€œGo with the flowโ€”clinical im- portance of flow curves during mechani- cal ventilation: A narrative reviewโ€.
  • [3]  Michael C. K. Khoo. Physiological control systems: analysis, simulation, and estima- tion. en. Second editon. IEEE Press series in biomedical engineering.
  • [4]  MathWorks. โ€œSimulinkโ€. In: (2022). URL:https://it.mathworks.com/products/ simulink.html. Noman Q. Al-Naggar. โ€œModelling and Sim- ulation of Pressure Controlled Mechanical Ventilation Systemโ€. en. In: Journal of Biomedical Science and Engineering 08.10
  • [6]  Irene Grossbach, Linda Chlan, and Mary Fran Tracy. โ€œOverview of Mechanical Ven- tilatory Support and Management of Patient- and Ventilator-Related Responsesโ€. en. In: Critical Care Nurse 
  • [7]  Lorenzo Ball, Maddalena Dameri, and Paolo Pelosi. โ€œModes of mechanical ventilation for the operating roomโ€. en. In: Best Practice & Research Clinical Anaesthesiology 29.3
  • [8]  Dean Hess. โ€œVentilator waveforms and the physiology of pressure support ventilationโ€. In: Respiratory care 50
  • [9]  R. Duncan Hite. โ€œModes of Mechanical Ven- tilationโ€. en. In: A Practical Guide to Me- chanical Ventilation. Ed. by Jonathon D. Truwit and Scott K. Epstein.
  • [10]  (Roy G. Browe. โ€œVentilation with Lower Tidal Volumes as Compared with Tradi- tional Tidal Volumes for Acute Lung In- jury and the Acute Respiratory Distress Syn- dromeโ€. en. In: New England Journal of Medicine 342.18
  • [11] J. Milic-Emili et al., eds. Basics of Respira- tory Mechanics and Artificial Ventilation. en. Milano: Springer Milan, 1999. 


Code for generating the inlet pressure

function y = fcn(t,flag_ventilation,breath_for_minute,tau_int,Paw,PEEP,T_insp) % % % to  avoid error use the โ€˜odeNโ€˜ solver !
 f=breath_for_minute/60; % breathing frequence in Hz
 % pressure diffrence from maximus value and PEEP
 A=0; % initialize output variable
 if flag_ventilation==1 % flag=1 for sine wave
  % sine wave from Khoo Physiological Control Sistem % amplitude peak -peak of 5 cmH2O
  amplitude =5;
 if flag_ventilation==2 % flag=2 for perfect square wave
   dt=rem(t,(1/f)); % current time (of single period)
   half_period=period/2; % duty cycle of 50 % by selecting half period if   dt<half_period % semi-period where the output is on
   amplitude=5; % amplitude of 5 [cmH2O]
   A=amplitude; % set the output constant end
   if dt>= half_period % semi-period where the output is zero 
    A=0; % set the output to zero
 if flag_ventilation==3 % flag=3 for square wave with rise time tau
  dt=rem(t,(1/f)); % current time (of single period)
% the inspiratory time (where the output is on) is defined usign percentage of total period with T_insp from ventilator GUI % also the rise time is defined using percentage of inspiratory time with tau_int from ventilator   GUI insp_Time=(T_insp/100)*period;
  tau=(tau_int/100)*insp_Time; if dt < tau % rise time
% linear growth of the pressur with offset
  if (dt>=tau) && (dt<insp_Time) % the pressure is max (square wave on)
  if dt>= insp_Time %the pressure is min (square wave off)
 y=A; % set the pressure wave as function output 

Complete graphic interface

FIG. 18: Interfaccia grafica completa del modello di ventilatore polmonare con possibilitร  di selezionare la forma dโ€™onda, frequenza, pressione massima e minima, rise time e duty cycle.
FIG. 18: Complete graphic interface of the pulmonary ventilator model with the possibility of selecting the waveform, frequency, maximum and minimum pressure, rise time and duty cycle.

High-level model

FIG. 19: Modello Simulink di alto livello
FIG. 19: High-level Simulink model