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 |
---|
32 | allows users to model realistic flow problems in complex geometries. Examples include dam breaks or |
---|
33 | the effects of natural hazards such as riverine flooding, storm surges and tsunami. |
---|
34 | |
---|
35 | The user must specify a study area represented by a mesh of triangular |
---|
36 | cells, the topography and bathymetry, frictional resistance, initial |
---|
37 | values for water level (called {\emph{stage} within Anuga), boundary |
---|
38 | conditions and forces such as windstress or pressure gradients if |
---|
39 | applicable. |
---|
40 | |
---|
41 | Anuga tracks the evolution of water depth and horizontal momentum |
---|
42 | within each cell over time by solving the shallow water wave equation |
---|
43 | governing equation using a finite-volume method. |
---|
44 | |
---|
45 | Anuga cannot model details of breaking waves, flow under ceilings such |
---|
46 | as pipes, turbulence and vortices, vertical convection or viscous |
---|
47 | flows. |
---|
48 | |
---|
49 | Anuga also incorporates a mesh generator, called \texttt{pmesh}, that |
---|
50 | allows the user to set up the geometry of the problem interactively as |
---|
51 | well as tools for interpolation and surface fitting, and a number of |
---|
52 | auxiliary tools for visualising and interrogating the model output. |
---|
53 | |
---|
54 | Most AnuGA components are written in the object-oriented programming |
---|
55 | language Python and most users will interact with Anuga by writing |
---|
56 | small Python programs based on the Anuga library |
---|
57 | functions. Computationally intensive components are written for |
---|
58 | efficiency in C routines working directly with the Numerical Python |
---|
59 | structures. |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | \subsection*{Purpose} |
---|
65 | |
---|
66 | The purpose of this user manual is to introduce the new user to |
---|
67 | the software, describe what it can do and give step-by-step |
---|
68 | instructions for setting up, configuring and running the software. |
---|
69 | |
---|
70 | \subsection*{Scope} |
---|
71 | |
---|
72 | This manual covers only what is needed to operate the software |
---|
73 | after installation. It does not includes instructions for |
---|
74 | installing the software or detailed API documentation, both of |
---|
75 | which will be covered in separate publications. |
---|
76 | |
---|
77 | \subsection*{Audience} |
---|
78 | |
---|
79 | Readers are assumed to be familiar with the operating environment |
---|
80 | and have a general understanding of the problem background, as |
---|
81 | well as enough programming experience to adapt the code to |
---|
82 | different requirements, as described in this manual, and to |
---|
83 | understand the basic terminology of object-oriented programming. |
---|
84 | |
---|
85 | \subsection*{Structure of This Manual} |
---|
86 | |
---|
87 | This 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 | |
---|
99 | This section is designed to assist the reader to get started with |
---|
100 | \textbf{AnuGA} by working through a simple example. What follows |
---|
101 | is a discussion of the structure and operation of the file |
---|
102 | \texttt{bedslope.py}, with just enough detail to allow the reader |
---|
103 | to appreciate what's involved in setting up a scenario like the |
---|
104 | one it depicts. |
---|
105 | |
---|
106 | \subsection*{Overview} |
---|
107 | |
---|
108 | This example carries out the solution of the shallow-water wave |
---|
109 | equation in the simple case of a configuration comprising a flat |
---|
110 | bed, sloping at a fixed angle in one direction and having a |
---|
111 | constant depth across each line in the perpendicular direction. |
---|
112 | |
---|
113 | The example demonstrates many of the basic ideas involved in |
---|
114 | setting up a more complex scenario. In the general case the user |
---|
115 | specifies the geometry (bathymetry and topography), the initial |
---|
116 | water level, boundary conditions such as tide, and any forcing |
---|
117 | terms that may drive the system such as wind stress or atmospheric |
---|
118 | pressure gradients. Frictional resistance from the different |
---|
119 | terrains in the model is represented by predefined forcing |
---|
120 | terms. The boundary is reflective on three sides and a time dependent wave on one side. |
---|
121 | |
---|
122 | The present example, as it represents a simple scenario, does not |
---|
123 | include any forcing term, nor is the data taken from a file as it |
---|
124 | would be in many typical cases. The quantities involved in the |
---|
125 | present 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 | |
---|
137 | In 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 |
---|
144 | operation of the model-specifying, for instance, where to store the model output. |
---|
145 | |
---|
146 | |
---|
147 | \item Inputs various quantities describing physical measurements, such |
---|
148 | as 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 |
---|
153 | steps and outputs the results, providing a results file that can |
---|
154 | be visualised. |
---|
155 | |
---|
156 | \end{enumerate} |
---|
157 | |
---|
158 | \subsection*{The Code} |
---|
159 | |
---|
160 | For reference we include below the complete code listing for |
---|
161 | \texttt{bedslope.py}. Subsequent paragraphs provide a `commentary' |
---|
162 | that 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} |
---|
170 | from pyvolution.mesh_factory import rectangular |
---|
171 | from pyvolution.shallow_water import Domain, Reflective_boundary, |
---|
172 | Dirichlet_boundary, Time_boundary, Transmissive_boundary |
---|
173 | |
---|
174 | #Create basic mesh |
---|
175 | points, vertices, boundary = rectangular(10,10) |
---|
176 | |
---|
177 | #Create shallow water domain |
---|
178 | domain = Domain(points, vertices,boundary) |
---|
179 | domain.set_name('bedslope') |
---|
180 | |
---|
181 | |
---|
182 | ####################### |
---|
183 | # Initial conditions |
---|
184 | def f(x,y): |
---|
185 | return -x/2 |
---|
186 | |
---|
187 | domain.set_quantity('elevation', f) |
---|
188 | domain.set_quantity('friction', 0.1) |
---|
189 | |
---|
190 | h = 0.05 # Constant depth |
---|
191 | domain.set_quantity('stage', expression = 'elevation + %f' %h) |
---|
192 | |
---|
193 | |
---|
194 | # Boundary conditions |
---|
195 | from math import sin, pi |
---|
196 | Br = Reflective_boundary(domain) |
---|
197 | Bt = Transmissive_boundary(domain) |
---|
198 | Bd = Dirichlet_boundary([0.2,0.,0.]) |
---|
199 | |
---|
200 | Bw = Time_boundary(domain=domain, |
---|
201 | f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0]) |
---|
202 | |
---|
203 | |
---|
204 | domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
205 | |
---|
206 | |
---|
207 | ###################### |
---|
208 | #Evolution |
---|
209 | |
---|
210 | domain.check_integrity() |
---|
211 | |
---|
212 | for 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 | |
---|
221 | The first task is to set up the triangular mesh to be used for the |
---|
222 | scenario. This is carried out through the statement: |
---|
223 | |
---|
224 | {\small \begin{verbatim} |
---|
225 | points, vertices, boundary = rectangular(10, 10) |
---|
226 | \end{verbatim}} |
---|
227 | |
---|
228 | The function \texttt{rectangular} is imported from a module |
---|
229 | \texttt{mesh\_factory} defined elsewhere. (\textbf{AnuGA} also |
---|
230 | contains several other schemes that can be used for setting up |
---|
231 | meshes, but we shall not discuss these now.) The above assignment |
---|
232 | sets up a $10 \times 10$ rectangular mesh, triangulated in a |
---|
233 | specific way. In general, the assignment |
---|
234 | |
---|
235 | {\small \begin{verbatim} |
---|
236 | points, vertices, boundary = rectangular(m, n) |
---|
237 | \end{verbatim}} |
---|
238 | |
---|
239 | returns: |
---|
240 | |
---|
241 | \begin{itemize} |
---|
242 | |
---|
243 | \item a list \texttt{points} of length $N$, where $N = (m + 1)(n + 1)$, |
---|
244 | comprising the coordinates $(x, y)$ of each of the $N$ mesh |
---|
245 | points, |
---|
246 | |
---|
247 | \item a list \texttt{vertices} of length $2mn$ (each entry specifies the three |
---|
248 | vertices of one of the triangles used in the triangulation) , and |
---|
249 | |
---|
250 | \item a dictionary \texttt{boundary}, used to tag the triangle edges on |
---|
251 | the boundaries. Each key corresponds to a triangle edge on one of |
---|
252 | the four boundaries and its value is one of \texttt{`left'}, |
---|
253 | \texttt{`right'}, \texttt{`top'} and \texttt{`bottom'}, indicating |
---|
254 | which boundary the edge in question belongs to. |
---|
255 | |
---|
256 | \end{itemize} |
---|
257 | |
---|
258 | |
---|
259 | \subsection*{Initialising the domain} |
---|
260 | |
---|
261 | These 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 | |
---|
268 | This uses a Python class \texttt{Domain}, imported from |
---|
269 | \texttt{shallow\_water}, which is an extension of a more generic |
---|
270 | class of the same name in the module \texttt{domain}, and inherits |
---|
271 | some methods from the generic class but has others specific to the |
---|
272 | shallow-water scenarios in which it is used. Specific options for domain |
---|
273 | are 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 | |
---|
282 | The next task is to specify a number of quantities that we wish to set |
---|
283 | for each mesh point. The class \texttt{Domain} has a method |
---|
284 | \texttt{set\_quantity}, used to specify these quantities. It is a |
---|
285 | particularly flexible method that allows the user to set quantities in |
---|
286 | a variety of ways---using constants, functions, numeric arrays or |
---|
287 | expressions involving other quantities, arbitrary data points with |
---|
288 | associated values, all of which can be passed as arguments. All |
---|
289 | quantities can be initialised using \texttt{set\_quantity}. For |
---|
290 | conserved quantities (\texttt{stage, xmomentum, ymomentum}) this is |
---|
291 | called the \emph{initial condition}, for other quantities that aren't |
---|
292 | updated by the equation, the same interface is used to assign their |
---|
293 | values. The code in the present example demonstrates a number of forms |
---|
294 | in which we can invoke \texttt{set\_quantity}. |
---|
295 | |
---|
296 | |
---|
297 | \subsubsection*{Elevation} |
---|
298 | |
---|
299 | The elevation is set using a function, defined through the |
---|
300 | statements below, which is specific to this example and specifies |
---|
301 | a particularly simple initial configuration for demonstration |
---|
302 | purposes: |
---|
303 | |
---|
304 | {\small \begin{verbatim} |
---|
305 | def f(x,y): |
---|
306 | return -x/2 |
---|
307 | \end{verbatim}} |
---|
308 | |
---|
309 | This simply associates an elevation with each point $(x, y)$ of |
---|
310 | the plane. It specifies that the bed slopes linearly in the $x$ |
---|
311 | direction, with slope $-\frac{1}{2}$, and is constant in the $y$ |
---|
312 | direction.\\ %[screen shot?] |
---|
313 | \\ |
---|
314 | Once 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 | |
---|
325 | The assignment of the friction quantity demonstrates another way |
---|
326 | we can use \texttt{set\_quantity} to set quantities---namely, |
---|
327 | assign them to a constant numerical value: |
---|
328 | |
---|
329 | {\small \begin{verbatim} |
---|
330 | domain.set_quantity('friction', 0.1) |
---|
331 | \end{verbatim}} |
---|
332 | |
---|
333 | This just specifies that the Manning friction coefficient is set |
---|
334 | to 0.1 at every mesh point. |
---|
335 | |
---|
336 | \subsubsection*{Depth} |
---|
337 | |
---|
338 | Assigning depth illustrates a more complex way to use |
---|
339 | \texttt{set\_quantity}, introducing an expression involving other |
---|
340 | quantities: |
---|
341 | |
---|
342 | {\small \begin{verbatim} |
---|
343 | h = 0.05 \# Constant depth |
---|
344 | domain.set_quantity('stage', expression = 'elevation + %f' %h) |
---|
345 | \end{verbatim}} |
---|
346 | |
---|
347 | Here the quantity \texttt{stage} is defined by taking the quantity |
---|
348 | elevation already defined and adding a constant value $h = 0.05$ |
---|
349 | to it everywhere. This expresses the fact that the water depth is |
---|
350 | everywhere constant, so the surface is a constant height above the |
---|
351 | elevation of the bed. |
---|
352 | |
---|
353 | \subsubsection*{Boundary Conditions} |
---|
354 | |
---|
355 | The 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 | |
---|
368 | The effect of these statements is to set up four alternative |
---|
369 | boundary conditions and store them in variables that can be |
---|
370 | assigned as needed. Each boundary condition specifies the |
---|
371 | behaviour at a boundary in terms of the behaviour in neighbouring |
---|
372 | elements. The boundary conditions may be briefly described as |
---|
373 | follows: |
---|
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 |
---|
384 | boundary. |
---|
385 | \item[Time boundary.]A Dirichlet boundary whose behaviour varies with time. |
---|
386 | \end{description} |
---|
387 | |
---|
388 | Once the four boundary types have been specified through the |
---|
389 | statements above, they can be applied through a statement of the |
---|
390 | form |
---|
391 | |
---|
392 | {\small \begin{verbatim} |
---|
393 | domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
394 | \end{verbatim}} |
---|
395 | |
---|
396 | This statement stipulates that, in the current example, the left |
---|
397 | boundary is fixed, with an elevation of 0.2, while the other |
---|
398 | boundaries are all reflective. |
---|
399 | |
---|
400 | |
---|
401 | \subsection*{Evolution} |
---|
402 | |
---|
403 | The 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 | |
---|
409 | is the key step that causes the configuration of the domain to |
---|
410 | `evolve' in accordance with the model embodied in the code, over a |
---|
411 | series of steps indicated by the values of \texttt{yieldstep} and |
---|
412 | \texttt{finaltime}, which can be altered as required. |
---|
413 | The 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 | |
---|
423 | The output is a NetCDF file with the extension \texttt{.sww}. It |
---|
424 | contains 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 | |
---|
430 | The 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} |
---|