source: branches/numpy/anuga/culvert_flows/culvert_routines.py @ 6517

Last change on this file since 6517 was 6517, checked in by rwilson, 15 years ago

Hand-merged recent changes in main trunk. Still work to be done in shallow_water.

File size: 9.8 KB
Line 
1"""Collection of culvert routines for use with Culvert_flow in culvert_class
2
3Usage:
4
5   
6
7"""
8
9#NOTE:
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)
14
15
16from math import pi, sqrt, sin, cos
17
18
19def 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
42    """
43
44    from anuga.utilities.system_tools import log_to_file
45    from anuga.config import velocity_protection
46    from anuga.utilities.numerical_tools import safe_acos as acos
47
48    if inlet_depth > 0.01:
49        # Water has risen above inlet
50       
51        if log_filename is not None:                           
52            s = 'Specific energy  = %f m' % inlet_specific_energy
53            log_to_file(log_filename, s)
54       
55        msg = 'Specific energy at inlet is negative'
56        assert inlet_specific_energy >= 0.0, msg
57                     
58        if culvert_type == 'circle':
59            # Round culvert (use width as diameter)
60            diameter = culvert_width           
61
62            # Calculate flows for inlet control           
63            Q_inlet_unsubmerged = 0.421*g**0.5*diameter**0.87*inlet_specific_energy**1.63 # Inlet Ctrl Inlet Unsubmerged
64            Q_inlet_submerged = 0.530*g**0.5*diameter**1.87*inlet_specific_energy**0.63   # Inlet Ctrl Inlet Submerged
65
66            if log_filename is not None:                                       
67                s = 'Q_inlet_unsubmerged = %.6f, Q_inlet_submerged = %.6f' % (Q_inlet_unsubmerged, Q_inlet_submerged)
68                log_to_file(log_filename, s)
69
70            # FIXME(Ole): Are these functions really for inlet control?                   
71            if Q_inlet_unsubmerged < Q_inlet_submerged:
72                Q = Q_inlet_unsubmerged
73
74                alpha = acos(1 - inlet_depth/diameter)
75                flow_area = diameter**2 * (alpha - sin(alpha)*cos(alpha))
76                outlet_culvert_depth = inlet_depth
77                case = 'Inlet unsubmerged'
78            else:   
79                Q = Q_inlet_submerged
80                flow_area = (diameter/2)**2 * pi
81                outlet_culvert_depth = diameter
82                case = 'Inlet submerged'                   
83
84
85
86            if delta_total_energy < inlet_specific_energy:
87                # Calculate flows for outlet control
88                # Determine the depth at the outlet relative to the depth of flow in the Culvert
89
90                if outlet_depth > diameter:        # The Outlet is Submerged
91                    outlet_culvert_depth=diameter
92                    flow_area = (diameter/2)**2 * pi  # Cross sectional area of flow in the culvert
93                    perimeter = diameter * pi
94                    case = 'Outlet submerged'
95                elif outlet_depth==0.0: 
96                    outlet_culvert_depth=inlet_depth # For purpose of calculation assume the outlet depth = the inlet depth
97                    alpha = acos(1 - inlet_depth/diameter)
98                    flow_area = diameter**2 * (alpha - sin(alpha)*cos(alpha))
99                    perimeter = alpha*diameter
100
101                    case = 'Outlet depth is zero'                       
102                else:   # Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity
103                    outlet_culvert_depth=outlet_depth   # For purpose of calculation assume the outlet depth = the inlet depth
104                    alpha = acos(1 - outlet_depth/diameter)
105                    flow_area = diameter**2 * (alpha - sin(alpha)*cos(alpha))
106                    perimeter = alpha*diameter
107                    case = 'Outlet is open channel flow'
108
109                hyd_rad = flow_area/perimeter
110               
111                if log_filename is not None:
112                    s = 'hydraulic radius at outlet = %f' %hyd_rad
113                    log_to_file(log_filename, s)
114
115                # Outlet control velocity using tail water
116                culvert_velocity = sqrt(delta_total_energy/((sum_loss/2*g)+(manning**2*culvert_length)/hyd_rad**1.33333)) 
117                Q_outlet_tailwater = flow_area * culvert_velocity
118               
119                if log_filename is not None:               
120                    s = 'Q_outlet_tailwater = %.6f' %Q_outlet_tailwater
121                    log_to_file(log_filename, s)
122                   
123                Q = min(Q, Q_outlet_tailwater)
124            else:
125                pass
126                #FIXME(Ole): What about inlet control?
127
128
129        else:
130            # Box culvert (rectangle or square)
131
132            # Calculate flows for inlet control
133            height = culvert_height
134            width = culvert_width           
135           
136            Q_inlet_unsubmerged = 0.540*g**0.5*width*inlet_specific_energy**1.50 # Flow based on Inlet Ctrl Inlet Unsubmerged
137            Q_inlet_submerged = 0.702*g**0.5*width*height**0.89*inlet_specific_energy**0.61  # Flow based on Inlet Ctrl Inlet Submerged
138
139            if log_filename is not None:                           
140                s = 'Q_inlet_unsubmerged = %.6f, Q_inlet_submerged = %.6f' %(Q_inlet_unsubmerged, Q_inlet_submerged)
141                log_to_file(log_filename, s)
142
143            # FIXME(Ole): Are these functions really for inlet control?   
144            if Q_inlet_unsubmerged < Q_inlet_submerged:
145                Q = Q_inlet_unsubmerged
146                flow_area = width*inlet_depth
147                outlet_culvert_depth = inlet_depth
148                case = 'Inlet unsubmerged'
149            else:   
150                Q = Q_inlet_submerged
151                flow_area = width*height
152                outlet_culvert_depth = height
153                #perimeter=2.0*(width+height)               
154                case = 'Inlet submerged'                   
155
156            if delta_total_energy < inlet_specific_energy:
157                # Calculate flows for outlet control
158                # Determine the depth at the outlet relative to the depth of flow in the Culvert
159
160                if outlet_depth > height:        # The Outlet is Submerged
161                    outlet_culvert_depth=height
162                    flow_area=width*height       # Cross sectional area of flow in the culvert
163                    perimeter=2.0*(width+height)
164                    case = 'Outlet submerged'
165                elif outlet_depth==0.0: 
166                    outlet_culvert_depth=inlet_depth   # For purpose of calculation assume the outlet depth = the inlet depth
167                    flow_area=width*inlet_depth
168                    perimeter=(width+2.0*inlet_depth)
169                    case = 'Outlet depth is zero'                       
170                else:   # Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity
171                    outlet_culvert_depth=outlet_depth
172                    flow_area=width*outlet_depth
173                    perimeter=(width+2.0*outlet_depth)
174                    case = 'Outlet is open channel flow'
175
176                hyd_rad = flow_area/perimeter
177               
178                if log_filename is not None:                               
179                    s = 'hydraulic radius at outlet = %f' % hyd_rad
180                    log_to_file(log_filename, s)
181
182                # Outlet control velocity using tail water
183                culvert_velocity = sqrt(delta_total_energy/((sum_loss/2*g)+(manning**2*culvert_length)/hyd_rad**1.33333)) 
184                Q_outlet_tailwater = flow_area * culvert_velocity
185
186                if log_filename is not None:                           
187                    s = 'Q_outlet_tailwater = %.6f' % Q_outlet_tailwater
188                    log_to_file(log_filename, s)
189                Q = min(Q, Q_outlet_tailwater)
190            else:
191                pass
192                #FIXME(Ole): What about inlet control?
193
194        # Common code for circle and square geometries
195        if log_filename is not None:
196            log_to_file(log_filename, 'Case: "%s"' % case)
197           
198        if log_filename is not None:                       
199            s = 'Flow Rate Control = %f' % Q
200            log_to_file(log_filename, s)
201
202        culv_froude=sqrt(Q**2*width/(g*flow_area**3))
203       
204        if log_filename is not None:                           
205            s = 'Froude in Culvert = %f' % culv_froude
206            log_to_file(log_filename, s)
207
208        # Determine momentum at the outlet
209        barrel_velocity = Q/(flow_area + velocity_protection/flow_area)
210
211
212    else: # inlet_depth < 0.01:
213        Q = barrel_velocity = outlet_culvert_depth = 0.0
214       
215    return Q, barrel_velocity, outlet_culvert_depth
216
217
Note: See TracBrowser for help on using the repository browser.