1 | """Simple water flow example using ANUGA |
---|
2 | |
---|
3 | Water flowing down a channel |
---|
4 | """ |
---|
5 | |
---|
6 | #------------------------------------------------------------------------------ |
---|
7 | # Import necessary modules |
---|
8 | #------------------------------------------------------------------------------ |
---|
9 | import anuga |
---|
10 | |
---|
11 | #------------------------------------------------------------------------------ |
---|
12 | # Setup computational domain |
---|
13 | #------------------------------------------------------------------------------ |
---|
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) |
---|
16 | |
---|
17 | |
---|
18 | domain.set_name('channel1') # Output name |
---|
19 | |
---|
20 | #------------------------------------------------------------------------------ |
---|
21 | # Setup initial conditions |
---|
22 | #------------------------------------------------------------------------------ |
---|
23 | def topography(x, y): |
---|
24 | return -x/10 # linear bed slope |
---|
25 | |
---|
26 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
27 | domain.set_quantity('friction', 0.01) # Constant friction |
---|
28 | domain.set_quantity('stage', # Dry bed |
---|
29 | expression='elevation') |
---|
30 | |
---|
31 | #------------------------------------------------------------------------------ |
---|
32 | # Setup boundary conditions |
---|
33 | #------------------------------------------------------------------------------ |
---|
34 | Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow |
---|
35 | Br = anuga.Reflective_boundary(domain) # Solid reflective wall |
---|
36 | |
---|
37 | domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
38 | |
---|
39 | #------------------------------------------------------------------------------ |
---|
40 | # Evolve system through time |
---|
41 | #------------------------------------------------------------------------------ |
---|
42 | for t in domain.evolve(yieldstep=0.2, finaltime=40.0): |
---|
43 | domain.print_timestepping_statistics() |
---|
44 | |
---|