- Timestamp:
- Nov 19, 2010, 2:53:46 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/structures/structure_operator.py
r8056 r8073 5 5 6 6 from anuga.utilities.system_tools import log_to_file 7 from anuga.utilities.numerical_tools import ensure_numeric 8 7 9 8 10 … … 14 16 discharge_routine method for specific subclasses) 15 17 16 Input: Two points, pipe_size (either diameter or width, height),18 Input: Two points, pipe_size (either diameter or width, depth), 17 19 mannings_rougness, 18 20 """ … … 38 40 self.domain = domain 39 41 self.domain.set_fractional_step_operator(self) 40 self.end_points = end_points 41 self.exchange_lines = exchange_lines 42 self.enquiry_points = enquiry_points 42 self.end_points = ensure_numeric(end_points) 43 self.exchange_lines = ensure_numeric(exchange_lines) 44 self.enquiry_points = ensure_numeric(enquiry_points) 45 46 47 if domain.numproc > 1: 48 msg = 'Not implemented to run in parallel' 49 assert self.__parallel_safe(), msg 50 43 51 44 52 if height is None: … … 106 114 timestep = self.domain.get_timestep() 107 115 108 self.determine_inflow_outflow()109 110 116 Q, barrel_speed, outlet_depth = self.discharge_routine() 111 117 112 old_inflow_height = self.inflow.get_average_height() 118 old_inflow_depth = self.inflow.get_average_depth() 119 old_inflow_stage = self.inflow.get_average_stage() 113 120 old_inflow_xmom = self.inflow.get_average_xmom() 114 121 old_inflow_ymom = self.inflow.get_average_ymom() 115 122 123 116 124 # Implement the update of flow over a timestep by 117 125 # using a semi-implict update. This ensures that 118 # the update does not create a negative height119 if old_inflow_ height> 0.0 :120 Q_star = Q/old_inflow_ height126 # the update does not create a negative depth 127 if old_inflow_depth > 0.0 : 128 Q_star = Q/old_inflow_depth 121 129 else: 122 130 Q_star = 0.0 … … 124 132 factor = 1.0/(1.0 + Q_star*timestep/self.inflow.get_area()) 125 133 126 new_inflow_ height = old_inflow_height*factor134 new_inflow_depth = old_inflow_depth*factor 127 135 new_inflow_xmom = old_inflow_xmom*factor 128 136 new_inflow_ymom = old_inflow_ymom*factor 129 137 130 self.inflow.set_ heights(new_inflow_height)138 self.inflow.set_depths(new_inflow_depth) 131 139 132 140 #inflow.set_xmoms(Q/inflow.get_area()) … … 136 144 self.inflow.set_ymoms(new_inflow_ymom) 137 145 138 loss = (old_inflow_ height - new_inflow_height)*self.inflow.get_area()146 loss = (old_inflow_depth - new_inflow_depth)*self.inflow.get_area() 139 147 140 148 # set outflow 141 if old_inflow_ height> 0.0 :142 timestep_star = timestep*new_inflow_ height/old_inflow_height149 if old_inflow_depth > 0.0 : 150 timestep_star = timestep*new_inflow_depth/old_inflow_depth 143 151 else: 144 152 timestep_star = 0.0 145 153 146 outflow_extra_height = Q*timestep_star/self.outflow.get_area() 154 155 156 157 outflow_extra_depth = Q*timestep_star/self.outflow.get_area() 147 158 outflow_direction = - self.outflow.outward_culvert_vector 148 outflow_extra_momentum = outflow_extra_ height*barrel_speed*outflow_direction149 150 gain = outflow_extra_ height*self.outflow.get_area()159 outflow_extra_momentum = outflow_extra_depth*barrel_speed*outflow_direction 160 161 gain = outflow_extra_depth*self.outflow.get_area() 151 162 152 163 #print Q, Q*timestep, barrel_speed, outlet_depth, Qstar, factor, timestep_star … … 154 165 155 166 # Stats 156 self.discharge = Q#outflow_extra_ height*self.outflow.get_area()/timestep167 self.discharge = Q#outflow_extra_depth*self.outflow.get_area()/timestep 157 168 self.velocity = barrel_speed#self.discharge/outlet_depth/self.width 158 169 159 new_outflow_ height = self.outflow.get_average_height() + outflow_extra_height170 new_outflow_depth = self.outflow.get_average_depth() + outflow_extra_depth 160 171 161 172 if self.use_momentum_jet : … … 164 175 #new_outflow_ymom = outflow.get_average_ymom() + outflow_extra_momentum[1] 165 176 166 new_outflow_xmom = barrel_speed*new_outflow_ height*outflow_direction[0]167 new_outflow_ymom = barrel_speed*new_outflow_ height*outflow_direction[1]177 new_outflow_xmom = barrel_speed*new_outflow_depth*outflow_direction[0] 178 new_outflow_ymom = barrel_speed*new_outflow_depth*outflow_direction[1] 168 179 169 180 else: … … 174 185 new_outflow_ymom = 0.0 175 186 176 self.outflow.set_ heights(new_outflow_height)187 self.outflow.set_depths(new_outflow_depth) 177 188 self.outflow.set_xmoms(new_outflow_xmom) 178 189 self.outflow.set_ymoms(new_outflow_ymom) 179 190 180 191 181 def determine_inflow_outflow(self): 182 # Determine flow direction based on total energy difference 183 184 if self.use_velocity_head: 185 self.delta_total_energy = self.inlets[0].get_enquiry_total_energy() - self.inlets[1].get_enquiry_total_energy() 186 else: 187 self.delta_total_energy = self.inlets[0].get_enquiry_stage() - self.inlets[1].get_enquiry_stage() 188 189 self.inflow = self.inlets[0] 190 self.outflow = self.inlets[1] 191 192 if self.delta_total_energy < 0: 193 self.inflow = self.inlets[1] 194 self.outflow = self.inlets[0] 195 self.delta_total_energy = -self.delta_total_energy 192 196 193 197 194 … … 262 259 self.enquiry_points.append(centre_point1 + gap) 263 260 264 261 262 def __parallel_safe(self): 263 264 return False 265 265 266 def discharge_routine(self): 266 267 pass 267 268 msg = 'Need to impelement ' 269 raise 268 270 269 271
Note: See TracChangeset
for help on using the changeset viewer.