source: documentation/AnuGA_user_manual.tex @ 2289

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

Tidy tidy

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