source: documentation/AnuGA_user_manual.tex @ 2355

Last change on this file since 2355 was 2355, checked in by ole, 19 years ago

test of conflicts

File size: 18.3 KB
Line 
1% Complete documentation on the extended LaTeX markup used for Python
2% documentation is available in ``Documenting Python'', which is part
3% of the standard documentation for Python.  It may be found online
4% at:
5%
6%     http://www.python.org/doc/current/doc/doc.html
7
8
9%\newcommand{\code}[1]{{\small \tt #1}} %For use with one-line code snippets
10       
11\documentclass{manual}
12
13\title{AnuGA User Manual}
14\author{Howard Silcock, Ole Nielsen, Duncan Gray, Jane Sexton}
15
16% Please at least include a long-lived email address;
17% the rest is at your discretion.
18\authoraddress{Geoscience Australia \\
19  Email: \email{ole.nielsen@ga.gov.au}
20}
21
22\date{2 February, 2006}         % update before release!
23                                % Use an explicit date so that reformatting
24                                % doesn't cause a new date to be used.  Setting
25                                % the date to \today can be used during draft
26                                % stages to make it easier to handle versions.
27
28\release{1.0}                   % release version; this is used to define the
29                                % \version macro
30
31\makeindex                      % tell \index to actually write the .idx file
32%\makemodindex                  % If this contains a lot of module sections.
33
34
35
36
37% Can we get rid of indenting and put a blank line before each para?
38% Find out how to change date format
39% Relabel sections, subsections
40Make conflict here
41%\setlength{\parindent}{0mm} %\setlength{\parskip}{3pt}
42%\setlength{\oddsidemargin}{0.6in}\setlength{\evensidemargin}{0.6in}
43%\addtolength{\textheight}{1in} \addtolength{\textwidth}{0.5in}
44%\setlength{\marginparwidth}{0in}
45%\setlength{\topmargin}{0mm}\setlength{\headheight}{0in}
46
47\begin{document}
48\maketitle
49
50% This makes the contents more accessible from the front page of the HTML.
51\ifhtml
52\chapter*{Front Matter\label{front}}
53\fi
54
55%Subversion keywords:
56%
57%$LastChangedDate: 2006-01-13 16:43:01 +1100 (Fri, 13 Jan 2006) $
58%$LastChangedRevision: 2206 $
59%$LastChangedBy: steve $
60
61
62\begin{abstract}
63
64\noindent
65\textbf{AnuGA}\index{AnuGA} is a hydrodynamic modelling tool that
66allows users to model realistic flow problems in complex geometries. Examples include dam breaks or   
67the effects of natural hazards such as riverine flooding, storm surges and tsunami.
68
69The user must specify a study area represented by a mesh of triangular
70cells, the topography and bathymetry, frictional resistance, initial
71values for water level (called \emph{stage}\index{stage} within Anuga),
72boundary
73conditions and forces such as windstress or pressure gradients if
74applicable.
75
76Anuga tracks the evolution of water depth and horizontal momentum
77within each cell over time by solving the shallow water wave equation
78governing equation using a finite-volume method.
79
80Anuga cannot model details of breaking waves, flow under ceilings such
81as pipes, turbulence and vortices, vertical convection or viscous
82flows.
83
84Anuga also incorporates a mesh generator, called \texttt{pmesh}, that
85allows the user to set up the geometry of the problem interactively as
86well as tools for interpolation and surface fitting, and a number of
87auxiliary tools for visualising and interrogating the model output.
88
89Most AnuGA components are written in the object-oriented programming
90language Python and most users will interact with Anuga by writing
91small Python programs based on the Anuga library
92functions. Computationally intensive components are written for
93efficiency in C routines working directly with the Numerical Python
94structures.
95
96
97\end{abstract}
98
99\tableofcontents
100
101
102\chapter{Introduction}
103
104
105\section{Purpose}
106
107The purpose of this user manual is to introduce the new user to
108the software, describe what it can do and give step-by-step
109instructions for setting up, configuring and running the software.
110
111\section{Scope}
112
113This manual covers only what is needed to operate the software
114after installation. It does not includes instructions for
115installing the software or detailed API documentation, both of
116which will be covered in separate publications.
117
118\section{Audience}
119
120Readers are assumed to be familiar with the operating environment
121and have a general understanding of the problem background, as
122well as enough programming experience to adapt the code to
123different requirements, as described in this manual,  and to
124understand the basic terminology of object-oriented programming.
125
126\section{Structure of This Manual}
127
128This manual is structured as follows:
129
130\begin{itemize}
131  \item Background (What Anuga does)
132  \item A \emph{Getting Started} section
133  \item Anuga's overall architecture, components and file formats
134  \item Detailed descriptions of the user interface
135\end{itemize}
136
137
138\pagebreak
139\chapter{Getting Started}
140
141This section is designed to assist the reader to get started with
142\textbf{AnuGA} by working through a simple example. What follows
143is a discussion of the structure and operation of the file
144\texttt{bedslope.py}, with just enough detail to allow the reader
145to appreciate what's involved in setting up a scenario like the
146one it depicts.
147
148\section{Overview}
149
150This example carries out the solution of the shallow-water wave
151equation in the simple case of a configuration comprising a flat
152bed, sloping at a fixed angle in one direction and having a
153constant depth across each line in the perpendicular direction.
154
155The example demonstrates many of the basic ideas involved in
156setting up a more complex scenario. In the general case the user
157specifies the geometry (bathymetry and topography), the initial
158water level, boundary conditions such as tide, and any forcing
159terms that may drive the system such as wind stress or atmospheric
160pressure gradients. Frictional resistance from the different
161terrains in the model is represented by predefined forcing
162terms. The boundary is reflective on three sides and a time dependent wave on one side.
163
164The present example, as it represents a simple scenario, does not
165include any forcing term, nor is the data taken from a file as it
166would be in many typical cases. The quantities involved in the
167present problem are:
168\begin{itemize}
169   \item elevation\index{elevation}
170   \item friction\index{friction}
171   \item depth\index{depth}
172   \item stage\index{stage}
173\end{itemize}
174
175%\emph{[More details of the problem background]}
176
177\section{Outline of the Program}
178
179In outline, \texttt{bedslope.py} performs the following steps:
180
181\begin{enumerate}
182
183   \item Sets up a triangular mesh.
184
185   \item Sets certain parameters governing the mode of
186operation of the model-specifying, for instance, where to store the model output.
187
188
189   \item Inputs various quantities describing physical measurements, such
190as the elevation, to be specified at each mesh point (vertex).
191
192   \item Sets up the boundary conditions.
193
194   \item Carries out the evolution of the model through a series of time
195steps and outputs the results, providing a results file that can
196be visualised.
197
198\end{enumerate}
199
200\section{The Code}
201
202%FIXME: we are using the \code function here. This should be used whereever possible
203For reference we include below the complete code listing for
204\code{bedslope.py}. Subsequent paragraphs provide a `commentary'
205that describes each step of the program and explains it significance.
206
207
208%\emph{[Can't work out how to prevent \LaTeX (or WinEdt) from
209%wrapping lines, even in \emph{verbatim} mode, without putting}
210%\verb+\\+\emph{s at the ends of lines!]}
211
212{\scriptsize \begin{verbatim}
213from pyvolution.mesh_factory import rectangular
214from pyvolution.shallow_water import Domain, Reflective_boundary,
215     Dirichlet_boundary, Time_boundary, Transmissive_boundary
216
217#Create basic mesh
218points, vertices, boundary = rectangular(10,10)
219
220#Create shallow water domain
221domain = Domain(points, vertices,boundary)
222domain.set_name('bedslope')
223
224
225#######################
226# Initial conditions
227def f(x,y):
228    return -x/2
229
230domain.set_quantity('elevation', f)
231domain.set_quantity('friction', 0.1)
232
233h = 0.05  # Constant depth
234domain.set_quantity('stage', expression = 'elevation + %f' %h)
235
236
237# Boundary conditions
238from math import sin, pi
239Br = Reflective_boundary(domain)
240Bt = Transmissive_boundary(domain)
241Bd = Dirichlet_boundary([0.2,0.,0.])
242
243Bw = Time_boundary(domain=domain,
244                   f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0])
245
246
247domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br})
248
249
250######################
251#Evolution
252
253domain.check_integrity()
254
255for t in domain.evolve(yieldstep = 0.1, finaltime = 4.0):
256    domain.write_time()
257
258
259\end{verbatim}}
260
261
262\section{Establishing the Mesh}
263
264The first task is to set up the triangular mesh to be used for the
265scenario. This is carried out through the statement:
266
267{\small \begin{verbatim}
268    points, vertices, boundary = rectangular(10, 10)
269\end{verbatim}}
270
271The function \texttt{rectangular} is imported from a module
272\texttt{mesh\_factory} defined elsewhere. (\textbf{AnuGA} also
273contains several other schemes that can be used for setting up
274meshes, but we shall not discuss these now.) The above assignment
275sets up a $10 \times 10$ rectangular mesh, triangulated in a
276specific way. In general, the assignment
277
278{\small \begin{verbatim}
279    points, vertices, boundary = rectangular(m, n)
280\end{verbatim}}
281
282returns:
283
284\begin{itemize}
285
286   \item a list \texttt{points} of length $N$, where $N = (m + 1)(n + 1)$,
287comprising the coordinates $(x, y)$ of each of the $N$ mesh
288points,
289
290   \item a list \texttt{vertices} of length $2mn$ (each entry specifies the three
291vertices of one of the triangles used in the triangulation) , and
292
293   \item a dictionary \texttt{boundary}, used to tag the triangle edges on
294the boundaries. Each key corresponds to a triangle edge on one of
295the four boundaries and its value is one of \texttt{`left'},
296\texttt{`right'}, \texttt{`top'} and \texttt{`bottom'}, indicating
297which boundary the edge in question belongs to.
298
299\end{itemize}
300
301
302\section{Initialising the domain}
303
304These variables are then used to set up a data structure
305\texttt{domain}, through the assignment:
306
307{\small \begin{verbatim}
308    domain = Domain(points, vertices, boundary)
309\end{verbatim}}
310
311This uses a Python class \texttt{Domain}, imported from
312\texttt{shallow\_water}, which is an extension of a more generic
313class of the same name in the module \texttt{domain}, and inherits
314some methods from the generic class but has others specific to the
315shallow-water scenarios in which it is used. Specific options for domain
316are set at this point. One of them are to set the basename for the output file
317
318{\scriptsize \begin{verbatim}
319    domain.set_name('bedslope')
320\end{verbatim}}
321
322
323\section{Specifying the Quantities}
324
325The next task is to specify a number of quantities that we wish to set
326for each mesh point. The class \texttt{Domain} has a method
327\texttt{set\_quantity}, used to specify these quantities. It is a
328particularly flexible method that allows the user to set quantities in
329a variety of ways---using constants, functions, numeric arrays or
330expressions involving other quantities, arbitrary data points with
331associated values, all of which can be passed as arguments. All
332quantities can be initialised using \texttt{set\_quantity}. For
333conserved quantities (\texttt{stage, xmomentum, ymomentum}) this is
334called the \emph{initial condition}, for other quantities that aren't
335updated by the equation, the same interface is used to assign their
336values. The code in the present example demonstrates a number of forms
337in which we can invoke \texttt{set\_quantity}.
338
339
340\subsection{Elevation}
341
342The elevation is set using a function, defined through the
343statements below, which is specific to this example and specifies
344a particularly simple initial configuration for demonstration
345purposes:
346
347{\small \begin{verbatim}
348    def f(x,y):
349        return -x/2
350\end{verbatim}}
351
352This simply associates an elevation with each point $(x, y)$ of
353the plane.  It specifies that the bed slopes linearly in the $x$
354direction, with slope $-\frac{1}{2}$,  and is constant in the $y$
355direction.\\ %[screen shot?]
356\\
357Once the function $f$ is specified, the quantity
358\texttt{elevation} is assigned through the simple statement:
359
360{\small \begin{verbatim}
361\begin{verbatim}
362    domain.set_quantity('elevation', f)
363\end{verbatim}}
364
365
366\subsection{Friction}
367
368The assignment of the friction quantity demonstrates another way
369we can use \texttt{set\_quantity} to set quantities---namely,
370assign them to a constant numerical value:
371
372{\small \begin{verbatim}
373    domain.set_quantity('friction', 0.1)
374\end{verbatim}}
375
376This just specifies that the Manning friction coefficient is set
377to 0.1 at every mesh point.
378
379\subsection{Depth}
380
381Assigning depth illustrates a more complex way to use
382\texttt{set\_quantity}, introducing an expression involving other
383quantities:
384
385{\small \begin{verbatim}
386    h = 0.05 \# Constant depth
387    domain.set_quantity('stage', expression = 'elevation + %f' %h)
388\end{verbatim}}
389
390Here the quantity \texttt{stage} is defined by taking the quantity
391elevation already defined and adding a constant value $h = 0.05$
392to it everywhere. This expresses the fact that the water depth is
393everywhere constant, so the surface is a constant height above the
394elevation of the bed.
395
396\subsection{Boundary Conditions}
397
398The boundary conditions are specified as follows:
399
400{\small \begin{verbatim}
401    Br = Reflective_boundary(domain)
402
403    Bt = Transmissive_boundary(domain)
404
405    Bd = Dirichlet_boundary([0.2,0.,0.])
406
407    Bw = Time_boundary(domain=domain,
408                f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0])
409\end{verbatim}}
410
411The effect of these statements is to set up four alternative
412boundary conditions and store them in variables that can be
413assigned as needed. Each boundary condition specifies the
414behaviour at a boundary in terms of the behaviour in neighbouring
415elements. The boundary conditions may be briefly described as
416follows:
417
418\begin{description}
419    \item[Reflective boundary] Returns same \texttt{stage} as
420    as present in its neighbour volume but momentum vector reversed 180 degrees (reflected).
421    Specific to the shallow water equation as it works with the
422    momentum quantities assumed to be the second and third conserved
423    quantities.
424    \item[Transmissive boundary]Returns same conserved quantities as
425    those present in its neighbour volume.
426    \item[Dirichlet boundary]Specifies a fixed value at the
427boundary.
428    \item[Time boundary.]A Dirichlet boundary whose behaviour varies with time.
429\end{description}
430
431Once the four boundary types have been specified through the
432statements above, they can be applied through a statement of the
433form
434
435{\small \begin{verbatim}
436    domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br})
437\end{verbatim}}
438
439This statement stipulates that, in the current example, the left
440boundary is fixed, with an elevation of 0.2, while the other
441boundaries are all reflective.
442
443
444\section{Evolution}
445
446The final statement \nopagebreak[3]
447{\small \begin{verbatim}
448    for t in domain.evolve(yieldstep = 0.1, finaltime = 4.0):
449        domain.write_time()
450\end{verbatim}}
451
452is the key step that causes the configuration of the domain to
453`evolve' in accordance with the model embodied in the code, over a
454series of steps indicated by the values of \texttt{yieldstep} and
455\texttt{finaltime}, which can be altered as required.
456The yieldstep control the time interval between model output. Behind the scenes more timesteps are generally taken.
457
458
459
460
461\section{Output}
462
463%Give details here of the form of the output and explain how it can
464%be used with swollen. Include screen shots.//
465
466The output is a NetCDF file with the extension \texttt{.sww}. It
467contains stage and momentum information and can be used with the
468\texttt{swollen} visualisation package to generate a visual display.
469
470
471\section{How to Run the Code}
472
473The code can be run in various ways:
474
475\begin{itemize}
476\item{from a Windows command line} as in \texttt{python bedslope.py}
477
478\item{within the Python IDLE environment}
479
480\item{within emacs}
481
482\item{from a Linux command line} as in \texttt{python bedslope.py}
483\end{itemize}
484
485
486
487
488\appendix
489\chapter{Glossary}
490
491\begin{description}
492
493    \item[AnuGA] name of software (joint development between ANU and GA)
494   
495    \item[Conserved quantity]   
496
497    \item[Default order] is this really needed?
498
499    \item[Domain]
500
501    \item[Dirichlet boundary]
502
503    \item[Elevation] - refers to bathymetry and topography
504
505    \item[bathymetry] offshore
506
507    \item[topography] onshore
508
509    \item[Evolution] integration of the shallow water wave equations over time
510
511    \item[Forcing term]
512
513    \item[IDLE] development environment shipped with Python
514
515    \item[Manning friction coefficient]
516   
517    \item[Mesh]    triangulation of domain
518
519    \item[Grid] evenly spaced
520
521    \item[NetCDF]
522
523    \item[pmesh] does this really need to be here? it's a class/module?
524
525    \item[pyvolution] does this really need to be here? it's a class/module?
526
527    \item[Quantity] conserved (state, x and y momentum)
528
529    \item[Reflective boundary]
530
531    \item[Smoothing] is this really needed?
532
533    \item[Stage]
534
535    \item[Swollen] visualisation tool
536
537    \item[Time boundary] defined in the manual (flog from there)
538
539    \item[Transmissive boundary] defined in the manual (flog from there)
540
541    \item[xmomentum] conserved quantity (note, two-dimensional SWW equations say only x and y and NOT z)
542   
543    \item[ymomentum]  conserved quantity
544
545    \item[resolution]   refers to the maximal area of each triangular cell in the mesh
546
547    \item[easting]   
548
549    \item[northing]   
550
551    \item[latitude]   
552
553    \item[longitude]   
554
555    \item[edge]   
556
557    \item[vertex] 
558 
559    \item[finite volume] 
560
561    \item[flux] 
562
563    \item[Digital Elevation Model (DEM)]   
564
565
566\end{description}
567
568The \code{\e appendix} markup need not be repeated for additional
569appendices.
570
571
572%
573%  The ugly "%begin{latexonly}" pseudo-environments are really just to
574%  keep LaTeX2HTML quiet during the \renewcommand{} macros; they're
575%  not really valuable.
576%
577%  If you don't want the Module Index, you can remove all of this up
578%  until the second \input line.
579%
580
581%begin{latexonly}
582%\renewcommand{\indexname}{Module Index}
583%end{latexonly}
584%\input{mod\jobname.ind}                % Module Index
585
586%begin{latexonly}
587\renewcommand{\indexname}{Index}
588%end{latexonly}
589\input{\jobname.ind}                    % Index
590
591
592
593\end{document}
Note: See TracBrowser for help on using the repository browser.