Changeset 3754


Ignore:
Timestamp:
Oct 11, 2006, 4:45:01 PM (18 years ago)
Author:
ole
Message:

Added channel examples to user manual

Location:
anuga_core/documentation/user_manual
Files:
2 edited
3 moved

Legend:

Unmodified
Added
Removed
  • anuga_core/documentation/user_manual/anuga_user_manual.tex

    r3710 r3754  
    658658  \caption{Bedslope example viewed with Swollen}
    659659  \label{fig:bedslope2}
     660\end{figure}
     661
     662
     663
     664\clearpage
     665
     666%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     667
     668\section{A slightly more complex example}
     669\label{sec:channelexample}
     670
     671\subsection{Overview}
     672
     673The next example is about waterflow in a channel with varying boundary conditions and
     674more complex topograhies. These examples build on the
     675concepts introduced through the \file{runup.py} in Section \ref{sec:simpleexample}.
     676The example will be built up through three progressively more complex scripts.
     677
     678\subsection{Overview}
     679As in the case of \file{runup.py}, the actions carried
     680out by the program can be organised according to this outline:
     681
     682\begin{enumerate}
     683
     684   \item Set up a triangular mesh.
     685
     686   \item Set certain parameters governing the mode of
     687operation of the model---specifying, for instance, where to store the
     688model output.
     689
     690   \item Set up initial conditions for various quantities such as the elevation, to be specified at each mesh point (vertex).
     691
     692   \item Set up the boundary conditions.
     693
     694   \item Carry out the evolution of the model through a series of time
     695steps and output the results, providing a results file that can be
     696visualised.
     697
     698\end{enumerate}
     699
     700
     701\subsection{The Code}
     702
     703Here is the code for the first version of the channel flow \file{channel1.py}:
     704
     705\verbatiminput{examples/channel1.py}
     706
     707In discussing the details of this example, we follow the outline
     708given above, discussing each major step of the code in turn.
     709
     710\subsection{Establishing the Mesh}\index{mesh, establishing}
     711
     712In this example we use a similar simple structured triangular mesh as in \code{runup.py}
     713for simplicity, but this time we will use a symmetric one and also
     714change the physical extent of the domain. The assignment
     715
     716{\small \begin{verbatim}
     717    points, vertices, boundary = rectangular_cross(m, n,
     718                                                   len1=length, len2=width)
     719\end{verbatim}}
     720returns a m x n mesh similar to the one used in the previous example, except that now the
     721extent in the x and y directions are given by the value of \code{length} and \code{width}
     722respectively.
     723
     724Defining m and n in terms of the extent as in this example provides a convenient way of
     725controlling the resolution: By defining dx and dy to be the desired size of each hypothenuse in the mesh we can write the mesh generation as follows:
     726
     727{\small \begin{verbatim}
     728length = 10.
     729width = 5.
     730dx = dy = 1           # Resolution: Length of subdivisions on both axes
     731
     732points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
     733                                               len1=length, len2=width)
     734\end{verbatim}}
     735which yields a mesh of length=10m, width=5m with 1m spacings. To increase the resolution, as we will later in this example, one merely decrease the values of dx and dy.
     736
     737The rest of this script is as in the previous example.
     738% except for an application of the 'expression' form of \code{set\_quantity} where we use the value of \code{elevation} to define the (dry) initial condition for \code{stage}:
     739%{\small \begin{verbatim}
     740%  domain.set_quantity('stage', expression='elevation')
     741%\end{verbatim}}
     742
     743\section{Model Output}
     744
     745The following figures are screenshots from the \anuga visualisation
     746tool \code{swollen} of output from this example.
     747%\begin{figure}[hbt]
     748%  \centerline{\includegraphics[width=75mm, height=75mm]
     749%    {examples/runupstart.eps}}%
     750%
     751%  \caption{Bedslope example viewed with Swollen}
     752%  \label{fig:runupstart}
     753%\end{figure}
     754
     755
     756\subsection{Changing boundary conditions on the fly}
     757
     758Here is the code for the second version of the channel flow \file{channel2.py}:
     759\verbatiminput{examples/channel2.py}
     760This example differs from the first version in that a constant outflow boundary condition has
     761been defined
     762{\small \begin{verbatim}
     763    Bo = Dirichlet_boundary([-5, 0, 0]) # Outflow
     764\end{verbatim}}
     765and that it is applied to the right hand side boundary when the water level there exceeds 0m.
     766{\small \begin{verbatim}
     767for t in domain.evolve(yieldstep = 0.2, finaltime = 40.0):
     768    domain.write_time()
     769
     770    if domain.get_quantity('stage').get_values(interpolation_points=[[10, 2.5]]) > 0:       
     771        print 'Stage > 0: Changing to outflow boundary'
     772        domain.modify_boundary({'right': Bo})
     773\end{verbatim}}
     774
     775The if statement in the timestepping loop (evolve) gets the quantity
     776\code{stage} and obtain the interpolated value at the point (10m,
     7772.5m) which is on the right boundary. If the stage exceeds 0m a
     778message is printed and the old boundary condition at tag 'right' is
     779replaced by the outflow boundary using the method
     780{\small \begin{verbatim}
     781    domain.modify_boundary({'right': Bo})
     782\end{verbatim}}
     783This type of dynamically varying boundary could for example be used to model the
     784breakdown of a sluice door when water exceeds a certain level.
     785
     786\subsection{Output}
     787
     788The text output from this example looks like this
     789{\small \begin{verbatim}
     790...
     791Time = 15.4000, delta t in [0.03789902, 0.03789916], steps=6 (6)
     792Time = 15.6000, delta t in [0.03789896, 0.03789908], steps=6 (6)
     793Time = 15.8000, delta t in [0.03789891, 0.03789903], steps=6 (6)
     794Stage > 0: Changing to outflow boundary
     795Time = 16.0000, delta t in [0.02709050, 0.03789898], steps=6 (6)
     796Time = 16.2000, delta t in [0.03789892, 0.03789904], steps=6 (6)
     797...
     798\end{verbatim}}
     799
     800
     801\subsection{Flow through more complex topograhies}
     802
     803Here is the code for the third version of the channel flow \file{channel3.py}:
     804\verbatiminput{examples/channel3.py}
     805
     806This example differs from the first two versions in that the topography
     807contains obstacles.
     808
     809This is accomplished here by defining the function \code{topography} as follows
     810{\small \begin{verbatim}
     811def topography(x,y):
     812    """Complex topography defined by a function of vectors x and y
     813    """
     814   
     815    z = -x/10                               
     816
     817    N = len(x)
     818    for i in range(N):
     819
     820        # Step
     821        if 10 < x[i] < 12:
     822            z[i] += 0.4 - 0.05*y[i]       
     823       
     824        # Constriction
     825        if 27 < x[i] < 29 and y[i] > 3:
     826            z[i] += 2       
     827       
     828        # Pole
     829        if (x[i] - 34)**2 + (y[i] - 2)**2 < 0.4**2:
     830            z[i] += 2
     831
     832    return z
     833\end{verbatim}}
     834
     835In addition, changing the resolution to dx=dy=0.1 creates a finer mesh resolving the new featurse better.
     836
     837A screenshot of this model at time == ... is
     838\begin{figure}[hbt]
     839
     840  \centerline{\includegraphics[width=75mm, height=75mm]
     841    {examples/runupstart.eps}}
     842
     843  \caption{Channel3 example viewed with Swollen}
     844  \label{fig:channel3}
    660845\end{figure}
    661846
  • anuga_core/documentation/user_manual/examples/channel1.py

    r3753 r3754  
    3838                    expression='elevation')        # Dry
    3939#domain.set_quantity('stage',
    40                      expression='elevation + 0.1') # Wet
     40#                     expression='elevation + 0.1') # Wet
    4141
    4242
  • anuga_core/documentation/user_manual/examples/channel3.py

    r3753 r3754  
    1919length = 40.
    2020width = 5.
    21 dx = dy = 1           # Resolution: Length of subdivisions on both axes
    22 #dx = dy = .1           # Resolution: Length of subdivisions on both axes
     21#dx = dy = 1           # Resolution: Length of subdivisions on both axes
     22dx = dy = .1           # Resolution: Length of subdivisions on both axes
    2323
    2424points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
     
    7878
    7979
     80    if domain.get_quantity('stage').\
     81           get_values(interpolation_points=[[10, 2.5]]) > 0:       
     82        print 'Stage > 0: Changing to outflow boundary'
     83        domain.modify_boundary({'right': Bo})
  • anuga_core/documentation/user_manual/examples/runup.py

    r3563 r3754  
    1010#------------------------------------------------------------------------------
    1111
    12 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
     12from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular
    1313from anuga.shallow_water import Domain
    1414from anuga.shallow_water import Reflective_boundary
     
    2222#------------------------------------------------------------------------------
    2323
    24 points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh
     24points, vertices, boundary = rectangular(10, 10) # Basic mesh
    2525
    2626domain = Domain(points, vertices, boundary) # Create domain
Note: See TracChangeset for help on using the changeset viewer.