source: anuga_core/documentation/user_manual/examples/channel1.py @ 3754

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

Added channel examples to user manual

File size: 2.2 KB
Line 
1"""Simple water flow example using ANUGA
2
3Water flowing down a channel
4"""
5
6#------------------------------------------------------------------------------
7# Import necessary modules
8#------------------------------------------------------------------------------
9from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
10from anuga.shallow_water import Domain
11from anuga.shallow_water import Reflective_boundary
12from anuga.shallow_water import Dirichlet_boundary
13
14
15#------------------------------------------------------------------------------
16# Setup computational domain
17#------------------------------------------------------------------------------
18length = 10.
19width = 5.
20dx = dy = 1           # Resolution: Length of subdivisions on both axes
21
22points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
23                                               len1=length, len2=width)
24
25domain = Domain(points, vertices, boundary)   # Create domain
26domain.set_name('channel_1')                  # Output name
27
28
29#------------------------------------------------------------------------------
30# Setup initial conditions
31#------------------------------------------------------------------------------
32def topography(x,y):
33    return -x/10                             # linear bed slope
34
35domain.set_quantity('elevation', topography) # Use function for elevation
36domain.set_quantity('friction', 0.01)        # Constant friction
37domain.set_quantity('stage',
38                    expression='elevation')        # Dry
39#domain.set_quantity('stage',
40#                     expression='elevation + 0.1') # Wet
41
42
43#------------------------------------------------------------------------------
44# Setup boundary conditions
45#------------------------------------------------------------------------------
46Bi = Dirichlet_boundary([0.4, 0, 0])         # Inflow
47Br = Reflective_boundary(domain)             # Solid reflective wall
48
49domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
50
51
52#------------------------------------------------------------------------------
53# Evolve system through time
54#------------------------------------------------------------------------------
55for t in domain.evolve(yieldstep = 0.2, finaltime = 40.0):
56    domain.write_time()
57
58
Note: See TracBrowser for help on using the repository browser.