Changeset 3754
- Timestamp:
- Oct 11, 2006, 4:45:01 PM (18 years ago)
- 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 658 658 \caption{Bedslope example viewed with Swollen} 659 659 \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 673 The next example is about waterflow in a channel with varying boundary conditions and 674 more complex topograhies. These examples build on the 675 concepts introduced through the \file{runup.py} in Section \ref{sec:simpleexample}. 676 The example will be built up through three progressively more complex scripts. 677 678 \subsection{Overview} 679 As in the case of \file{runup.py}, the actions carried 680 out 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 687 operation of the model---specifying, for instance, where to store the 688 model 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 695 steps and output the results, providing a results file that can be 696 visualised. 697 698 \end{enumerate} 699 700 701 \subsection{The Code} 702 703 Here is the code for the first version of the channel flow \file{channel1.py}: 704 705 \verbatiminput{examples/channel1.py} 706 707 In discussing the details of this example, we follow the outline 708 given above, discussing each major step of the code in turn. 709 710 \subsection{Establishing the Mesh}\index{mesh, establishing} 711 712 In this example we use a similar simple structured triangular mesh as in \code{runup.py} 713 for simplicity, but this time we will use a symmetric one and also 714 change 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}} 720 returns a m x n mesh similar to the one used in the previous example, except that now the 721 extent in the x and y directions are given by the value of \code{length} and \code{width} 722 respectively. 723 724 Defining m and n in terms of the extent as in this example provides a convenient way of 725 controlling 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} 728 length = 10. 729 width = 5. 730 dx = dy = 1 # Resolution: Length of subdivisions on both axes 731 732 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), 733 len1=length, len2=width) 734 \end{verbatim}} 735 which 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 737 The 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 745 The following figures are screenshots from the \anuga visualisation 746 tool \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 758 Here is the code for the second version of the channel flow \file{channel2.py}: 759 \verbatiminput{examples/channel2.py} 760 This example differs from the first version in that a constant outflow boundary condition has 761 been defined 762 {\small \begin{verbatim} 763 Bo = Dirichlet_boundary([-5, 0, 0]) # Outflow 764 \end{verbatim}} 765 and that it is applied to the right hand side boundary when the water level there exceeds 0m. 766 {\small \begin{verbatim} 767 for 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 775 The if statement in the timestepping loop (evolve) gets the quantity 776 \code{stage} and obtain the interpolated value at the point (10m, 777 2.5m) which is on the right boundary. If the stage exceeds 0m a 778 message is printed and the old boundary condition at tag 'right' is 779 replaced by the outflow boundary using the method 780 {\small \begin{verbatim} 781 domain.modify_boundary({'right': Bo}) 782 \end{verbatim}} 783 This type of dynamically varying boundary could for example be used to model the 784 breakdown of a sluice door when water exceeds a certain level. 785 786 \subsection{Output} 787 788 The text output from this example looks like this 789 {\small \begin{verbatim} 790 ... 791 Time = 15.4000, delta t in [0.03789902, 0.03789916], steps=6 (6) 792 Time = 15.6000, delta t in [0.03789896, 0.03789908], steps=6 (6) 793 Time = 15.8000, delta t in [0.03789891, 0.03789903], steps=6 (6) 794 Stage > 0: Changing to outflow boundary 795 Time = 16.0000, delta t in [0.02709050, 0.03789898], steps=6 (6) 796 Time = 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 803 Here is the code for the third version of the channel flow \file{channel3.py}: 804 \verbatiminput{examples/channel3.py} 805 806 This example differs from the first two versions in that the topography 807 contains obstacles. 808 809 This is accomplished here by defining the function \code{topography} as follows 810 {\small \begin{verbatim} 811 def 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 835 In addition, changing the resolution to dx=dy=0.1 creates a finer mesh resolving the new featurse better. 836 837 A 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} 660 845 \end{figure} 661 846 -
anuga_core/documentation/user_manual/examples/channel1.py
r3753 r3754 38 38 expression='elevation') # Dry 39 39 #domain.set_quantity('stage', 40 expression='elevation + 0.1') # Wet40 # expression='elevation + 0.1') # Wet 41 41 42 42 -
anuga_core/documentation/user_manual/examples/channel3.py
r3753 r3754 19 19 length = 40. 20 20 width = 5. 21 dx = dy = 1 # Resolution: Length of subdivisions on both axes22 #dx = dy = .1 # Resolution: Length of subdivisions on both axes21 #dx = dy = 1 # Resolution: Length of subdivisions on both axes 22 dx = dy = .1 # Resolution: Length of subdivisions on both axes 23 23 24 24 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), … … 78 78 79 79 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 10 10 #------------------------------------------------------------------------------ 11 11 12 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular _cross12 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular 13 13 from anuga.shallow_water import Domain 14 14 from anuga.shallow_water import Reflective_boundary … … 22 22 #------------------------------------------------------------------------------ 23 23 24 points, vertices, boundary = rectangular _cross(10, 10) # Basic mesh24 points, vertices, boundary = rectangular(10, 10) # Basic mesh 25 25 26 26 domain = Domain(points, vertices, boundary) # Create domain
Note: See TracChangeset
for help on using the changeset viewer.