source: trunk/anuga_core/source/anuga/structures/boyd_box_operator.py @ 8008

Last change on this file since 8008 was 8008, checked in by habili, 14 years ago

Deleting unnecessary structure test scripts

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