An enhanced respiratory mechanics model based on double-exponential and fractional calculus

We address mathematical modelling of respiratory mechanics and put forward a model based on double-exponential and fractional calculus for parameter estimation, model simulation, and evaluation based on actual data. Our model has been implemented on a publicly available executable code with adjustable parameters, making it suitable for different applications. Our analysis represents the first application of fractional calculus and double-exponential modelling to respiratory mechanics, and allows us to propose a hybrid model fitting experimental data in different ventilation modes. Furthermore, our model can be used to study the mechanical features of the respiratory system, improve the safety of ventilation techniques, reduce ventilation damages, and provide strong support for fast and adaptive determination of ventilation parameters.


Introduction
With the aging population and the increase in chronic respiratory diseases (Divo et al., 2014;Soriano et al., 2020;Xie et al., 2020), the demand for mechanical ventilation treatment has largely increased (Wunsch, 2020).At the same time, the outbreak of COVID-19 in recent years has further boosted the demand for ventilators.As a consequence, the analysis of more accurate respiratory mechanics models has become extremely important, as it can be used to predict and optimize parameter settings in mechanical ventilation therapy.Further, this kind of models are required to dynamically adjust parameters according to the respiratory characteristics of different patients, in order to improve treatment outcomes and reduce ventilation injuries.
In the field of mechanical ventilation, the respiratory system is often modelled as a linear dynamical system described by linear differential equations.Examples are provided by the single-compartment model (Bates, 2009;Ghafarian et al., 2016;Gertler, 2021) corresponding to a first-order linear differential system, the two-compartment model (Bates, 2009;Carvalho and Zin, 2011;Ghafarian et al., 2016) corresponding to a second-order differential system, and the viscoelastic model (Ganzert et al., 2009).Over the last few years, different types of respiratory mechanics models have been put forward, including nonlinear models involving elastance and resistance of the respiratory system (Chiew et al., 2015;Redmond et al., 2017;Ellwein Fix et al., 2018;Marconi and De Lazzari, 2020).These studies generally provide a good theoretical modelling and may be used to simulate the respiratory system.However, they generally involve idealized elementary function description of ventilation pressure (Ellwein Fix et al., 2018;Marconi and De Lazzari, 2020;Dincel, 2021), and ignore the inherent randomness and background noise/ error of real respiratory processes.Other studies are based on experimental data, but produce results in disagreement with actual data.For example, the simulations of Albanese et al. (2016), lead to a minimum CV(RMSE) (stands for the coefficient of variations of the root mean square errors) volume curve equal to 0.079, which is an order of magnitude higher than the simulation results of all models in this paper.At the same time, these studies did not provide executable program code and corresponding original data.
In this paper, we propose an accurate respiratory mechanics model based on previous research and studies based on actual measurement data.We consider Bama pigs for actual measurements, since they provide conditions close to the healthy state of the human respiratory system, and assess results of our models against actual measurement data.By combining fractional calculus with a double-exponential model, we are able to describe the dynamical behaviour of the coefficients in the differential equations, and to put forward a hybrid model consistent with the experimental in wide range of ventilation modes, and provided.We also provide a public executable code package for parameter estimation, simulation methods, and optimized parameter search.

