A simulation of a medical ventilator with a realistic lungs model [version 1; peer review: 1 not approved]

Background: The outbreak of COVID-19 pandemic highlighted the necessity for accessible and affordable medical ventilators for healthcare providers. To meet this challenge, researchers and engineers world-wide have embarked on an effort to design simple medical ventilators that can be easily distributed. This study provides a simulation model of a simple one-sensor controlled, medical ventilator system including a realistic lungs model and the synchronization between a patient breathing and the ventilator. This model can assist in the design and optimization of these newly developed systems. Methods: The model simulates the ventilator system suggested and built by the “Manshema” team which employs a positive-pressure controlled system, with air and oxygen inputs from a hospital external gas supply. The model was constructed using SimscapeTM (MathWorks®) and guidelines for building an equivalent model in OpenModelica software are suggested. The model implements an autonomously breathing, realistic lung model, and was calibrated against the ventilator prototype, accurately simulating the ventilator operation. Results: The model allows studying the expected gas flow and pressure in the patient’s lungs, testing various control schemes and their synchronization with the patient’s breathing. The model components, inputs, and outputs are described, an example for a simple, positive end expiratory pressure control mode is given, and the synchronization with healthy and ARDS patients is analyzed. Conclusions: We provide a simulator of a medical ventilation including realistic, autonomously breathing lungs model.  The simulator allows testing different control schemes for the ventilator and its synchronization with a breathing patient. Implementation of this model may assist in efforts to develop simple and accessible medical ventilators to meet the global demand. Open Peer Review


Introduction
One of the positive COVID-19 consequences is a great social gathering of creators, scientists and engineers to assist the worldwide pandemic effort, including the design of custom-made open source ventilators 1 . The review of Pearce (2020) covers about 160 publications and links to websites that provide computer-assisted design (CAD) models, construction and installation instructions and bills of materials. It is probably not covering hundreds of other projects that are not published yet or could not pass the strict definitions of the opensource ventilator of the author.
Manshema is an emergency ventilation machine and was created during the Assuta COVID-19 Hackathon Sprint by the group comprising engineers, medical doctors, and scientists. The Manshema Ventilator (MV) was designed to assist in the ventilation of patients who are capable of autonomous breathing yet require assistance to maintain a sufficient positive end expiratory pressure (PEEP) and blood oxygen saturation levels.
One of the major drawbacks of the custom-made open-source ventilator designs is that these are created in a very short time and do not allow detailed analysis of their performance, quality assurance and thus regulatory approval. One of the key points is a lack of proper set of mathematical models that describe the performance of a specific ventilator due to a large variety of the parts, sensors and components used in its creation. This study is addressing this gap by creating a detailed mathematical model and a simulator of a realistic lung ventilation, carefully calibrated and tuned specifically to the MV design, parts and sensors. The simulation will provide the design team the opportunity to design the next version, to extend the ventilator capabilities and to assure its performance corresponding to the specific patient condition. Furthermore, the simulation provides a template for a large variety of open source designs, such as Ambu bag ventilators or linear actuator ventilators, and may eventually lead to a closed loop, feedback-back control at the level of commercial regulatory approved mechanical ventilators.

Methods and materials General description
The MV consists of an input branch which mixes air and oxygen from the hospital reservoirs and feeds it into the patient mask, and an expiratory output branch which is opened or closed by the control system. Figure 1a shows a schematic illustration of the MV. The input compressed air and oxygen are supplied by the hospital central reservoirs. The flow from each of the reservoirs is controlled with a flow control valve. After the flow control valves, the gases flow through two similar pipes, mix and flow through the main pipe and mask pipe towards the breathing mask. A pressure relief valve marked Popoff is located between the Main pipe and the Mask pipe. This pressure relief is set to mechanically control the maximal pressure in the system and avoid over-pressuring the lungs. The expiratory air flows through a directional check valve which does not permit breathing the exhaled gasses. After the check valve, the outlet pipe leads to the expiratory flow control system which opens and closes the expiratory pipe flow path using an ON/OFF solenoid valve. The outlet of the control system is connected to a pressure relief valve that is set according to the required PEEP valve. Figure 1b shows a CAD drawing of the complete MV system, and Figure 1c shows a CAD drawing of the main components of the MV. Figure 1d is a photograph of the main components of the MV prototype.

