source: trunk/anuga_core/documentation/user_manual/demos/channel2.py @ 7959

Last change on this file since 7959 was 7959, checked in by steve, 14 years ago

no real change in channel2.py just changed the resolution and then back again

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