source: trunk/anuga_work/development/Rudy_vandrie_2007/run_hydro_example.py @ 7924

Last change on this file since 7924 was 5442, checked in by ole, 17 years ago

Retired h-limiter and beta_h as per ticket:194.
All unit tests and validation tests pass.

File size: 3.8 KB
Line 
1"""Simple water flow example using ANUGA
2
3Water flowing down a channel with more complex topography
4"""
5
6#------------------------------------------------------------------------------
7# Import necessary modules
8#------------------------------------------------------------------------------
9from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
10from anuga.abstract_2d_finite_volumes.util import file_function
11from anuga.shallow_water import Domain
12from anuga.shallow_water import Reflective_boundary
13from anuga.shallow_water import Dirichlet_boundary
14from anuga.shallow_water import Time_boundary
15from anuga.shallow_water import Field_boundary
16from anuga.shallow_water.shallow_water_domain import Inflow
17
18
19#------------------------------------------------------------------------------
20# Setup computational domain
21#------------------------------------------------------------------------------
22length = 40.
23width = 5.
24dx = dy = .1           # Resolution: Length of subdivisions on both axes
25#dx = dy = .1           # Resolution: Length of subdivisions on both axes
26
27points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
28                                               len1=length, len2=width)
29domain = Domain(points, vertices, boundary)   
30domain.set_name('hydro_example')                  # Output name
31domain.set_minimum_storable_height(0.0001)
32
33
34
35#------------------------------------------------------------------------------
36# Setup initial conditions
37#------------------------------------------------------------------------------
38def topography(x,y):
39    """Complex topography defined by a function of vectors x and y
40    """
41   
42    z = -x/10
43    #z = x*0.0
44
45    N = len(x)
46    for i in range(N):
47
48        #Step
49        if 10 < x[i] < 12:
50            z[i] += 0.4 - 0.05*y[i]       
51       
52        #Constriction
53        if 27 < x[i] < 29 and y[i] > 3:
54            z[i] += 2       
55       
56        # Pole
57        if (x[i] - 34)**2 + (y[i] - 2)**2 < 0.4**2:
58            z[i] += 2
59
60    return z
61
62
63domain.set_quantity('elevation', topography)  # Use function for elevation
64domain.set_quantity('friction', 0.01)         # Constant friction
65domain.set_quantity('stage',
66                    expression='elevation')   # Dry initial condition
67
68
69#------------------------------------------------------------------------------
70# Setup specialised forcing terms
71#------------------------------------------------------------------------------
72
73#hydrograph = Inflow(center=(1.0, 0.5*width), radius=1.0,
74#            flow=lambda t: min(0.01*t, 0.0142)) # Tap turning up       
75
76hydrograph = Inflow(center=(1.0, 0.5*width), radius=1.0,
77             flow=file_function('Island_Pt_Rd_Meta.tms'))
78
79domain.forcing_terms.append(hydrograph)
80
81
82#------------------------------------------------------------------------------
83# Setup boundary conditions
84#------------------------------------------------------------------------------
85
86#Hydrograph = Field_boundary('Island_Pt_Rd_Meta.tms', domain,
87#                            mean_stage=0.01)
88                 
89Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
90Br = Reflective_boundary(domain)              # Solid reflective wall
91Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
92
93domain.set_boundary({'left': Br,
94                     'right': Br,
95                     'top': Br,
96                     'bottom': Br})
97
98
99#------------------------------------------------------------------------------
100# Evolve system through time
101#------------------------------------------------------------------------------
102domain.start_time = 2800
103for t in domain.evolve(yieldstep = 1, finaltime = 32700):
104    domain.write_time()
105
106
107    #if domain.get_quantity('stage').\
108    #       get_values(interpolation_points=[[10, 2.5]]) > 0:       
109    #    print 'Stage > 0: Changing to outflow boundary'
110    #    domain.set_boundary({'right': Bo})
Note: See TracBrowser for help on using the repository browser.