1 
% $Id$ 
% $Id$ 
2 

% 
3 

% Copyright © 2006 by ACcESS MNRF 
4 

% \url{http://www.access.edu.au 
5 

% Primary Business: Queensland, Australia. 
6 

% Licensed under the Open Software License version 3.0 
7 

% http://www.opensource.org/licenses/osl3.0.php 
8 

% 
9 


10 
\section{The Diffusion Problem} 
\section{The Diffusion Problem} 
11 
\label{DIFFUSION CHAP} 
\label{DIFFUSION CHAP} 
12 


129 


130 
We want to use the \LinearPDE class provided by \escript to define and solve a general linear,steady, second order PDE such as the 
We want to use the \LinearPDE class provided by \escript to define and solve a general linear,steady, second order PDE such as the 
131 
Helmholtz equation. For a single PDE the \LinearPDE class supports the following form: 
Helmholtz equation. For a single PDE the \LinearPDE class supports the following form: 
132 
\begin{equation}\label{LINEARPDE.SINGLE.1} 
\begin{equation}\label{LINEARPDE.SINGLE.1 TUTORIAL} 
133 
(A\hackscore{jl} u\hackscore{,l})\hackscore{,j}+(B\hackscore{j} u)\hackscore{,j}+C\hackscore{l} u\hackscore{,l}+D u =X\hackscore{j,j}+Y \; . 
(A\hackscore{jl} u\hackscore{,l})\hackscore{,j}+D u = Y \; . 
134 
\end{equation} 
\end{equation} 
135 
The coefficients $A$, $B$, $C$, $D$, $X$ and $Y$ have to be specified through \Data objects in the 
where we show only the coefficients relevant for the problem discussed here. For the general form of 
136 

single PDE see \eqn{LINEARPDE.SINGLE.1}. 
137 

The coefficients $A$, and $Y$ have to be specified through \Data objects in the 
138 
\Function on the PDE or objects that can be converted into such \Data objects. 
\Function on the PDE or objects that can be converted into such \Data objects. 
139 
$A$ is a \RankTwo, $B$, $C$ and $X$ are \RankOne and $D$ and $Y$ are scalar. 
$A$ is a \RankTwo and $D$ and $Y$ are scalar. 
140 
The following natural 
The following natural 
141 
boundary conditions are considered \index{boundary condition!natural} on $\Gamma$: 
boundary conditions are considered \index{boundary condition!natural} on $\Gamma$: 
142 
\begin{equation}\label{LINEARPDE.SINGLE.2} 
\begin{equation}\label{LINEARPDE.SINGLE.2 TUTORIAL} 
143 
n\hackscore{j}(A\hackscore{jl} u\hackscore{,l}+B\hackscore{j} u)+d u=n\hackscore{j}X\hackscore{j} + y \;. 
n\hackscore{j}A\hackscore{jl} u\hackscore{,l}+d u= y \;. 
144 
\end{equation} 
\end{equation} 
145 
Notice that the coefficients $A$, $B$ and $X$ are the same like in the PDE~\eqn{LINEARPDE.SINGLE.1}. The coefficients $d$ and $y$ are 
Notice that the coefficient $A$ is the same like in the PDE~\eqn{LINEARPDE.SINGLE.1 TUTORIAL}. 
146 

The coefficients $d$ and $y$ are 
147 
each a \Scalar in the \FunctionOnBoundary. Constraints \index{constraint} for the solution prescribing the value of the 
each a \Scalar in the \FunctionOnBoundary. Constraints \index{constraint} for the solution prescribing the value of the 
148 
solution at certain locations in the domain. They have the form 
solution at certain locations in the domain. They have the form 
149 
\begin{equation}\label{LINEARPDE.SINGLE.3} 
\begin{equation}\label{LINEARPDE.SINGLE.3 TUTORIAL} 
150 
u=r \mbox{ where } q>0 
u=r \mbox{ where } q>0 
151 
\end{equation} 
\end{equation} 
152 
$r$ and $q$ are each \Scalar where $q$ is the characteristic function 
$r$ and $q$ are each \Scalar where $q$ is the characteristic function 
153 
\index{characteristic function} defining where the constraint is applied. 
\index{characteristic function} defining where the constraint is applied. 
154 
The constraints defined by \eqn{LINEARPDE.SINGLE.3} override any other condition set by \eqn{LINEARPDE.SINGLE.1} 
The constraints defined by \eqn{LINEARPDE.SINGLE.3 TUTORIAL} override any other condition set by 
155 
or \eqn{LINEARPDE.SINGLE.2}. 
\eqn{LINEARPDE.SINGLE.1 TUTORIAL} or \eqn{LINEARPDE.SINGLE.2 TUTORIAL}. 
156 
The \Poisson class of the \linearPDEs module, 
The \Poisson class of the \linearPDEs module, 
157 
which we have already used in \Chap{FirstSteps}, is in fact a subclass of the more general 
which we have already used in \Chap{FirstSteps}, is in fact a subclass of the more general 
158 
\LinearPDE class. The \linearPDEs module provides a \Helmholtz class but 
\LinearPDE class. The \linearPDEs module provides a \Helmholtz class but 
175 
it is more efficient to leave a coefficient undefined instead of assigning zero to it.} 
it is more efficient to leave a coefficient undefined instead of assigning zero to it.} 
176 
In this diffusion example we do not need to define a characteristic function $q$ because the 
In this diffusion example we do not need to define a characteristic function $q$ because the 
177 
boundary conditions we consider in \eqn{DIFFUSION HELM EQ 2} are just the natural boundary 
boundary conditions we consider in \eqn{DIFFUSION HELM EQ 2} are just the natural boundary 
178 
conditions which are already defined in the \LinearPDE class (shown in \eqn{LINEARPDE.SINGLE.2}). 
conditions which are already defined in the \LinearPDE class (shown in \eqn{LINEARPDE.SINGLE.2 TUTORIAL}). 
179 


180 
Defining and solving the Helmholtz equation is very easy now: 
Defining and solving the Helmholtz equation is very easy now: 
181 
\begin{python} 
\begin{python} 
204 
\end{python} 
\end{python} 
205 
In some cases the solver of the PDE can make use of the fact that the PDE is symmetric\index{symmetric PDE} where the 
In some cases the solver of the PDE can make use of the fact that the PDE is symmetric\index{symmetric PDE} where the 
206 
PDE is called symmetric if 
PDE is called symmetric if 
207 
\begin{equation}\label{LINEARPDE.SINGLE.4} 
\begin{equation}\label{LINEARPDE.SINGLE.4 TUTORIAL} 
208 
A\hackscore{jl}=A\hackscore{lj} \mbox{ and } B\hackscore{j}=C\hackscore{j} \;. 
A\hackscore{jl}=A\hackscore{lj}\;. 
209 
\end{equation} 
\end{equation} 
210 
Note that $D$ and $d$ may have any value and the right hand side $X$, $Y$, $y$ as well as the constraints 
Note that $D$ and $d$ may have any value and the right hand sides $Y$, $y$ as well as the constraints 
211 
are not relevant. The Helmholtz problem is symmetric. 
are not relevant. The Helmholtz problem is symmetric. 
212 
The \LinearPDE class provides the method \method{checkSymmetry} method to check if the given PDE is symmetric. 
The \LinearPDE class provides the method \method{checkSymmetry} method to check if the given PDE is symmetric. 
213 
\begin{python} 
\begin{python} 