/[escript]/trunk/doc/cookbook/example01.tex
ViewVC logotype

Diff of /trunk/doc/cookbook/example01.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3029 by ahallam, Fri May 21 02:01:37 2010 UTC revision 3308 by jfenwick, Tue Oct 26 03:24:54 2010 UTC
# Line 39  heat diffusion equation is derived can b Line 39  heat diffusion equation is derived can b
39  http://online.redwoods.edu/instruct/darnold/DEProj/sp02/AbeRichards/paper.pdf}};  http://online.redwoods.edu/instruct/darnold/DEProj/sp02/AbeRichards/paper.pdf}};
40  which is defined as:  which is defined as:
41  \begin{equation}  \begin{equation}
42  \rho c\hackscore p \frac{\partial T}{\partial t} - \kappa \frac{\partial^{2}  \rho c_p \frac{\partial T}{\partial t} - \kappa \frac{\partial^{2}
43  T}{\partial x^{2}} = q\hackscore H  T}{\partial x^{2}} = q_H
44  \label{eqn:hd}  \label{eqn:hd}
45  \end{equation}  \end{equation}
46  where $\rho$ is the material density, $c\hackscore p$ is the specific heat and  where $\rho$ is the material density, $c_p$ is the specific heat and
47  $\kappa$ is the thermal  $\kappa$ is the thermal
48  conductivity\footnote{A list of some common thermal conductivities is available  conductivity\footnote{A list of some common thermal conductivities is available
49  from Wikipedia  from Wikipedia
# Line 51  from Wikipedia Line 51  from Wikipedia
51  assume that these material  assume that these material
52  parameters are \textbf{constant}.  parameters are \textbf{constant}.
53  The heat source is defined by the right hand side of \refEq{eqn:hd} as  The heat source is defined by the right hand side of \refEq{eqn:hd} as
54  $q\hackscore{H}$; this can take the form of a constant or a function of time and  $q_{H}$; this can take the form of a constant or a function of time and
55  space. For example $q\hackscore{H} = q\hackscore{0}e^{-\gamma t}$ where we have  space. For example $q_{H} = q_{0}e^{-\gamma t}$ where we have
56  the output of our heat source decaying with time. There are also two partial  the output of our heat source decaying with time. There are also two partial
57  derivatives in \refEq{eqn:hd}; $\frac{\partial T}{\partial t}$ describes the  derivatives in \refEq{eqn:hd}; $\frac{\partial T}{\partial t}$ describes the
58  change in temperature with time while $\frac{\partial ^2 T}{\partial x^2}$ is  change in temperature with time while $\frac{\partial ^2 T}{\partial x^2}$ is
# Line 99  T^{(n)} & = & T(t^{(n-1)}) \\ Line 99  T^{(n)} & = & T(t^{(n-1)}) \\
99  \end{equation}  \end{equation}
100  Substituting \refEq{eqn:Tbeuler} into \refEq{eqn:hd} we get;  Substituting \refEq{eqn:Tbeuler} into \refEq{eqn:hd} we get;
101  \begin{equation}  \begin{equation}
102  \frac{\rho c\hackscore p}{h} (T^{(n)} - T^{(n-1)}) - \kappa \frac{\partial^{2}  \frac{\rho c_p}{h} (T^{(n)} - T^{(n-1)}) - \kappa \frac{\partial^{2}
103  T^{(n)}}{\partial x^{2}} = q\hackscore H  T^{(n)}}{\partial x^{2}} = q_H
104  \label{eqn:hddisc}  \label{eqn:hddisc}
105  \end{equation}  \end{equation}
106  Notice that we evaluate the spatial derivative term at the current time  Notice that we evaluate the spatial derivative term at the current time
# Line 135  this introduction we illustrate a simple Line 135  this introduction we illustrate a simple
135  linear PDEs which is available in the \esc user's guide. A simplified form that  linear PDEs which is available in the \esc user's guide. A simplified form that
136  suits our heat diffusion problem\footnote{The form in the \esc users guide which  suits our heat diffusion problem\footnote{The form in the \esc users guide which
137  uses the Einstein convention is written as  uses the Einstein convention is written as
138  $-(A\hackscore{jl} u\hackscore{,l})\hackscore{,j}+D u =Y$}  $-(A_{jl} u_{,l})_{,j}+D u =Y$}
139  is described by;  is described by;
140  \begin{equation}\label{eqn:commonform nabla}  \begin{equation}\label{eqn:commonform nabla}
141  -\nabla\cdot(A\cdot\nabla u) + Du = f  -\nabla\cdot(A\cdot\nabla u) + Du = f
# Line 156  if $A$ is constant. To match this simpli Line 156  if $A$ is constant. To match this simpli
156  \refEq{eqn:hddisc}  \refEq{eqn:hddisc}
157  we rearrange \refEq{eqn:hddisc};  we rearrange \refEq{eqn:hddisc};
158  \begin{equation}  \begin{equation}
159  \frac{\rho c\hackscore p}{h} T^{(n)} - \kappa \frac{\partial^2 T^{(n)}}{\partial  \frac{\rho c_p}{h} T^{(n)} - \kappa \frac{\partial^2 T^{(n)}}{\partial
160  x^2} = q\hackscore H +  \frac{\rho c\hackscore p}{h} T^{(n-1)}  x^2} = q_H +  \frac{\rho c_p}{h} T^{(n-1)}
161  \label{eqn:hdgenf}  \label{eqn:hdgenf}
162  \end{equation}  \end{equation}
163  The PDE is now in a form that satisfies \refEq{eqn:commonform nabla} which is  The PDE is now in a form that satisfies \refEq{eqn:commonform nabla} which is
# Line 170  Finally, by comparing \refEq{eqn:hdgenf} Line 170  Finally, by comparing \refEq{eqn:hdgenf}
170  that;  that;
171  \begin{equation}\label{ESCRIPT SET}  \begin{equation}\label{ESCRIPT SET}
172  u=T^{(n)};  u=T^{(n)};
173  A = \kappa; D = \frac{\rho c \hackscore{p}}{h}; f = q \hackscore{H} + \frac{\rho  A = \kappa; D = \frac{\rho c _{p}}{h}; f = q _{H} + \frac{\rho
174  c\hackscore p}{h} T^{(n-1)}  c_p}{h} T^{(n-1)}
175  \end{equation}  \end{equation}
176    
177  \subsection{Boundary Conditions}  \subsection{Boundary Conditions}
# Line 208  The $\cdot$ (dot) refers to the dot prod Line 208  The $\cdot$ (dot) refers to the dot prod
208  In fact, the term $\nabla T \cdot n$ is the normal derivative of  In fact, the term $\nabla T \cdot n$ is the normal derivative of
209  the temperature $T$. Other notations used here are\footnote{The \esc notation  the temperature $T$. Other notations used here are\footnote{The \esc notation
210  for the normal  for the normal
211  derivative is $T\hackscore{,i} n\hackscore i$.};  derivative is $T_{,i} n_i$.};
212  \begin{equation}  \begin{equation}
213  \nabla T \cdot n  = \frac{\partial T}{\partial n} \; .  \nabla T \cdot n  = \frac{\partial T}{\partial n} \; .
214  \end{equation}  \end{equation}
# Line 233  the user may modify where appropriate. Line 233  the user may modify where appropriate.
233  For a problem of the form in~\refEq{eqn:commonform nabla} the default  For a problem of the form in~\refEq{eqn:commonform nabla} the default
234  condition\footnote{In the \esc user guide which uses the Einstein convention  condition\footnote{In the \esc user guide which uses the Einstein convention
235  this is written as  this is written as
236  $n\hackscore{j}A\hackscore{jl} u\hackscore{,l}=0$.} is;  $n_{j}A_{jl} u_{,l}=0$.} is;
237  \begin{equation}\label{NEUMAN 2}  \begin{equation}\label{NEUMAN 2}
238  -n\cdot A \cdot\nabla u = 0  -n\cdot A \cdot\nabla u = 0
239  \end{equation}  \end{equation}
# Line 392  two components $\nabla = (\frac{\partial Line 392  two components $\nabla = (\frac{\partial
392  y})$. Assuming the coefficient $A$ is constant, the \refEq{eqn:commonform nabla}  y})$. Assuming the coefficient $A$ is constant, the \refEq{eqn:commonform nabla}
393  takes the following form;  takes the following form;
394  \begin{equation}\label{eqn:commonform2D}  \begin{equation}\label{eqn:commonform2D}
395  -A\hackscore{00}\frac{\partial^{2}u}{\partial x^{2}}  -A_{00}\frac{\partial^{2}u}{\partial x^{2}}
396  -A\hackscore{01}\frac{\partial^{2}u}{\partial x\partial y}  -A_{01}\frac{\partial^{2}u}{\partial x\partial y}
397  -A\hackscore{10}\frac{\partial^{2}u}{\partial y\partial x}  -A_{10}\frac{\partial^{2}u}{\partial y\partial x}
398  -A\hackscore{11}\frac{\partial^{2}u}{\partial y^{2}}  -A_{11}\frac{\partial^{2}u}{\partial y^{2}}
399  + Du = f  + Du = f
400  \end{equation}  \end{equation}
401  Notice that for the higher dimensional case $A$ becomes a matrix. It is also  Notice that for the higher dimensional case $A$ becomes a matrix. It is also
# Line 404  a compact formulation which is also inde Line 404  a compact formulation which is also inde
404  To make the general PDE \refEq{eqn:commonform2D} one dimensional as  To make the general PDE \refEq{eqn:commonform2D} one dimensional as
405  shown in \refEq{eqn:commonform} we need to set  shown in \refEq{eqn:commonform} we need to set
406  \begin{equation}  \begin{equation}
407  A\hackscore{00}=A; A\hackscore{01}=A\hackscore{10}=A\hackscore{11}=0  A_{00}=A; A_{01}=A_{10}=A_{11}=0
408  \end{equation}  \end{equation}
409    
410    
# Line 520  In many cases it may be possible to decr Line 520  In many cases it may be possible to decr
520  solver if the PDE is symmetric.  solver if the PDE is symmetric.
521  Symmetry of a PDE is defined by;  Symmetry of a PDE is defined by;
522  \begin{equation}\label{eqn:symm}  \begin{equation}\label{eqn:symm}
523  A\hackscore{jl}=A\hackscore{lj}  A_{jl}=A_{lj}
524  \end{equation}  \end{equation}
525  Symmetry is only dependent on the $A$ coefficient in the general form and the  Symmetry is only dependent on the $A$ coefficient in the general form and the
526  other coefficients $D$ as well as the right hand side $Y$. From the above  other coefficients $D$ as well as the right hand side $Y$. From the above
# Line 533  myPDE.setSymmetryOn() Line 533  myPDE.setSymmetryOn()
533  Next we need to establish the initial temperature distribution \verb|T|. We need  Next we need to establish the initial temperature distribution \verb|T|. We need
534  to  to
535  assign the value \verb|T1| to all sample points left to the contact interface at  assign the value \verb|T1| to all sample points left to the contact interface at
536  $x\hackscore{0}=\frac{mx}{2}$  $x_{0}=\frac{mx}{2}$
537  and the value \verb|T2| right to the contact interface. \esc  and the value \verb|T2| right to the contact interface. \esc
538  provides the \verb|whereNegative| function to construct this. More  provides the \verb|whereNegative| function to construct this. More
539  specifically, \verb|whereNegative| returns the value $1$ at those sample points  specifically, \verb|whereNegative| returns the value $1$ at those sample points
540  where the argument has a negative value. Otherwise zero is returned.  where the argument has a negative value. Otherwise zero is returned.
541  If \verb|x| are the $x\hackscore{0}$  If \verb|x| are the $x_{0}$
542  coordinates of the sample points used to represent the temperature distribution  coordinates of the sample points used to represent the temperature distribution
543  then \verb|x[0]-boundloc| gives us a negative value for  then \verb|x[0]-boundloc| gives us a negative value for
544  all sample points left to the interface and non-negative value to  all sample points left to the interface and non-negative value to
# Line 576  while t < tend: Line 576  while t < tend:
576      totE = integrate(rhocp*T) #get the total heat (energy) in the system      totE = integrate(rhocp*T) #get the total heat (energy) in the system
577  \end{python}  \end{python}
578  The last statement in this script calculates the total energy in the system as  The last statement in this script calculates the total energy in the system as
579  the volume integral of $\rho c\hackscore{p} T$ over the block.  the volume integral of $\rho c_{p} T$ over the block.
580  As the blocks are insulated no energy should be lost or added.  As the blocks are insulated no energy should be lost or added.
581  The total energy should stay constant for the example discussed here.  The total energy should stay constant for the example discussed here.
582    
# Line 750  the temperature as a \pyt list of tuples Line 750  the temperature as a \pyt list of tuples
750  plotting function.  plotting function.
751  We need to convert the array \verb|x| previously set as  We need to convert the array \verb|x| previously set as
752  \verb|Solution(blocks).getX()| into a \pyt list  \verb|Solution(blocks).getX()| into a \pyt list
753  and then to a \numpy array. The $x\hackscore{0}$ component is then extracted via  and then to a \numpy array. The $x_{0}$ component is then extracted via
754  an array slice to the variable \verb|plx|;  an array slice to the variable \verb|plx|;
755  \begin{python}  \begin{python}
756  import numpy as np # array package.  import numpy as np # array package.

Legend:
Removed from v.3029  
changed lines
  Added in v.3308

  ViewVC Help
Powered by ViewVC 1.1.26