15 |
\section{The First Steps} |
\section{The First Steps} |
16 |
\label{FirstSteps} |
\label{FirstSteps} |
17 |
|
|
18 |
\begin{figure} |
|
|
\centerline{\includegraphics[width=\figwidth]{figures/FirstStepDomain}} |
|
|
\caption{Domain $\Omega=[0,1]^2$ with outer normal field $n$.} |
|
|
\label{fig:FirstSteps.1} |
|
|
\end{figure} |
|
19 |
|
|
20 |
In this chapter we give an introduction how to use \escript to solve |
In this chapter we give an introduction how to use \escript to solve |
21 |
a partial differential equation \index{partial differential equation} (PDE \index{partial differential equation!PDE}). We assume you are at least a little familiar with Python. The knowledge presented at the Python tutorial at \url{http://docs.python.org/tut/tut.html} |
a partial differential equation \index{partial differential equation} (PDE \index{partial differential equation!PDE}). We assume you are at least a little familiar with Python. The knowledge presented at the Python tutorial at \url{http://docs.python.org/tut/tut.html} |
33 |
\label{eq:FirstSteps.1b} |
\label{eq:FirstSteps.1b} |
34 |
\end{equation} |
\end{equation} |
35 |
The domain is shown in \fig{fig:FirstSteps.1}. |
The domain is shown in \fig{fig:FirstSteps.1}. |
36 |
|
\begin{figure} [h!] |
37 |
|
\centerline{\includegraphics[width=\figwidth]{figures/FirstStepDomain}} |
38 |
|
\caption{Domain $\Omega=[0,1]^2$ with outer normal field $n$.} |
39 |
|
\label{fig:FirstSteps.1} |
40 |
|
\end{figure} |
41 |
|
|
42 |
$\Delta$ denotes the Laplace operator\index{Laplace operator}, which is defined by |
$\Delta$ denotes the Laplace operator\index{Laplace operator}, which is defined by |
43 |
\begin{equation} |
\begin{equation} |
59 |
\end{equation*} |
\end{equation*} |
60 |
} |
} |
61 |
Basically, in the subindex of a function, any index to the left of the comma denotes a spatial derivative with respect |
Basically, in the subindex of a function, any index to the left of the comma denotes a spatial derivative with respect |
62 |
to the index. To get a more compact form we will write $w\hackscore{,ij}=(w\hackscore {,i})\hackscore{,j}$ |
to the index. To get a more compact form we will write $u\hackscore{,ij}=(u\hackscore {,i})\hackscore{,j}$ |
63 |
which leads to |
which leads to |
64 |
\begin{equation} |
\begin{equation} |
65 |
\Delta u = u\hackscore{,00}+u\hackscore{,11}=\sum\hackscore{i=0}^2 u\hackscore{,ii} |
\Delta u = u\hackscore{,00}+u\hackscore{,11}=\sum\hackscore{i=0}^2 u\hackscore{,ii} |
98 |
$n\hackscore{i} u\hackscore{,i}= n\hackscore{0} u\hackscore{,0} + |
$n\hackscore{i} u\hackscore{,i}= n\hackscore{0} u\hackscore{,0} + |
99 |
n\hackscore{1} u\hackscore{,1}$. |
n\hackscore{1} u\hackscore{,1}$. |
100 |
\footnote{Some readers may familiar with the notation |
\footnote{Some readers may familiar with the notation |
101 |
\begin{equation*} |
$ |
102 |
\frac{\partial u}{\partial n} = n\hackscore{i} u\hackscore{,i} |
\frac{\partial u}{\partial n} = n\hackscore{i} u\hackscore{,i} |
103 |
\end{equation*} |
$ |
104 |
for the normal derivative.} |
for the normal derivative.} |
105 |
The Neumann boundary condition of \eqn{eq:FirstSteps.2} should be fulfilled on the |
The Neumann boundary condition of \eqn{eq:FirstSteps.2} should be fulfilled on the |
106 |
set $\Gamma^N$ which is the top and right edge of the domain: |
set $\Gamma^N$ which is the top and right edge of the domain: |
125 |
Dirichlet boundary condition in \eqn{eq:FirstSteps.2d} form a so |
Dirichlet boundary condition in \eqn{eq:FirstSteps.2d} form a so |
126 |
called boundary value |
called boundary value |
127 |
problem\index{boundary value problem} (BVP\index{boundary value problem!BVP}) for |
problem\index{boundary value problem} (BVP\index{boundary value problem!BVP}) for |
128 |
the unknown |
the unknown function~$u$. |
|
function $u$. |
|
129 |
|
|
130 |
|
|
131 |
\begin{figure} |
\begin{figure}[h] |
132 |
\centerline{\includegraphics[width=\figwidth]{figures/FirstStepMesh.eps}} |
\centerline{\includegraphics[width=\figwidth]{figures/FirstStepMesh.eps}} |
133 |
\caption{Mesh of $4 \time 4$ elements on a rectangular domain. Here |
\caption{Mesh of $4 \time 4$ elements on a rectangular domain. Here |
134 |
each element is a quadrilateral and described by four nodes, namely |
each element is a quadrilateral and described by four nodes, namely |
248 |
Similarly, \code{whereZero(x[1])} creates function which equals $1$ where \code{x[1]} is |
Similarly, \code{whereZero(x[1])} creates function which equals $1$ where \code{x[1]} is |
249 |
equal to zero and $0$ elsewhere. |
equal to zero and $0$ elsewhere. |
250 |
The sum of the results of \code{whereZero(x[0])} and \code{whereZero(x[1])} |
The sum of the results of \code{whereZero(x[0])} and \code{whereZero(x[1])} |
251 |
gives a function on the domain \var{mydomain} which is exactly positive where $x\hackscore{0}$ or $x\hackscore{1}$ is equal to zero. |
gives a function on the domain \var{mydomain} which is strictly positive where $x\hackscore{0}$ or $x\hackscore{1}$ is equal to zero. |
252 |
Note that \var{gammaD} has the same \Rank, \Shape and \FunctionSpace like \var{x0} used to define it. So from |
Note that \var{gammaD} has the same \Rank, \Shape and \FunctionSpace like \var{x0} used to define it. So from |
253 |
\begin{python} |
\begin{python} |
254 |
print gammaD.getRank(),gammaD.getShape(),gammaD.getFunctionSpace() |
print gammaD.getRank(),gammaD.getShape(),gammaD.getFunctionSpace() |