Figure 1: Steady State: Default parameter set
The steady state solution can be solved by either running the model
for a long time (so that the solutions do not change), or solving for
the steady state algebraically. Both calculations are available in this model.
Figure 1 shows the concentrations as a function of time (solid lines). The
dashed lines are the steady state results.
Figure 2: Quantity: Any Set of Parameters
The quantity is calculated by two methods,
Direct:
Q=V1*(A1+B1)+V2*(A2+B2)
and by the integral of the flow multiplying the inflowing
concentration minus the outflowing correction and subtracting
the integral of the consumption of B in the flowing compartment.
Table 1: No graph. Use Text tab: Any set of parameters.
PSa is set to zero. A Lagged Normal input function was used for
A1in. The expected transit time of the system, t_sys, is 1 sec.
The relative dispersion of the system, RD_sys, is 1. This
configuration of parameters is a single compartment model with
just flow.
/* MODEL NAME: AllProcessesTutorial
SHORT DESCRIPTION: A two compartmental model with flow, exchange, reaction
and decay for two species, A and B. */
import nsrunit; unit conversion on;
math AllProcessesTutorial {
// INDEPENDENT VARIABLE
realDomain t s; t.min=0; t.max=95; t.delta=0.1;
// PARAMETERS
real Flow = 3 ml/(g*min), // Flow, units are milliliters/((gram of tissue)*minute)
V1 = 0.05 ml/g, // Volume of flowing compartment
V2 = 0.15 ml/g, // Volume of compartment without flow
PSa = 3 ml/(g*min), // Passive exchange rate for A between V1 and V2
PSb = 3 ml/(g*min), // Passive exchange rate for B between V1 and V2
G1B = 3.0 ml/(g*min), // Decay rate for B in V1
Ga2b = 1.0 ml/(g*min), // Conversion rate for A becoming B in 2nd volume
A10 = 0 mM, // Initial concentration of A in V1
A20 = 0 mM, // Initial concentration of A in V2
B10 = 0 mM, // Initial concentration of B in V1
B20 = 0 mM; // Initial concentration of B in V2
extern real A1in(t) mM; // Inflow concentration of A into V1
// defined by function generator
// DEPENDENT VARIABLES
real A1(t) mM, // Concentration of A in V1
A2(t) mM, // Concentration of A in V2
B1(t) mM, // Concentration of B in V1
B2(t) mM, // Concentration of B in V2
A1out(t) mM, // Outflow concentration of A from V1
B1out(t) mM; // Outflow concentration of B from V1
// INITIAL CONDITIONS
when(t=t.min) {A1 = A10; A2 = A20; B1 = B10; B2 = B20; }
// ORDINARY DIFFERENTIAL EQUATIONS
A1:t = (Flow/V1)*(A1in-A1) + (PSa/V1)*(A2-A1);
A2:t = (PSa/V2)*(A1-A2) -(Ga2b/V2)*A2;
B1:t = (Flow/V1)*(0.0 -B1) + (PSb/V1)*(B2-B1) -(G1B/V1)*B1;
B2:t = (PSb/V2)*(B1-B2) +(Ga2b/V2)*A2;
A1out=A1;
B1out=B1;
// ADDITIONAL CALCULATIONS
// I. A STEADY STATE SOLUTION FOR CONSTANT INPUT
real ssA1 mM, ssA2 mM, ssB1 mM, ssB2 mM;
0 = (Flow/V1)*(A1in(t.max)-ssA1) + (PSa/V1)*(ssA2-ssA1);
0 = (PSa/V2)*(ssA1-ssA2) -(Ga2b/V2)*ssA2;
0 = (Flow/V1)*(0.0-ssB1) + (PSb/V1)*(ssB2-ssB1) -(G1B/V1)*ssB1;
0 = (PSb/V2)*(ssB1-ssB2) +(Ga2b/V2)*ssA2;
// II. QUANTITY OF MATERIAL IN COMPARTMENTS
real Q(t) nanomol/g; // Quantity by direct calculation
Q=V1*(A1+B1)+V2*(A2+B2);
real Qint(t) nanomol/g; // Quantity by difference method
when(t=t.min) {Qint=V1*(A1+B1)+V2*(A2+B2); }
Qint:t = Flow*((A1in)-(A1out+B1out)) -G1B*B1;
// III. CALCULATIONS FOR AREA, TRANSIT TIME, RELATIVE DISPERSION FOR
// INFLOW, OUTFLOW, AND SYSTEM
choice STATISTICS ("A+B","A only","B only")=1; // Choice Variable on computation
private real S=STATISTICS;
private real Tout(t) = ( if (S=1 or S=2) A1out else 0)
+( if (S=1 or S=3) B1out else 0); // Sum of Ouputs
private real Tin(t) = A1in;
private real S1_in(t) mM*sec, S2_in(t) mM*sec^2, S3_in(t) mM*sec^3,
S1_out(t) mM*sec, S2_out(t) mM*sec^2, S3_out(t) mM*sec^3;
when(t=t.min) {S1_in = 0; S2_in = 0; S3_in = 0;
S1_out = 0; S2_out = 0; S3_out = 0;}
real area_in mM*sec, // area of inflow concentration
area_out mM*sec, // area of outflow concentrations
t_in sec, // transit time of inflow concentration
t_out sec, // transit time of outflow concentrations
t_sys sec, // transit time of system
// Relative Dispersion is the square root of the variance divided by the transit time
RD_in, // Relative dispersion of inflow concentration
RD_out, // Relative dispersion of outflow concentrations
RD_sys; // Relative dispersion of system
S1_in:t = Tin; // integral to calculate area
S2_in:t = Tin*t; // integral to calculate mean transit time
S3_in:t = Tin*t*t; // integral to calculate variance
S1_out:t = (Tout);
S2_out:t = (Tout)*t;
S3_out:t = (Tout)*t*t;
area_in = S1_in(t.max);
area_out = S1_out(t.max);
t_in = if(area_in>0 ) S2_in(t.max) /area_in else 0;
t_out = if(area_out>0) S2_out(t.max)/area_out else 0;
RD_in = if( t_in>0 and ( (S3_in(t.max)/S2_in(t.max))/t_in)-1 >0 )
sqrt(abs((S3_in(t.max) /S2_in(t.max)) /t_in-1 ) ) else 0;
RD_out = if( t_out>0 and ( (S3_out(t.max)/S2_out(t.max))/t_out)-1>0 )
sqrt(abs((S3_out(t.max)/S2_out(t.max))/t_out-1 ) )else 0;
t_sys = t_out-t_in;
RD_sys = if(t_sys>0 and (RD_out*t_out)^2-(RD_in*t_in)^2 > 0)
sqrt( (RD_out*t_out)^2-(RD_in*t_in)^2 )/t_sys else 0;
} // End of model
/*
DIAGRAM:
Source +----------------------------------------+ Sinks
Flow*A1in --> A1, B1, V1, A10, B10 --> Flow*A1
| (Sink) -G1B/V1*B1 --> Flow*B1
| |
| Sink Source Sink Source |
+--- v ----- ^ ------ V ----- ^ ---------+
| | | |
Psa*A1 PSa*A2 PSb*B1 PSb*B2
| | | |
+--- v ----- ^ ------ V ----- ^ ---------+
| Source Sink Source Sink +
| |
| Ga2b--> |
| A2 --------> B2 |
| |
| V2, A20, B20 |
+----------------------------------------+
DETAILED DESCRIPTION:
This is a tutorial model for testing what you have learned
with the four models, CompDecayTutorial, CompFlowTutorial,
CompReactionTutorial, and CompExchangeReaction. It is
recommended that you write the complete set of equations
identifying the sources and sinks, before you look at the solution.
SHORTCOMINGS/GENERAL COMMENTS:
- None.
KEY WORDS:
Course, compartment, compartmental, tutorial, flow, exchange,
reaction, decay, AllProcessesTutorial
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
*/