Changeset 2529


Ignore:
Timestamp:
Mar 12, 2006, 11:16:03 PM (18 years ago)
Author:
howard
Message:

Ongoing editing of earlier sections and padding out of Chapter 3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • documentation/user_manual/anuga_user_manual.tex

    r2524 r2529  
    4343
    4444\setcounter{tocdepth}{3}
    45 
     45\setcounter{secnumdepth}{3}
    4646\begin{document}
    4747\maketitle
     
    108108The purpose of this user manual is to introduce the new user to
    109109the software, describe what it can do and give step-by-step
    110 instructions for setting up, configuring and running the software.
     110instructions for setting up and running hydrodynamic simulations.
    111111
    112112\section{Scope}
    113113
    114114This manual covers only what is needed to operate the software
    115 after installation. It does not includes instructions for
     115after installation and configuration. It does not includes instructions for
    116116installing the software or detailed API documentation, both of
    117117which will be covered in separate publications.
     
    144144\anuga by working through simple examples. Two examples are discussed;
    145145the first is a simple but artificial example that is useful to illustrate
    146 many of the ideas, and the second is a real-life example.
     146many of the ideas, and the second is a more realistic example.
    147147
    148148\section{A Simple Example}
     
    150150\subsection{Overview}
    151151
    152 What follows
    153 is a discussion of the structure and operation of the file
    154 \code{bedslope.py}, with just enough detail to allow the reader
     152What follows is a discussion of the structure and operation of the file
     153\code{bedslopephysical.py}, with just enough detail to allow the reader
    155154to appreciate what's involved in setting up a scenario like the
    156155one it depicts.
     
    170169terms. The boundary is reflective on three sides and a time dependent wave on one side.
    171170
    172 The present example, as it represents a simple scenario, does not
    173 include any forcing term, nor is the data taken from a file as it
    174 would be in many typical cases. The quantities involved in the
    175 present problem are:
    176 \begin{itemize}
    177    \item elevation\index{elevation}
    178    \item friction\index{friction}
    179    \item depth\index{depth}
    180    \item stage\index{stage}
    181 \end{itemize}
     171The present example represents a simple scenario and does not
     172include any forcing terms, nor is the data taken from a file as it
     173would be in many typical cases.
     174
     175The conserved quantities involved in the
     176problem are water depth, $x$-momentum and $y$-momentum. Other quantities
     177involved in the computation are the friction, stage (absolute height of water surface)
     178and elevation, the last two being related to
     179the depth through the equation
     180
     181{\small \begin{verbatim}
     182\code{stage} = \code{elevation} + \code{depth}
     183\end{verbatim}}
    182184
    183185%\emph{[More details of the problem background]}
     
    185187\subsection{Outline of the Program}
    186188
    187 In outline, \code{bedslope.py} performs the following steps:
     189In outline, \code{bedslopephysical.py} performs the following steps:
    188190
    189191\begin{enumerate}
     
    210212%This should be used wherever possible
    211213For reference we include below the complete code listing for
    212 \code{bedslope.py}. Subsequent paragraphs provide a `commentary'
     214\code{bedslopephysical.py}. Subsequent paragraphs provide a `commentary'
    213215that describes each step of the program and explains it significance.
    214216
    215 \verbatiminput{examples/bedslope_physical.py}
     217\verbatiminput{examples/bedslopephysical.py}
    216218
    217219\subsection{Establishing the Mesh}
     
    334336The stage (the height of the water surface) is related to the
    335337elevation and the depth at any time by the equation \[\code{stage} =
    336 \code{elevation} + \code{depth}\] To specify a constant depth of a
    337 particular value, therefore, we need to specify that \code{stage} is
    338 everywhere obtained by adding that constant value to the already
    339 specified \code{elevation}. Doing this allows us to illustrate
    340 another way to use \code{set\_quantity}, introducing an expression
    341 involving other quantities:
     338\code{elevation} + \code{depth}\]
     339
     340For this example, we simply assign a constant value to \code{stage},
     341using the statement
     342
     343{\small \begin{verbatim}
     344    domain.set_quantity('stage', -.4)
     345\end{verbatim}}
     346
     347which specifies that the surface level is set to a height of $-0.4$, i.e. 0.4 units
     348below the zero level.
     349
     350(Although it is not necessary for this example, it may be useful to digress here
     351and mention a variant to this requirement, which allows us to illustrate
     352another way to use \code{set\_quantity}---namely, incorporating an expression
     353involving other quantities. Suppose, instead of setting a constant value
     354for the stage, we wished
     355to specify a constant value for the \emph{depth}. For such a case we 
     356need to specify that \code{stage} is
     357everywhere obtained by adding that value to the value already
     358specified for \code{elevation}. We would do this by means of the statements:
    342359
    343360{\small \begin{verbatim}
     
    346363\end{verbatim}}
    347364
    348 Here we are stipulating that the quantity \code{stage} is defined by
    349 taking the quantity elevation already defined and adding a constant
    350 value $h = 0.05$ to it everywhere.
     365That is, the value of \code{stage} is set to $\code{h} = 0.05$ plus the
     366value of \code{elevation} already defined.
     367
     368The reader will probably appreciate that this capability to incorporate
     369expressions into statements using \code{set\_quantity} greatly expands
     370its power.)
    351371
    352372\subsubsection{Boundary Conditions}
     
    369389assigned as needed. Each boundary condition specifies the
    370390behaviour at a boundary in terms of the behaviour in neighbouring
    371 elements. The boundary conditions may be briefly described as
     391elements. The boundary conditions introduced here may be briefly described as
    372392follows:
    373393
     
    383403
    384404    \item[Dirichlet boundary]Specifies a fixed value at the
    385 boundary.
     405boundary and assigns initial values to the $x$-momentum and $y$-momentum. 
    386406
    387407    \item[Time boundary.]A Dirichlet boundary whose behaviour varies with time.
     
    399419boundary is fixed, with an elevation of 0.2, while the other
    400420boundaries are all reflective.
     421
     422The reader may wish to experiment by varying the choice of boundary types
     423for one or more of the boundaries. In the case of \code{Bd} and \code{Bw},
     424the three arguments in each case represent the
     425
     426{\small \begin{verbatim}
     427    Bw = Time_boundary(domain=domain,
     428                f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0])
     429\end{verbatim}}
     430
    401431
    402432
     
    432462
    433463\begin{itemize}
    434   \item{from a Windows command line} as in \code{python bedslope.py}
     464  \item{from a Windows command line} as in \code{python bedslopephysical.py}
    435465  \item{within the Python IDLE environment}
    436466  \item{within emacs}
    437   \item{from a Linux command line} as in \code{python bedslope.py}
     467  \item{from a Linux command line} as in \code{python bedslopephysical.py}
    438468\end{itemize}
    439469
     
    441471\section{Exploring the model output}
    442472
    443 blablabal Figure \ref{fig:bedslope start} shows the
     473Figure \ref{fig:bedslopestart} shows the \\
    444474Figure \ref{fig:bedslope2} shows later snapshots...
    445475
     
    448478\begin{figure}[hbt]
    449479
    450   \centerline{ \includegraphics[width=75mm, height=75mm]{examples/bedslopestart.eps}}
    451  
    452   \caption{Bedslope example viewed with Swollen.}
    453   \label{fig:bedslope start}
     480  \centerline{ \includegraphics[width=75mm, height=75mm]{examples/bedslope_start.eps}}
     481 
     482  \caption{Bedslope example viewed with Swollen}
     483  \label{fig:bedslopestart}
    454484\end{figure}
    455485
     
    458488
    459489  \centerline{
    460     \includegraphics[width=75mm, height=75mm]{examples/bedslopeduring.eps}
    461     \includegraphics[width=75mm, height=75mm]{examples/bedslopeend.eps}
     490    \includegraphics[width=75mm, height=75mm]{examples/bedslope_during.eps}
     491    \includegraphics[width=75mm, height=75mm]{examples/bedslope_end.eps}
    462492   }   
    463493 
    464   \caption{Bedslope example viewed with Swollen.}
     494  \caption{Bedslope example viewed with Swollen}
    465495  \label{fig:bedslope2}
    466496\end{figure}
     
    476506
    477507The following discussion builds on the concepts introduced through
    478 the \code{bedslope.py} example and introduces a second example,
     508the \code{bedslopephysical.py} example and introduces a second example,
    479509\code{run\_sydney\_smf.py}, that follows the same basic outline, but
    480510incorporates more complex features and refers to a real-life
    481511scenario, rather than the artificial illustrative one used in
    482 \code{bedslope.py}. [Include details of the scenario to which it
    483 refers??]
     512\code{bedslopephysical.py}. The domain of interest surrounds the Sydney region,
     513and predominantly covers Sydney Harbour. A hypothetical tsunami wave is
     514generated by a submarine mass failure situated on the edge of the
     515continental shelf.
    484516
    485517\subsection{Overview}
    486 As in the case of \code{bedslope.py}, the actions carried out by the
     518As in the case of \code{bedslopephysical.py}, the actions carried out by the
    487519program can be organised according to this outline:
    488520
     
    492524
    493525   \item Set certain parameters governing the mode of
    494 operation of the model-specifying, for instance, where to store the
     526operation of the model---specifying, for instance, where to store the
    495527model output.
    496528
     
    521553
    522554One obvious way that the present example differs from
    523 \code{bedslope.py} is in the use of a more complex method to create
     555\code{bedslopephysical.py} is in the use of a more complex method to create
    524556the mesh. Instead of imposing a mesh structure on a rectangular
    525557grid, the technique used for this example involves building mesh
     
    543575
    544576 
    545   \caption{Mesh points are created inside the polygon.}
     577  \caption{Mesh points are created inside the polygon}
    546578  \label{fig:pentagon} 
    547579\end{figure}
     
    549581Boundary tags are not restricted to \code{`left'}, \code{`right'},
    550582\code{`bottom'} and \code{`top'}, as in the case of
    551 \code{bedslope.py}. Instead the user specifies a list of tags
     583\code{bedslopephysical.py}. Instead the user specifies a list of tags
    552584appropriate to the configuration being modelled.
    553585
     
    566598
    567599 
    568   \caption{Interior meshes with individual resolution.}
     600  \caption{Interior meshes with individual resolution}
    569601  \label{fig:interior meshes} 
    570602\end{figure}
     
    599631\code{meshname}.
    600632
     633The statements
     634
     635{\small \begin{verbatim}
     636    interior_res = 5000%
     637    interior_regions = [[project.harbour_polygon_2, interior_res],
     638                    [project.botanybay_polygon_2, interior_res]]
     639\end{verbatim}}
     640
     641are used to read in the specific polygons \code{project.harbour\_polygon\_2} and
     642\code{botanybay\_polygon\_2} from \code{project.py} and assign a
     643common resolution of 5000 to each. The statement
     644
     645{\small \begin{verbatim}
     646    create_mesh_from_regions(project.diffpolygonall,%
     647                         boundary_tags= {'bottom': [0],%
     648                                         'right1': [1],%
     649                                         'right0': [2],%
     650                                         'right2': [3],%
     651                                         'top': [4],%
     652                                         'left1': [5],%
     653                                         'left2': [6],%
     654                                         'left3': [7]},%
     655                         maximum_triangle_area=100000,%
     656                         filename=meshname,%           
     657                         interior_regions=interior_regions)
     658\end{verbatim}}
     659
     660is then used to create the mesh, taking the bounding polygon to be the polygon
     661\code{diffpolygonall} specified in \code{project.py}. The
     662argument \code{boundary\_tags} assigns a dictionary, whose keys are the
     663names of the boundary tags used for the bounding polygon---\code{`bottom'},
     664`right0', `right1', `right2', `top', `left1', `left2' and `left3'---
     665and whose values identify the indices of the segments associated with each of these
     666tags. (The value associated with each boundary tag is a one-element list.)
     667
    601668
    602669\subsection{Initialising the Domain}
    603670
    604 As with \code{bedslope.py}, once we have created the mesh, the next
     671As with \code{bedslopephysical.py}, once we have created the mesh, the next
    605672step is to create the data structure \code{domain}. We did this for
    606 \code{bedslope.py} by inputting lists of points and triangles and
     673\code{bedslopephysical.py} by inputting lists of points and triangles and
    607674specifying the boundary tags directly. However, in the present case,
    608675we use a method that works directly with the meshfile
     
    610677
    611678{\small \begin{verbatim}
    612 domain = pmesh_to_domain_instance(meshname,
    613 Domain, use_cache = True, verbose = True)
     679    domain = pmesh_to_domain_instance(meshname,
     680    Domain, use_cache = True, verbose = True)
    614681\end{verbatim}}
    615682
     
    624691\code{Domain}.)
    625692
     693The following statements specify a basename and data directory, and
     694identify quantities to be stored. For the first two, values are
     695taken from \code{project.py}.
     696
     697{\small \begin{verbatim}
     698    domain.set_name(project.basename)%
     699    domain.set_datadir(project.outputdir)%
     700    domain.set_quantities_to_be_stored(['stage', 'xmomentum',
     701        'ymomentum'])
     702\end{verbatim}}
     703
     704
    626705\subsection{Specifying the Quantities}
    627 Setting quantities for \code{run\_sydney\_smf.py} is accomplished
    628 using similar methods to those used in \code{bedslope.py}. However,
     706Quantities for \code{run\_sydney\_smf.py} are set
     707using similar methods to those in \code{bedslopephysical.py}. However,
    629708in this case, many of the values are read from the auxiliary file
    630709\code{project.py} or, in the case of \code{elevation}, from an
     
    632711
    633712
    634 \subsubsection{Fundamental Quantities}
    635 
    636 The following statements specify a basename and data directory, and
    637 identify quantities to be stored. For the first two, values are
    638 taken from \code{project.py}.
    639 
    640 {\small \begin{verbatim} domain.set_name(project.basename)
    641 domain.set_datadir(project.outputdir)
    642 domain.set_quantities_to_be_stored(['stage', 'xmomentum',
    643 'ymomentum'])
    644 \end{verbatim}}
    645713
    646714\subsubsection{Stage}
     
    649717object \code{tsunami\_source}, assigned by means of a function
    650718\code{slump\_tsunami}. This is similar to how we set elevation in
    651 \code{bedslope.py} using a function---however, in this case the
    652 function is both more complex and more interesting.
    653 
    654 {\small \begin{verbatim}
    655 #-------------------------------------------------------------------------------
    656 # Set up scenario (tsunami_source is a callable object used with
    657 set_quantity)
    658 #-------------------------------------------------------------------------------
    659 
    660 tsunami_source = slump_tsunami(length=30000.0,
    661                                depth=400.0,
    662                                slope=6.0,
    663                                thickness=176.0,
    664                                radius=3330,
    665                                dphi=0.23,
    666                                x0=project.slump_origin[0],
    667                                y0=project.slump_origin[1],
    668                                alpha=0.0,
    669                                domain=domain)
    670 
    671 
    672 #-------------------------------------------------------------------------------
    673 # Set up initial conditions
    674 #-------------------------------------------------------------------------------
    675 
    676 domain.set_quantity('stage', tsunami_source)
    677 \end{verbatim}}
     719\code{bedslopephysical.py} using a function---however, in this case the
     720function is both more complex and more interesting.
     721
     722The function returns the water displacement for all \code{x}
     723and \code{y} in the domain. The water displacement is a ?? function that depends
     724on the characteristics of the slump (length, thickness, slope, etc), its
     725location (origin) and the depth at that location.
     726
    678727
    679728\subsubsection{Friction}
    680729
    681 Assigning the friction is exactly parallel to what we did for
    682 \code{bedslope.py}:
    683 
    684 {\small \begin{verbatim}
    685 domain.set_quantity('friction', 0.03)
    686 #supplied by Benfield
     730We assign the friction exactly as we did for \code{bedslopephysical.py}:
     731
     732{\small \begin{verbatim}
     733    domain.set_quantity('friction', 0.03)
    687734\end{verbatim}}
    688735
     
    690737\subsubsection{Elevation}
    691738
    692 In this example, the elevation is specified by reading data from a
    693 file.
    694 
    695 {\small \begin{verbatim}
    696 domain.set_quantity('elevation',
    697                     filename = project.combineddemname + '.pts',
    698                     use_cache = True,
    699                     verbose = True)
     739The elevation is specified by reading data from a file:
     740
     741{\small \begin{verbatim}%
     742    domain.set_quantity('elevation',%
     743                    filename = project.combineddemname + '.pts',%
     744                    use_cache = True,%
     745                    verbose = True)%
    700746\end{verbatim}}
    701747
     
    724770\subsection{Boundary Conditions}
    725771
    726 Setting boundaries in \code{run\_sydney\_smf.py} is very similar to
    727 what we did in \code{bedslope.py}, except that we now have a larger
    728 number of boundary tags:
    729 
    730 {\small \begin{verbatim}
    731 Br = Reflective_boundary(domain)
    732 domain.set_boundary( {'bottom': Br, 'right1': Br, 'right0': Br,
    733                       'right2': Br, 'top': Br, 'left1': Br,
    734                       'left2': Br, 'left3': Br} )
     772Setting boundaries follows a similar pattern to the one used for
     773\code{bedslopephysical.py}, except that in this case we need to associate a
     774boundary type with each of the
     775boundary tag names introduced when we established the mesh. In place of the four
     776boundary types introduced for \code{bedslopephysical.py}, we use the reflective
     777boundary for each of the
     778eight tagged segments:
     779
     780{\small \begin{verbatim}
     781    Br = Reflective_boundary(domain)
     782    domain.set_boundary( {'bottom': Br, 'right1': Br, 'right0': Br,
     783                          'right2': Br, 'top': Br, 'left1': Br,
     784                          'left2': Br, 'left3': Br} )
    735785\end{verbatim}}
    736786
     
    738788
    739789With the basics established, the running of the `evolve' step is
    740 very similar to the corresponding step in \code{bedslope.py}:
    741 
    742 {\small \begin{verbatim}
    743 import time t0 = time.time()
    744 
    745 for t in domain.evolve(yieldstep = 120, duration = 18000):
    746     print domain.timestepping_statistics()
    747     print domain.boundary_statistics(tags = 'bottom')
    748 
    749 print 'That took %.2f seconds' %(time.time()-t0)
     790very similar to the corresponding step in \code{bedslopephysical.py}:
     791
     792{\small \begin{verbatim}
     793    import time t0 = time.time()
     794   
     795    for t in domain.evolve(yieldstep = 120, duration = 18000):
     796        print domain.timestepping_statistics()
     797        print domain.boundary_statistics(tags = 'bottom')
     798   
     799    print 'That took %.2f seconds' %(time.time()
    750800\end{verbatim}}
    751801
     
    777827introducing the code, between two sets of triple quotes.
    778828
    779 Each paragraph also describes the location of the module in which
     829Each listing also describes the location of the module in which
    780830the code for the feature being described can be found. All modules
    781 are in the folder \code{inundation} or its subfolders, and the
    782 location of each module is described relative to this folder. Rather
     831are in the folder \code{inundation} or one of its subfolders, and the
     832location of each module is described relative to \code{inundation}. Rather
    783833than using pathnames, whose syntax depends on the operating system,
    784834we use the format adopted for importing the function or class for
     
    790840
    791841\begin{center}
    792 \code{pmesh/mesh\_interface.py}
     842    \code{pmesh/mesh\_interface.py}
    793843\end{center}
    794844
     
    796846
    797847\begin{center}
    798 \code{pmesh}$\backslash$\code{mesh\_interface.py}
     848    \code{pmesh}$\backslash$\code{mesh\_interface.py}
    799849\end{center}
    800850
     
    804854namely:
    805855\begin{center}
    806 \code{from pmesh.mesh\_interface import create\_mesh\_from\_regions}
     856    \code{from pmesh.mesh\_interface import create\_mesh\_from\_regions}
    807857\end{center}
    808858
     
    820870Module: \code{pmesh.mesh\_interface}
    821871
     872% Translate following into layman's language
    822873Creates a triangular mesh based on a bounding polygon and a number
    823874of internal polygons. For each polygon the user specifies a
     
    836887\code{file\_name} is the name of the mesh file to be converted,
    837888including the extension. \code{DomainClass} is the class to be
    838 returned, which must be a subclass of \code{Domain}, with the same
     889returned, which must be a subclass of \code{Domain} having the same
    839890interface as \code{Domain}---in practice, it can usually be set
    840891simply to \code{Domain}.
     
    866917\section{Setting Quantities}
    867918
    868 \begin{funcdesc}{set\_quantity}{name, *args, **kwargs}
    869 Module: \code{pyvolution.domain} -- see also
    870 \code{pyvolution.quantity.set_values}
     919\begin{funcdesc}{set\_quantity}{name, numeric = None, quantity = None, function = None,
     920                   geospatial_data = None, filename = None, attribute_name = None,
     921                   alpha = None, location = 'vertices', indices = None, verbose = False,
     922                   use_cache = False}
     923Module: \code{pyvolution.domain}  (see also
     924\code{pyvolution.quantity.set_values})
    871925
    872926numeric:\\
     
    921975
    922976
    923 location: Where values are to be stored.
    924   Permissible options are: vertices, edges, centroids
    925   Default is 'vertices'
    926 
    927   In case of location == 'centroids' the dimension values must
    928   be a list of a Numerical array of length N,
    929   N being the number of elements.
    930   Otherwise it must be of dimension Nx3
    931 
    932 
    933   The values will be stored in elements following their
    934   internal ordering.
    935 
    936   If location is not 'unique vertices' Indices is the
    937   set of element ids that the operation applies to.
    938   If location is 'unique vertices' Indices is the set
    939   of vertex ids that the operation applies to.
    940 
    941   If selected location is vertices, values for
    942   centroid and edges will be assigned interpolated
    943   values.  In any other case, only values for the
    944   specified locations will be assigned and the others
    945   will be left undefined.
    946 
    947 verbose: True means that output to stdout is generated
    948 
    949 use_cache: True means that caching of intermediate results is
    950            attempted for least squares fit.
     977%location: Where values are to be stored.
     978%  Permissible options are: vertices, edges, centroids
     979%  Default is 'vertices'
     980
     981%  In case of location == 'centroids' the dimension values must
     982%  be a list of a Numerical array of length N,
     983%  N being the number of elements.
     984%  Otherwise it must be of dimension Nx3
     985
     986
     987%  The values will be stored in elements following their
     988%  internal ordering.
     989
     990%  If location is not 'unique vertices' Indices is the
     991%  set of element ids that the operation applies to.
     992%  If location is 'unique vertices' Indices is the set
     993%  of vertex ids that the operation applies to.
     994
     995%  If selected location is vertices, values for
     996%  centroid and edges will be assigned interpolated
     997%  values.  In any other case, only values for the
     998%  specified locations will be assigned and the others
     999%  will be left undefined.
     1000
     1001%verbose: True means that output to stdout is generated
     1002
     1003%use_cache: True means that caching of intermediate results is
     1004%           attempted for least squares fit.
    9511005
    9521006Exactly one of the arguments
     
    11741228\section{Other} 
    11751229
    1176   \begin{funcdesc}{domain.create_quantity_from_expression}{
    1177  
    1178   Handy for creating derived quantities on-the-fly
    1179   See Analytical\_solution_\circular\_hydraulic\_jump.py for an example of use.
     1230  \begin{funcdesc}{domain.create_quantity_from_expression}{???
     1231 
     1232  Handy for creating derived quantities on-the-fly.
     1233  See \code{Analytical\_solution\_circular\_hydraulic\_jump.py} for an example of use.
    11801234  \end{funcdesc}       
    11811235
Note: See TracChangeset for help on using the changeset viewer.