Figure 1: Conversion A->B: Default parameter set
The numeric and analytic solutions for A and B as
functions of time are plotted.
Figure 2: Error in NUmeric Calculations: Default
parameter set.
The error is calculated and plotted as a function of
time. Use other solvers (Solvers available from the
Run Time GUI under the Pages TAB. Try Euler with 1 step
for comparison.
/*MODEL NUMBER: 0231
MODEL NAME: CompReactionTutorial
SHORT DESCRIPTION: Models single compartment with
substance A irreversibly becoming substance B. */
import nsrunit; unit conversion on;
math CompReactionTutorial {
// INDEPENDENT VARIABLE
realDomain t s; t.min=0; t.max=3; t.delta=0.1;
// PARAMETERS
real A0 = 1 mM, // Initial concentration of A
B0 = 0.3 mM, // Initial concentration of B
V = 0.05 ml, // Volume
Ga2b = 5 ml/min; // Reaction rate for A->B
// VARIABLES
real A(t) mM, // Concentration of A
B(t) mM; // Concentration of B
// INITIAL CONDITIONS
when(t=t.min) {A=A0; B=B0;}// Note the use of brackets
// ORDINARY DIFFERENTIAL EQUATIONS
A:t = -(Ga2b/V)*A; // Decay equation for A
B:t = (Ga2b/V)*A; // Synthesis equation for B
// ANALYTIC SOLUTIONS from Maple(TM)
real analyticA(t) mM, analyticB(t) mM;
analyticA=A0*exp(-Ga2b*t/V);
analyticB=B0+A0*(1-exp(-Ga2b*t/V));
} // END
/*
FIGURE:
+--------------------------+
| |
| Ga2b |
| A --------> B |
| |
| V |
+--------------------------+
DETAILED DESCRIPTION:
This is a tutorial model for irreversible reaction of substance
A becoming substance B.
KEY WORDS:
Course, compartment, compartmental, tutorial, reaction, irreversible
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
*/