Changeset 8974 for trunk/anuga_core
- Timestamp:
- Sep 12, 2013, 9:32:39 PM (12 years ago)
- Location:
- trunk/anuga_core
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/demos/channel1.py
r8728 r8974 7 7 # Import necessary modules 8 8 #------------------------------------------------------------------------------ 9 10 # Import standard shallow water domain and standard boundaries.11 9 import anuga 12 13 10 14 11 #------------------------------------------------------------------------------ 15 12 # Setup computational domain 16 13 #------------------------------------------------------------------------------ 17 points, vertices, boundary = anuga.rectangular_cross(10, 5, 18 len1=10.0, len2=5.0) # Mesh 14 # Create a domain with named boundaries "left", "right", "top" and "bottom" 15 domain = anuga.rectangular_cross_domain(10, 5, len1=10.0, len2=5.0) # Create domain 19 16 20 domain = anuga.Domain(points, vertices, boundary) # Create domain 17 21 18 domain.set_name('channel1') # Output name 22 19 … … 44 41 #------------------------------------------------------------------------------ 45 42 for t in domain.evolve(yieldstep=0.2, finaltime=40.0): 46 print domain.timestepping_statistics()43 domain.print_timestepping_statistics() 47 44 -
trunk/anuga_core/source/anuga/__init__.py
r8972 r8974 66 66 67 67 #----------------------------- 68 # S tandard Boundaries68 # SwW Standard Boundaries 69 69 #----------------------------- 70 70 from anuga.shallow_water.boundaries import File_boundary … … 82 82 83 83 #----------------------------- 84 # SWW-specificBoundaries84 # General Boundaries 85 85 #----------------------------- 86 86 from anuga.abstract_2d_finite_volumes.generic_boundary_conditions \ … … 96 96 97 97 #----------------------------- 98 # Shal ow Water Tsunamis98 # Shallow Water Tsunamis 99 99 #----------------------------- 100 100 … … 106 106 #----------------------------- 107 107 from anuga.shallow_water.forcing import Inflow, Rainfall, Wind_stress 108 109 108 110 109 111 #----------------------------- … … 140 142 from anuga.operators.base_operator import Operator 141 143 from anuga.operators.kinematic_viscosity_operator import Kinematic_viscosity_operator 144 from anuga.operators.rate_operators import Rate_operator 145 from anuga.operators.set_friction_operators import Depth_friction_operator 142 146 143 147 #--------------------------- … … 371 375 import time 372 376 from os.path import join 373 from scipy import interpolate 377 374 378 from anuga import indent 375 379 from anuga.utilities.model_tools import read_polygon_dir, read_hole_dir, read_multi_poly_file, read_multi_poly_file_value 376 from anuga.operators.rate_operators import Rate_operator, Polygonal_rate_operator377 from anuga.operators.set_friction_operators import Depth_friction_operator378 from anuga.structures.boyd_box_operator import Boyd_box_operator379 from anuga.structures.boyd_pipe_operator import Boyd_pipe_operator -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/file_function.py
r8953 r8974 179 179 'First argument to File_function must be a string' 180 180 181 try:182 fid = open(filename)183 except IOError, e:184 msg = 'File "%s" could not be opened: Error="%s"' % (filename, e)185 raise IOError(msg)186 181 #try: 182 # fid = open(filename) 183 #except IOError, e: 184 # msg = 'File "%s" could not be opened: Error="%s"' % (filename, e) 185 # raise IOError(msg) 186 187 187 # read first line of file, guess file type 188 line = fid.readline() 189 fid.close() 190 191 if line[:3] == 'CDF': 188 #line = fid.readline() 189 #fid.close() 190 191 import os 192 ext = os.path.splitext(filename)[1] 193 msg = 'Extension should be csv sww, tms or sts ' 194 assert ext in [".csv", ".sww", ".tms", ".sts"], msg 195 196 197 if ext in [".sww", ".tms", ".sts"]: 192 198 return get_netcdf_file_function(filename, 193 199 quantities, … … 199 205 boundary_polygon=boundary_polygon, 200 206 output_centroids=output_centroids) 201 el se:207 elif ext in [".csv"]: 202 208 # FIXME (Ole): Could add csv file here to address Ted Rigby's 203 209 # suggestion about reading hydrographs. 204 # This may also deal with the gist of ticket:289 210 # This may also deal with the gist of ticket:289 211 raise Exception('Must be a NetCDF File') 212 else: 213 205 214 raise Exception('Must be a NetCDF File') 206 215 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r8973 r8974 1257 1257 points = ensure_absolute(points, geo_reference=self.domain.geo_reference) 1258 1258 1259 print numpy.max(points[:,0])1260 print numpy.min(points[:,0])1261 print numpy.max(points[:,1])1262 print numpy.min(points[:,1])1263 1264 print numpy.max(x)1265 print numpy.min(x)1266 print numpy.max(y)1267 print numpy.min(y)1259 # print numpy.max(points[:,0]) 1260 # print numpy.min(points[:,0]) 1261 # print numpy.max(points[:,1]) 1262 # print numpy.min(points[:,1]) 1263 # 1264 # print numpy.max(x) 1265 # print numpy.min(x) 1266 # print numpy.max(y) 1267 # print numpy.min(y) 1268 1268 1269 1269 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py
r8973 r8974 1388 1388 1389 1389 def test_set_values_from_asc_vertices(self): 1390 1391 1392 1393 1394 1395 x0 = 0.0 1396 y0 = 0.0 1397 1398 a = [0.0, 0.0] 1399 b = [0.0, 2.0] 1400 c = [2.0, 0.0] 1401 d = [0.0, 4.0] 1402 e = [2.0, 2.0] 1403 f = [4.0, 0.0] 1404 1405 points = [a, b, c, d, e, f] 1406 1407 #bac, bce, ecf, dbe 1408 elements = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4] ] 1409 1410 mesh4 = Generic_Domain(points, elements) 1411 # geo_reference = Geo_reference(56, x0, y0)) 1412 mesh4.check_integrity() 1413 quantity = Quantity(mesh4) 1414 1390 1415 """ Format of asc file 1391 1416 ncols 11 … … 1396 1421 NODATA_value -9999 1397 1422 """ 1398 1399 #x0 = 314036.587279821400 #y0 = 6224951.29600921401 x0 = 0.01402 y0 = 0.01403 1404 a = [0.0, 0.0]1405 b = [0.0, 2.0]1406 c = [2.0, 0.0]1407 d = [0.0, 4.0]1408 e = [2.0, 2.0]1409 f = [4.0, 0.0]1410 1411 points = [a, b, c, d, e, f]1412 1413 #bac, bce, ecf, dbe1414 elements = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4] ]1415 1416 mesh4 = Generic_Domain(points, elements)1417 # geo_reference = Geo_reference(56, x0, y0))1418 mesh4.check_integrity()1419 quantity = Quantity(mesh4)1420 1421 1422 1423 ncols = 11 # Nx 1423 1424 nrows = 12 # Ny -
trunk/anuga_core/source/anuga/config.py
r8970 r8974 223 223 netcdf_mode_a = 'a' 224 224 netcdf_mode_r = 'r' 225 226 227 indent = ' ' 225 228 226 229 # Code to set the write mode depending on -
trunk/anuga_core/source/anuga/operators/rate_operators.py
r8945 r8974 11 11 12 12 13 from anuga import indent13 from anuga.config import indent 14 14 import numpy as num 15 15 import anuga.utilities.log as log -
trunk/anuga_core/source/anuga/operators/set_elevation.py
r8931 r8974 17 17 18 18 from anuga.operators.set_quantity import Set_quantity 19 20 from anuga import indent 19 from anuga.config import indent 21 20 22 21 class Set_elevation(Set_quantity): -
trunk/anuga_core/source/anuga/operators/set_elevation_operator.py
r8945 r8974 13 13 from anuga.operators.set_elevation import Set_elevation 14 14 15 from anuga import indent15 from anuga.config import indent 16 16 17 17 -
trunk/anuga_core/source/anuga/operators/set_friction_operators.py
r8951 r8974 15 15 from anuga.operators.base_operator import Operator 16 16 from anuga.operators.region import Region 17 18 19 from anuga import indent 17 from anuga.config import indent 20 18 21 19 -
trunk/anuga_core/source/anuga/operators/set_quantity.py
r8931 r8974 17 17 from anuga.utilities.function_utils import determine_function_type 18 18 from anuga.operators.region import Region 19 from anuga import indent19 from anuga.config import indent 20 20 21 21 class Set_quantity(Region): -
trunk/anuga_core/source/anuga/operators/set_quantity_operator.py
r8945 r8974 13 13 from anuga.operators.base_operator import Operator 14 14 from anuga.operators.set_quantity import Set_quantity 15 16 from anuga import indent 15 from anuga.config import indent 17 16 18 17 -
trunk/anuga_core/source/anuga/operators/set_stage_operator.py
r8945 r8974 18 18 19 19 from anuga.operators.set_quantity_operator import Set_quantity_operator 20 21 22 from anuga import indent 20 from anuga.config import indent 23 21 24 22 -
trunk/anuga_core/source/anuga/operators/set_w_uh_vh_operators.py
r8619 r8974 20 20 from anuga.fit_interpolate.interpolate import Modeltime_too_early, \ 21 21 Modeltime_too_late 22 from anuga import indent22 from anuga.config import indent 23 23 24 24 -
trunk/anuga_core/source/anuga/structures/test_inlet_operator.py
r8874 r8974 299 299 # ========================================================================= 300 300 if __name__ == "__main__": 301 suite = unittest.makeSuite(Test_inlet_operator, 'test _inlet_constant_Q_polygon')301 suite = unittest.makeSuite(Test_inlet_operator, 'test') 302 302 runner = unittest.TextTestRunner() 303 303 runner.run(suite) -
trunk/anuga_core/source/anuga/version.py
r8251 r8974 1 #! /usr/bin/python 2 3 # To change this template, choose Tools | Templates 4 # and open the template in the editor. 5 6 __author__="steve" 7 __date__ ="$18/11/2011 11:35:22 AM$" 8 9 if __name__ == "__main__": 10 import anuga 11 print 'Anuga version:',anuga.__version__ 1 version = 8973 2 status = 'Modified' 3 date = '2013/09/12 15:18:38' -
trunk/anuga_core/user_manual/anuga_user_manual.tex
r8973 r8974 45 45 46 46 \title{\anuga User Manual} 47 \author{ Geoscience Australia and the Australian National University}47 \author{Stephen Roberts, Ole Nielsen, Duncan Gray and Jane Sexton} 48 48 49 49 % Please at least include a long-lived email address; … … 61 61 % stages to make it easier to handle versions. 62 62 63 \longdate % Make date format long using datetime.sty63 %\longdate % Make date format long using datetime.sty 64 64 %\settimeformat{xxivtime} % 24 hour Format 65 \settimeformat{oclock} % Verbose66 \date{\today ,\ \currenttime}65 %\settimeformat{oclock} % Verbose 66 \date{\today \ \currenttime} 67 67 %\hyphenation{set\_datadir} 68 68 … … 1394 1394 \end{verbatim} 1395 1395 1396 All modules are in the folder \file{ inundation} or one of its subfolders, and the1397 location of each module is described relative to \file{ inundation}. Rather1396 All modules are in the folder \file{anuga} or one of its subfolders, and the 1397 location of each module is described relative to \file{anuga}. Rather 1398 1398 than using pathnames, whose syntax depends on the operating system, 1399 1399 we use the format adopted for importing the function or class for … … 2566 2566 2567 2567 2568 \section{Forcing Terms}\index{Forcing terms}2569 \label{sec:forcing terms}2570 2571 \anuga provides a number of predefined forcing functions to be used with simulations.2572 Gravity and friction are always calculated using the elevation and friction quantities,2573 but the user may additionally add forcing terms to the list2574 \code{domain.forcing_terms} and have them affect the model.2575 2576 Currently, predefined forcing terms are: \\2577 \begin{classdesc}{General_forcing}{domain,2578 quantity_name,2579 rate=0.0,2580 center=None,2581 radius=None,2582 polygon=None,2583 default_rate=None,2584 verbose=False}2585 Module: \module{shallow_water.shallow_water_domain}2586 2587 This is a general class to modify any quantity according to a given rate of change.2588 Other specific forcing terms are based on this class but it can be used by itself as well (e.g.\ to modify momentum).2589 2590 \code{domain} is the domain being evolved.2591 2592 \code{quantity_name} is the name of the quantity that will be affected by this forcing term.2593 2594 \code{rate} is the rate at which the quantity should change. This can be either a constant or a2595 function of time. Positive values indicate increases, negative values indicate decreases.2596 The parameter \code{rate} can be \code{None} at initialisation but must be specified2597 before a forcing term is applied (i.e.\ simulation has started).2598 The default value is 0.0 -- i.e.\ no forcing.2599 2600 \code{center} and \code{ radius} optionally restrict forcing to a circle with given center and radius.2601 2602 \code{polygon} optionally restricts forcing to an area enclosed by the given polygon.2603 2604 Note: specifying \code{center}, \code{radius} and \code{polygon} will cause an exception to be thrown.2605 Moreover, if the specified polygon or circle does not lie fully within the mesh boundary an Exception will be thrown.2606 2607 Example:2608 2609 \begin{verbatim}2610 P = [[x0, y0], [x1, y0], [x1, y1], [x0, y1]] # Square polygon2611 2612 xmom = General_forcing(domain, 'xmomentum', polygon=P)2613 ymom = General_forcing(domain, 'ymomentum', polygon=P)2614 2615 xmom.rate = f2616 ymom.rate = g2617 2618 domain.forcing_terms.append(xmom)2619 domain.forcing_terms.append(ymom)2620 \end{verbatim}2621 2622 Here, \code{f} and \code{g} are assumed to be defined as functions of time providing2623 a time dependent rate of change for xmomentum and ymomentum respectively.2624 \code{P} is assumed to be the polygon, specified as a list of points.2625 \end{classdesc}2626 2627 \begin{classdesc}{Inflow}{domain,2628 rate=0.0,2629 center=None, radius=None,2630 polygon=None,2631 default_rate=None,2632 verbose=False}2633 Module: \module{shallow_water.shallow_water_domain}2634 2635 This is a general class for inflow and abstraction of water according to a given rate of change.2636 This class will always modify the \code{stage} quantity.2637 2638 Inflow is based on the \code{General_forcing} class so the functionality is similar.2639 2640 \code{domain} is the domain being evolved.2641 2642 \code{rate} is the flow rate ($m^3/s$) at which the quantity should change. This can be either a constant or a2643 function of time. Positive values indicate inflow, negative values indicate outflow.2644 Note: The specified flow will be divided by the area of the inflow region and then applied to update the2645 stage quantity.2646 2647 \code{center} and \code{ radius} optionally restrict forcing to a circle with given center and radius.2648 2649 \code{polygon} optionally restricts forcing to an area enclosed by the given polygon.2650 2651 Example:2652 2653 \begin{verbatim}2654 hydrograph = Inflow(center=(320, 300), radius=10,2655 rate=file_function('QPMF_Rot_Sub13.tms'))2656 2657 domain.forcing_terms.append(hydrograph)2658 \end{verbatim}2659 2660 Here, \code{'QPMF_Rot_Sub13.tms'} is assumed to be a NetCDF file in the TMS format defining a timeseries for a hydrograph.2661 \end{classdesc}2662 2663 \begin{classdesc}{Rainfall}{domain,2664 rate=0.0,2665 center=None,2666 radius=None,2667 polygon=None,2668 default_rate=None,2669 verbose=False}2670 Module: \module{shallow_water.shallow_water_domain}2671 2672 This is a general class for implementing rainfall over the domain, possibly restricted to a given circle or polygon.2673 This class will always modify the \code{stage} quantity.2674 2675 Rainfall is based on the \code{General_forcing} class so the functionality is similar.2676 2677 \code{domain} is the domain being evolved.2678 2679 \code{rate} is the total rain rate over the specified domain.2680 Note: Raingauge Data needs to reflect the time step.2681 For example, if rain gauge is \code{mm} read every \code{dt} seconds, then the input2682 here is as \code{mm/dt} so 10 mm in 5 minutes becomes2683 10/(5x60) = 0.0333mm/s. This parameter can be either a constant or a2684 function of time. Positive values indicate rain being added (or be used for general infiltration),2685 negative values indicate outflow at the specified rate (presumably this could model evaporation or abstraction).2686 2687 \code{center} and \code{ radius} optionally restrict forcing to a circle with given center and radius.2688 2689 \code{polygon} optionally restricts forcing to an area enclosed by the given polygon.2690 2691 Example:2692 2693 \begin{verbatim}2694 catchmentrainfall = Rainfall(rate=file_function('Q100_2hr_Rain.tms'))2695 domain.forcing_terms.append(catchmentrainfall)2696 \end{verbatim}2697 2698 Here, \code{'Q100_2hr_Rain.tms'} is assumed to be a NetCDF file in the TMS format defining a timeseries for the rainfall.2699 \end{classdesc}2700 2701 \begin{classdesc}{Culvert_flow}{domain,2702 culvert_description_filename=None,2703 culvert_routine=None,2704 end_point0=None,2705 end_point1=None,2706 enquiry_point0=None,2707 enquiry_point1=None,2708 type='box',2709 width=None,2710 height=None,2711 length=None,2712 number_of_barrels=1,2713 trigger_depth=0.01,2714 manning=None,2715 sum_loss=None,2716 use_velocity_head=False,2717 use_momentum_jet=False,2718 label=None,2719 description=None,2720 update_interval=None,2721 log_file=False,2722 discharge_hydrograph=False,2723 verbose=False}2724 Module: \module{culvert_flows.culvert_class}2725 2726 This is a general class for implementing flow through a culvert.2727 This class modifies the quantities \code{stage}, \code{xmomentum} and \code{ymomentum} in areas at both ends of the culvert.2728 2729 The \code{Culvert_flow} forcing term uses \code{Inflow} and \code{General_forcing} to update the quantities.2730 The flow direction is determined on-the-fly so openings are referenced simple as opening0 and opening12731 with either being able to take the role as Inflow or Outflow.2732 2733 The \code{Culvert_flow} class takes as input:2734 2735 \code{domain}: a reference to the domain being evolved2736 2737 \code{culvert_description_filename}:2738 2739 \code{culvert_routine}:2740 2741 \code{end_point0}: Coordinates of one opening2742 2743 \code{end_point1}: Coordinates of other opening2744 2745 \code{enquiry_point0}:2746 2747 \code{enquiry_point1}:2748 2749 \code{type}: (default is 'box')2750 2751 \code{width}:2752 2753 \code{height}:2754 2755 \code{length}:2756 2757 \code{number_of_barrels}: Number of identical pipes in the culvert (default is 1)2758 2759 \code{trigger_depth}: (default is 0.01)2760 2761 \code{manning}: Mannings Roughness for Culvert2762 2763 \code{sum_loss}:2764 2765 \code{use_velocity_head}:2766 2767 \code{use_momentum_jet}:2768 2769 \code{label}: Short text naming the culvert2770 2771 \code{description}: Text describing the culvert2772 2773 \code{update_interval}:2774 2775 \code{log_file}:2776 2777 \code{discharge_hydrograph}:2778 2779 2780 The user can specify different culvert routines. However, \anuga currently provides only one, namely the2781 \code{boyd_generalised_culvert_model} as used in the example below:2782 2783 \begin{verbatim}2784 from anuga.culvert_flows.culvert_class import Culvert_flow2785 from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model2786 2787 culvert1 = Culvert_flow(domain,2788 label='Culvert No. 1',2789 description='This culvert is a test unit 1.2m Wide by 0.75m High',2790 end_point0=[9.0, 2.5],2791 end_point1=[13.0, 2.5],2792 width=1.20,2793 height=0.75,2794 culvert_routine=boyd_generalised_culvert_model,2795 number_of_barrels=1,2796 verbose=True)2797 2798 culvert2 = Culvert_flow(domain,2799 label='Culvert No. 2',2800 description='This culvert is a circular test with d=1.2m',2801 end_point0=[9.0, 1.5],2802 end_point1=[30.0, 3.5],2803 diameter=1.20,2804 invert_level0=7,2805 culvert_routine=boyd_generalised_culvert_model,2806 number_of_barrels=1,2807 verbose=True)2808 2809 domain.forcing_terms.append(culvert1)2810 domain.forcing_terms.append(culvert2)2811 \end{verbatim}2812 \end{classdesc}2813 2568 %\section{Forcing Terms}\index{Forcing terms} 2569 %\label{sec:forcing terms} 2570 % 2571 %\anuga provides a number of predefined forcing functions to be used with simulations. 2572 %Gravity and friction are always calculated using the elevation and friction quantities, 2573 %but the user may additionally add forcing terms to the list 2574 %\code{domain.forcing_terms} and have them affect the model. 2575 % 2576 %Currently, predefined forcing terms are: \\ 2577 %\begin{classdesc}{General_forcing}{domain, 2578 % quantity_name, 2579 % rate=0.0, 2580 % center=None, 2581 % radius=None, 2582 % polygon=None, 2583 % default_rate=None, 2584 % verbose=False} 2585 %Module: \module{shallow_water.shallow_water_domain} 2586 % 2587 %This is a general class to modify any quantity according to a given rate of change. 2588 %Other specific forcing terms are based on this class but it can be used by itself as well (e.g.\ to modify momentum). 2589 % 2590 %\code{domain} is the domain being evolved. 2591 % 2592 %\code{quantity_name} is the name of the quantity that will be affected by this forcing term. 2593 % 2594 %\code{rate} is the rate at which the quantity should change. This can be either a constant or a 2595 %function of time. Positive values indicate increases, negative values indicate decreases. 2596 %The parameter \code{rate} can be \code{None} at initialisation but must be specified 2597 %before a forcing term is applied (i.e.\ simulation has started). 2598 %The default value is 0.0 -- i.e.\ no forcing. 2599 % 2600 %\code{center} and \code{ radius} optionally restrict forcing to a circle with given center and radius. 2601 % 2602 %\code{polygon} optionally restricts forcing to an area enclosed by the given polygon. 2603 % 2604 %Note: specifying \code{center}, \code{radius} and \code{polygon} will cause an exception to be thrown. 2605 %Moreover, if the specified polygon or circle does not lie fully within the mesh boundary an Exception will be thrown. 2606 % 2607 %Example: 2608 % 2609 %\begin{verbatim} 2610 %P = [[x0, y0], [x1, y0], [x1, y1], [x0, y1]] # Square polygon 2611 % 2612 %xmom = General_forcing(domain, 'xmomentum', polygon=P) 2613 %ymom = General_forcing(domain, 'ymomentum', polygon=P) 2614 % 2615 %xmom.rate = f 2616 %ymom.rate = g 2617 % 2618 %domain.forcing_terms.append(xmom) 2619 %domain.forcing_terms.append(ymom) 2620 %\end{verbatim} 2621 % 2622 %Here, \code{f} and \code{g} are assumed to be defined as functions of time providing 2623 %a time dependent rate of change for xmomentum and ymomentum respectively. 2624 %\code{P} is assumed to be the polygon, specified as a list of points. 2625 %\end{classdesc} 2626 % 2627 %\begin{classdesc}{Inflow}{domain, 2628 % rate=0.0, 2629 % center=None, radius=None, 2630 % polygon=None, 2631 % default_rate=None, 2632 % verbose=False} 2633 %Module: \module{shallow_water.shallow_water_domain} 2634 % 2635 %This is a general class for inflow and abstraction of water according to a given rate of change. 2636 %This class will always modify the \code{stage} quantity. 2637 % 2638 %Inflow is based on the \code{General_forcing} class so the functionality is similar. 2639 % 2640 %\code{domain} is the domain being evolved. 2641 % 2642 %\code{rate} is the flow rate ($m^3/s$) at which the quantity should change. This can be either a constant or a 2643 %function of time. Positive values indicate inflow, negative values indicate outflow. 2644 %Note: The specified flow will be divided by the area of the inflow region and then applied to update the 2645 %stage quantity. 2646 % 2647 %\code{center} and \code{ radius} optionally restrict forcing to a circle with given center and radius. 2648 % 2649 %\code{polygon} optionally restricts forcing to an area enclosed by the given polygon. 2650 % 2651 %Example: 2652 % 2653 %\begin{verbatim} 2654 %hydrograph = Inflow(center=(320, 300), radius=10, 2655 % rate=file_function('QPMF_Rot_Sub13.tms')) 2656 % 2657 %domain.forcing_terms.append(hydrograph) 2658 %\end{verbatim} 2659 % 2660 %Here, \code{'QPMF_Rot_Sub13.tms'} is assumed to be a NetCDF file in the TMS format defining a timeseries for a hydrograph. 2661 %\end{classdesc} 2662 % 2663 %\begin{classdesc}{Rainfall}{domain, 2664 % rate=0.0, 2665 % center=None, 2666 % radius=None, 2667 % polygon=None, 2668 % default_rate=None, 2669 % verbose=False} 2670 %Module: \module{shallow_water.shallow_water_domain} 2671 % 2672 %This is a general class for implementing rainfall over the domain, possibly restricted to a given circle or polygon. 2673 %This class will always modify the \code{stage} quantity. 2674 % 2675 %Rainfall is based on the \code{General_forcing} class so the functionality is similar. 2676 % 2677 %\code{domain} is the domain being evolved. 2678 % 2679 %\code{rate} is the total rain rate over the specified domain. 2680 %Note: Raingauge Data needs to reflect the time step. 2681 %For example, if rain gauge is \code{mm} read every \code{dt} seconds, then the input 2682 %here is as \code{mm/dt} so 10 mm in 5 minutes becomes 2683 %10/(5x60) = 0.0333mm/s. This parameter can be either a constant or a 2684 %function of time. Positive values indicate rain being added (or be used for general infiltration), 2685 %negative values indicate outflow at the specified rate (presumably this could model evaporation or abstraction). 2686 % 2687 %\code{center} and \code{ radius} optionally restrict forcing to a circle with given center and radius. 2688 % 2689 %\code{polygon} optionally restricts forcing to an area enclosed by the given polygon. 2690 % 2691 %Example: 2692 % 2693 %\begin{verbatim} 2694 %catchmentrainfall = Rainfall(rate=file_function('Q100_2hr_Rain.tms')) 2695 %domain.forcing_terms.append(catchmentrainfall) 2696 %\end{verbatim} 2697 % 2698 %Here, \code{'Q100_2hr_Rain.tms'} is assumed to be a NetCDF file in the TMS format defining a timeseries for the rainfall. 2699 %\end{classdesc} 2700 % 2701 %\begin{classdesc}{Culvert_flow}{domain, 2702 % culvert_description_filename=None, 2703 % culvert_routine=None, 2704 % end_point0=None, 2705 % end_point1=None, 2706 % enquiry_point0=None, 2707 % enquiry_point1=None, 2708 % type='box', 2709 % width=None, 2710 % height=None, 2711 % length=None, 2712 % number_of_barrels=1, 2713 % trigger_depth=0.01, 2714 % manning=None, 2715 % sum_loss=None, 2716 % use_velocity_head=False, 2717 % use_momentum_jet=False, 2718 % label=None, 2719 % description=None, 2720 % update_interval=None, 2721 % log_file=False, 2722 % discharge_hydrograph=False, 2723 % verbose=False} 2724 %Module: \module{culvert_flows.culvert_class} 2725 % 2726 %This is a general class for implementing flow through a culvert. 2727 %This class modifies the quantities \code{stage}, \code{xmomentum} and \code{ymomentum} in areas at both ends of the culvert. 2728 % 2729 %The \code{Culvert_flow} forcing term uses \code{Inflow} and \code{General_forcing} to update the quantities. 2730 %The flow direction is determined on-the-fly so openings are referenced simple as opening0 and opening1 2731 %with either being able to take the role as Inflow or Outflow. 2732 % 2733 %The \code{Culvert_flow} class takes as input: 2734 % 2735 % \code{domain}: a reference to the domain being evolved 2736 % 2737 %\code{culvert_description_filename}: 2738 % 2739 %\code{culvert_routine}: 2740 % 2741 % \code{end_point0}: Coordinates of one opening 2742 % 2743 % \code{end_point1}: Coordinates of other opening 2744 % 2745 % \code{enquiry_point0}: 2746 % 2747 % \code{enquiry_point1}: 2748 % 2749 % \code{type}: (default is 'box') 2750 % 2751 % \code{width}: 2752 % 2753 % \code{height}: 2754 % 2755 % \code{length}: 2756 % 2757 % \code{number_of_barrels}: Number of identical pipes in the culvert (default is 1) 2758 % 2759 % \code{trigger_depth}: (default is 0.01) 2760 % 2761 % \code{manning}: Mannings Roughness for Culvert 2762 % 2763 % \code{sum_loss}: 2764 % 2765 % \code{use_velocity_head}: 2766 % 2767 % \code{use_momentum_jet}: 2768 % 2769 % \code{label}: Short text naming the culvert 2770 % 2771 % \code{description}: Text describing the culvert 2772 % 2773 % \code{update_interval}: 2774 % 2775 % \code{log_file}: 2776 % 2777 % \code{discharge_hydrograph}: 2778 % 2779 % 2780 %The user can specify different culvert routines. However, \anuga currently provides only one, namely the 2781 %\code{boyd_generalised_culvert_model} as used in the example below: 2782 % 2783 %\begin{verbatim} 2784 %from anuga.culvert_flows.culvert_class import Culvert_flow 2785 %from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model 2786 % 2787 %culvert1 = Culvert_flow(domain, 2788 % label='Culvert No. 1', 2789 % description='This culvert is a test unit 1.2m Wide by 0.75m High', 2790 % end_point0=[9.0, 2.5], 2791 % end_point1=[13.0, 2.5], 2792 % width=1.20, 2793 % height=0.75, 2794 % culvert_routine=boyd_generalised_culvert_model, 2795 % number_of_barrels=1, 2796 % verbose=True) 2797 % 2798 %culvert2 = Culvert_flow(domain, 2799 % label='Culvert No. 2', 2800 % description='This culvert is a circular test with d=1.2m', 2801 % end_point0=[9.0, 1.5], 2802 % end_point1=[30.0, 3.5], 2803 % diameter=1.20, 2804 % invert_level0=7, 2805 % culvert_routine=boyd_generalised_culvert_model, 2806 % number_of_barrels=1, 2807 % verbose=True) 2808 % 2809 %domain.forcing_terms.append(culvert1) 2810 %domain.forcing_terms.append(culvert2) 2811 %\end{verbatim} 2812 %\end{classdesc} 2813 % 2814 2814 2815 2815 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2816 \section{Fractional Step Operators}\index{fractional step operators} 2817 2818 An alternative way to effect the evolution is via fractional step operators. The idea is that at each inner timestep we can use 2819 a fractional step operator to change the centroid values of our conserved quantities, the stage and the xmomentum and the ymomentum. The elevation can also be changed but more care needs to be applied as the \code{elevation} quantity needs to remain continuous. The moral, play with \code{elevation} at your peril. 2820 2821 We are tending to move away from forcing terms and towards fractpional step operators as they are easier to parallelize. 2822 2823 2824 Currently predefined fractional step operators: 2816 \section{Operators}\index{operators} 2817 2818 A way to effect the evolution is via fractional step \code{operators}. The idea is that at each inner timestep we can use 2819 an \code{operator} to change the centroid values of quantities such as the stage and the xmomentum and the ymomentum. T 2820 2821 The elevation can also be changed but more care needs to be applied as the \code{elevation} quantity needs to remain continuous. The moral, play with \code{elevation} at your peril. 2822 2823 Currently predefined operators: 2825 2824 2826 2825 … … 2837 2836 Module: \module{anuga.operators.set_elevation_operator} 2838 2837 2839 Set the elevation in a region (careful to maintain continuit iy of elevation)2838 Set the elevation in a region (careful to maintain continuity of elevation) 2840 2839 2841 2840 … … 2854 2853 \code{description} is a description of this operator. 2855 2854 2856 \code{label} is the lab leused when reporting on the operator.2855 \code{label} is the label used when reporting on the operator. 2857 2856 2858 2857 \code{logging} is the boolean flag to set logging to a file. … … 2863 2862 2864 2863 \begin{verbatim} 2865 from anuga.operators.set_elevation_operator import Set_elevation_operator 2866 2867 op0 =Set_elevation_operator(domain, elevation = lambda t : 0.01*t) 2864 op0 = anuga.Set_elevation_operator(domain, elevation = lambda t : 0.01*t) 2868 2865 \end{verbatim} 2869 2866 would setup an operator which raises the elevation over the whole domain 1 cm per second. … … 2872 2869 While 2873 2870 \begin{verbatim} 2874 from anuga.operators.set_elevation_operator import Set_elevation_operator2875 2871 P = [[x0, y0], [x1, y0], [x1, y1], [x0, y1]] 2876 2872 2877 op0 =Set_elevation_operator(domain, elevation = lambda t : 0.01*t, polygon=P) 2873 op0 = anuga.Set_elevation_operator(domain, \ 2874 elevation = lambda t : 0.01*t, polygon=P) 2878 2875 \end{verbatim} 2879 2876 would setup an operator which raises the elevation over the polygon \code{P} 1 cm per second. … … 2881 2878 \end{classdesc} 2882 2879 2883 2884 2885 \subsection{User developed fractional step operator} 2880 %-------------------------------------------- 2881 \subsection{Culvert operators} 2882 2883 A culvert is a structure that allows water to flow under a road, rail road, trail, or similar obstruction that would otherwise build up behind the embankment. But culverts are also used to drain basins, dams or lakes. \anuga now has the ability to model a culvert by transferring flows from one point in the 2D domain to another. It should be noted that flow from the culvert inlet to the outlet occurs instantaneously with no lagging of the flows. 2884 2885 Only box culverts and pipe culverts can be modelled at present using the Boyd Method (Generalised head-discharge equations for culverts, Proceedings of the fourth national local government engineering conference pp. 161-165, Perth, August, 1987). 2886 2887 Usage 2888 2889 In \anuga, a culvert can be modelled as two points (an inlet point and an outlet point) or along two lines (and inlet line and an outlet line) to account for skew. 2890 2891 The user needs to nominate the location of the culvert inlet and outlet, any culvert losses (i.e. inlet, outlet, bends etc) and the culvert dimensions (in metres). 2892 2893 The user can also model the effects of momentum jetting at the outlet of the culvert and also account for velocity head of the flow at the inlet for more realistic results. 2894 2895 Culvert hydraulics information can be logged by switching logging on or off. 2896 2897 To use the Boyd Method in \anuga, the user can just copy the code below into their script. So if your model run has 10 pipe culverts, copy the pipe culvert routine five times into your run script and fill in the details for each of your five culverts. 2898 \begin{verbatim} 2899 #------------------------------------- ----------------- 2900 # Box Culvert modelled along two lines 2901 #------------------------------------- ----------------- 2902 losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 2903 el0 = numpy.array([[297750.2,6181379.1], [297753.5,6181380.9]]) 2904 el1 = numpy.array([[297731.8,6181416.4], [297735.1,6181418.3]]) 2905 culvert = anuga.Boyd_box_operator(domain, 2906 losses=losses, 2907 width=1.5, 2908 height=1.5, 2909 end_points=[ep0, ep1], 2910 use_momentum_jet=True, #False to switch it off 2911 use_velocity_head=True, #False to switch it off 2912 manning=0.013, #culvert manning's n 2913 logging=True, #False to switch it off 2914 label='culvert_log_file', 2915 verbose=False) 2916 \end{verbatim} 2917 2918 \begin{verbatim} 2919 #------------------------------------- ------------------ 2920 # Pipe Culvert modelled with a single point 2921 #------------------------------------- ------------------ 2922 losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 2923 ep0 = numpy.array([296653.0,6180014.9]) 2924 ep1 = numpy.array([296642.5,6180036.3]) 2925 culvert = anuga.Boyd_pipe_operator(domain, 2926 losses=losses, 2927 diameter=1.5, 2928 end_points=[ep0, ep1], 2929 use_momentum_jet=True, #False to switch it off 2930 use_velocity_head=True, #False to switch it off 2931 manning=0.013, #culvert manning's n 2932 logging=True, #False to switch it off 2933 label='culvert_log_file', 2934 verbose=False) 2935 \end{verbatim} 2936 2937 \subsection{User developed operators} 2886 2938 2887 2939 Suppose we want to add water to our domain at a steady rate. we can create a class based on the \code{Operator} class which has a \code{__call__} function to do the required update to the centroid values of the stage variable. … … 2889 2941 Here is some code to do this: 2890 2942 \begin{verbatim} 2891 from anuga .operators.base_operatorimport Operator2943 from anuga import Operator 2892 2944 2893 2945 class My_operator(Operator): 2894 2946 """ 2895 Addwater to the domain at a given rate (m/sec)2947 An operator which adds water to the domain at a given rate (m/sec) 2896 2948 """ 2897 2949 … … 3293 3345 If no inundation is found (within the \code{polygon} and \code{time_interval}, if specified) 3294 3346 the return value is \code{None}. This indicates "No Runup" or "Everything is dry". 3295 is \code{None}. This indicates "No Runup" or "Everything is dry".3296 3347 \end{funcdesc} 3297 3348
Note: See TracChangeset
for help on using the changeset viewer.