Control strategy
In order to reduce the system costs to minimum, the MV operates with a single pressure sensor and a solenoid valve which controls the gas flow out of the system. The minimum and maximum pressure in the system are controlled with a hysteresis control scheme. This control strategy is realized with a pressure sensor located near the inlet to the solenoid valve and a relay which sets the state of the solenoid valve according to the measured pressure. In its initial state, the solenoid valve is closed directing the input air to the patient allowing the pressure to build up. When the patient exhales, the pressure at the expiratory pipe increases rapidly and after it reaches the expiratory positive airway pressure (EPAP), the relay opens the solenoid valve, the exhaled air is removed, and the pressure starts to drop. Once the patient starts to inhale, air is removed from the pipes and the pressure drops. When the pressure reaches the inspiratory positive airway pressure (IPAP) the solenoid valve closes, and the breathing cycle continues.

The Manshema ventilator model
The MV model was built with MathWorks® Simulink® Simscape™ Gas system toolbox. The outline for the model followed the MathWorks® "Medical Ventilator with Lung Model" example and was modified to describe the MV design, control system as well as an autonomously breathing patient. The model source files, along with an elaborated description of model parameters, variables, Simulink® block parameters and their values can be found under the data availability section as well as in the model OSF webpage 2 . Figure 2 shows the block diagram of the model and Figure 3 shows a block diagram of the control system. The lungs are modeled as a translational mechanical converter that is coupled to a spring, a damper, and a force source. The spring and damper model the mechanical compliance and resistance of the lungs 3 and force source models the muscle induced pressure 4 which is a result of the patient autonomous breathing (patients that cannot breath autonomously can be modeled by replacing the variable muscle pressure term with a constant pressure). The pressure induced by the muscles contraction and relaxation, P mus , is realized with exponential functions as described by Fresnel et al. 4 : Where T 1 is the time period for muscles contraction in every breathing cycle and T tot is the breathing cycle length. τ c and τ r are the contraction and relaxation time constants, respectively, and P max is the maximum pressure that can be induced by the muscles. All the parameters in Equation (1) can be easily derived from the mouth occlusion pressure, P 0.1 and the breathing frequency, f v as described in 4. A block diagram of the lungs branch is shown in Figure 4.
Model calibration. The model was calibrated against the MV prototype in two steps. First, the parameters of the PEEP  and Popoff pressure relief valves were calibrated by comparing the model output to the measured output when the lungs port was blocked. In this set of experiments, the pressure at the inlet to the solenoid control valve was measured as a function of the total input gas flow rate when the solenoid valve was open and when it was closed. The experiment was repeated for PEEP values of 2, 5 and 10 cmH 2 O. For each of the pressure relief valves in the model the set pressure differential and the maximum valve open area were tuned to provide the best fit to the measured data. Figure 5 shows the modeled and measured pressure as a function of the input gas flow rate and PEEP values of 2, 5 and 10 cmH 2 O.  Next, the model calibration was tested by comparing model results to the output of the MV prototype when it was connected to an IMTMedical Easylung test lung. In order to minimize the effects of the popoff and PEEP valves, the total input gas flow rate was set to 10 L/min and the PEEP was set to 2 cmH 2 O. To probe the transient response of the MV, the solenoid valve was opened and closed in intervals of 3.5 seconds. Under these conditions, pressure drops across the different parts of the system are low, the Popoff valve remains closed throughout the experiment and the pressure in the system is determined mostly by the mechanical lung parameters. This provides optimal conditions for calibrating the mechanical lungs' compliance and resistance in the model. Figure 6 shows the measured and modeled pressure (a) and gas flow (b). The gray regions in the figure are time periods in which the solenoid valve is closed. The fitted spring and damper constants for the lungs model are 148.5 N/m and 40 N/(m/s), respectively. When the solenoid valve is closed, air is directed into the test lung, increasing the pressure in it. Then, when the solenoid valve is reopened, the air in the test lung along with air from the reservoirs flow out of the system through the PEEP pressure relief valve. The MV model was able to capture the measured transient response of the system well. Particularly, the modeled gas flow follows the measured values closely.
Once the lungs parameters were found, the model predictions were compared to experimental measurements at input flow rates of 20L/min and 30 L/min and a PEEP of 5 cmH 2 O, which better represent the operating conditions of the MV.  Figure 7 are the time periods in which the solenoid valve was closed. Unlike the lung calibration experiments in which the Popoff valve remains constantly closed, at a flow rate of 20 L/min the Popoff valve opens when the pressure rises above 13 cmH 2 O and closes back when it drops below 8 cmH 2 O. This transition, which is not instantaneous, is not captured well in the simulation, resulting in a deviation between the measured and modeled responses. Nevertheless, the simulation was able to predict fairly well the minimum and maximum pressure in the system, which are most important for its safe operation. In a similar manner, there is a deviation between the measured and modeled flow in the system when the input gas flow rate. The overestimation of the calculated air flow under higher input flow rates may be a result of leakages in the system that are not considered in the model.

