## 4 Simulation Code VC-CMV Mode  
A simulation code, reproducing the pneumatic scheme of Figure 11, has been produced in Simulink, software developed by MathWorks(r) based in Natick, MA, USA. In particular the Simscape Fluids (gas) library [39; 40] has been used. The code, whose graphical scheme is shown in Figure 13, can easily be reproduced and used by manufacturers, and is available at the link provided in [48]. In particular, it consists of:  
* The \"Gas Properties\" block, which allows the user to select from three gas propriety models: perfect gas, semi-perfect gas, or real gas; the specific gas constant is also set in this block;
* The \"Pressure Source\" block, used to simulate the air and oxygen sources (0); this block maintains a constant pressure at its outlet;
* The \"Check Valve\" block, which reproduces the check valves (2 and 20) and allows the flow to go in only one direction; the cracking pressure, which is the minimum upstream pressure required to open the valve, is set in this block;  
Figure 13: VC-CMV simulation code produced with Simulink (Simscape Fluids (gas) library). * The \"Reducing Valve\" block, used to simulate the pressure reducing valve (3); the valve remains open when the downstream pressure is less than the set pressure, defined in the block proprieties;
* The \"Pressure and Temperature Sensor\" block, which reproduces the pressure sensors (4, 14, and 17) in order to monitor the pressure downstream of the pressure reducing valves, and downstream of the inspiratory and expiratory valves;
* The \"Variable Orifice ISO 6358\" block, used to simulate the air and oxygen metering valves (5 and 6); this block models a controlled pressure loss from port A to port B, based on the ISO 6358 standard, which can represent a valve, orifice, or restriction. The orifice opening fraction between 0 (valve closed) and 1 (maximum opening) is set by the control signal at port L. The valve properties, inside the block, can be set using the sonic conductance, the flow coefficient, or the restriction area of the corresponding valve;
* The \"Constant Volume Chamber\" block, used to reproduce the tank (7); the tank volume, located inside the block, can be set. The pressure in the tank is calculated according to the mass, the volume, and the temperature of the tank. This block is characterised by four ports: a sole inlet port (port A), two outlet ports (port B, connected to the downstream inspiratory valve (11), and port C, connected to the nebulizer), and the thermal conserving port associated with the thermal mass of the gas volume (port H);
* The \"Two-Way Directional Valve\" block, used to simulate the inspiratory and expiratory valve (11 and 19); the flow rate is calculated according to the ISO 6358 standard. The gas flows from port A to port B, and the open connection between these gas ports is determined by a positive control signal at port S. The valve properties can be set in the block using the sonic conductance, the flow coefficient, or the restriction area of the corresponding valve;
* The \"Pressure Relief Valve\" block, which reproduces the pressure relief valve (12); during normal operation the valve remains closed; however, if the upstream pressure is higher than the maximum pressure set in the block, the valve opens to permit gas flow;
* The \"Two-Way Directional Valve\" block, used to simulate the safety valve (13); during normal operation the valve is closed (the control signal is 0 at port S); however, if the system malfunctions, it opens to allow the patient to breathe out (the control signal is 1 at port S);
* The \"Pipe\" block, implemented in order to take into account the pressure drops in the circuit due to the presence of the heat exchanger and humidifier (15); this is possible by setting an equivalent length and an equivalent diameter in the block;
* The \"Volumetric Flow Rate Sensor\" block, which reproduces the flow sensor (16) in order to measure the flow rate (and tidal volume) inspired (>0) and expired (<0) by the patient.