source: documentation/user_manual/anuga_user_manual.tex @ 2374

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

All lowercase filename

File size: 23.0 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{\indexedcode}[1]{\code{#1}\index{#1}}
10\newcommand{\indexedbold}[1]{\textbf{#1}\index{#1}}
11       
12\documentclass{manual}
13
14\title{AnuGA User Manual}
15\author{Howard Silcock, Ole Nielsen, Duncan Gray, Jane Sexton}
16
17% Please at least include a long-lived email address;
18% the rest is at your discretion.
19\authoraddress{Geoscience Australia \\
20  Email: \email{ole.nielsen@ga.gov.au}
21}
22
23\date{2 February, 2006}         % update before release!
24                                % Use an explicit date so that reformatting
25                                % doesn't cause a new date to be used.  Setting
26                                % the date to \today can be used during draft
27                                % stages to make it easier to handle versions.
28
29\release{1.0}                   % release version; this is used to define the
30                                % \version macro
31
32\makeindex                      % tell \index to actually write the .idx file
33%\makemodindex                  % If this contains a lot of module sections.
34
35
36
37\begin{document}
38\maketitle
39
40% This makes the contents more accessible from the front page of the HTML.
41\ifhtml
42\chapter*{Front Matter\label{front}}
43\fi
44
45%Subversion keywords:
46%
47%$LastChangedDate: 2006-01-13 16:43:01 +1100 (Fri, 13 Jan 2006) $
48%$LastChangedRevision: 2206 $
49%$LastChangedBy: steve $
50
51
52\begin{abstract}
53
54\noindent
55\textbf{AnuGA}\index{AnuGA} is a hydrodynamic modelling tool that
56allows users to model realistic flow problems in complex
57geometries. Examples include dam breaks or the effects of natural
58hazards such as riverine flooding, storm surges and tsunami.
59
60The user must specify a study area represented by a mesh of triangular
61cells, the topography and bathymetry, frictional resistance, initial
62values for water level (called \emph{stage}\index{stage} within Anuga),
63boundary
64conditions and forces such as windstress or pressure gradients if
65applicable.
66
67Anuga tracks the evolution of water depth and horizontal momentum
68within each cell over time by solving the shallow water wave equation
69governing equation using a finite-volume method.
70
71Anuga cannot model details of breaking waves, flow under ceilings such
72as pipes, turbulence and vortices, vertical convection or viscous
73flows.
74
75Anuga also incorporates a mesh generator, called \code{pmesh}, that
76allows the user to set up the geometry of the problem interactively as
77well as tools for interpolation and surface fitting, and a number of
78auxiliary tools for visualising and interrogating the model output.
79
80Most AnuGA components are written in the object-oriented programming
81language Python and most users will interact with Anuga by writing
82small Python programs based on the Anuga library
83functions. Computationally intensive components are written for
84efficiency in C routines working directly with the Numerical Python
85structures.
86
87
88\end{abstract}
89
90\tableofcontents
91
92
93\chapter{Introduction}
94
95
96\section{Purpose}
97
98The purpose of this user manual is to introduce the new user to
99the software, describe what it can do and give step-by-step
100instructions for setting up, configuring and running the software.
101
102\section{Scope}
103
104This manual covers only what is needed to operate the software
105after installation. It does not includes instructions for
106installing the software or detailed API documentation, both of
107which will be covered in separate publications.
108
109\section{Audience}
110
111Readers are assumed to be familiar with the operating environment
112and have a general understanding of the problem background, as
113well as enough programming experience to adapt the code to
114different requirements, as described in this manual,  and to
115understand the basic terminology of object-oriented programming.
116
117\section{Structure of This Manual}
118
119This manual is structured as follows:
120
121\begin{itemize}
122  \item Background (What Anuga does)
123  \item A \emph{Getting Started} section
124  \item Anuga's overall architecture, components and file formats
125  \item Detailed descriptions of the user interface
126\end{itemize}
127
128
129\pagebreak
130\chapter{Getting Started}
131
132This section is designed to assist the reader to get started with
133\textbf{AnuGA} by working through a simple example. What follows
134is a discussion of the structure and operation of the file
135\code{bedslope.py}, with just enough detail to allow the reader
136to appreciate what's involved in setting up a scenario like the
137one it depicts.
138
139\section{Overview}
140
141This example carries out the solution of the shallow-water wave
142equation in the simple case of a configuration comprising a flat
143bed, sloping at a fixed angle in one direction and having a
144constant depth across each line in the perpendicular direction.
145
146The example demonstrates many of the basic ideas involved in
147setting up a more complex scenario. In the general case the user
148specifies the geometry (bathymetry and topography), the initial
149water level, boundary conditions such as tide, and any forcing
150terms that may drive the system such as wind stress or atmospheric
151pressure gradients. Frictional resistance from the different
152terrains in the model is represented by predefined forcing
153terms. The boundary is reflective on three sides and a time dependent wave on one side.
154
155The present example, as it represents a simple scenario, does not
156include any forcing term, nor is the data taken from a file as it
157would be in many typical cases. The quantities involved in the
158present problem are:
159\begin{itemize}
160   \item elevation\index{elevation}
161   \item friction\index{friction}
162   \item depth\index{depth}
163   \item stage\index{stage}
164\end{itemize}
165
166%\emph{[More details of the problem background]}
167
168\section{Outline of the Program}
169
170In outline, \code{bedslope.py} performs the following steps:
171
172\begin{enumerate}
173
174   \item Sets up a triangular mesh.
175
176   \item Sets certain parameters governing the mode of
177operation of the model-specifying, for instance, where to store the model output.
178
179
180   \item Inputs various quantities describing physical measurements, such
181as the elevation, to be specified at each mesh point (vertex).
182
183   \item Sets up the boundary conditions.
184
185   \item Carries out the evolution of the model through a series of time
186steps and outputs the results, providing a results file that can
187be visualised.
188
189\end{enumerate}
190
191\section{The Code}
192
193%FIXME: we are using the \code function here.
194%This should be used whereever possible
195For reference we include below the complete code listing for
196\code{bedslope.py}. Subsequent paragraphs provide a `commentary'
197that describes each step of the program and explains it significance.
198
199
200{\scriptsize \begin{verbatim}
201from pyvolution.mesh_factory import rectangular
202from pyvolution.shallow_water import Domain, Reflective_boundary,
203     Dirichlet_boundary, Time_boundary, Transmissive_boundary
204
205#Create basic mesh
206points, vertices, boundary = rectangular(10,10)
207
208#Create shallow water domain
209domain = Domain(points, vertices,boundary)
210domain.set_name('bedslope')
211
212
213#######################
214# Initial conditions
215def f(x,y):
216    return -x/2
217
218domain.set_quantity('elevation', f)
219domain.set_quantity('friction', 0.1)
220
221h = 0.05  # Constant depth
222domain.set_quantity('stage', expression = 'elevation + %f' %h)
223
224
225# Boundary conditions
226from math import sin, pi
227Br = Reflective_boundary(domain)
228Bt = Transmissive_boundary(domain)
229Bd = Dirichlet_boundary([0.2,0.,0.])
230
231Bw = Time_boundary(domain=domain,
232                   f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0])
233
234
235domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br})
236
237
238######################
239#Evolution
240
241domain.check_integrity()
242
243for t in domain.evolve(yieldstep = 0.1, finaltime = 4.0):
244    domain.write_time()
245
246
247\end{verbatim}}
248
249
250\section{Establishing the Mesh}
251
252The first task is to set up the triangular mesh to be used for the
253scenario. This is carried out through the statement:
254
255{\small \begin{verbatim}
256    points, vertices, boundary = rectangular(10, 10)
257\end{verbatim}}
258
259The function \code{rectangular} is imported from a module
260\code{mesh\_factory} defined elsewhere. (\textbf{AnuGA} also
261contains several other schemes that can be used for setting up
262meshes, but we shall not discuss these now.) The above assignment
263sets up a $10 \times 10$ rectangular mesh, triangulated in a
264specific way. In general, the assignment
265
266{\small \begin{verbatim}
267    points, vertices, boundary = rectangular(m, n)
268\end{verbatim}}
269
270returns:
271
272\begin{itemize}
273
274   \item a list \code{points} of length $N$, where $N = (m + 1)(n + 1)$,
275comprising the coordinates $(x, y)$ of each of the $N$ mesh
276points,
277
278   \item a list \code{vertices} of length $2mn$ (each entry specifies the three
279vertices of one of the triangles used in the triangulation) , and
280
281   \item a dictionary \code{boundary}, used to tag the triangle edges on
282the boundaries. Each key corresponds to a triangle edge on one of
283the four boundaries and its value is one of \code{`left'},
284\code{`right'}, \code{`top'} and \code{`bottom'}, indicating
285which boundary the edge in question belongs to.
286
287\end{itemize}
288
289
290\section{Initialising the domain}
291
292These variables are then used to set up a data structure
293\code{domain}, through the assignment:
294
295{\small \begin{verbatim}
296    domain = Domain(points, vertices, boundary)
297\end{verbatim}}
298
299This uses a Python class \code{Domain}, imported from
300\code{shallow\_water}, which is an extension of a more generic
301class of the same name in the module \code{domain}, and inherits
302some methods from the generic class but has others specific to the
303shallow-water scenarios in which it is used. Specific options for domain
304are set at this point. One of them are to set the basename for the output file
305
306{\scriptsize \begin{verbatim}
307    domain.set_name('bedslope')
308\end{verbatim}}
309
310
311\section{Specifying the Quantities}
312
313The next task is to specify a number of quantities that we wish to set
314for each mesh point. The class \code{Domain} has a method
315\code{set\_quantity}, used to specify these quantities. It is a
316particularly flexible method that allows the user to set quantities in
317a variety of ways---using constants, functions, numeric arrays or
318expressions involving other quantities, arbitrary data points with
319associated values, all of which can be passed as arguments. All
320quantities can be initialised using \code{set\_quantity}. For
321conserved quantities (\code{stage, xmomentum, ymomentum}) this is
322called the \emph{initial condition}, for other quantities that aren't
323updated by the equation, the same interface is used to assign their
324values. The code in the present example demonstrates a number of forms
325in which we can invoke \code{set\_quantity}.
326
327
328\subsection{Elevation}
329
330The elevation is set using a function, defined through the
331statements below, which is specific to this example and specifies
332a particularly simple initial configuration for demonstration
333purposes:
334
335{\small \begin{verbatim}
336    def f(x,y):
337        return -x/2
338\end{verbatim}}
339
340This simply associates an elevation with each point $(x, y)$ of
341the plane.  It specifies that the bed slopes linearly in the $x$
342direction, with slope $-\frac{1}{2}$,  and is constant in the $y$
343direction.\\ %[screen shot?]
344\\
345Once the function $f$ is specified, the quantity
346\code{elevation} is assigned through the simple statement:
347
348{\small \begin{verbatim}
349\begin{verbatim}
350    domain.set_quantity('elevation', f)
351\end{verbatim}}
352
353
354\subsection{Friction}
355
356The assignment of the friction quantity demonstrates another way
357we can use \code{set\_quantity} to set quantities---namely,
358assign them to a constant numerical value:
359
360{\small \begin{verbatim}
361    domain.set_quantity('friction', 0.1)
362\end{verbatim}}
363
364This just specifies that the Manning friction coefficient is set
365to 0.1 at every mesh point.
366
367\subsection{Depth}
368
369Assigning depth illustrates a more complex way to use
370\code{set\_quantity}, introducing an expression involving other
371quantities:
372
373{\small \begin{verbatim}
374    h = 0.05 \# Constant depth
375    domain.set_quantity('stage', expression = 'elevation + %f' %h)
376\end{verbatim}}
377
378Here the quantity \code{stage} is defined by taking the quantity
379elevation already defined and adding a constant value $h = 0.05$
380to it everywhere. This expresses the fact that the water depth is
381everywhere constant, so the surface is a constant height above the
382elevation of the bed.
383
384\subsection{Boundary Conditions}
385
386The boundary conditions are specified as follows:
387
388{\small \begin{verbatim}
389    Br = Reflective_boundary(domain)
390
391    Bt = Transmissive_boundary(domain)
392
393    Bd = Dirichlet_boundary([0.2,0.,0.])
394
395    Bw = Time_boundary(domain=domain,
396                f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0])
397\end{verbatim}}
398
399The effect of these statements is to set up four alternative
400boundary conditions and store them in variables that can be
401assigned as needed. Each boundary condition specifies the
402behaviour at a boundary in terms of the behaviour in neighbouring
403elements. The boundary conditions may be briefly described as
404follows:
405
406\begin{description}
407    \item[Reflective boundary] Returns same \code{stage} as
408    as present in its neighbour volume but momentum vector reversed 180 degrees (reflected).
409    Specific to the shallow water equation as it works with the
410    momentum quantities assumed to be the second and third conserved
411    quantities.
412    \item[Transmissive boundary]Returns same conserved quantities as
413    those present in its neighbour volume.
414    \item[Dirichlet boundary]Specifies a fixed value at the
415boundary.
416    \item[Time boundary.]A Dirichlet boundary whose behaviour varies with time.
417\end{description}
418
419Once the four boundary types have been specified through the
420statements above, they can be applied through a statement of the
421form
422
423{\small \begin{verbatim}
424    domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br})
425\end{verbatim}}
426
427This statement stipulates that, in the current example, the left
428boundary is fixed, with an elevation of 0.2, while the other
429boundaries are all reflective.
430
431
432\section{Evolution}
433
434The final statement \nopagebreak[3]
435{\small \begin{verbatim}
436    for t in domain.evolve(yieldstep = 0.1, finaltime = 4.0):
437        domain.write_time()
438\end{verbatim}}
439
440is the key step that causes the configuration of the domain to
441`evolve' in accordance with the model embodied in the code, over a
442series of steps indicated by the values of \code{yieldstep} and
443\code{finaltime}, which can be altered as required.
444The yieldstep control the time interval between model output. Behind the scenes more timesteps are generally taken.
445
446
447
448
449\section{Output}
450
451%Give details here of the form of the output and explain how it can
452%be used with swollen. Include screen shots.//
453
454The output is a NetCDF file with the extension \code{.sww}. It
455contains stage and momentum information and can be used with the
456\code{swollen} visualisation package to generate a visual display.
457
458
459\section{How to Run the Code}
460
461The code can be run in various ways:
462
463\begin{itemize}
464\item{from a Windows command line} as in \code{python bedslope.py}
465
466\item{within the Python IDLE environment}
467
468\item{within emacs}
469
470\item{from a Linux command line} as in \code{python bedslope.py}
471\end{itemize}
472
473
474\section{Example with real data}
475
476The following discussion builds on the \code{bedslope.py} example and
477shows how, using the same basic outline, we can incorporate many more
478complex features.
479
480The chief difference is in the method used to create the mesh. Instead of imposing a mesh
481structure on a rectangular grid, the technique used for this example involves building
482mesh structures inside polygons.
483
484In its simplest form, the mesh is created within a single polygon
485whose vertices are at geographical locations specified by the user.  A
486triangular mesh is created using points inside the polygon selected
487through a random process, the user specifying the
488\emph{resolution}---that is, the maximal area of a triangle used for
489triangulation.
490
491Figure XXX shows a simple example, in which the triangulation is
492carried out within a pentagon. Instead of using the four tags
493\code{`left'}, \code{`right'}, \code{`bottom'} and
494\code{`top'} to distinguish boundary elements, the user can define
495tags appropriate to the configuration being modelled.
496
497While this offers more flexibility than the rectangular grid, it
498doesn't provide a way to adapt to geographic or other features in the
499landscape, for which we may require to vary the resolution. We achieve
500more flexibility by extending this method, allowing the user to
501specify a number of interior polygons which are triangulated
502separately, possibly using different resolutions.  See Figure XXX.
503
504
505\chapter{ANUGA Public Interface}
506
507thoaedut
508
509
510
511\begin{itemize} 
512
513  \item \indexedcode{create_mesh_from_region}: Create mesh based on a bounding polygon and a number of internal polygons. Each polygon has a maximal area of triangles associated with it - the resolution. The bounding polygon also has symbolic \code{tags} associated with it.   
514  Arguments are:
515  \item \indexedcode{pmesh_to_domain_instance}: Convert generated mesh file to domain object. Arguments are: Mesh file name and class specifying which domain class to instantiate. (Simpler)
516 
517  \item \indexedcode{file_function} %in util.py "High priority" 
518  \item \indexedcode{Interpolation_function} %In least_squares.py ("High priority") 
519
520  \item \indexedcode{set_region} ``Low priority. Will be merged into set\_quantity'' 
521  \item \indexedcode{set_quantity} ``Pretty mature''
522  \item \indexedcode{set_boundary} ``Pretty mature''
523 
524\end{itemize} 
525
526
527Diagnostics
528\begin{itemize} 
529  \item \indexedcode{write_time}
530  \item \indexedcode{write_boundary_statistics}
531 
532
533\end{itemize} 
534
535
536\subsection{Boundary conditions}
537
538ANUGA provides a large number of predefined boundary conditions to be used with
539\code{set_boundary}
540
541What do they do
542How are they used
543
544\begin{itemize} 
545  \item \indexedcode{Reflective_boundary}
546  function, arguments
547 
548  \item \indexedcode{Transmissive_boundary}
549  function, arguments, CAVEATS 
550 
551  \item \indexedcode{Dirichlet_boundary}
552 
553  \item \indexedcode{Time_boundary} 
554 
555  \item \indexedcode{File_boundary}   
556  Based on File\_function
557 
558  \item \indexedcode{}     
559 
560  \item \indexedcode{}       
561 
562 
563  \item \indexedcode{User defined boundary conditions.}
564  How to roll your own     
565 
566 
567
568\end{itemize} 
569
570
571
572\subsection{Initial conditions}
573
574ANUGA provides a number of predefined initial conditions to be used with
575\code{set_quantity}.
576
577\begin{itemize} 
578
579
580  \item \indexedcode{tsunami_slump}
581  function, arguments
582 
583  \item \indexedcode{}
584
585\end{itemize} 
586
587
588\subsection{Initial conditions}
589
590ANUGA provides a number of predefined forcing functions to be used with .....
591
592\begin{itemize} 
593
594
595  \item \indexedcode{}
596  function, arguments
597 
598  \item \indexedcode{}
599
600\end{itemize} 
601
602
603
604
605\chapter{ANUGA system architecture}
606
607Take some stuff from pyvolution/documentation and update it.
608
609
610
611
612
613\appendix
614
615\chapter{Supporting tools}
616
617
618\section{caching} Could do now.
619
620
621
622\section{swollen} Could do now.
623
624
625\section{utilities/polygons} Could do now.
626
627\begin{itemize} 
628  \item \indexedcode{polygon_function} 
629  \item \indexedcode{read_polygon} 
630  \item \indexedcode{populate_polygon} 
631  \item \indexedcode{point_in_polygon} 
632  \item \indexedcode{inside_polygon} 
633  \item \indexedcode{outside_polygon} 
634  \item \indexedcode{point_on_line} 
635  \item \indexedcode{separate_points_by_polygon} 
636\end{itemize}   
637 
638
639
640
641
642\section{coordinate_transforms}
643
644\section{geo_spatial_data}
645
646\section{pmesh GUI}
647
648\section{alpha_shape}
649
650
651
652
653
654\chapter{Glossary}
655
656\begin{itemize}
657    \item \indexedbold{ANUGA} name of software (joint development between ANU and GA)
658   
659    \item \indexedbold{Conserved quantity}   
660
661    \item \indexedbold{Default order} is this really needed?
662
663    \item \indexedbold{Domain}
664
665    \item \indexedbold{Dirichlet boundary}
666
667    \item \indexedbold{Elevation} - refers to bathymetry and topography
668
669    \item \indexedbold{bathymetry} offshore
670
671    \item \indexedbold{topography} onshore
672
673    \item \indexedbold{Evolution} integration of the shallow water wave equations over time
674
675    \item \indexedbold{Forcing term}
676
677    \item \indexedbold{IDLE} development environment shipped with Python
678
679    \item \indexedbold{Manning friction coefficient}
680   
681    \item \indexedbold{Mesh}    triangulation of domain
682
683    \item \indexedbold{Grid} evenly spaced
684
685    \item \indexedbold{NetCDF}
686
687    \item \indexedbold{pmesh} does this really need to be here? it's a class/module?
688
689    \item \indexedbold{pyvolution} does this really need to be here? it's a class/module?
690
691    \item \indexedbold{Quantity} conserved (state, x and y momentum)
692
693    \item \indexedbold{Reflective boundary}
694
695    \item \indexedbold{Smoothing} is this really needed?
696
697    \item \indexedbold{Stage}
698
699    \item \indexedbold{Swollen} visualisation tool
700
701    \item \indexedbold{Time boundary} defined in the manual (flog from there)
702
703    \item \indexedbold{Transmissive boundary} defined in the manual (flog from there)
704
705    \item \indexedbold{xmomentum} conserved quantity (note, two-dimensional SWW equations say only x and y and NOT z)
706   
707    \item \indexedbold{ymomentum}  conserved quantity
708
709    \item \indexedbold{resolution}   refers to the maximal area of each triangular cell in the mesh
710   
711    \item \indexedbold{polygon} A sequence of points in the plane. (Arbitrary polygons can be created in this way )
712    ANUGA represents polygons as either a list of 2-tuples, where the latter are either Python tuples or Python lists of length 2. The unit square, for example, would be represented by the polygon [ [0,0], [1,0], [1,1], [0,1] ]. Alternatively, polygons can be represented as $N \times 2$ Numeric arrays, where $N$ is the number of points.       
713   
714    NOTE: More can be read in the module utilities/polygon.py ....
715
716    \item \indexedbold{easting}   
717
718    \item \indexedbold{northing}   
719
720    \item \indexedbold{latitude}   
721
722    \item \indexedbold{longitude}   
723
724    \item \indexedbold{edge}   
725
726    \item \indexedbold{vertex} 
727 
728    \item \indexedbold{finite volume} 
729
730    \item \indexedbold{flux} 
731
732    \item \indexedbold{Digital Elevation Model (DEM)}   
733
734
735\end{itemize}
736
737The \code{\e appendix} markup need not be repeated for additional
738appendices.
739
740
741%
742%  The ugly "%begin{latexonly}" pseudo-environments are really just to
743%  keep LaTeX2HTML quiet during the \renewcommand{} macros; they're
744%  not really valuable.
745%
746%  If you don't want the Module Index, you can remove all of this up
747%  until the second \input line.
748%
749
750%begin{latexonly}
751%\renewcommand{\indexname}{Module Index}
752%end{latexonly}
753%\input{mod\jobname.ind}                % Module Index
754
755%begin{latexonly}
756\renewcommand{\indexname}{Index}
757%end{latexonly}
758\input{\jobname.ind}                    % Index
759
760
761
762\end{document}
Note: See TracBrowser for help on using the repository browser.