Simulated ventilation of autonomously breathing patients
After the model is calibrated and tested, we turn to simulate the ventilation of autonomously breathing patients. We start by simulating the ventilation of a healthy person which is  Table 2. As the patient begins to inhale (purple region), the lungs expand, air flows into the lungs, and the pressure in the expiratory pipe drops. Once the pressure reaches the IPAP, the solenoid valve closes (pink region) and the input gas is inhaled by the patient, resulting in a nearly constant gas flow at a rate that is determined by the flow regulating valves at the inputs to the system. The pressure in the lungs decreases at the beginning of this stage as the lungs are still expanding and then it increases slowly as the lungs fill with air. When the patient attempts to exhale the pressure increases rapidly in the system. At first the solenoid valve is still closed and gas flows into the patient's lungs (white region), but once the EPAP is reached, the solenoid valve opens and the air flows out of the MV through the expiratory pipe (light blue region).   Figure 9 shows the time evolution of the pressure, air flow and tidal volume simulating the ventilation of an acute respiratory distress syndrome (ARDS) patient. The patient breathing rate was taken to be 20 breaths per minute 5 , the occlusion pressure is 6.65 cmH 2 O 6 , IPAP was set to 5 cmH 2 O and the EPAP was set to 13 cmH 2 O 5 . The color coding is as described in Table 2. It can be easily seen that MV output ventilation of the ARDS patient is very similar to that shown in Figure 8. The slight decrease in tidal volume is a result of the higher breathing rate which is recommended for patients with ARDS 5 . The low Figure 8. Healthy patient example. The calculated pressure (a) flow (b) and tidal volume (c) time evolution in the lungs and at the control system solenoid valve. The patient breathing rate was taken to be 15 breaths per minute, the occlusion pressure is 4 cmH 2 O, IPAP was set to 5 cmH 2 O and the EPAP was set to 13 cmH 2 O. The color coding is as described in Table 2. Figure 9. Acute respiratory distress syndrome (ARDS) patient example. The calculated pressure (a) flow (b) and tidal volume (c) time evolution in the lungs and at the control system solenoid valve. The patient breathing rate was taken to be 20 breaths per minute, the occlusion pressure is 6.65 cmH 2 O, IPAP was set to 5 cmH 2 O and the EPAP was set to 13 cmH 2 O. The color coding is as described in Table 2. variance in the MV output with respect to the patient condition is a result of the fairly constant gas flow upon inhalation. This may be an advantage since it allows simple tuning of the ventilation parameters according the guidelines for specific respiratory syndromes.
Perfect synchronization between the MV and the patient is obtained if the solenoid valve opens and closes exactly when the patient attempts to inhale and exhale. Thus, the synchronization level of the MV can be optimized by attempting to minimize the white and purple regions in the output plot.

Conclusions
In this study we provide a solution for the majority of the custom-designed ventilators created around the world in a response to the COVID-19 crisis. The simulator can lead to the opportunity to assure quality of the designed machines versus the digital twin model, analyze human response as compared to the realistic lung model and enable future, regulatory approved designs. This project contains the following underlying data:

Data availability
Peep and Popoff calibration (data underlying Figure 5):   This project contains the following extended data: -Manshema_Sim_Parameters.csv (Table of input  The benefits of publishing with F1000Research: Your article is published within days, with no editorial bias • You can publish traditional articles, null/negative results, case reports, data notes and more • The peer review process is transparent and collaborative • Your article is indexed in PubMed after passing peer review • Dedicated customer support at every stage • For pre-submission enquiries, contact research@f1000.com