/* MODEL NUMBER: 0364
MODEL NAME: Diffusion1DpdeConsumption
SHORT DESCRIPTION: Diffusion in one dimension with asymmetrical consumption is modeled using a
partial differential equation.
*/
import nsrunit; unit conversion on;
math Diffusion1DpdeConsumption { // Diffusion in one region, no flow
// INDEPENDENT VARIABLES
real L=0.1 cm, Ndivx = 51;
realDomain x cm; x.min=0.0; x.max=L; x.ct=Ndivx;
realDomain t sec; t.min=0; t.max=16.0; t.delta=0.02;
// PARAMETERS
real D= 0.00001 cm^2/sec; // Diffusion coefficient
extern real C0(x) mM; // Initial distribution of Material
extern real Ctest(x) mM; // Test distribution of material
extern real G(x) sec^(-1);// Consumption
// DEPENDENT VARIABLE
real C(x,t) mM; // Concentration variable
// INITIAL CONDITION
when(t=t.min) {C=C0;}
// BOUNDARY CONDITIONS (no flux)
when(x=x.min) {C:x=0;}
when(x=x.max) {C:x=0;}
// PARTIAL DIFFERENTIAL EQUATION
C:t=D*C:x:x-G*C ;
}
/*
DETAILED DESCRIPTION:
This model illustrates using function generators to
generator an initial condition and a parameter that
are spatial functions in x. It also generates a
comparison function, Ctest, which shows that the
solution in the presence of consumption evolves into
a profile which is approximately Gaussian although the
mean has been shifted downstream.
The diffusion of a substance in one dimension over a finite
length is modeled. The solution is plotted as
(1) Contours in the x-t plane,
(2) As functions of distance at specific times, and
(3) As functions of time and specific locations.
The initial values are given as
C(x) = 5, 0.049<=x<=0.051,
C(x) = 0, x<0.049 or x>0.051.
The boundary conditions are the zero-flux condition
(boundaries are reflective).
The consumption in the model is controlled by the area of a Gaussian curve
centered at 1/4 the length from the entrance of the capillary. Set the
area to 1e-8 to remove the effect.
KEY WORDS: 1d, 1-d, 1D, 1-D, one dimension, diffusion, PDE, consumption,
function generator, optimize, no flux, boundary condition, tutorial
REFERENCES:
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-2011 University of Washington.
Contact Information:
The National Simulation Resource,
Director J. B. Bassingthwaighte,
Department of Bioengineering,
University of Washington, Seattle, WA
98195-5061
*/