1 | """test_flow_in_vee.py |
---|
2 | Test the ability of ANUGA to |
---|
3 | a) maintain the flow rate input into the channel at the upstream end |
---|
4 | |
---|
5 | The vee channel is 20m wide by 400m long with side slopes of 1:1 |
---|
6 | The equations for dn are generalised with side slope as 1 V in Side_Slope H |
---|
7 | The test location is half way down the channel X=200m |
---|
8 | This script explores flow as given by ANUGA and compares it with |
---|
9 | the ref_flow |
---|
10 | """ |
---|
11 | |
---|
12 | verbose = True |
---|
13 | import numpy as num |
---|
14 | |
---|
15 | #------------------------------------------------------------------------------ |
---|
16 | # Import necessary modules |
---|
17 | #------------------------------------------------------------------------------ |
---|
18 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross |
---|
19 | from anuga.shallow_water import Domain |
---|
20 | from anuga.shallow_water.shallow_water_domain import Reflective_boundary |
---|
21 | from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary |
---|
22 | from anuga.shallow_water.shallow_water_domain import Transmissive_Momentum_Set_Stage_boundary |
---|
23 | from anuga.shallow_water.shallow_water_domain import Transmissive_boundary |
---|
24 | from anuga.shallow_water.shallow_water_domain import Inflow |
---|
25 | from anuga.shallow_water.data_manager import get_flow_through_cross_section |
---|
26 | from anuga.abstract_2d_finite_volumes.util import sww2csv_gauges, csv2timeseries_graphs |
---|
27 | |
---|
28 | |
---|
29 | #------------------------------------------------------------------------------ |
---|
30 | # Setup computational domain |
---|
31 | #------------------------------------------------------------------------------ |
---|
32 | |
---|
33 | finaltime = 1800.0 # 1/2 hour |
---|
34 | |
---|
35 | length = 400. |
---|
36 | width = 20. |
---|
37 | side_slope = 1.0 |
---|
38 | dx = dy = 2 # Resolution: of points (elev) grid on both axes |
---|
39 | ref_flow = 5.0 # Inflow at head of vee |
---|
40 | slope = 1.0/1000 |
---|
41 | mannings_n = 0.150 |
---|
42 | |
---|
43 | points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), |
---|
44 | len1=length, len2=width) |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | domain = Domain(points, vertices, boundary) |
---|
49 | domain.set_name('test_flow_in_vee') # Output name |
---|
50 | print domain.statistics() |
---|
51 | |
---|
52 | |
---|
53 | #------------------------------------------------------------------------------ |
---|
54 | # Seup Inflow and compute flow characteristics |
---|
55 | #------------------------------------------------------------------------------ |
---|
56 | |
---|
57 | # Compute normal depth, and velocity for the vee using Mannings equation |
---|
58 | |
---|
59 | normal_depth = ( ref_flow*mannings_n* ( (2.0*( (1.0+(1.0/side_slope)**2.0)**0.5) )**0.6667 ) / (side_slope*(slope**0.5)) )**0.375 |
---|
60 | area = (normal_depth**2.0) *side_slope |
---|
61 | wet_perimeter = 2*normal_depth*((1+(side_slope)**2.0)**0.5) |
---|
62 | hyd_radius = area/wet_perimeter |
---|
63 | flow_velocity = ref_flow/area |
---|
64 | top_width = 2*side_slope*normal_depth |
---|
65 | |
---|
66 | # Compute xmomentum to input into the ANUGA inflow boundary |
---|
67 | # assuming momentum is applied uniformly to inflow boundary by ANUGA |
---|
68 | |
---|
69 | #xmomentum = ref_flow/top_width # this is all very unrealistic but should replicate ref_flow in ANUGA |
---|
70 | xmomentum = ref_flow/width # This only applies where channel is flat. |
---|
71 | |
---|
72 | print 'ref_flow', ref_flow |
---|
73 | print 'xmomentum', xmomentum |
---|
74 | print 'normal_depth', normal_depth |
---|
75 | print 'width', width |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | #------------------------------------------------------------------------------ |
---|
80 | # Setup initial conditions |
---|
81 | #------------------------------------------------------------------------------ |
---|
82 | |
---|
83 | def topography(x, y): |
---|
84 | z = -x * slope + abs((y-10)*side_slope) |
---|
85 | |
---|
86 | # Let both ends of domain be square so that the applied xmomentum |
---|
87 | # represents flow correctly |
---|
88 | for i in range(len(x)): |
---|
89 | if x[i] < 20 or x[i] > 380: |
---|
90 | z[i] = -x[i] * slope |
---|
91 | |
---|
92 | return z |
---|
93 | |
---|
94 | |
---|
95 | def initial_stage(x, y): |
---|
96 | """Set constant depth based on calculated normal flow |
---|
97 | """ |
---|
98 | |
---|
99 | w = -x*slope + normal_depth |
---|
100 | return w |
---|
101 | |
---|
102 | |
---|
103 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
104 | domain.set_quantity('friction', mannings_n) # Constant friction of conc surface |
---|
105 | domain.set_quantity('stage', initial_stage) |
---|
106 | domain.set_quantity('xmomentum', xmomentum) # Initial momentum commensurate with normal flow |
---|
107 | |
---|
108 | |
---|
109 | |
---|
110 | #------------------------------------------------------------------------------ |
---|
111 | # Setup boundary conditions |
---|
112 | #------------------------------------------------------------------------------ |
---|
113 | |
---|
114 | |
---|
115 | Br = Reflective_boundary(domain) # Solid reflective wall on edge of sides |
---|
116 | Bi = Dirichlet_boundary([normal_depth,xmomentum,0.0]) # inflow at top |
---|
117 | Bo = Dirichlet_boundary([-length*slope+normal_depth,xmomentum,0.0]) # Outflow at bottom |
---|
118 | |
---|
119 | domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br}) |
---|
120 | |
---|
121 | #------------------------------------------------------------------------------ |
---|
122 | # Evolve system through time |
---|
123 | #------------------------------------------------------------------------------ |
---|
124 | |
---|
125 | for t in domain.evolve(yieldstep=100.0, finaltime=finaltime): |
---|
126 | if verbose : |
---|
127 | print domain.timestepping_statistics() |
---|
128 | |
---|
129 | |
---|
130 | # Check flow across flowline at 200m at every yield step |
---|
131 | q=domain.get_flow_through_cross_section([[200.0,0.0],[200.0,width]]) |
---|
132 | print '90 degree flowline: ANUGA Q = %f, Ref_flow = %f' %(q, ref_flow) |
---|
133 | |
---|
134 | |
---|
135 | #------------------------------------------------------------------------------ |
---|
136 | # Compute flow in vee cf inflow |
---|
137 | #------------------------------------------------------------------------------ |
---|
138 | |
---|
139 | |
---|
140 | |
---|
141 | #------------------------------------------------------------------------------ |
---|
142 | # Compute flow across flowline -v- ref_flow |
---|
143 | #------------------------------------------------------------------------------ |
---|
144 | |
---|
145 | # Check flow across flowline at 200m |
---|
146 | q=domain.get_flow_through_cross_section([[200.0,0.0],[200.0,width]]) |
---|
147 | print '90 degree flowline: ANUGA Q = %f, Ref_flow = %f' %(q, ref_flow) |
---|
148 | |
---|