Respiratory mechanics models 2.1.1 Linear models
First order linear differential models with constant coefficients (linear single-compartment model).According to previous studies on respiratory mechanics models (Bates, 2009;Carvalho and Zin, 2011;Hess, 2014;Ghafarian et al., 2016;Gertler, 2021), the classical linear single-compartment model corresponds to the following differential equation: for the pressure (applied power) to the lung P(t), where V(t) is the air volume entering the lung (Tidal volume), E and R denote the elastance and resistance of respiratory system respectively.The offset pressure P 0 represents the positive end-expiratory pressure (PEEP).The compliance C of respiratory system is the reciprocal of elastance E, that is C = 1/E.The electrical circuit that represents the linear singlecompartment model consists of a resistance R, a capacitor C (1/ E) and a generator P(t) (Figure 1A).The corresponding impedance is (Carvalho and Zin, 2011;Li, 2011): where ω is the angular frequency in radians/second, and the symbol j represents the unit imaginary number.Moreover, based on the electrical analogous (a), if we assume the initial value V (0) = 0 and P 0 = 0 (or define a new pressure P(t) P(t) − P 0 ) for simplicity, we can obtain the open-loop transfer function between the pressure P(t) and volume V(t): The inverse Laplace transform of transfer function G(s) is given by: If P(t) is a unit step signal, this will be the solution in time domain.
If we express the pressure P(t) as a linear combination of elementary functions: Such as sin (at), e −at , or polynomial functions, and the k i are constant coefficients, then we can theoretically obtain the general solution of V(t) in time domain as follows where "*" denotes convolution.The result is the same as that obtained by directly solving the equation by Laplace transform.
Based on the superposition principle of linear differential equation, the final solution of V(t) is given by For example, if P(t) P constant sin(at), t ∈[0, π] , Eq. 1 can be written as: R dV (t)  dt + EV(t) P constant sin(at) − P 0 , with general solution (sin(at) − aCRcos(at)) − CP 0 , where K is a constant determined by the initial conditions and P constant is also a constant that determines the magnitude of pressure.
Other simple examples are illustrated in the Supplementary Material Section S1.
Although it is theoretically possible to represent any P(t) based on the Fourier transform, this method is not particularly useful due to the computational complexity and the lack of accuracy.
Second order models with constant coefficients.Assuming that the airway is an approximately cylindrical structure of length l and radius r and using Newton's second law (Carvalho and Zin, 2011;Hess, 2014) we have: that is: where ρ is the gas density, and I lρ .Due to the relatively low gas density, the inertia coefficient I (Inertia) is generally very small compared to other parameters with the same dimensions in respiratory mechanics models.Taking airway resistance and elasticity into account, the pressure P and volume V are related by the following Eq.10.
This is a second order linear differential equation, which corresponds to the electrical analogue shown in Figure 1B with impedance: where I represents the total inductance of the circuit.
If we assume the initial conditions V (0) = 0 and V' (0) = 0 (the first-order derivative of V) and P 0 = 0 (or define new pressure P(t) P(t) − P 0 ) for simplicity, we can also obtain the transfer function, which can be written as the sum of two fractions: where a, b, c 1 , c 2 are constant and the real part of a and b are positive, that is Re(a) > 0, Re(b) > 0 (satisfying the stability constraint conditions) (Zhong, 1988;Hu, 2007).
The inverse Laplace transform of the transfer function in Eq. 12 is given by: Assuming that P(t) is a step signal, the general solution of Eq. 10 has the same form as Eq.14.On the other hand, if we have single-compartment models connected in series or in parallel, we obtain the two-compartment model proposed by Bates (Bates, 2009), whose dynamics is similar to that governed by Eq. 10 (Figure 1C), i.e., where k is a constant.The transfer function of Eq. 14 is similar to that reported in Eq. 12: In other words, Eqs 10, 14 has the same solutions.
According to the superposition principle, we can also obtain the general solution of second order linear differential models based on Eq. 7. Simple examples are given in the Supplementary Material Section 2.
High-order linear differential models.The term I d 2 V(t) dt 2 in Eq. 10 corresponds to an acceleration, however, in a respiratory mechanical model (Carvalho and Zin, 2011;Eager et al., 2016;Dincel, 2021) we may also consider higher derivatives (like jerk and snap), such that more general models may be obtained, in the following general form: where n > m.
Assuming the initial values V (0), V' (0), V'' (0), . . .= 0, we obtain the transfer function as In a stable respiratory system, the system should satisfy Routh-Hurwitz criterion.The inverse Laplace transform of transfer function G(s) is as follows: where Re(λ i ) < 0. If P(t) is a unit step signal, this represents the solution of Eq. 16.
Using again the electrical analogy, Eq. 16 corresponds to put more components in series or in parallel (in a circuit, components connected in parallel are equivalent to adding their transfer functions in the s domain, while components connected in series are equivalent to multiplying their transfer functions in the s domain).The overall circuit has an equivalent impedance Z total : where R total , I total , C total represent the overall equivalent resistance, capacitor, inductance respectively in the circuit (Figure 1D).Eq. 19 and Eq.11 have indeed a similar form.However, high-order linear differential models are rarely encountered and applied in practical applications.We suggest caution in using high-order models to describe the respiratory system, primarily based on the following reasons: 1. Since Eq. 19 and Eq.11 have a similar form, we can approximate the effect of high-order differential models by using first and second order differential models.2. Higher-order differential models are difficult to stabilize in practical applications, as there are always disturbances present in real-world situations.We illustrate some examples in the Supplementary Material Section 3. 3.There are many parameters in high-order differential models, which typically require more measured data to be estimated.In the following sections, we introduce fractional calculus models with fewer parameters and similar accuracy.4. In nondegenerate mechanics systems, (the Hessian matrix is full rank), based the Hamilton's Principle and Ostrogradsky's theorem, terms of order three and higher in higher-order differential models do not exist.More details on thus point may be found in the Supplementary Material Section 4.
Overall, given the above analysis, we are not going to employ high-order differential models in processing measured data.

Fractional calculus models
If there is uncertainty about the appropriate order of the differential terms in the respiratory mechanics model and on the actual weight of each order, we may consider introducing fractional-order terms involving different orders of derivatives into the model.This would also allow us to take into account the memory-dependent viscoelasticity and heterogeneity features of the lung tissue (Bates, 2009;Ganzert et al., 2009;Chen et al., 2010;Carvalho and Zin, 2011;Ionescu and Kelly, 2017;Xue and Bai, 2023), which cannot be captured by classical integer-order differential equations-based lumped-parameter models.Here, we propose a fractional calculus model to solve this problem, which has fewer parameters to be estimated compared to classical models.
Fractional calculus may be introduced in different and slightly inequivalent ways, involving Grünwald-Letnikov, Riemann-Liouville, and Caputo fractional derivatives.Here, we primarily consider the Grünwald-Letnikov definition that is convenient for numerical calculations.The α-order derivative of a given function f(t) is expressed as (Xue and Bai, 2023): In the above formula, h is a sufficiently small time step, and Γ denotes the Gamma function, that is Γ(z) ∞ 0 e −t t z−1 dt。This definition assumes that the value of the function f(t) is 0 when t ≤ t 0 , in agreement with the assumption that any physical quantity is zero before the initial time t0.Fractional order derivatives are able to capture memory properties (applicable to differentiation where α > 0 and to integration where α < 0).More about numerical calculations of fractional order calculus can be found in the Supplementary Material Section 5.
Furthermore, according to Eq. 20, any fractional order derivative term also involves some higher order derivative features.
Based on the fractional order differentiation proposed above, we modify Eqs 1, 20, thus obtaining the following fractional order derivative respiratory mechanics model: where D α t0 V(t) is the α-order derivative of the V(t), with a fractional order differential term α > 0. When α = 1, it takes the form of Eq. 10.
In the subsequent sections, we mainly focus on cases with 0<α < 1.
The above formula contains a single fractional order derivative term.Analogously, we may also introduce models containing more fractional terms, such as the generalization of Eq. 22 containing 2 fractional order derivative terms, i.e., As a matter of fact, upon considering actual measurement data, one sees that more fractional order terms do not provide better results than a single one.Parameters estimation and model simulation results for Eq.21, 22 are reported in the Supplementary Material Section 6.

