# Diff of /trunk/doc/user/diffusion.tex

revision 107 by jgs, Thu Jan 27 06:21:48 2005 UTC revision 121 by jgs, Fri May 6 04:26:16 2005 UTC
# Line 1  Line 1
1  % $Id$  % $Id$
2  \chapter{How to Solve A Diffusion Problem}  \section{The Diffusion Problem}
3  \label{DIFFUSION CHAP}  \label{DIFFUSION CHAP}
4
5  \begin{figure}  \begin{figure}
# Line 8  Line 8
8  \label{DIFFUSION FIG 1}  \label{DIFFUSION FIG 1}
9  \end{figure}  \end{figure}
10
11  \section{\label{DIFFUSION OUT SEC}Outline}  \subsection{\label{DIFFUSION OUT SEC}Outline}
12  In this chapter we will discuss how to solve the time dependent-temperature diffusion\index{diffusion equation} for  In this chapter we will discuss how to solve the time dependent-temperature diffusion\index{diffusion equation} for
13  a block of material. Within the block there is a heat source which drives the temperature diffusion.  a block of material. Within the block there is a heat source which drives the temperature diffusion.
14  On the surface, energy can radiate into the surrounding environment.  On the surface, energy can radiate into the surrounding environment.
# Line 22  The implementation of a Helmholtz equati Line 22  The implementation of a Helmholtz equati
22  In Section~\ref{DIFFUSION TRANS SEC} the solver of the Helmholtz equation is used to build a  In Section~\ref{DIFFUSION TRANS SEC} the solver of the Helmholtz equation is used to build a
23  solver for the temperature diffusion problem.  solver for the temperature diffusion problem.
24
25  \section{\label{DIFFUSION TEMP SEC}Temperature Diffusion}  \subsection{\label{DIFFUSION TEMP SEC}Temperature Diffusion}
26
27  The unknown temperature $T$ is a function of its location in the domain and time $t>0$. The governing equation  The unknown temperature $T$ is a function of its location in the domain and time $t>0$. The governing equation
28  in the interior of the domain is given by  in the interior of the domain is given by
# Line 100  this forms a boundary value problem that Line 100  this forms a boundary value problem that
100  As a first step to implement a solver for the temperature diffusion problem we will  As a first step to implement a solver for the temperature diffusion problem we will
101  first implement a solver for the  boundary value problem that has to be solved at each time step.  first implement a solver for the  boundary value problem that has to be solved at each time step.
102
103  \section{\label{DIFFUSION HELM SEC}Helmholtz Problem}  \subsection{\label{DIFFUSION HELM SEC}Helmholtz Problem}
104  The partial differential equation to be solved for $T^{(n)}$ has the form  The partial differential equation to be solved for $T^{(n)}$ has the form
105
106  \omega u  - (\kappa u\hackscore{,i})\hackscore{,i} = f  \omega u  - (\kappa u\hackscore{,i})\hackscore{,i} = f
# Line 177  class Helmholtz(LinearPDE): Line 177  class Helmholtz(LinearPDE):
177     def setValue(self,kappa=0,omega=1,f=0,eta=0,g=0)     def setValue(self,kappa=0,omega=1,f=0,eta=0,g=0)
178          ndim=self.getDim()          ndim=self.getDim()
179          kronecker=numarray.identity(ndim)          kronecker=numarray.identity(ndim)
180          self._setValue(A=kappa*kronecker,D=omega,Y=f,d=eta,y=g)          self._LinearPDE_setValue(A=kappa*kronecker,D=omega,Y=f,d=eta,y=g)
181  \end{python}  \end{python}
182  \code{class Helmholtz(linearPDE)} declares the new \class{Helmholtz} class as a subclass  \code{class Helmholtz(linearPDE)} declares the new \class{Helmholtz} class as a subclass
183  of \LinearPDE which we have imported in the first line of the script.  of \LinearPDE which we have imported in the first line of the script.
# Line 185  We add the method \method{setValue} to t Line 185  We add the method \method{setValue} to t
185  \method{setValue} method of the \LinearPDE class. The new method which has the  \method{setValue} method of the \LinearPDE class. The new method which has the
186  parameters of the Helmholtz \eqn{DIFFUSION HELM EQ 1} as arguments  parameters of the Helmholtz \eqn{DIFFUSION HELM EQ 1} as arguments
187  maps the parameters of the coefficients of the general PDE defined  maps the parameters of the coefficients of the general PDE defined
188  in \eqn{EQU.FEM.1}. We are actually using the \method{_setValue} of  in \eqn{EQU.FEM.1}. We are actually using the \method{_LinearPDE__setValue} of
189  the \LinearPDE class (notice the leeding underscoure).  the \LinearPDE class.
190  The coefficient \var{A} involves the Kronecker symbol. We use the  The coefficient \var{A} involves the Kronecker symbol. We use the
191  \numarray function \function{identity} which returns a square matrix with ones on the  \numarray function \function{identity} which returns a square matrix with ones on the
192  main diagonal and zeros off the main diagonal. The argument of \function{identity} gives the order of the matrix.  main diagonal and zeros off the main diagonal. The argument of \function{identity} gives the order of the matrix.
# Line 249  However most PDE packages use an iterati Line 249  However most PDE packages use an iterati
249  when a given tolerance has been reached. The default tolerance is $10^{-8}$. This value can be altered by using the  when a given tolerance has been reached. The default tolerance is $10^{-8}$. This value can be altered by using the
250  \method{setTolerance} of the \LinearPDE class.  \method{setTolerance} of the \LinearPDE class.
251
252  \section{The Transition Problem}  \subsection{The Transition Problem}
253  \label{DIFFUSION TRANS SEC}  \label{DIFFUSION TRANS SEC}
254  Now we are ready to solve the original time dependent problem. The main  Now we are ready to solve the original time dependent problem. The main
255  part of the script is the loop over time $t$ which takes the following form:  part of the script is the loop over time $t$ which takes the following form:
# Line 359  dx -edit diffusion.net & Line 359  dx -edit diffusion.net &
359  \end{verbatim}  \end{verbatim}
360  where \file{diffusion.net} is an \OpenDX script available in the \ExampleDirectory.  where \file{diffusion.net} is an \OpenDX script available in the \ExampleDirectory.
361  Use the \texttt{Sequencer} to move forward and and backwards in time.  Use the \texttt{Sequencer} to move forward and and backwards in time.
\fig{DIFFUSION FIG 2} shows the result for some selected time steps.
362    \fig{DIFFUSION FIG 2} shows the result for some selected time steps.

Legend:
 Removed from v.107 changed lines Added in v.121