/* MODEL NUMBER: 0237
MODEL NAME: Comp1FlowReaction
SHORT DESCRIPTION: In a single compartment with flow, substrates C and D
convert to each other using an equilibrium constraint.
*/
import nsrunit; unit conversion on;
math Comp1FlowReaction {
// INDEPENDENT VARIABLE
realDomain t sec; t.min=0; t.max=40; t.delta=0.1;
// PARAMETERS
real F = 1 ml/(g*min), // Flow
Kd = 1 dimensionless, // Equilibrium constant
kd2c = 0.5 sec^(-1), // Rate constant for D->C
kc2d = Kd*kd2c, // Rate constant for C->D
V = 0.05 ml/g, // Volume
C0 = 0 mM, // Initial concentration of C
D0 = 0.0 mM; // Initial concentration of D
extern real Cin(t) mM; // Inflow Concentration of C
// VARIABLES
real C(t) mM, // Time dependent concentration of C
D(t) mM, // Time dependent concentration of D
Cout(t) mM, // Outflow concentration of C
Dout(t) mM; // Outflow concentrations of D
// INITIAL CONDITIONS
when(t=t.min) {C = C0; D = D0;}
// ORDINARY DIFFERENTIAL EQUATIONS (ODE's)
C:t = (F/V)*(Cin-C) - kc2d*C + kd2c*D;
D:t = (F/V)*( -D) + kc2d*C - kd2c*D;
// NOTE: Cout=C and Dout=D because compartments are instantaneous well mixed.
Cout = C;
Dout = D;
// CALCULATIONS FOR MASS BALANCE
real Q(t) nanomol/g; // Amount of material in compartment
Q=V*(C+D);
real Qint(t) nanomol/g; // Amount of material from integral of inflow
// concentration minus outflow concentration
when(t=t.min) {Qint=V*(C+D);}
Qint:t = F*(Cin -(Cout+Dout) );
// CALCULATIONS FOR AREA, TRANSIT TIME, RELATIVE DISPERSION FOR
// INFLOW, OUTFLOW, AND SYSTEM
// Cin is the model input
choice STATISTICS ("Cout+Dout","Cout only","Dout only")=1;
private real S=STATISTICS;
private real Tout(t) = ( if (S=1 or S=2) Cout else 0)
+( if (S=1 or S=3) Dout else 0);
// 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 = Tout;
S2_in:t = Cin*t;
S2_out:t = Tout*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:
+-----------------------------+
F*Cin --> -->F*(Cout+Dout)
| C0 kc2d D0 |
| C----->D |
| <---- |
| kd2c |
| V |
| instantaneously well-mixed |
+-----------------------------+
DETAILED DESCRIPTION:
This is a one compartment model. F is flow, Cin is inflow
concentration, Cout and Dout are outflow concentrations, V
is volume, kc2d is the rate at which substance C is converted
to substance D, and kd2c is the rate at which substance D is
converted to substance C. C0 and D0 are the initial concentrations of
C and D respectively. The amount of material in the compartment
is calculated by multiplying the volume by the sum of the
concentrations and also by integrating the flow multiplying the
difference of what flows in minus what flows out. Statistics
about this system can be calculated on either the sum of Cout
plus Dout, or on either substance separately.
KEY WORDS: compartment, compartmental, one compartment,
single compartment, flow, reaction, conversion, Tutorial
REFERENCES:
Jacquez JA. Compartmental Analysis in Biology
and Medicine. Ann Arbor: University of Michigan Press, 1996.
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
*/