Non-linear models
The models mentioned earlier are all cases where the coefficients of the differential equations are constants.In the actual respiratory system, the elasticity E and airway resistance R may be variables rather than constants (Van Drunen et al., 2014;Chiew et al., 2015;Redmond et al., 2017;Ellwein Fix et al., 2018;Marconi and De Lazzari, 2020).When the elasticity E changes with V(t), and the resistance R changes with V′(t), based on Eq. 1, pressure P(t) and volume V(t) satisfy the following equation: where V′(t) represents the first-order derivative of V with respect to t.Specifically, when only the elasticity E varies with V(t) or only the resistance R varies with V′(t), Eq. 23 can be evolved into Eq.24 and Eq.25.
Nonlinear models containing polynomial terms.In order to describe physical situations in which the elasticity E is monotonically (and strongly) positively correlated with V(t) and the resistance R is monotonically strongly positively correlated with V′(t), we should consider polynomial functions f and h in Eq. 23.To a first approximation, we may safely ignore the different inflection points of the polynomials and focus on the highest order term that mostly affects the behaviour of the functions.This amounts to consider f of the form of E of f set + αV(t) β , where E offset > 0, and the constants α and β capture the behaviour of the elasticity E as a function of V(t).The form of the function h is analogue, i.e., R of f set + αV′(t) β .Overall, we have Then Eq. 23 can be written as where a, b, x and y are constant.
Similarly, when only the elasticity E changes with V(t) in a polynomial form or only the resistance R changes with V′(t) in a polynomial form, Eq. 27 can be written as As a matter of fact, there exists some nonlinear models with analytic solutions in terms of elementary functions.For instance, for the model (t) E 0 (E offset + kV(t))V(t) + RV′(t) + P 0 EV(t)+ RV′(t) + aV(t) 2 + P 0 , if we assume the P(t) is a step signal with constant value P c , then its analytic general solution is , where k is the constant coefficient determined by the initial conditions.
Non-linear models containing exponential terms.In some cases, the respiratory system elasticity E may show a step response property 10,12 .Combined with the results presented in the following sections, this corresponds to the model described by Eq. 24.If function f is an exponential function, double-exponential function and triple exponential function, P and V satisfy one of the following equations.
The growth in single exponential function is fast, but not as fast as the factorial function.The double-exponential function grows faster than the factorial function (see the Supplementary Material Section 7).The growth rate of the Ackermann's function is much faster than the double-exponential function.As it may intuitively be expected, we will show that without using piecewise functions the faster is the growth, the better is the fitting of the measured data (for a step response).

Hybrid model
Considering the step-like features of the respiratory system elasticity, as well as the memory-dependent viscoelasticity and heterogeneity characteristics of lung tissue, we may combine Eq.21 with Eq. 30 to obtain the hybrid model of Eq. 33, which itself incorporates different properties: As we will see in the following Sections, this hybrid model provides the best fit for measured data in most situations.

