// MODEL NUMBER: 0241
// MODEL NAME: Comp1Flow
// SHORT DESCRIPTION: Models single compartment with inflowing and outflowing
// concentration of a single substance.
import nsrunit; unit conversion on;
math Comp1Flow {
// INDEPENDENT VARIABLE
realDomain t sec; t.min=0; t.max=40; t.delta=0.1;
// PARAMETERS
real C0 = 0 mM, // Initial Concentration
Volume = 0.06 ml, // Volume of compartment
Flow = 0.01 ml/sec; // Flow rate (volume per second)
extern real Cin(t) mM; // Inflowing concentration (defined with
// function generator)
// VARIABLES
real C(t) mM, // Concentration in compartment
Cout(t) mM; // Outflowing concentration NOTE that Cout=C because
// the compartment is instantaneously well mixed.
// INITIAL CONDITION
when(t = t.min) C=C0;
// ORDINARY DIFFERENTIAL EQUATION
C:t = (Flow/Volume)*(Cin-Cout);
Cout = C;
//ADDITIONAL CALCULATIONS
real Canalytic(t) mM;
Canalytic= Cin+(C0-Cin)*exp(-Flow*t/Volume);
// QUANTITY OF SUBSTANCE FROM TWO DIFFERENT CALCULATIONS
real Q(t) nmol, // Quantity = Volume* Concentration
Qint(t) nmol; // Quantity = integral of Flow multiplying inflow
// concentration minus outflow concentration
Q = Volume*C;when (t=t.min) Qint=Volume*C0;
Qint:t = Flow*(Cin-Cout);
// AREA AND TRANSIT TIME OF INFLOW AND OUTFLOW CONCENTRATIONS
private real S2_in(t) mM*sec^2, S2_out(t) mM*sec^2; // First moments
real Area_in(t) mM*sec, Area_out(t) mM*sec, // Areas
Tbar_in(t) sec, Tbar_out(t) sec, Tbar_sys(t) sec; // Transit times
when(t=t.min) {Area_in = 0; S2_in = 0;
Area_out = 0; S2_out = 0; }
Area_in:t = Cin;
Area_out:t = Cout;
S2_in:t = Cin*t;
S2_out:t = Cout*t;
Tbar_in = if(Area_in>0) S2_in /Area_in else 0;
Tbar_out = if(Area_out>0) S2_out/Area_out else 0;
Tbar_sys = Tbar_out-Tbar_in;
}
/* DIAGRAM
+-----------------------------+
Flow*Cin ---> C ---> Flow*Cout
| Volume | Cout = C
| instantaneously well mixed |
+-----------------------------+
DETAILED DESCRIPTION:
In a single compartment with flow, there is a source
term, (Flow/Volume)*Cin, which adds material to the
compartment, and a sink term, -(Flow/Volume)*C, the washout
term, which removes material from the compartment. These
two terms are usually combined as a single term in the
mass balance ordinary differential equation after dividing
left and right hand sides by the volume:
dC/dt = (Flow/Volume)*(Cin-C).
The compartment is instantaneously well mixed.
Various methods for checking the
calculations in a model are illustrated: (1) two methods of
calculating the amount of material in a compartment with
flow, (2) comparison of the running integrals of inflow and
outflow concentrations, and (3) calculation of the system
transit time of a compartment model with flow by
two different methods.
SHORTCOMINGS/GENERAL COMMENTS:
- None.
KEY WORDS:
compartment, compartmental, flow, first order process, Tutorial
REFERENCES: None.
REVISION HISTORY:
JSim SOFTWARE COPYRIGHT AND REQUEST FOR ACKNOWLEDGMENT OF USE:
JSim software was developed with support from NIH grants HL088516,
and HL073598. Please cite these grants in any publication for which
this software is used and send one reprint of published abstracts or
articles to the address given below. Academic use is unrestricted.
Software may be copied so long as this copyright notice is included.
Copyright (C) 1999-2009 University of Washington.
Contact Information:
The National Simulation Resource,
Director J. B. Bassingthwaighte,
Department of Bioengineering,
University of Washington, Seattle, WA
98195-5061
*/