source: documentation/AnuGA_user_manual.tex @ 2277

Last change on this file since 2277 was 2277, checked in by ole, 18 years ago

Updated program example format

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