Data collection
We use a Dräger Savina 300 to measure airway pressure P(t), flow speed V'(t) and respiratory volume V(t) in the actual respiration of three Bama pigs.The first Bama pig (sample ID as case1) weighs 28 kg, and data are taken for three ventilation modes, namely, pressure control -assist control (PC-AC), volume controlassist control (VC-AC), and volume control -synchronized intermittent mandatory ventilation (VC-SIMV).The second one (sample ID as case2) weighs 31 kg and the third one (sample ID as case3) weighs 24.3 kg, and data are taken for the VC-AC ventilation mode.In all measurements, pressure P(t), flow speed V′(t), and respiratory volume V(t) data are collected every 10 ms for at least 6 min.In the pressure control ventilation mode, set peak breathing pressure = 16 mbar, plateau pressure = 15 mbar and PEEP = 3 mbar.In the volume control ventilation mode, the tidal volume is set to 0.3 L.
During the measurement process, the original HL7 data are first obtained through serial communication, and then the pressure P, flow speed V′, and respiratory volume V data at each moment are further parsed and extracted.The data at the same moment are placed in the same row, with each row divided into three columns: pressure P, flow speed V', and respiratory volume V, separated by tabs.The data are arranged in chronological order.Finally, the unit of P is converted to mbar, the flow rate is in L/s, and the respiratory volume is in L, which are written into the txt file.
For cross-validation at different time periods, two data files of 150 s duration (15,

Parameter estimation
Parameter estimation for all the above-mentioned ordinary differential equations with constant coefficients can be performed using the following procedure (Bates, 2009;Redmond et al., 2017;Avilés-Rojas and Hurtado, 2022).The first observation is that all the models analyzed in this paper may be recasted as where f 1 (t), f 2 (t) . . .f n (t) denotes any linear or nonlinear term of the differential equation, for example, f n (t) may represent (V′(t)) 2 , D α t0 V(t), e xV(t) , etc., while A a 1 , a 2 . . .a n { } is the corresponding set of coefficients, i.e., the quantities to be estimated.
The values of pressure P(t), flow speed V′(t), and respiratory volume V(t) collected in real time are organized in vector and matrix form and used as input for the algorithm.If the collected values of the respiratory system are at n time points t 1 , t 2 . . .t n { } , then the input data are the n-dimensional pressure vector P(t), and the data matrix X with n rows and m+1 columns: . . .
Then, the coefficients can be estimated from In the above Eq.37, X T represents matrix transposition, and [*] −1 represents matrix inversion.We estimate parameters by minimizing the sum of squared residuals (SSR).At the extreme point, the partial derivatives with respect to each coefficient are zero, and this provides constraints to obtain their values.In order to determine the fractional-order in Eq.21, we employ Particle Swarm Optimization (PSO) algorithm in machine learning (Kennedy and Eberhart, 1995;Gad, 2022;Shami et al., 2022;Xie et al., 2022;Yang et al., 2022), searching for the stable optimal solution with the lowest overall SSR.In this way, we also find the coefficient x for the exponential Eqs 30-32, and the hybrid Eq.33.For all the models, suitable values of the number of particles N and iterations M may be found, which ensure stable optimal solutions.In general, for Eq.21, M = N = 5 is enough, whereas for the exponential model we need M = N = 10, and for the hybrid model, M = N = 20.Once the values of α and x are determined, their corresponding constant coefficients can be calculated according to Eq. 37.
To ensure computational accuracy, we use the different packages in Python to calculate the fractional order derivatives (Adams, 2019), and call Python code within MATLAB while optimizing the SSR value of the models.In addition, since the exponential Eqs 30-32, is prone to produce a singular matrix, we perform address Eq. 37 using a pseudo-inverse matrix to reduce the distortion and deviation of numerical results.
More details about faster empirical estimation methods of the parameters for fractional calculus and exponential terms may be found in the Supplementary Material Section 8.

Numerical simulations
After obtaining the estimated values of the parameters, the stability of the models is assessed using the Routh-Hurwitz stability criterion, and then the subsequent simulations are carried out carefully considering their actual physical meaning (Hu, 2007;Wang et al., 2007).Generally, we accept estimated values of the parameters only if they are positive.On the one hand, this is required by the Routh-Hurwitz stability criterion, dictating that our models are stable only if all coefficients are positive.On the other hand, from a practical physical perspective, most of the variables of interest, e.g., the elasticity E of lung tissue are positive numbers.
After the parameters meet the above conditions, we use MATLAB/Simulink and Python to complete the calculations and construct the Simulink model for all the models considered in this work.The open-source vfoderiv3 module of Simulink (Scherer et al., 2011;Sierociuk et al., 2015;Sierociuk, 2023) is used for the simulation of fractional calculus.The Simulink model for the other models may be found in the Supplementary Material Section 9.

Evaluation criteria
The comparison of models with the same number of parameters to be estimated is made in terms of the SSR and the root mean square error (RMSE).Models with lower values of these two indicators should be preferred.The definition is given by where V i represents the actual respiratory volume value from measured data at time i (the i th data point), and V i represents the value from model simulations.The actual measurement period contains a total of n data points (an overall duration of 150 s corresponds to n = 15,000).The comparison between different models is made using the Bayesian Information Criterion (BIC) which considers the number of parameters.If residuals~N(0, σ 2 ), we ignore the irrelevant constants and use the equivalent BIC value, i.e., Eq. 40, for model comparison and evaluation (Sheng et al., 2020).
In the above formula, k represents the number of model parameters.The process of deriving Eq. 40 based on the original BIC definition and the assumption of residual distribution may be found in the Supplementary Material Section 10.
In addition, we also use the Pearson correlation coefficient between the measured and simulated values of the respiratory volume as an additional criterion for optimization (the closer the correlation coefficient is to 1, the better).

Computation details
The executable code and actual respiratory data can be found in the Supplementary Material and our Gitee repository (https://gitee.com/lizwtest/mechanical_ventilation).
For models that do not contain exponential or fractional order differential terms, such as Eq 1 and Eq. 2 and Eq. 10, and (27-29), the measured respiratory mechanical data of the respiratory system can be substituted into Eq.37 based on Section 2.3.This results in calculated values with practical physical characteristics such as respiratory system elasticity E, airway resistance R, P0 (PEEP), and so on.
For the calculation of models containing double exponential or fractional order differential terms, taking the double exponential model of Eq. 31 as an example, when a suitable value of the exponential parameter x is given in the model, the respiratory system mechanics data is substituted into Eq.37 to obtain the elasticity "E," airway resistance "R" and coefficient "a" which can reflect the weight of the step mechanical characteristic.At this time, the SSR value can be obtained by Eq. 38 as the score of the PSO function based on the predicted respiratory volume V (t) and the measured volume V(t), and then the velocity vector of N particles is continuously updated for M rounds to find a better value of x (corresponding to the position of the particle), thus obtaining a lower SSR value corresponding to the optimized parameter x.The main flow of the proposed Algorithm 1 is shown in the pseudo-code.The NCP in the pseudo-code stands for non-coefficient parameters.P_SSR best , G_SSR best , P best , G best , represent the particle best SSR value, the global best SSR value, the particle best location, and the global best location, respectively.(2) for each particle i = 1 to N do  Furthermore, for the Grünwald-Letnikov discretization calculation formula of the open-source vfoderiv3 module in Simulink, you can refer to the following Eqs 41, 42 or the instruction file and related literature of this module (Scherer et al., 2011;Sierociuk et al., 2015;Sierociuk, 2023;Xue and Bai, 2023).When the step size h is sufficiently small and the start time involved in the calculation is t 0 , the calculation of fractional calculus under the Grünwald-Letnikov definition is as follows: where the coefficient ω j in the above formula (41) has the following recursive formula that is convenient for numerical calculation: For instance, applying it to calculate the α fractional derivative of the respiratory volume V(t) at a certain moment t, is to substitute the measured values of V (t 0 ) to V(t) into Eq.41 for calculation.The coefficients ω j of Eq. 41 are determined by recursive calculation from Eq. 42.

Results
3.1 Our results indicate that the parameter estimation and model simulation methods proposed in this paper are fast and effective for all the considered classes of models Four representative different models have been employed to analyze 150 s of PC-AC mode data (corresponding to case1PCAC1.txt, 15,000 data points) for parameter estimation and model simulation.Results for the different models are summarized in Table 1 along with their mean computation time obtained from three runs (all the calculations are retained to four decimal places).
As it is apparent from Table 1, the fractional model has the best performance, although the computation time is slightly higher than the other models.For all the models, parameter estimation and model simulation and evaluation may be completed within seconds.Figure 2 shows that models reproduce accurately the measured respiratory volumes V(t) data.Looking at the first row of Table 1 as an example, we see that the values of respiratory system elastance E = 26.1130cmH2O/L and respiratory system resistance R = 7.1716 cmH2O*s/L obtained from Eq. 37 both fall within the known range of normal measurements (Protti et al., 2011;Henderson et al., 2017).
In addition, compared to the study by Albanese et al. (2016), our modelling provides an improvement in accuracy by an order of magnitude in terms of the CV(RMSE).In particular, their model achieved an optimal CV(RMSE) = RMSE/average (V(t)) = 0.079 for the volume V(t).While just using the most basic Eq. 1 we find CV(RMSE) = 0.0089 (the results of other models are even better).This demonstrates the accuracy and reliability of our modelling and parameter estimation methods.

The double-exponential model can be chosen as a representative of exponential models
As mentioned above, we have proposed the exponential Eqs 30-32 to describe data measured in three different ventilation modes: PC-AC, VC-AC, VC-SIMV (corresponding to data files case1PCAC1.txt,case1VCAC1.txt,case1VCSIMV1.txt).The x parameter in the exponentials of Eqs 30-32 is optimized using PSO to obtain the most suitable value, and the criterion for optimization is the SSR value (lower SSR value is better).The number of particles N and the number of iterations M are taken as 5, 10, 20, respectively.The SSR and computation time of each model are summarized as shown in Figure 3.
Overall, the computational results improve (lower SSR values) as the exponent increases (i.e., at a faster growth rate), suggesting that the respiratory system elasticity E has certain step characteristics (the exponential term corresponding to the component separated from the elasticity E), and the closer is to the step characteristics, the better are the results.
Looking at the dashed line in the graph, we conclude that Eq. 32 shows a significant improvement compared to Eq. 30 (with a significant difference of p-value = 0.0001009, and an average difference rate of 12.91% in the three ventilation modes).However, there are no significant differences between Eq. 32 and 31 (with a non-significant difference of p-value = 0.8271, and an average difference rate of 1.05% in the three ventilation modes).Further increasing the exponential order results only in an increase of the computational time.We thus recommend using the double exponential model as a representative of this type of models.The particle number N and iteration rounds M for this type of model PSO optimization are both set to 10, which allows us to achieve saturation in calculations.

Exponential models provide superior results compared to the polynomial models in volume-controlled ventilation mode
In order to investigate and find out a suitable nonlinear model to describe the actual respiratory data, we simulate the dynamics of Eq. 27, with the exponent ranging from 1 to 11, and select the best model based on its SSR value.When x = 1 Eq.27 is equivalent to Eq. 29, whereas for y = 1 Eq.27 is equivalent to Eq. 28.When both x = 1 and y = 1, Eq. 27 reduces to (1).We use three different ventilation modes, PC-AC, VC-AC and VC-SIMV, to estimate the parameters of each model using measured data (corresponding to data files case1PCAC1.txt,case1VCAC1.txt,case1VCSIMV1.txt),and only the parameter values that meet the Routh-Hurwitz criterion and the actual physical meaning are taken for subsequent simulation calculations of SSR values.The results may be summarized as follows: Figure 4 shows that the exponent y only weakly influences the overall SSR.To reduce the undetermined parameters Eq. 28 is thus taken as the more suitable model for the discussion in the subsequent sections.
The SSR decreases with the exponent x in the term aV(t) x with an approximately exponential behaviour.We take the mean and the logarithm of the mean of the SSR values of all curves in Figures 4A-C respectively, and through linear regression analysis, we find that the logarithm of the mean of the SSR is more significantly correlated to the independent variable x (higher coefficient of determination r2, see Supplementary Material Section 11).This suggests that the SSR of Eq. 28 converges slowly and other may be more convenient in terms of convergence and model fitting.
To simplify and more clearly illustrate our results, we further take the best results obtained by using polynomial Eqs 27-29 of orders 1-11, and compare them with results obtained from Eq. 31.
Comparison is made in terms of SSR for the three different ventilation modes, PC-AC, VC-AC, VC-SIMV, for parameter estimation and simulation (corresponding to data files case1PCAC1.txt,case1VCAC1.txt and case1VCSIMV1.txt).For the double exponential Eq.31, the exponent x is optimized by PSO for a number of particles N = 10 and iterations M = 10.
As can be seen from the results in Table 2, in the Volume-Controlled ventilation mode (VC-AC, VC-SIMV), the double exponential model Eq. 31 has significantly superior BIC and SSR, obtained in a computational time of the same order of magnitude compared with the other models.According to Eq. 26, the exponential term ae exV(t) V(t) in Eq. 31 and the aV(t) x term in Eq. 28 are physically related to the elasticity E (component of respiratory elasticity E), and the results of this Section indicates that the elasticity E of the respiratory system has a step-like characteristic, which is more suitable to be modeled and described by exponential or similar fast-growing functions.

The fractional calculus model provides superior results compared to integer-order differential models in Pressure-Controlled ventilation mode
We further compare results for the Pressure-Controlled ventilation mode, introducing the fractional calculus term into the respiratory mechanical model.
Before comparing Eq.21 with other different models, the undetermined fractional order in the fractional calculus model of Eq.21 should be estimated using the PSO algorithm to obtain the optimal solution.First, we use PSO algorithm to determine for which values of the particle number N and iteration rounds M one obtains a stable optimal solution for Eq. 21.We use data files from three different breathing patterns: case1PCAC1.txt,case1VCAC1.txt,case1VCSIMV1.txt,and compare SSR for N and M ranging from 3 to 30.
The results are shown in Figure 5.Using M = N = 5, PSO already reaches a stable optimal solution, and increasing N and M provides only little improvement on the final result.For N = M = 5, the maximum difference rate from the optimal SSR (N = 30 and M = 30) in the three ventilation modes is 0.14% for the PC-AC mode.Hence, for the PSO algorithm optimization of Eq.21 we consistently set N = M = 5.
After determining that Eq.21 has reached a stable optimal solution based on the PSO algorithm with particle number N = 5 and iteration number M = 5, we can further compare the single-compartment model Eq. 1, fractional calculus model Eq.21, polynomial model Eqs 27-29, and double-exponential model Eq. 31 based on the actual measured data from the three ventilation modes case1PCAC1.txt,case1VCAC1.txt,case1VCSIMV1.txt.We calculate their respective BIC values, SSR values, and computation time.The PSO algorithm is used to optimize the fractional order of Eq.21 and the exponential parameter of Eq.31, with the goal of minimizing SSR.In the optimization calculation based on the PSO algorithm, for Eq.21, the particle number N = 5 and the iteration number M = 5 are taken, while for Eq.31, according to the previous results, N = M = 10 is taken to achieve saturation.To simplify and clearly present our results, the best results from the polynomial models up to order 11 are compared, and the results are shown in Table 3.
From the above results, it is apparent that the fractional calculus model performs better (lower BIC and SSR values) compared to the single-compartment Eq. 1 for all the ventilation modes.The running time is generally within half a minute on our computing platform.The additional computation time of the fractional order model is mostly due to the iterative search, required to find the suitable order, whereas the computational time required for saturation is shorter compared to the exponential Eq. 31.In particular, for the Pressure-Controlled ventilation mode (PC-AC), the fractional calculus model of Eq.21 is superior to other types of models.

Significant improvement of respiratory model fitting based on hybrid model
As illustrated in the previous Sections, Eq.21 is optimal for the Pressure-Controlled ventilation mode and Eq. 31 for the Volume-Controlled ventilation mode.In this Section, we investigate whether the hybrid model in Eq. 33, which has features of both models may achieve better results (lower BIC and SSR values) for all the ventilation modes.
Since the fractional order α and the exponential term parameter β in the hybrid Eq.33 are obtained by PSO algorithm, we first calculate the number of particles N and the number of iterations M  required to achieve stable optimal solution based on data from the three different ventilation modes, case1PCAC1.txt,case1VCAC1.txt and case1VCSIMV1.txt.
From Figure 6, we see that the hybrid Eq.33 reaches stable optimal solutions for all ventilation modes when N = M = 20, and that there is no statistical difference compared with the optimal SSR (N = 50 and M = 50) (p-value = 0.1835, average difference rate 0.0087% in three ventilation modes).In the following, we use N = M = 20 to optimize the parameters of the hybrid model Eq.33.
Next, we compare the BIC and computational time of the singlecompartment model Eq. 1, fractional calculus model Eq.21, polynomial model Eqs 27-29, double-exponential model Eq. 31 and hybrid model Eq.33 using the same data (case1PCAC1.txt,case1VCAC1.txt,case1VCSIMV1.txt).For the polynomial model Eqs 27-29, we take the best results from orders 1-11.For Eqs 21, 31, 33, which need to be optimized based on the PSO algorithm, we take their corresponding stable optimal solutions, i.e., N = M = 5, N = M = 10 and N = M = 20, respectively.The results are shown in Figure 7A.After parameter estimation, we further use the relationship between pressure P(t) and respiratory volume V(t) in the data of case1PCAC2.txt,case1VCAC2.txt,case1VCSIMV2.txtfor cross-validation (i.e., the pressure in the second time period is used as the input, and the model parameters estimated in the first time period are used for model simulation.The simulated volume V(t) results are compared with the actual measured respiratory volume V(t) in the second time period to calculate SSR and BIC values), and the results of their BIC, SSR values and computational time correspond to Figure 7B.
Results in Figure 7A show that our proposed hybrid model Eq.33 is the optimal model for all ventilation modes, and that its BIC value is significantly better than other models.When applied to actual measured data from different time periods of the same mode after estimating the model parameters (Figure 7B), similar results are obtained (the behaviour of the BIC for each model is similar), that is, the hybrid model is the optimal model within a given time period and for cross-validation in different time periods.
In terms of computation time, the optimal hybrid model also takes the longest time for parameter estimation stage.The singlecompartment model has the worst BIC value and the shortest calculation time (average 0.26 s).Since the hybrid model involves two parameters to be estimated, the main overhead in computation is the optimization of parameters by the PSO algorithm.However, if the personalized characteristic parameters are known, the singleround running time for each model is on the same order of magnitude (Figure 7B), i.e., less than 1 s on our computing platform.
In addition, in order to verify the consistency of the results of each model in different experimental animals, we validated results on measured data from another two Bama pig for the VC-AC mode.First, based on the measured data file case2VCAC1.txt,we estimated  the parameters and calculated the BIC and SSR values to evaluate the results of each model.Meanwhile, the model parameters obtained from case2VCAC1.txt were used for cross-validation of the relationship between pressure P(t) and respiratory volume V(t) in the measured data of case2VCAC2.txt.Moreover, the validation for case3 data (case3VCAC1.txtand case3VCAC2.txt) is the same.The calculated results of BIC and SSR values are summarized in Table 4.
The validation results are consistent with the results in Figure 7, indicating that the hybrid model Eq.33 can achieve significantly better results for different ventilation modes.Compared with the basic single-compartment model Eq. 1, the SSR value of hybrid model Eq.33 is nearly halved and the difference in BIC value is even more significant.In addition, the results of Table 4 also re-verify that if personalized characteristic parameters are obtained based on several respiratory cycle data, they can be used for simulations under the same ventilation mode, and even predict the respiratory volume V(t) curve based on the specified pressure P(t), without having to recalculate the parameter values, with a single round of calculation that can be completed in seconds.
In summary, if there is sufficient computing power or quick calculations is not required, the hybrid model is recommended as the optimal model to universally describe different ventilation modes.When quick calculations are required, the fastest model is the basic Eq. 1.For the same individual, the model parameters that conform to its personalized characteristics can also be pre-calculated based on measured data (Figure 7B), and respiratory volume V(t) can be directly calculated based on pressure P(t) in the same conditions.

Discussion
We have addressed effective modelling of respiratory mechanics and put forward a set of methods for rapid parameter estimation based on measured data (each model round calculation is less than 1 s), model simulation and evaluation system, also providing the corresponding executable code (https://gitee.com/lizwtest/mechanical_ventilation) and measured data.Using our approach, different models and parameters can be selected and tailored to different applications to further explore the mechanical characteristics of the respiratory system, improve the ventilation mode of the ventilator, and lay the foundation for the implementation of rapid adaptive parameter ventilation.Some models analyzed in the article have time-domain general solutions, and so when P(t) in the respiratory system is very close to some elementary functions (or multiple superpositions), the volume V(t) curve (or multiple solutions superposition in linear systems) can be obtained directly through the time-domain general solution.However, considering certain autonomous randomness of individual's breathing and the presence of background, more realistic simulations may be obtained by substituting each point in time order.
In addition, the actual elasticity E of respiratory systems shows a step characteristic.In Volume-Controlled ventilation modes, the pressure P(t) is not fixed, and decreases as it approaches the expected tidal volume, causing a sudden change in the pressure P(t) and respiratory volume V(t) curve.In Pressure-Controlled ventilation modes, the pressure is fixed, which reflects the memory-dependent viscoelasticity and heterogeneity characteristics of lung tissue, whereas in volume-controlled ventilation modes, the pressure P(t) has not a fixed value.The pressure P(t) decreases when it is close to the expected tidal volume, and if it reaches the thoracic/lung volume, the elasticity E of the respiratory system will significantly increase (a larger pressure increment ΔP is required to produce the same volume increment ΔV).This corresponds to a sudden change in the pressure P(t) and volume V(t) curve, and the volume V(t) curve is more likely to reflect the plateau feature.In Pressure-Controlled ventilation modes, the pressure is fixed to reflect the memory-dependent viscoelasticity and heterogeneity characteristics of lung tissue.
Finally, using the systematic approach proposed in this paper, we have proposed and validated an optimal hybrid model useful for various ventilation modes.To this aim, we have for the first time applied fractional calculus and double exponential terms to the modelling of respiratory mechanics.Compared to other models, the hybrid one shows significantly better BIC and SSR results for different ventilation modes, i.e., it better describes the actual pressure P(t) and respiratory volume V(t) relationship.This implies that we can more accurately describe and simulate the characteristics of respiratory mechanics.Based on this model, we can further study the mechanical characteristics of the respiratory system, deepen our understanding of the impact of mechanical ventilation on patients, and optimize the ventilation mode of the ventilator to improve ventilation effects and reduce ventilation damage.
Furthermore, after pre-calculating personalized parameters using several respiratory cycles of different individuals, we can also implement rapid adaptive parameter ventilation based on the hybrid model.Traditional ventilation mode parameters are generally fixed and cannot be dynamically adjusted according to the patient's real-time respiratory characteristics.However, in the hybrid and other models and methods mentioned in this article, we can dynamically adapt the model and estimate the corresponding model parameters according to the actual data measured at different time intervals of individuals.This makes the overall approach more personalized and adaptable to the actual situation of the patient, thereby achieving better results.

Conclusion
We have proposed a system for parameter estimation, model simulation, and evaluation based on actual measured data, and after carefully comparing different models, we have put forward an optimal hybrid model valid for various ventilation modes.It may not only help doctors to better understand the mechanical characteristics of the respiratory system, but also improve the ventilation mode of the ventilator, enhance the effect of respiratory therapy, and provide strong support for the realization of rapid adaptive parameter ventilation, which is a relevant feature to improve the safety, effectiveness, and personalization level of mechanical ventilation.Frontiers in Physiology frontiersin.org14 Li et al. 10.3389/fphys.2023.1273645

( 3 )
for each NCP j = 1 to D do (4) Initialize particle velocity and position randomly within [LB, UB] D ; (5) end for (6) Substituting Data into Eq.37 to determine all the model parameters; (7) Compute predicted respiratory volume V (t) based on respiratory mechanical model; (8) Substituting V (t) and V(t) to Eq. 38 to initialize P_SSR best to the initial value; (9) end for (10) Initialize G best and G_SSR best based on the lowest P_ SSR best ; (11) while iteration < max generation M (12) for each particle i = 1 to N do (13) Update the velocity and position of particle i (14) if the position of particle i exceeds the boundary [LB, UB] D then (15) the position of particle i is set to the boundary value;(16) Substituting Data into Eq.37 to determine all the model parameters;

P
D1.1(V) represents the 1.1-order fractional derivative of V.That the bold values indicates the important BIC indicator results.

FIGURE 3
FIGURE 3 Comparison of SSR and computation time for Eqs 30-32 in three respiratory modes.The left y-axis in the Figure denotes time (in seconds), corresponding to the line graph, while the right y-axis represents the SSR values, corresponding to the bar graph.The x-axis is the particle number N (equal to the number of iterations M).The purple line and bar denote results for Eq. 30, green is for Eq.31, and blue is for Eq.32.(A) reports results for the PC-AC ventilation mode, (B) for the VC-AC ventilation mode and (C) for the VC-SIMV ventilation mode.

FIGURE 4
FIGURE 4 SSR of nonlinear polynomial models.(A-C) illustrate the behaviour of the SSR as a function of the exponent x of the aV(t) x term in Eq. 27.The fitting functions corresponding to the mean of all curves in the 3 ventilation modes are shown in Figures 5A-C, respectively (retaining 2 decimal places).(D-F) illustrate the behaviour of the SSR as a function of the exponent y of the bV′(t) y term in Eq. 27.The numbers in x1, x2. and y1, y2. in the legend represent the values corresponding to x and y in Eq. 27.

FIGURE 5
FIGURE 5 SSR values as obtained from different PSO parameters in the three ventilation modes for Eq. 21.The black line is for the PC-AC mode, green for VC-AC mode, and blue for VC-SIMV mode.The horizontal axis represents the values of M and N in the PSO algorithm, for example, the position of x = 5 denotes N = 5 and M = 5.The SSR value data points calculated from different M and N values are marked with red "x" in the Figure.

FIGURE 6
FIGURE 6 SSR values obtained from different PSO parameters in three ventilation modes for Eq.33.The horizontal axis denotes the values of M = N in the PSO algorithm, and the SSR value data points calculated from different M and N values are marked with red "x" in the Figure.

FIGURE 7
FIGURE 7 BIC and computational time for the three respiratory modes.The left axis in the figure represents BIC value (bar graph), while the right axis represents time (line graph).The horizontal axis represents three different ventilation modes [black for Eq. 1, green for (Eq.21), cyan for (Eqs 27-29), blue for (Eq.31), and purple for (Eq.33)].(A) The results based on data from the first time period (case1PCAC1.txt,case1VCAC1.txt,case1VCSIMV1.txt).(B) The crossvalidation results based on data from the second time period (case1PCAC2.txt,case1VCAC2.txt,case1VCSIMV2.txt),with the parameter estimation based on data from the first time period.

TABLE 1
Parameter estimation and simulation results of four representative models.

TABLE 2
Comparison of double-exponential model and polynomial models.That the bold values indicates superior model results in volume-controlled ventilation modes.

TABLE 3
Comparison of fractional calculus model and integer-order differential models.

TABLE 4
Validation of results based on VC-AC mode case2 and case3 data.