Changeset 6299
- Timestamp:
- Feb 10, 2009, 5:31:46 AM (16 years ago)
- Location:
- anuga_core/source/anuga/culvert_flows
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/culvert_flows/culvert_class.py
r6150 r6299 204 204 log_to_file(self.log_filename, description) 205 205 log_to_file(self.log_filename, self.culvert_type) 206 else: 207 self.log_filename = None 206 208 207 209 … … 296 298 297 299 # Print some diagnostics to log if requested 298 if hasattr(self, 'log_filename'):300 if self.log_filename is not None: 299 301 s = 'Culvert Effective Length = %.2f m' %(self.length) 300 302 log_to_file(self.log_filename, s) … … 323 325 if time - self.last_update > self.update_interval or time == 0.0: 324 326 update = True 325 326 if hasattr(self, 'log_filename'):327 328 if self.log_filename is not None: 327 329 s = '\nTime = %.2f, delta_t = %f' %(time, delta_t) 328 330 log_to_file(self.log_filename, s) … … 439 441 if self.verbose is True: 440 442 print msg 441 if hasattr(self, 'log_filename'): 443 444 if self.log_filename is not None: 442 445 log_to_file(self.log_filename, msg) 443 446 … … 524 527 print '%.2fs - WARNING: Flow is running uphill.' % time 525 528 526 if hasattr(self, 'log_filename'):529 if self.log_filename is not None: 527 530 s = 'Time=%.2f, inlet stage = %.2f, outlet stage = %.2f'\ 528 531 %(time, self.inlet.stage, self.outlet.stage) … … 573 576 msg += 'for culvert "%s"' % self.label 574 577 575 if hasattr(self, 'log_filename'):578 if self.log_filename is not None: 576 579 log_to_file(self.log_filename, msg) 577 580 else: 578 581 # User culvert routine 579 582 Q, barrel_velocity, culvert_outlet_depth =\ 580 self.culvert_routine(self, delta_total_energy, g) 583 self.culvert_routine(inlet.depth, 584 outlet.depth, 585 inlet.specific_energy, 586 delta_total_energy, 587 g, 588 culvert_length=self.length, 589 culvert_width=self.width, 590 culvert_height=self.height, 591 culvert_type=self.culvert_type, 592 manning=self.manning, 593 sum_loss=self.sum_loss, 594 log_filename=self.log_filename) 581 595 582 596 … … 601 615 602 616 603 617 # OBSOLETE (Except for momentum jet in Culvert_flow_energy) 604 618 class Culvert_flow_rating: 605 619 """Culvert flow - transfer water from one hole to another -
anuga_core/source/anuga/culvert_flows/culvert_routines.py
r6128 r6299 8 8 9 9 #NOTE: 10 # Inlet control: Delta_Et > Es at the inlet 11 # Outlet control: Delta_Et < Es at the inlet 12 # where Et is total energy (w + 0.5*v^2/g) and 13 # Es is the specific energy (h + 0.5*v^2/g) 14 15 16 17 # NEW DEFINED CULVERT FLOW---- Flow from INLET 1 ------> INLET 2 (Outlet) 18 # 19 # The First Attempt has a Simple Horizontal Circle as a Hole on the Bed 20 # Flow Is Removed at a Rate of INFLOW 21 # Downstream there is a similar Circular Hole on the Bed where INFLOW effectively Surcharges 22 # 23 # This SHould be changed to a Vertical Opening Both BOX and Circular 24 # There will be several Culvert Routines such as: 25 # CULVERT_Boyd_Channel 26 # CULVERT_Orifice_and_Weir 27 # CULVERT_Simple_FLOOR 28 # CULVERT_Simple_WALL 29 # CULVERT_Eqn_Floor 30 # CULVERT_Eqn_Wall 31 # CULVERT_Tab_Floor 32 # CULVERT_Tab_Wall 33 # BRIDGES..... 34 # NOTE NEED TO DEVELOP CONCEPT 1D Model for Linked Pipe System !!!! 35 36 # COULD USE EPA SWMM Model !!!! 10 # Inlet control: Delta_total_energy > inlet_specific_energy 11 # Outlet control: Delta_total_energy < inlet_specific_energy 12 # where total energy is (w + 0.5*v^2/g) and 13 # specific energy is (h + 0.5*v^2/g) 37 14 38 15 … … 40 17 41 18 42 def boyd_generalised_culvert_model(culvert, delta_total_energy, g): 43 44 """Boyd's generalisation of the US department of transportation culvert model 45 # == The quantity of flow passing through a culvert is controlled by many factors 46 # == It could be that the culvert is controled by the inlet only, with it being Un submerged this is effectively equivalent to the WEIR Equation 47 # == Else the culvert could be controlled by the inlet, with it being Submerged, this is effectively the Orifice Equation 48 # == Else it may be controlled by Down stream conditions where depending on the down stream depth, the momentum in the culvert etc. flow is controlled 19 def boyd_generalised_culvert_model(inlet_depth, 20 outlet_depth, 21 inlet_specific_energy, 22 delta_total_energy, 23 g, 24 culvert_length=0.0, 25 culvert_width=0.0, 26 culvert_height=0.0, 27 culvert_type='box', 28 manning=0.0, 29 sum_loss=0.0, 30 log_filename=None): 31 32 """Boyd's generalisation of the US department of transportation culvert 33 model 34 35 The quantity of flow passing through a culvert is controlled by many factors 36 It could be that the culvert is controlled by the inlet only, with it 37 being unsubmerged this is effectively equivalent to the weir Equation 38 Else the culvert could be controlled by the inlet, with it being 39 submerged, this is effectively the Orifice Equation 40 Else it may be controlled by down stream conditions where depending on 41 the down stream depth, the momentum in the culvert etc. flow is controlled 49 42 """ 50 43 … … 53 46 from anuga.utilities.numerical_tools import safe_acos as acos 54 47 55 inlet = culvert.inlet 56 outlet = culvert.outlet 57 Q_outlet_tailwater = 0.0 58 inlet.rate = 0.0 59 outlet.rate = 0.0 60 Q_inlet_unsubmerged = 0.0 61 Q_inlet_submerged = 0.0 62 Q_outlet_critical_depth = 0.0 63 64 if hasattr(culvert, 'log_filename'): 65 log_filename = culvert.log_filename 66 67 manning = culvert.manning 68 sum_loss = culvert.sum_loss 69 length = culvert.length 70 71 if inlet.depth > 0.01: 72 73 E = inlet.specific_energy 74 75 if hasattr(culvert, 'log_filename'): 76 s = 'Specific energy = %f m' %E 48 49 if inlet_depth > 0.01: 50 # Water has risen above inlet 51 52 if log_filename is not None: 53 s = 'Specific energy = %f m' % inlet_specific_energy 77 54 log_to_file(log_filename, s) 78 55 79 msg = 'Specific energy is negative'80 assert E>= 0.0, msg56 msg = 'Specific energy at inlet is negative' 57 assert inlet_specific_energy >= 0.0, msg 81 58 82 83 # Water has risen above inlet84 if culvert.culvert_type == 'circle':85 # Round culvert59 60 if culvert_type == 'circle': 61 # Round culvert (use width as diameter) 62 diameter = culvert_width 86 63 87 64 # Calculate flows for inlet control 88 diameter = culvert.diameter 89 90 Q_inlet_unsubmerged = 0.421*g**0.5*diameter**0.87*E**1.63 # Inlet Ctrl Inlet Unsubmerged 91 Q_inlet_submerged = 0.530*g**0.5*diameter**1.87*E**0.63 # Inlet Ctrl Inlet Submerged 92 93 if hasattr(culvert, 'log_filename'): 94 s = 'Q_inlet_unsubmerged = %.6f, Q_inlet_submerged = %.6f' %(Q_inlet_unsubmerged, Q_inlet_submerged) 65 Q_inlet_unsubmerged = 0.421*g**0.5*diameter**0.87*inlet_specific_energy**1.63 # Inlet Ctrl Inlet Unsubmerged 66 Q_inlet_submerged = 0.530*g**0.5*diameter**1.87*inlet_specific_energy**0.63 # Inlet Ctrl Inlet Submerged 67 68 if log_filename is not None: 69 s = 'Q_inlet_unsubmerged = %.6f, Q_inlet_submerged = %.6f' % (Q_inlet_unsubmerged, Q_inlet_submerged) 95 70 log_to_file(log_filename, s) 96 71 97 case = '' 72 73 # FIXME(Ole): Are these functions really for inlet control? 98 74 if Q_inlet_unsubmerged < Q_inlet_submerged: 99 75 Q = Q_inlet_unsubmerged 100 101 alpha = acos(1 - inlet.depth/diameter) 76 alpha = acos(1 - inlet_depth/diameter) 102 77 flow_area = diameter**2 * (alpha - sin(alpha)*cos(alpha)) 103 outlet_culvert_depth = inlet.depth 104 width = diameter*sin(alpha) 105 #perimeter = alpha*diameter 78 outlet_culvert_depth = inlet_depth 106 79 case = 'Inlet unsubmerged' 107 80 else: … … 109 82 flow_area = (diameter/2)**2 * pi 110 83 outlet_culvert_depth = diameter 111 width = diameter112 #perimeter = diameter113 84 case = 'Inlet submerged' 114 85 115 86 116 87 117 if delta_total_energy < E:88 if delta_total_energy < inlet_specific_energy: 118 89 # Calculate flows for outlet control 90 119 91 # Determine the depth at the outlet relative to the depth of flow in the Culvert 120 121 if outlet.depth > diameter: # The Outlet is Submerged 92 if outlet_depth > diameter: # The Outlet is Submerged 122 93 outlet_culvert_depth=diameter 123 94 flow_area = (diameter/2)**2 * pi # Cross sectional area of flow in the culvert 124 95 perimeter = diameter * pi 125 width = diameter126 96 case = 'Outlet submerged' 127 elif outlet .depth==0.0:128 outlet_culvert_depth=inlet .depth# For purpose of calculation assume the outlet depth = the inlet depth129 alpha = acos(1 - inlet .depth/diameter)97 elif outlet_depth==0.0: 98 outlet_culvert_depth=inlet_depth # For purpose of calculation assume the outlet depth = the inlet depth 99 alpha = acos(1 - inlet_depth/diameter) 130 100 flow_area = diameter**2 * (alpha - sin(alpha)*cos(alpha)) 131 101 perimeter = alpha*diameter 132 width = diameter*sin(alpha)133 102 134 103 case = 'Outlet depth is zero' 135 104 else: # Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity 136 outlet_culvert_depth=outlet .depth # For purpose of calculation assume the outlet depth = the inlet depth137 alpha = acos(1 - outlet .depth/diameter)105 outlet_culvert_depth=outlet_depth # For purpose of calculation assume the outlet depth = the inlet depth 106 alpha = acos(1 - outlet_depth/diameter) 138 107 flow_area = diameter**2 * (alpha - sin(alpha)*cos(alpha)) 139 108 perimeter = alpha*diameter 140 width = diameter*sin(alpha)141 109 case = 'Outlet is open channel flow' 142 110 143 111 hyd_rad = flow_area/perimeter 144 112 145 if hasattr(culvert, 'log_filename'):113 if log_filename is not None: 146 114 s = 'hydraulic radius at outlet = %f' %hyd_rad 147 115 log_to_file(log_filename, s) 148 116 149 117 # Outlet control velocity using tail water 150 culvert_velocity = sqrt(delta_total_energy/((sum_loss/2*g)+(manning**2* length)/hyd_rad**1.33333))118 culvert_velocity = sqrt(delta_total_energy/((sum_loss/2*g)+(manning**2*culvert_length)/hyd_rad**1.33333)) 151 119 Q_outlet_tailwater = flow_area * culvert_velocity 152 120 153 if hasattr(culvert, 'log_filename'):121 if log_filename is not None: 154 122 s = 'Q_outlet_tailwater = %.6f' %Q_outlet_tailwater 155 123 log_to_file(log_filename, s) … … 165 133 166 134 # Calculate flows for inlet control 167 height = culvert .height168 width = culvert .width135 height = culvert_height 136 width = culvert_width 169 137 170 Q_inlet_unsubmerged = 0.540*g**0.5*width* E**1.50 # Flow based on Inlet Ctrl Inlet Unsubmerged171 Q_inlet_submerged = 0.702*g**0.5*width*height**0.89* E**0.61 # Flow based on Inlet Ctrl Inlet Submerged172 173 if hasattr(culvert, 'log_filename'):138 Q_inlet_unsubmerged = 0.540*g**0.5*width*inlet_specific_energy**1.50 # Flow based on Inlet Ctrl Inlet Unsubmerged 139 Q_inlet_submerged = 0.702*g**0.5*width*height**0.89*inlet_specific_energy**0.61 # Flow based on Inlet Ctrl Inlet Submerged 140 141 if log_filename is not None: 174 142 s = 'Q_inlet_unsubmerged = %.6f, Q_inlet_submerged = %.6f' %(Q_inlet_unsubmerged, Q_inlet_submerged) 175 143 log_to_file(log_filename, s) 176 144 177 case = '' 145 146 # FIXME(Ole): Are these functions really for inlet control? 178 147 if Q_inlet_unsubmerged < Q_inlet_submerged: 179 148 Q = Q_inlet_unsubmerged 180 flow_area = width*inlet.depth 181 outlet_culvert_depth = inlet.depth 182 #perimeter=(width+2.0*inlet.depth) 149 flow_area = width*inlet_depth 150 outlet_culvert_depth = inlet_depth 183 151 case = 'Inlet unsubmerged' 184 152 else: … … 186 154 flow_area = width*height 187 155 outlet_culvert_depth = height 188 #perimeter=2.0*(width+height)189 156 case = 'Inlet submerged' 190 157 191 if delta_total_energy < E:158 if delta_total_energy < inlet_specific_energy: 192 159 # Calculate flows for outlet control 160 193 161 # Determine the depth at the outlet relative to the depth of flow in the Culvert 194 195 if outlet.depth > height: # The Outlet is Submerged 162 if outlet_depth > height: # The Outlet is Submerged 196 163 outlet_culvert_depth=height 197 164 flow_area=width*height # Cross sectional area of flow in the culvert 198 165 perimeter=2.0*(width+height) 199 166 case = 'Outlet submerged' 200 elif outlet .depth==0.0:201 outlet_culvert_depth=inlet .depth # For purpose of calculation assume the outlet depth = the inlet depth202 flow_area=width*inlet .depth203 perimeter=(width+2.0*inlet .depth)167 elif outlet_depth==0.0: 168 outlet_culvert_depth=inlet_depth # For purpose of calculation assume the outlet depth = the inlet depth 169 flow_area=width*inlet_depth 170 perimeter=(width+2.0*inlet_depth) 204 171 case = 'Outlet depth is zero' 205 172 else: # Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity 206 outlet_culvert_depth=outlet .depth207 flow_area=width*outlet .depth208 perimeter=(width+2.0*outlet .depth)173 outlet_culvert_depth=outlet_depth 174 flow_area=width*outlet_depth 175 perimeter=(width+2.0*outlet_depth) 209 176 case = 'Outlet is open channel flow' 210 177 211 178 hyd_rad = flow_area/perimeter 212 179 213 if hasattr(culvert, 'log_filename'):214 s = 'hydraulic radius at outlet = %f' % hyd_rad180 if log_filename is not None: 181 s = 'hydraulic radius at outlet = %f' % hyd_rad 215 182 log_to_file(log_filename, s) 216 183 217 184 # Outlet control velocity using tail water 218 culvert_velocity = sqrt(delta_total_energy/((sum_loss/2*g)+(manning**2* length)/hyd_rad**1.33333))185 culvert_velocity = sqrt(delta_total_energy/((sum_loss/2*g)+(manning**2*culvert_length)/hyd_rad**1.33333)) 219 186 Q_outlet_tailwater = flow_area * culvert_velocity 220 187 221 if hasattr(culvert, 'log_filename'):222 s = 'Q_outlet_tailwater = %.6f' % Q_outlet_tailwater188 if log_filename is not None: 189 s = 'Q_outlet_tailwater = %.6f' % Q_outlet_tailwater 223 190 log_to_file(log_filename, s) 224 191 Q = min(Q, Q_outlet_tailwater) … … 227 194 #FIXME(Ole): What about inlet control? 228 195 196 229 197 # Common code for circle and square geometries 230 if hasattr(culvert, 'log_filename'):231 log_to_file(log_filename, 'Case: "%s"' % case)198 if log_filename is not None: 199 log_to_file(log_filename, 'Case: "%s"' % case) 232 200 233 flow_rate_control=Q 234 235 if hasattr(culvert, 'log_filename'): 236 s = 'Flow Rate Control = %f' %flow_rate_control 201 if log_filename is not None: 202 s = 'Flow Rate Control = %f' % Q 237 203 log_to_file(log_filename, s) 238 204 239 inlet.rate = -flow_rate_control240 outlet.rate = flow_rate_control241 205 242 culv_froude=sqrt( flow_rate_control**2*width/(g*flow_area**3))243 244 if hasattr(culvert, 'log_filename'):245 s = 'Froude in Culvert = %f' % culv_froude206 culv_froude=sqrt(Q**2*width/(g*flow_area**3)) 207 208 if log_filename is not None: 209 s = 'Froude in Culvert = %f' % culv_froude 246 210 log_to_file(log_filename, s) 247 211 … … 250 214 251 215 252 else: # inlet.depth < 0.01:216 else: # inlet_depth < 0.01: 253 217 Q = barrel_velocity = outlet_culvert_depth = 0.0 254 218
Note: See TracChangeset
for help on using the changeset viewer.