Plot "P_V_F_vs_t":
Six variables are plotted as functions of time: pressure at the mouth
(black line), pressure in the lung (red dashed line), volume of the
lung (plotted as (Vlung + Vintrapl  VFRC)/50, with blue circles),
rate of air flow into lungs (plotted as Fair/100; green dashed line)
pressure applied by chest muscles (purple line), and intrapleural
pressure (dark green dashed line).
NOTE: for display Fair(t) divided by 100, volume divided by 50
Plot "PO2": Concentration in Lung:
PO2lung shows decay within each breath when PSuptake > 0. The final value
at the end of each breath can be fitted by a decaying exponential function
(See Figure 5, and formula for PO2test in code.)
Plot "VOL.PRESS" : Lung Pressure vs Lung Volume (Run Loops):
With the normal run, the almost linear relationship between
Plung and Vlung is apparent as Vlung ranges from 3000 ml
to over 3400 ml. Running Loops shows the nonlinearity of the Pressure
response as Vlung approaches either the residual volume (1500 ml) or
the total lung capacity volume (6000 ml). With Comslope = 0, the tidal
volume reaches 500 ml, and the PV curve slopes are constant, not curved.
Plot "COM": Linear Compliance :
The compliance is linear when the lung ranges between VFRC (3000 ml)
and VFRC+VT (3500 ml), where VFRC is the volume of the functional
residual capacity, and VT is the tidal volume. Running Loops, shows
the compliance decreasing as Vlung approaches either the residual volume,
VR (1500 ml), or the total lung capacity, VTLC (6000 ml).
Plot "Verify": Ctest (dashed), Clung (solid) match at breath end (Default):
With R*Com<=0.5 seconds, the concentration at the end of each ventilator cycle
is fit by a decaying exponential function plus a constant,
Ctest=Cgas+(Clung0Cgas)* exp(k * t)
where k = ln( Maximum value of Vlung/ Minimum value of Vlung ) / (6 seconds),
Cgas is the concentration in the inhaled air, and Clung0 is the initial
concentration in the lung. Run for 60 seconds or so.
This model illustrate:
1. Gas exchange and the switching of its flow to match to overall airflow.
2. The introduction of a nonlinear compliance, a stiffer lung at higher volume.
3. A verification test for flow as an exponentially decaying function of time when
compliance is constant. tau = Resistance X Compliance.
4. A verification test for concentration showing that when PSO2lung = 0, the
concentration rises inhalation by inhalation exponentially.
/* MODEL NUMBER: 0003
MODEL NAME: OneAlvLung.GasExch
SHORT DESCRIPTION: Exchange of gas in external air into a linearly compliant lung
with calculation of inhaled gas concentration in lung over a series of breaths.
*/
import nsrunit; unit conversion on;
math Lung_RC_Air { realDomain t s; t.min=0; t.max=15; t.delta= 0.01;
// PARAMETERS: (Values chosen to approximate an adult human)
real
ComLung0 = 100 ml/mmHg, // Compliance of the lung, linear
ComLungslope = 0.01 dimensionless, // slope of Compliance of lung times Vlung/VFRC
ComChest = 100 ml/mmHg, // Compliance of Chest
Res = 0.01 mmHg*sec/ml, // Resistance of airway
VFRC = 3000 ml, // Functional Residual Capacity (FRC)
ScalPvent = 10 dimensionless, // Scalar of amplitude of Pvent (Ventilator) :: for convenience
ScalPchest = 10 dimensionless, // Scalar of amplitude of Pchest ( +ve to expand Chest) :: for convenience
ScalPexhaust = 10 dimensionless, // Scalar of amplitude of Pexhaust ( ve to expand Chest) :: for convenience
Vintrapl0 = 100 ml, // Arbitrary amount air in pleura to allow Vintrapl changes
Vchest0 = 4000 ml, // Chest volume at FRC (incl heart,etc. of about 1000 ml)
Pintrapl0 = 15 mmHg, // Intrapleural pressure at FRC
Patmos = 0 mmHg, // Reference Pressure external to lung
PO2atmos = 10 mmHg, // O2 partial pressure in external air
PO2lung0 = 0 mmHg, // O2 partial pressure in lung
PSO2lung = 1 ml/sec; // Permeabilitysurface area
// VARIABLES
extern real
Pvent(t) mmHg, // Ventilator Driving Press.: 2 sec at 10 mmHg
Pchest(t) mmHg, // Press by Chest Muscle Expansion (Neg for inhale)
Pexhaust(t) mmHg; // Pressure in IronLung tank exhaust (Neg for inhale)
real
Pmouth(t) mmHg, // Pressure at the mouth
Plung(t) mmHg, // Pressure in the lung, NonLinear
Pintrapl(t) mmHg, // Pressure in intrapleural space (Neg to inhale)
Ptank(t) mmHg, // Pressure in iron lung tank
ComLung(t) ml/mmHg, // NonLinear Compliance and PV curve
Fair(t) ml/sec, // Flow at mouth
Vlung(t) ml, // Volume of air in lung
Vintrapl(t) ml, // Volume of air in intrapleural space (regarded as compressible)
Vchest(t) ml, // Chest volume at FRC = approx FRC (or TLCheart and lung tissue)
PO2lung(t) mmHg; // Partial pressure of O2 in lungs
// INITIAL CONDITIONS
when(t=t.min) {
Vlung = VFRC  Vintrapl0;
PO2lung= PO2lung0;
} // Lung volume at rest (open glottis)
// ALGEBRAIC AND ODE EQUATIONS
ComLung = ComLung0*(1+ ComLungslope*(1Vlung/VFRC)); // Compliance dependent on volume
Pmouth = ScalPvent*Pvent + Patmos; // = Ventil Pr at mouth. (Set PscalVentil = 0 for Chest breathing.)
Ptank = ScalPexhaust*Pexhaust;
Vchest = Vchest0 + (ScalPchest*Pchest + Ptank)*ComChest; // Chest expansion defined by fn generator Pmusc(t)
Pintrapl = Pintrapl0 + (Vlung + Vintrapl0  VFRC)/ComLung  (VchestVchest0)/ComChest;// Pintrapleural diminishes with chest expansion countered by lung compliane
Fair = (Pmouth  Plung)/Res; // Ohm's Law, flux = driving force / resistance
Vlung:t = Fair; // Assumes incompressible air
Plung = Patmos + (Vlung  VFRC + Vintrapl)/ComLung + (Pintrapl  Pintrapl0); // Assumes constant compliance
Vintrapl = Vintrapl0* (Pintrapl0 + Patmos)/(Pintrapl + Patmos); // Assumes compressible intrapleural air
PO2lung:t = ( if(Fair>0) (PO2atmosPO2lung)*Fair/Vlung else 0) // outflow concn in alveolus is const unless
PSO2lung*PO2lung/Vlung; // there is flux into body by PSO2lung
// VERIFICATION TEST with respect to Flow(t):
real Com = (1/ComLung0 + 1/ComChest)^(1);
real tau = Res*Com; // Time constant of system, resistance* compliance, sec
real TestF(t) ml/sec; // Test of FlowAir; FlowAir = TestF when ScalPvent * Pvent = 10 mmHg at t = 0
// until the value of ScalPvent * Pvent changes, and if ComSlope = 0
TestF = ((10 mmHg) / Res)*exp((t0.0)/tau);
// VERIFICATION EQUATIONS FOR USE WHEN PSlung = ZERO:
/* TestPO2 matches PO2lung once every 6 seconds if Com*R<0.5 or smaller and
PSO2lung = 0.
Verification assumes standard Pdrive function (Pventil = 1, for 2 seconds
followed by Pdrive = 0, for 4 seconds, repeating every 6 seconds). */
//Constants for verification test
real
VRV = 1500 ml, // Residual Volume
VTLC = 6000 ml; // General: Total Lung Capacity
// REALSTATE VARIABLES: value depends on an event
realState Vmax(t) ml; // Maximum Vlung calculated
realState Vmin(t) ml; // Minimum Vlung calculated
when (t=t.min) {Vmax=VRV; Vmin=VTLC;}
event(t>t.min and Vlung>Vmax) Vmax=Vlung;
event(t>t.min and Vlung<Vmin) Vmin=Vlung;
// ALGEBRAIC EQUATIONS FOR EVENT CALCULATIONS
real ktest = ln(Vmax(t.max)/Vmin(t.max))/(6 sec); // Overall rate constant
real TestPO2(t) = PO2atmos +(PO2lung0PO2atmos)*exp(ktest * t );
} // END OF MML CODE
/*
FIGURE:

Pmouth R Plung  
o/\/\/\/\o Pref
inhale Flow > + air   
exhale lung < Flow  Com 
v Vlung
PSO2lung PO2lung
DETAILED DESCRIPTION:
Most of the code for this model is identical to the code in OneAlvLung.Chest
The parts that are different are the additional code for calculating a
partial pressure of a substance in the lung and the nonlinear compliance
which decreases at high and low volumes causing the pressure in the lung
to rise or decrease respectively relative to a constant compliance.
The verification correctly calculates the concentration once every six
seconds when R*Com<=0.5 sec.
Main assumptions are the same as found in model Lung_RC.
GENERAL RESULTS: The ventilator, using a driving pressure of 10 mmHg gives
an approximately normal tidal volume. Normally of course, the driving force
is provided by expansion of the chest, creating a negative pressure in the
intrapleural space, just the oppposite of a positive pressure ventilator.
When R*Com<0.5, Partial Pressure in Lungs follows an exponential decay to
ambient (air) concentrations. The compliance is similar to that
portrayed by Levistsky p 30.
Loops to set Pscalar to 100 and 50 serve to reveal the whole P_V curve.
Second level loops show effects of a1 and A2 on compliance curve
(= slope of P_V curve).
SHORTCOMINGS:
1. Air is assumed incompressible. The maximum error with a 10 mmHg
driving force is only 10/760 or 1.3%.
2. There is no deadspace volume, so if there were to be gas exchange,
this model would assume that all of the volume is available for exchange.
VERIFICATION TESTS:
1.TestF: The response to a square pulse in venilator pressure is an
exponentially decaying Fair with tau = Res*Com0.
Valid only when driving force is square pulse, w/ magnitude 10
starting at t = 0 and Comslope = 0.
2.TestPO2: An exponential expression approximates the numeric solution
at a single time point every six seconds, but only when PSO2lung is
set to zero and compliance is constant. This could be strengthened by
accounting for PSO2lung relative to Fair, and running to the fluctuating
steady state where PO2lung is less that PO2atmos.
3. PO2lung converges to PO2atmos if PSO2lung (clearance from alveolus
into body) is zero.
KEY WORDS: lung, nonlinear, compliance, resistance, RC circuit, mechanics,
airflow, trachea, tidal volume, positive pressure, ventilation, tutorial
REFERENCES:
M.G. Levitsky, Pulmonary Physiology, Sixth Edition, McGraw Hill, 2003.
REVISION HISTORY:
Original Author: G. Raymond Date: 09/22/08
Revised by JBB 1sep2013 to add alternative calculations for Clung(t)
and add PSlung from lung into body allowing fluctuating steady
state as for oxygen.
Revised 20mar2014 by JBB. Original program replaced not quite totally to
simplify code and particularly to replace the code for volumedependent
compliance, and the basic equations for volumes, flows and
concentrations.
Revised 15.6.18 by M.Nolan to modify calculations for intrapleural
pressures, to add iron lung (Ptank) as driver and to update plots
COPYRIGHT AND REQUEST FOR ACKNOWLEDGMENT OF USE:
Copyright (C) 19992015 University of Washington. From the National Simulation Resource,
Director J. B. Bassingthwaighte, Department of Bioengineering, University of Washington, Seattle WA 981955061.
Academic use is unrestricted. Software may be copied so long as this copyright notice is included.
When citing JSim please use this reference: Butterworth E, Jardine BE, Raymond GM, Neal ML, Bassingthwaighte JB.
JSim, an opensource modeling system for data analysis [v3; ref status: indexed, http://f1000r.es/3n0]
F1000Research 2014, 2:288 (doi: 10.12688/f1000research.2288.v3)
This software was developed with support from NIH grants HL088516 and HL073598, NIBIB grant BE08417
and the Virtual Physiological Rat program GM094503 (PI: D.A.Beard). Please cite this grant in any
publication for which this software is used and send an email with the citation and, if possible,
a PDF file of the paper to: staff@physiome.org.
*/