/* MODEL NUMBER: 0242
MODEL NAME: Comp1FlowDecay
SHORT DESCRIPTION: Models single compartment with inflowing and
outflowing concentration of a single substance which undergoes decay.
Does not use physiological units.
*/
import nsrunit; unit conversion on;
math Comp1FlowDecay {
// INDEPENDENT VARIABLE
realDomain t sec; t.min=0; t.max=40; t.delta=0.1;
// PARAMETERS
real C0 = 0 mM, // Initial Concentration
V = 0.05 ml, // Volume of compartment
F = 0.01 ml/sec, // Flow rate (volume per second)
G = 0.01 ml/sec; // Consumption rate of C, defined as a clearance,
// or the flow of fluid cleared of C per unit time
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 compartment instantaneously well mixed.
// INITIAL CONDITION
when(t = t.min) C=C0;
// ORDINARY DIFFERENTIAL EQUATION
C:t = (F/V)*(Cin-C)-(G/V)*C;
Cout = C;
// ADDITIONAL CALCULATIONS
// ANALYTIC SOLUTION FOR CONSTANT INFLOW CONCENTRATION
real Canalytic(t) mM;
Canalytic=((F*Cin)-(F*(Cin-C0)-G*C0)*exp(-(F+G)*t/V) )/(F+G);
// 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 = V*C;
when (t=t.min) Qint=V*C0;
Qint:t = F*(Cin-Cout)-G*C;
// AREA AND TRANSIT TIME OF INFLOW AND OUTFLOW CONCENTRATIONS
private real TCin(t) mM*sec^2, TCout(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; TCin = 0;
Area_out = 0; TCout = 0; }
Area_in:t = Cin; // Running integral of inflow concentration
Area_out:t = Cout; // Running integral of outflow concentration
TCin:t = Cin*t;
TCout:t = Cout*t;
Tbar_in = if(Area_in>0) TCin /Area_in else 0;
Tbar_out = if(Area_out>0) TCout/Area_out else 0;
Tbar_sys = Tbar_out-Tbar_in; // System transit time
} // End of code.
/* Diagram
+-----------------------------+
F*Cin ---> G (decay) C ---> F*Cout
(flow) | V(volume) | Cout = C
| instantaneously well mixed |
+-----------------------------+
DETAILED DESCRIPTION:
A Flow carries an inflow concentration, Cin, into a
one compartment model with a given Volume. Cin is constantly
and instantaneously well mixed becoming C, the concentration
in the compartment. C empties out of the compartment and is
designated Cout. G is a clearance rate.
For a constant concentration of inflowing material
the analytic solution is given.
SHORTCOMINGS/GENERAL COMMENTS:
- None.
KEY WORDS:
Course, compartment, compartmental, tutorial, flow, decay, clearance,
Comp1FlowDecay
REFERENCES: None.
REVISION HISTORY:
08/09/11 M. Herrmannsfeldt: Added analytic solution to
SteadyState plotpage. Other minor changes.
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
*/