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