1 | import anuga |
---|
2 | import math |
---|
3 | |
---|
4 | class Boyd_box_operator(anuga.Structure_operator): |
---|
5 | """Culvert flow - transfer water from one rectangular box to another. |
---|
6 | Sets up the geometry of problem |
---|
7 | |
---|
8 | This is the base class for culverts. Inherit from this class (and overwrite |
---|
9 | compute_discharge method for specific subclasses) |
---|
10 | |
---|
11 | Input: Two points, pipe_size (either diameter or width, height), |
---|
12 | mannings_rougness, |
---|
13 | """ |
---|
14 | |
---|
15 | |
---|
16 | def __init__(self, |
---|
17 | domain, |
---|
18 | losses, |
---|
19 | width, |
---|
20 | height=None, |
---|
21 | end_points=None, |
---|
22 | exchange_lines=None, |
---|
23 | enquiry_points=None, |
---|
24 | apron=0.1, |
---|
25 | manning=0.013, |
---|
26 | enquiry_gap=0.0, |
---|
27 | use_momentum_jet=True, |
---|
28 | use_velocity_head=True, |
---|
29 | description=None, |
---|
30 | label=None, |
---|
31 | structure_type='boyd_box', |
---|
32 | logging=False, |
---|
33 | verbose=False): |
---|
34 | |
---|
35 | anuga.Structure_operator.__init__(self, |
---|
36 | domain, |
---|
37 | end_points, |
---|
38 | exchange_lines, |
---|
39 | enquiry_points, |
---|
40 | width, |
---|
41 | height, |
---|
42 | apron, |
---|
43 | manning, |
---|
44 | enquiry_gap, |
---|
45 | description, |
---|
46 | label, |
---|
47 | structure_type, |
---|
48 | logging, |
---|
49 | verbose) |
---|
50 | |
---|
51 | if isinstance(losses, dict): |
---|
52 | self.sum_loss = sum(losses.values()) |
---|
53 | elif isinstance(losses, list): |
---|
54 | self.sum_loss = sum(losses) |
---|
55 | else: |
---|
56 | self.sum_loss = losses |
---|
57 | |
---|
58 | self.use_momentum_jet = use_momentum_jet |
---|
59 | self.use_velocity_head = use_velocity_head |
---|
60 | |
---|
61 | self.culvert_length = self.get_culvert_length() |
---|
62 | self.culvert_width = self.get_culvert_width() |
---|
63 | self.culvert_height = self.get_culvert_height() |
---|
64 | |
---|
65 | self.max_velocity = 10.0 |
---|
66 | |
---|
67 | self.inlets = self.get_inlets() |
---|
68 | |
---|
69 | |
---|
70 | # Stats |
---|
71 | |
---|
72 | self.discharge = 0.0 |
---|
73 | self.velocity = 0.0 |
---|
74 | |
---|
75 | self.case = 'N/A' |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | def discharge_routine(self): |
---|
80 | |
---|
81 | local_debug ='false' |
---|
82 | |
---|
83 | if self.use_velocity_head: |
---|
84 | self.delta_total_energy = self.inlets[0].get_enquiry_total_energy() - self.inlets[1].get_enquiry_total_energy() |
---|
85 | else: |
---|
86 | self.delta_total_energy = self.inlets[0].get_enquiry_stage() - self.inlets[1].get_enquiry_stage() |
---|
87 | |
---|
88 | self.inflow = self.inlets[0] |
---|
89 | self.outflow = self.inlets[1] |
---|
90 | |
---|
91 | if self.delta_total_energy < 0: |
---|
92 | self.inflow = self.inlets[1] |
---|
93 | self.outflow = self.inlets[0] |
---|
94 | self.delta_total_energy = -self.delta_total_energy |
---|
95 | |
---|
96 | |
---|
97 | |
---|
98 | if self.inflow.get_enquiry_depth() > 0.01: #this value was 0.01: |
---|
99 | if local_debug =='true': |
---|
100 | anuga.log.critical('Specific E & Deltat Tot E = %s, %s' |
---|
101 | % (str(self.inflow.get_enquiry_specific_energy()), |
---|
102 | str(self.delta_total_energy))) |
---|
103 | anuga.log.critical('culvert type = %s' % str(culvert_type)) |
---|
104 | # Water has risen above inlet |
---|
105 | |
---|
106 | |
---|
107 | msg = 'Specific energy at inlet is negative' |
---|
108 | assert self.inflow.get_enquiry_specific_energy() >= 0.0, msg |
---|
109 | |
---|
110 | if self.use_velocity_head : |
---|
111 | self.driving_energy = self.inflow.get_enquiry_specific_energy() |
---|
112 | else: |
---|
113 | self.driving_energy = self.inflow.get_enquiry_depth() |
---|
114 | |
---|
115 | depth = self.culvert_height |
---|
116 | width = self.culvert_width |
---|
117 | flow_width = self.culvert_width |
---|
118 | # intially assume the culvert flow is controlled by the inlet |
---|
119 | # check unsubmerged and submerged condition and use Min Q |
---|
120 | # but ensure the correct flow area and wetted perimeter are used |
---|
121 | Q_inlet_unsubmerged = 0.544*anuga.g**0.5*width*self.driving_energy**1.50 # Flow based on Inlet Ctrl Inlet Unsubmerged |
---|
122 | Q_inlet_submerged = 0.702*anuga.g**0.5*width*depth**0.89*self.driving_energy**0.61 # Flow based on Inlet Ctrl Inlet Submerged |
---|
123 | |
---|
124 | # FIXME(Ole): Are these functions really for inlet control? |
---|
125 | if Q_inlet_unsubmerged < Q_inlet_submerged: |
---|
126 | Q = Q_inlet_unsubmerged |
---|
127 | dcrit = (Q**2/anuga.g/width**2)**0.333333 |
---|
128 | if dcrit > depth: |
---|
129 | dcrit = depth |
---|
130 | flow_area = width*dcrit |
---|
131 | perimeter= 2.0*(width+dcrit) |
---|
132 | else: # dcrit < depth |
---|
133 | flow_area = width*dcrit |
---|
134 | perimeter= 2.0*dcrit+width |
---|
135 | outlet_culvert_depth = dcrit |
---|
136 | self.case = 'Inlet unsubmerged Box Acts as Weir' |
---|
137 | else: # Inlet Submerged but check internal culvert flow depth |
---|
138 | Q = Q_inlet_submerged |
---|
139 | dcrit = (Q**2/anuga.g/width**2)**0.333333 |
---|
140 | if dcrit > depth: |
---|
141 | dcrit = depth |
---|
142 | flow_area = width*dcrit |
---|
143 | perimeter= 2.0*(width+dcrit) |
---|
144 | else: # dcrit < depth |
---|
145 | flow_area = width*dcrit |
---|
146 | perimeter= 2.0*dcrit+width |
---|
147 | outlet_culvert_depth = dcrit |
---|
148 | self.case = 'Inlet submerged Box Acts as Orifice' |
---|
149 | |
---|
150 | dcrit = (Q**2/anuga.g/width**2)**0.333333 |
---|
151 | # May not need this .... check if same is done above |
---|
152 | outlet_culvert_depth = dcrit |
---|
153 | if outlet_culvert_depth > depth: |
---|
154 | outlet_culvert_depth = depth # Once again the pipe is flowing full not partfull |
---|
155 | flow_area = width*depth # Cross sectional area of flow in the culvert |
---|
156 | perimeter = 2*(width+depth) |
---|
157 | self.case = 'Inlet CTRL Outlet unsubmerged PIPE PART FULL' |
---|
158 | else: |
---|
159 | flow_area = width * outlet_culvert_depth |
---|
160 | perimeter = width+2*outlet_culvert_depth |
---|
161 | self.case = 'INLET CTRL Culvert is open channel flow we will for now assume critical depth' |
---|
162 | # Initial Estimate of Flow for Outlet Control using energy slope |
---|
163 | #( may need to include Culvert Bed Slope Comparison) |
---|
164 | hyd_rad = flow_area/perimeter |
---|
165 | culvert_velocity = math.sqrt(self.delta_total_energy/((self.sum_loss/2/anuga.g)+(self.manning**2*self.culvert_length)/hyd_rad**1.33333)) |
---|
166 | Q_outlet_tailwater = flow_area * culvert_velocity |
---|
167 | |
---|
168 | |
---|
169 | if self.delta_total_energy < self.driving_energy: |
---|
170 | # Calculate flows for outlet control |
---|
171 | |
---|
172 | # Determine the depth at the outlet relative to the depth of flow in the Culvert |
---|
173 | if self.outflow.get_enquiry_depth() > depth: # The Outlet is Submerged |
---|
174 | outlet_culvert_depth=depth |
---|
175 | flow_area=width*depth # Cross sectional area of flow in the culvert |
---|
176 | perimeter=2.0*(width+depth) |
---|
177 | self.case = 'Outlet submerged' |
---|
178 | else: # Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity |
---|
179 | dcrit = (Q**2/anuga.g/width**2)**0.333333 |
---|
180 | outlet_culvert_depth=dcrit # For purpose of calculation assume the outlet depth = Critical Depth |
---|
181 | if outlet_culvert_depth > depth: |
---|
182 | outlet_culvert_depth=depth |
---|
183 | flow_area=width*depth |
---|
184 | perimeter=2.0*(width+depth) |
---|
185 | self.case = 'Outlet is Flowing Full' |
---|
186 | else: |
---|
187 | flow_area=width*outlet_culvert_depth |
---|
188 | perimeter=(width+2.0*outlet_culvert_depth) |
---|
189 | self.case = 'Outlet is open channel flow' |
---|
190 | |
---|
191 | hyd_rad = flow_area/perimeter |
---|
192 | |
---|
193 | |
---|
194 | |
---|
195 | # Final Outlet control velocity using tail water |
---|
196 | culvert_velocity = math.sqrt(self.delta_total_energy/((self.sum_loss/2/anuga.g)+(self.manning**2*self.culvert_length)/hyd_rad**1.33333)) |
---|
197 | Q_outlet_tailwater = flow_area * culvert_velocity |
---|
198 | |
---|
199 | Q = min(Q, Q_outlet_tailwater) |
---|
200 | else: |
---|
201 | |
---|
202 | pass |
---|
203 | #FIXME(Ole): What about inlet control? |
---|
204 | |
---|
205 | culv_froude=math.sqrt(Q**2*flow_width/(anuga.g*flow_area**3)) |
---|
206 | if local_debug =='true': |
---|
207 | anuga.log.critical('FLOW AREA = %s' % str(flow_area)) |
---|
208 | anuga.log.critical('PERIMETER = %s' % str(perimeter)) |
---|
209 | anuga.log.critical('Q final = %s' % str(Q)) |
---|
210 | anuga.log.critical('FROUDE = %s' % str(culv_froude)) |
---|
211 | |
---|
212 | # Determine momentum at the outlet |
---|
213 | barrel_velocity = Q/(flow_area + anuga.velocity_protection/flow_area) |
---|
214 | |
---|
215 | # END CODE BLOCK for DEPTH > Required depth for CULVERT Flow |
---|
216 | |
---|
217 | else: # self.inflow.get_enquiry_depth() < 0.01: |
---|
218 | Q = barrel_velocity = outlet_culvert_depth = 0.0 |
---|
219 | |
---|
220 | # Temporary flow limit |
---|
221 | if barrel_velocity > self.max_velocity: |
---|
222 | barrel_velocity = self.max_velocity |
---|
223 | Q = flow_area * barrel_velocity |
---|
224 | |
---|
225 | return Q, barrel_velocity, outlet_culvert_depth |
---|
226 | |
---|
227 | |
---|
228 | |
---|