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

revision 2337 by gross, Thu Mar 26 07:07:42 2009 UTC revision 2548 by jfenwick, Mon Jul 20 06:20:06 2009 UTC
# Line 1  Line 1
1
2  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3  %  %
4  % Copyright (c) 2003-2008 by University of Queensland  % Copyright (c) 2003-2009 by University of Queensland
5  % Earth Systems Science Computational Center (ESSCC)  % Earth Systems Science Computational Center (ESSCC)
6  % http://www.uq.edu.au/esscc  % http://www.uq.edu.au/esscc
7  %  %
# Line 21  In this chapter we give an introduction Line 21  In this chapter we give an introduction
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}
22  is more than sufficient.  is more than sufficient.
23
24  The PDE \index{partial differential equation} we wish to solve i  s the Poisson equation \index{Poisson equation}  The PDE \index{partial differential equation} we wish to solve is the Poisson equation \index{Poisson equation}
25
26  -\Delta u =f  -\Delta u =f
27  \label{eq:FirstSteps.1}  \label{eq:FirstSteps.1}
# Line 33  is the unit square Line 33  is the unit square
33  \label{eq:FirstSteps.1b}  \label{eq:FirstSteps.1b}
34
35  The domain is shown in \fig{fig:FirstSteps.1}.  The domain is shown in \fig{fig:FirstSteps.1}.
36  \begin{figure} [h!]  \begin{figure} [ht]
37  \centerline{\includegraphics[width=\figwidth]{figures/FirstStepDomain}}  \centerline{\includegraphics[width=\figwidth]{figures/FirstStepDomain}}
38  \caption{Domain $\Omega=[0,1]^2$ with outer normal field $n$.}  \caption{Domain $\Omega=[0,1]^2$ with outer normal field $n$.}
39  \label{fig:FirstSteps.1}  \label{fig:FirstSteps.1}
# Line 128  problem\index{boundary value problem} (B Line 128  problem\index{boundary value problem} (B
128  the unknown function~$u$.  the unknown function~$u$.
129
130
131  \begin{figure}[h]  \begin{figure}[ht]
132  \centerline{\includegraphics[width=\figwidth]{figures/FirstStepMesh}}  \centerline{\includegraphics[width=\figwidth]{figures/FirstStepMesh}}
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
# Line 153  elements is called a mesh\index{finite e Line 153  elements is called a mesh\index{finite e
153  method!mesh}. \fig{fig:FirstSteps.2} shows an  method!mesh}. \fig{fig:FirstSteps.2} shows an
154  example of a FEM mesh with four elements in the $x_0$ and four elements  example of a FEM mesh with four elements in the $x_0$ and four elements
155  in the $x_1$ direction over the unit square.    in the $x_1$ direction over the unit square.
156  For more details we refer the reader to the literature, for instance  For more details we refer the reader to the literature, for instance \Ref{Zienc,NumHand}.
157  \Ref{Zienc,NumHand}.
158    The \escript solver we want to use to solve this problem is embedded into the python interpreter language. So you can solve the problem interactively but you will learn quickly
159    that is more efficient to use scripts which you can edit with your favorite editor.
160    To enter the escript environment you use \program{escript} command\footnote{\program{escript} is not available under Windows yet. If you run under windows you can just use the
161    \program{python} command and the \env{OMP_NUM_THREADS} environment variable to control the number
163    \begin{verbatim}
164      escript
165    \end{verbatim}
166    which will pass you on to the python prompt
167    \begin{verbatim}
168    Python 2.5.2 (r252:60911, Oct  5 2008, 19:29:17)
169    [GCC 4.3.2] on linux2
171    >>>
172    \end{verbatim}
173    Here you can use all available python commands and language features, for instance
174    \begin{python}
175     >>> x=2+3
176    >>> print "2+3=",x
177    2+3= 5
178    \end{python}
179    We refer to the python users guide if you not familiar with python.
180
181  \escript provides the class \Poisson to define a Poisson equation \index{Poisson equation}.  \escript provides the class \Poisson to define a Poisson equation \index{Poisson equation}.
182  (We will discuss a more general form of a PDE \index{partial differential equation!PDE}  (We will discuss a more general form of a PDE \index{partial differential equation!PDE}
# Line 293  The entire code is available as \file{po Line 315  The entire code is available as \file{po
315
316  The last statement writes the solution (tagged with the name "sol") to a file named \file{u.xml} in  The last statement writes the solution (tagged with the name "sol") to a file named \file{u.xml} in
317  \VTK file format.  \VTK file format.
318  Now you may run the script and visualize the solution using \mayavi:  Now you may run the script using the \escript environment
319    and visualize the solution using \mayavi:
320  \begin{verbatim}  \begin{verbatim}
321    python poisson.py    escript poisson.py
322    mayavi -d u.xml -m SurfaceMap    mayavi -d u.xml -m SurfaceMap
323  \end{verbatim}  \end{verbatim}
324  See \fig{fig:FirstSteps.3}.  See \fig{fig:FirstSteps.3}.

Legend:
 Removed from v.2337 changed lines Added in v.2548