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

trunk/doc/cookbook/onedheatdiff001.tex revision 2948 by gross, Thu Feb 25 04:54:30 2010 UTC trunk/doc/cookbook/example01.tex revision 2949 by gross, Thu Feb 25 05:23:11 2010 UTC
# Line 17  Line 17
17  \label{fig:onedgbmodel}  \label{fig:onedgbmodel}
18  \end{figure}  \end{figure}
19
20  \section{One Dimensional Heat Diffusion in Granite}  \section{Example 1: One Dimensional Heat Diffusion in Granite}
21  \label{Sec:1DHDv00}  \label{Sec:1DHDv00}
22
23  The first model consists of two blocks of isotropic material, for instance granite, sitting next to each other.  The first model consists of two blocks of isotropic material, for instance granite, sitting next to each other.
# Line 269  A\hackscore{00}=A; A\hackscore{01}=A\hac Line 269  A\hackscore{00}=A; A\hackscore{01}=A\hac
269
270  \subsection{Developing a PDE Solution Script}  \subsection{Developing a PDE Solution Script}
271  \label{sec:key}  \label{sec:key}
272  \sslist{onedheatdiffbase.py}  \sslist{example01a.py}
273  We will write a simple \pyt script which uses the \modescript, \modfinley and \modmpl modules.  We will write a simple \pyt script which uses the \modescript, \modfinley and \modmpl modules.
274  By developing a script for \esc, the heat diffusion equation can be solved at successive time steps for a predefined period using our general form \refEq{eqn:hdgenf}. Firstly it is necessary to import all the libraries\footnote{The libraries contain predefined scripts that are required to solve certain problems, these can be simple like sine and cosine functions or more complicated like those from our \esc library.}  By developing a script for \esc, the heat diffusion equation can be solved at successive time steps for a predefined period using our general form \refEq{eqn:hdgenf}. Firstly it is necessary to import all the libraries\footnote{The libraries contain predefined scripts that are required to solve certain problems, these can be simple like sine and cosine functions or more complicated like those from our \esc library.}
275  that we will require.  that we will require.
# Line 380  The total energy should stay constant fo Line 380  The total energy should stay constant fo
380
381  \subsection{Running the Script}  \subsection{Running the Script}
382  The script presented so for is available under  The script presented so for is available under
383  \verb|onedheatdiffbase.py|. You can edit this file with your favourite text editor.  \verb|example01a.py|. You can edit this file with your favourite text editor.
384  On most operating systems\footnote{The you can use \texttt{run-escript} launcher is not supported under {\it MS Windows} yet.} you can use the \program{run-escript} command  On most operating systems\footnote{The you can use \texttt{run-escript} launcher is not supported under {\it MS Windows} yet.} you can use the \program{run-escript} command
385  to launch {\it escript} scripts. For the example script use;  to launch {\it escript} scripts. For the example script use;
386  \begin{verbatim}  \begin{verbatim}
387  run-escript onedheatdiffbase.py  run-escript example01a.py
388  \end{verbatim}  \end{verbatim}
389  The program will print a progress report. Alternatively, you can use  The program will print a progress report. Alternatively, you can use
390  the python interpreter directly;  the python interpreter directly;
391  \begin{verbatim}  \begin{verbatim}
392  python onedheatdiffbase.py  python example01a.py
393  \end{verbatim}  \end{verbatim}
395
# Line 402  if the system is configured correctly (P Line 402  if the system is configured correctly (P
402  \end{figure}  \end{figure}
403
404  \subsection{Plotting the Total Energy}  \subsection{Plotting the Total Energy}
405  \sslist{onedheatdiff001.py}  \sslist{example01b.py}
406
407  \esc does not include its own plotting capabilities. However, it is possible to use a variety of free \pyt packages for visualisation.  \esc does not include its own plotting capabilities. However, it is possible to use a variety of free \pyt packages for visualisation.
408  Two types will be demonstrated in this cookbook; \mpl\footnote{\url{http://matplotlib.sourceforge.net/}} and \verb VTK \footnote{\url{http://www.vtk.org/}} visualisation.  Two types will be demonstrated in this cookbook; \mpl\footnote{\url{http://matplotlib.sourceforge.net/}} and \verb VTK \footnote{\url{http://www.vtk.org/}} visualisation.
# Line 455  As expected the total energy is constant Line 455  As expected the total energy is constant
455
456  \subsection{Plotting the Temperature Distribution}  \subsection{Plotting the Temperature Distribution}
457  \label{sec: plot T}  \label{sec: plot T}
458  \sslist{onedheatdiff001b.py}  \sslist{example01c.py}
459  For plotting the spatial distribution of the temperature we need to modify the strategy we have used  For plotting the spatial distribution of the temperature we need to modify the strategy we have used
460  for the total energy. Instead of producing a final plot at the end we will generate a  for the total energy. Instead of producing a final plot at the end we will generate a
461  picture at each time step which can be browsed as slide show or composed to a movie.  picture at each time step which can be browsed as slide show or composed to a movie.
# Line 478  There are two arguments to the \verb joi Line 478  There are two arguments to the \verb joi
478  \begin{verbatim}  \begin{verbatim}
479  save_path = "data"  save_path = "data"
480  \end{verbatim}  \end{verbatim}
481  while a sub-folder of \verb data  called \verb onedheatdiff001  would be defined by;  while a sub-folder of \verb data  called \verb example01  would be defined by;
482  \begin{verbatim}  \begin{verbatim}
483  save_path = os.path.join("data","onedheatdiff001")  save_path = os.path.join("data","example01")
484  \end{verbatim}  \end{verbatim}
485  The second argument of \verb join \xspace contains a string which is the file name or subdirectory name. We can use the operator \verb|%| to increment our file names with the value \verb|i| denoting a incrementing counter. The sub-string \verb %03d  does this by defining the following parameters;  The second argument of \verb join \xspace contains a string which is the file name or subdirectory name. We can use the operator \verb|%| to increment our file names with the value \verb|i| denoting a incrementing counter. The sub-string \verb %03d  does this by defining the following parameters;
486  \begin{itemize}  \begin{itemize}
# Line 556  Our saved plots from the previous sectio Line 556  Our saved plots from the previous sectio
556
557  os.system("mencoder mf://"+save_path+"/tempT"+"/*.png -mf type=png:\  os.system("mencoder mf://"+save_path+"/tempT"+"/*.png -mf type=png:\
558             w=800:h=600:fps=25 -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o \             w=800:h=600:fps=25 -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o \
559             onedheatdiff001tempT.avi")             example01tempT.avi")
560  \end{python}  \end{python}
561

Legend:
 Removed from v.2948 changed lines Added in v.2949