1 | """ |
---|
2 | This script tests the ability of a flowline to match inflow above the flowline by |
---|
3 | creating constant inflow of 1 m3/sec onto a 5m dia circle at the head of a 20m |
---|
4 | wide plane dipping at 1:300 with a flowline and gauge downstream of the inflow. |
---|
5 | |
---|
6 | |
---|
7 | |
---|
8 | """ |
---|
9 | |
---|
10 | #------------------------------------------------------------------------------ |
---|
11 | # Import necessary modules |
---|
12 | #------------------------------------------------------------------------------ |
---|
13 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross |
---|
14 | from anuga.shallow_water import Domain |
---|
15 | from anuga.shallow_water.shallow_water_domain import Reflective_boundary |
---|
16 | from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary |
---|
17 | from anuga.shallow_water.shallow_water_domain import Inflow |
---|
18 | from anuga.shallow_water.data_manager import get_flow_through_cross_section |
---|
19 | from anuga.abstract_2d_finite_volumes.util import sww2csv_gauges, csv2timeseries_graphs |
---|
20 | |
---|
21 | |
---|
22 | |
---|
23 | #------------------------------------------------------------------------------ |
---|
24 | # Setup computational domain |
---|
25 | #------------------------------------------------------------------------------ |
---|
26 | |
---|
27 | |
---|
28 | |
---|
29 | length = 300. |
---|
30 | width = 20. |
---|
31 | |
---|
32 | dx = dy = 1 # Resolution: of grid on both axes |
---|
33 | |
---|
34 | |
---|
35 | points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), |
---|
36 | len1=length, len2=width) |
---|
37 | domain = Domain(points, vertices, boundary) |
---|
38 | domain.set_name('inflow_flowline_test') # Output name |
---|
39 | domain.set_default_order(2) |
---|
40 | domain.H0 = 0.01 |
---|
41 | domain.tight_slope_limiters = 1 |
---|
42 | |
---|
43 | print 'Size', len(domain) |
---|
44 | |
---|
45 | #------------------------------------------------------------------------------ |
---|
46 | # Setup initial conditions |
---|
47 | #------------------------------------------------------------------------------ |
---|
48 | |
---|
49 | def topography(x, y): |
---|
50 | |
---|
51 | # General Slope of plane is 1:100 |
---|
52 | z=-x/300 |
---|
53 | return z |
---|
54 | |
---|
55 | |
---|
56 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
57 | domain.set_quantity('friction', 0.012) # Constant friction of conc surface |
---|
58 | domain.set_quantity('stage', |
---|
59 | expression='elevation') # Dry initial condition |
---|
60 | |
---|
61 | # |
---|
62 | #------------------------------------------------------------------------------ |
---|
63 | # Setup boundary conditions |
---|
64 | #------------------------------------------------------------------------------ |
---|
65 | |
---|
66 | Br = Reflective_boundary(domain) # Solid reflective wall |
---|
67 | Bo = Dirichlet_boundary([-0.9, 0, 0]) # Outflow stsge at -0.9m d=0.1m |
---|
68 | |
---|
69 | domain.set_boundary({'left': Br, 'right': Bo, 'top': Br, 'bottom': Br}) |
---|
70 | |
---|
71 | #------------------------------------------------------------------------------ |
---|
72 | # Seup Inflow |
---|
73 | #------------------------------------------------------------------------------ |
---|
74 | |
---|
75 | |
---|
76 | fixed_inflow = Inflow(domain, |
---|
77 | center=(10.0, 10.0), |
---|
78 | radius=5.00, |
---|
79 | rate=1.00) # Fixed Flowrate onto Area |
---|
80 | |
---|
81 | domain.forcing_terms.append(fixed_inflow) |
---|
82 | |
---|
83 | |
---|
84 | #------------------------------------------------------------------------------ |
---|
85 | # Evolve system through time |
---|
86 | #------------------------------------------------------------------------------ |
---|
87 | |
---|
88 | for t in domain.evolve(yieldstep = 5.0, finaltime = 300): |
---|
89 | domain.write_time() |
---|
90 | |
---|
91 | |
---|
92 | #------------------------------------------------------------------------------ |
---|
93 | # Compute flow thru flowline ds of inflow |
---|
94 | #------------------------------------------------------------------------------ |
---|
95 | |
---|
96 | time, Q = get_flow_through_cross_section('inflow_flowline_test.sww', |
---|
97 | [[30.0,0.0],[30.0,20.0]], |
---|
98 | verbose=True) |
---|
99 | csv_fid= open('inflow_flowline_test.csv', 'w') |
---|
100 | for j in range(len(time)): |
---|
101 | csv_fid.write('%f, %f\n' %(time[j], Q[j])) |
---|
102 | csv_fid.close() |
---|
103 | |
---|
104 | #------------------------------------------------------------------------------ |
---|
105 | # Record stage hydrograph ds of inflow |
---|
106 | #------------------------------------------------------------------------------ |
---|
107 | |
---|
108 | sww2csv_gauges('inflow_flowline_test.sww', |
---|
109 | 'gauges.csv', |
---|
110 | quantities=['stage','elevation'], |
---|
111 | verbose=True) |
---|