Changeset 8073 for trunk/anuga_core
- Timestamp:
- Nov 19, 2010, 2:53:46 PM (14 years ago)
- Location:
- trunk/anuga_core/source
- Files:
-
- 2 added
- 17 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
r8068 r8073 1321 1321 # @note Raises exception of method not known. 1322 1322 def set_timestepping_method(self, timestepping_method): 1323 methods = ['euler', 'rk2', 'rk3'] 1323 methods = ['euler', 'rk2', 'rk3'] 1324 1324 if timestepping_method in methods: 1325 1325 self.timestepping_method = timestepping_method 1326 1326 return 1327 1327 if timestepping_method in [1,2,3]: 1328 self.time tepping_method = methods[timestepping_method-1]1328 self.timestepping_method = methods[timestepping_method-1] 1329 1329 return 1330 1330 -
trunk/anuga_core/source/anuga/geometry/polygon.py
r8062 r8073 4 4 5 5 import numpy as num 6 import math 6 7 7 8 from anuga.utilities.numerical_tools import ensure_numeric … … 274 275 275 276 return indices[:count] 277 278 279 def line_length(line): 280 """Determine the length of the line 281 """ 282 283 l12 = line[1]-line[0] 284 285 return math.sqrt(num.dot(l12,l12)) 276 286 277 287 def not_line_intersect(triangles, line, verbose=False): -
trunk/anuga_core/source/anuga/shallow_water/forcing.py
r7967 r8073 278 278 from math import pi, cos, sin 279 279 280 if domain.numproc > 1: 281 msg = 'Not implemented to run in parallel' 282 assert self.__parallel_safe(), msg 283 280 284 if center is None: 281 285 msg = 'I got radius but no center.' … … 510 514 511 515 516 def __parallel_safe(self): 517 518 return false 512 519 ## 513 520 # @brief A class for rainfall forcing function. -
trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r8068 r8073 173 173 174 174 # Stored output 175 self.s tore = True175 self.set_store(True) 176 176 self.set_store_vertices_uniquely(False) 177 177 self.quantities_to_be_stored = {'elevation': 1, … … 222 222 223 223 224 def set_store(self, flag=True): 225 """Set whether data saved to sww file. 226 """ 227 228 self.store = flag 229 230 224 231 def set_sloped_mannings_function(self, flag=True): 225 232 """Set mannings friction function to use the sloped -
trunk/anuga_core/source/anuga/shallow_water_balanced/test_swb_forcing_terms.py
r8072 r8073 9 9 from anuga.config import g, epsilon 10 10 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a 11 from anuga.utilities.numerical_tools import mean 11 from anuga.utilities.numerical_tools import mean, ensure_numeric 12 12 from anuga.geometry.polygon import is_inside_polygon 13 13 from anuga.coordinate_transforms.geo_reference import Geo_reference … … 1323 1323 1324 1324 1325 def test_inflow_using_flowline(self):1325 def xtest_inflow_using_flowline(self): 1326 1326 """test_inflow_using_flowline 1327 1327 … … 1430 1430 1431 1431 for t in domain.evolve(yieldstep=100.0, finaltime=finaltime): 1432 p ass1432 print domain.timestepping_statistics() 1433 1433 #if verbose : 1434 1434 # print domain.timestepping_statistics() … … 1610 1610 if __name__ == "__main__": 1611 1611 suite = unittest.makeSuite(Test_swb_forcing_terms, 'test') 1612 runner = unittest.TextTestRunner(verbosity= 1)1612 runner = unittest.TextTestRunner(verbosity=2) 1613 1613 runner.run(suite) -
trunk/anuga_core/source/anuga/structures/boyd_box_operator.py
r8056 r8073 10 10 compute_discharge method for specific subclasses) 11 11 12 Input: Two points, pipe_size (either diameter or width, height), 12 Input: Two points, pipe_size (either diameter or width, height), 13 13 mannings_rougness, 14 14 """ … … 77 77 self.case = 'N/A' 78 78 79 79 80 80 81 def discharge_routine(self): 81 82 82 83 local_debug ='false' 83 84 if self.inflow.get_enquiry_height() > 0.01: #this value was 0.01: 84 85 if self.use_velocity_head: 86 self.delta_total_energy = self.inlets[0].get_enquiry_total_energy() - self.inlets[1].get_enquiry_total_energy() 87 else: 88 self.delta_total_energy = self.inlets[0].get_enquiry_stage() - self.inlets[1].get_enquiry_stage() 89 90 self.inflow = self.inlets[0] 91 self.outflow = self.inlets[1] 92 93 if self.delta_total_energy < 0: 94 self.inflow = self.inlets[1] 95 self.outflow = self.inlets[0] 96 self.delta_total_energy = -self.delta_total_energy 97 98 99 100 if self.inflow.get_enquiry_depth() > 0.01: #this value was 0.01: 85 101 if local_debug =='true': 86 102 anuga.log.critical('Specific E & Deltat Tot E = %s, %s' … … 97 113 self.driving_energy = self.inflow.get_enquiry_specific_energy() 98 114 else: 99 self.driving_energy = self.inflow.get_enquiry_ height()100 101 height= self.culvert_height115 self.driving_energy = self.inflow.get_enquiry_depth() 116 117 depth = self.culvert_height 102 118 width = self.culvert_width 103 119 flow_width = self.culvert_width … … 106 122 # but ensure the correct flow area and wetted perimeter are used 107 123 Q_inlet_unsubmerged = 0.544*anuga.g**0.5*width*self.driving_energy**1.50 # Flow based on Inlet Ctrl Inlet Unsubmerged 108 Q_inlet_submerged = 0.702*anuga.g**0.5*width* height**0.89*self.driving_energy**0.61 # Flow based on Inlet Ctrl Inlet Submerged124 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 109 125 110 126 # FIXME(Ole): Are these functions really for inlet control? … … 112 128 Q = Q_inlet_unsubmerged 113 129 dcrit = (Q**2/anuga.g/width**2)**0.333333 114 if dcrit > height:115 dcrit = height130 if dcrit > depth: 131 dcrit = depth 116 132 flow_area = width*dcrit 117 133 perimeter= 2.0*(width+dcrit) 118 else: # dcrit < height134 else: # dcrit < depth 119 135 flow_area = width*dcrit 120 136 perimeter= 2.0*dcrit+width … … 124 140 Q = Q_inlet_submerged 125 141 dcrit = (Q**2/anuga.g/width**2)**0.333333 126 if dcrit > height:127 dcrit = height142 if dcrit > depth: 143 dcrit = depth 128 144 flow_area = width*dcrit 129 145 perimeter= 2.0*(width+dcrit) 130 else: # dcrit < height146 else: # dcrit < depth 131 147 flow_area = width*dcrit 132 148 perimeter= 2.0*dcrit+width … … 137 153 # May not need this .... check if same is done above 138 154 outlet_culvert_depth = dcrit 139 if outlet_culvert_depth > height:140 outlet_culvert_depth = height# Once again the pipe is flowing full not partfull141 flow_area = width* height# Cross sectional area of flow in the culvert142 perimeter = 2*(width+ height)155 if outlet_culvert_depth > depth: 156 outlet_culvert_depth = depth # Once again the pipe is flowing full not partfull 157 flow_area = width*depth # Cross sectional area of flow in the culvert 158 perimeter = 2*(width+depth) 143 159 self.case = 'Inlet CTRL Outlet unsubmerged PIPE PART FULL' 144 160 else: … … 157 173 158 174 # Determine the depth at the outlet relative to the depth of flow in the Culvert 159 if self.outflow.get_enquiry_ height() > height: # The Outlet is Submerged160 outlet_culvert_depth= height161 flow_area=width* height# Cross sectional area of flow in the culvert162 perimeter=2.0*(width+ height)175 if self.outflow.get_enquiry_depth() > depth: # The Outlet is Submerged 176 outlet_culvert_depth=depth 177 flow_area=width*depth # Cross sectional area of flow in the culvert 178 perimeter=2.0*(width+depth) 163 179 self.case = 'Outlet submerged' 164 180 else: # Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity 165 181 dcrit = (Q**2/anuga.g/width**2)**0.333333 166 182 outlet_culvert_depth=dcrit # For purpose of calculation assume the outlet depth = Critical Depth 167 if outlet_culvert_depth > height:168 outlet_culvert_depth= height169 flow_area=width* height170 perimeter=2.0*(width+ height)183 if outlet_culvert_depth > depth: 184 outlet_culvert_depth=depth 185 flow_area=width*depth 186 perimeter=2.0*(width+depth) 171 187 self.case = 'Outlet is Flowing Full' 172 188 else: … … 201 217 # END CODE BLOCK for DEPTH > Required depth for CULVERT Flow 202 218 203 else: # self.inflow.get_enquiry_ height() < 0.01:219 else: # self.inflow.get_enquiry_depth() < 0.01: 204 220 Q = barrel_velocity = outlet_culvert_depth = 0.0 205 221 -
trunk/anuga_core/source/anuga/structures/boyd_pipe_operator.py
r8056 r8073 38 38 enquiry_points, 39 39 width=diameter, 40 height=None,40 depth=None, 41 41 apron=apron, 42 42 manning=manning, … … 73 73 self.case = 'N/A' 74 74 75 75 76 def __determine_inflow_outflow(self): 77 # Determine flow direction based on total energy difference 78 79 if self.use_velocity_head: 80 self.delta_total_energy = self.inlets[0].get_enquiry_total_energy() - self.inlets[1].get_enquiry_total_energy() 81 else: 82 self.delta_total_energy = self.inlets[0].get_enquiry_stage() - self.inlets[1].get_enquiry_stage() 83 84 self.inflow = self.inlets[0] 85 self.outflow = self.inlets[1] 86 87 if self.delta_total_energy < 0: 88 self.inflow = self.inlets[1] 89 self.outflow = self.inlets[0] 90 self.delta_total_energy = -self.delta_total_energy 91 76 92 def discharge_routine(self): 93 94 self.__determine_inflow_outflow() 77 95 78 96 local_debug ='false' … … 81 99 #pdb.set_trace() 82 100 83 if self.inflow.get_enquiry_ height() > 0.01: #this value was 0.01: Remember this needs to be compared to the Invert Lvl101 if self.inflow.get_enquiry_depth() > 0.01: #this value was 0.01: Remember this needs to be compared to the Invert Lvl 84 102 if local_debug =='true': 85 103 anuga.log.critical('Specific E & Deltat Tot E = %s, %s' … … 96 114 self.driving_energy = self.inflow.get_enquiry_specific_energy() 97 115 else: 98 self.driving_energy = self.inflow.get_enquiry_ height()116 self.driving_energy = self.inflow.get_enquiry_depth() 99 117 """ 100 118 For a circular pipe the Boyd method reviews 3 conditions … … 109 127 110 128 local_debug ='false' 111 if self.inflow.get_average_ height() > 0.01: #this should test against invert129 if self.inflow.get_average_depth() > 0.01: #this should test against invert 112 130 if local_debug =='true': 113 131 anuga.log.critical('Specific E & Deltat Tot E = %s, %s' … … 167 185 168 186 # Determine the depth at the outlet relative to the depth of flow in the Culvert 169 if self.outflow.get_average_ height() > diameter: # Outlet is submerged Assume the end of the Pipe is flowing FULL187 if self.outflow.get_average_depth() > diameter: # Outlet is submerged Assume the end of the Pipe is flowing FULL 170 188 outlet_culvert_depth=diameter 171 189 flow_area = (diameter/2)**2 * math.pi # Cross sectional area of flow in the culvert … … 176 194 anuga.log.critical('Outlet submerged') 177 195 else: # Culvert running PART FULL for PART OF ITS LENGTH Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity 178 # IF self.outflow.get_average_ height() < diameter196 # IF self.outflow.get_average_depth() < diameter 179 197 dcrit1 = diameter/1.26*(Q/anuga.g**0.5*diameter**2.5)**(1/3.75) 180 198 dcrit2 = diameter/0.95*(Q/anuga.g**0.5*diameter**2.5)**(1/1.95) … … 243 261 barrel_velocity = Q/(flow_area + anuga.velocity_protection/flow_area) 244 262 245 else: # self.inflow.get_average_ height() < 0.01:263 else: # self.inflow.get_average_depth() < 0.01: 246 264 Q = barrel_velocity = outlet_culvert_depth = 0.0 247 265 -
trunk/anuga_core/source/anuga/structures/inlet.py
r8056 r8073 1 import anuga.geometry.polygon 1 2 from anuga.geometry.polygon import inside_polygon, is_inside_polygon, line_intersect 2 3 from anuga.config import velocity_protection, g … … 18 19 self.compute_triangle_indices() 19 20 self.compute_area() 21 self.compute_inlet_length() 22 20 23 21 24 … … 61 64 62 65 66 def compute_inlet_length(self): 67 """ Compute the length of the inlet (as 68 defined by the input line 69 """ 70 71 point0 = self.line[0] 72 point1 = self.line[1] 73 74 self.inlet_length = anuga.geometry.polygon.line_length(self.line) 75 76 77 def get_inlet_length(self): 78 79 return self.inlet_length 80 81 def get_line(self): 82 83 return self.line 84 63 85 def get_area(self): 64 86 … … 110 132 111 133 112 def get_ heights(self):134 def get_depths(self): 113 135 114 136 return self.get_stages() - self.get_elevations() … … 117 139 def get_total_water_volume(self): 118 140 119 return num.sum(self.get_ heights()*self.get_areas())141 return num.sum(self.get_depths()*self.get_areas()) 120 142 121 143 122 def get_average_ height(self):144 def get_average_depth(self): 123 145 124 146 return self.get_total_water_volume()/self.area … … 127 149 def get_velocities(self): 128 150 129 heights = self.get_heights()130 u = self.get_xmoms()/( heights + velocity_protection/heights)131 v = self.get_ymoms()/( heights + velocity_protection/heights)151 depths = self.get_depths() 152 u = self.get_xmoms()/(depths + velocity_protection/depths) 153 v = self.get_ymoms()/(depths + velocity_protection/depths) 132 154 133 155 return u, v … … 136 158 def get_xvelocities(self): 137 159 138 heights = self.get_heights()139 return self.get_xmoms()/( heights + velocity_protection/heights)160 depths = self.get_depths() 161 return self.get_xmoms()/(depths + velocity_protection/depths) 140 162 141 163 def get_yvelocities(self): 142 164 143 heights = self.get_heights()144 return self.get_ymoms()/( heights + velocity_protection/heights)165 depths = self.get_depths() 166 return self.get_ymoms()/(depths + velocity_protection/depths) 145 167 146 168 … … 167 189 def get_average_specific_energy(self): 168 190 169 return self.get_average_velocity_head() + self.get_average_ height()170 171 172 173 def set_ heights(self,height):174 175 self.domain.quantities['stage'].centroid_values.put(self.triangle_indices, self.get_elevations() + height)191 return self.get_average_velocity_head() + self.get_average_depth() 192 193 194 195 def set_depths(self,depth): 196 197 self.domain.quantities['stage'].centroid_values.put(self.triangle_indices, self.get_elevations() + depth) 176 198 177 199 -
trunk/anuga_core/source/anuga/structures/inlet_enquiry.py
r8056 r8073 45 45 raise Exception, msg 46 46 47 def get_enquiry_position(self): 47 48 49 return self.domain.get_centroid_coordinates(absolute=True)[self.enquiry_index] 48 50 49 51 def get_enquiry_stage(self): … … 65 67 return self.domain.quantities['elevation'].centroid_values[self.enquiry_index] 66 68 67 def get_enquiry_ height(self):69 def get_enquiry_depth(self): 68 70 69 71 return self.get_enquiry_stage() - self.get_enquiry_elevation() … … 72 74 def get_enquiry_velocity(self): 73 75 74 height = self.get_enquiry_height()75 u = self.get_enquiry_xmom()/( height + velocity_protection/height)76 v = self.get_enquiry_ymom()/( height + velocity_protection/height)76 depth = self.get_enquiry_depth() 77 u = self.get_enquiry_xmom()/(depth + velocity_protection/depth) 78 v = self.get_enquiry_ymom()/(depth + velocity_protection/depth) 77 79 78 80 return u, v … … 81 83 def get_enquiry_xvelocity(self): 82 84 83 height = self.get_enquiry_height()84 return self.get_enquiry_xmom()/( height + velocity_protection/height)85 depth = self.get_enquiry_depth() 86 return self.get_enquiry_xmom()/(depth + velocity_protection/depth) 85 87 86 88 def get_enquiry_yvelocity(self): 87 89 88 height = self.get_enquiry_height()89 return self.get_enquiry_ymom()/( height + velocity_protection/height)90 depth = self.get_enquiry_depth() 91 return self.get_enquiry_ymom()/(depth + velocity_protection/depth) 90 92 91 93 … … 109 111 def get_enquiry_specific_energy(self): 110 112 111 return self.get_enquiry_velocity_head() + self.get_enquiry_ height()113 return self.get_enquiry_velocity_head() + self.get_enquiry_depth() 112 114 113 115 -
trunk/anuga_core/source/anuga/structures/inlet_operator.py
r8050 r8073 8 8 9 9 class Inlet_operator: 10 """Inlet Operator - add water to oneinlet.10 """Inlet Operator - add water to an inlet. 11 11 Sets up the geometry of problem 12 12 … … 14 14 discharge_routine method for specific subclasses) 15 15 16 Input: Two points, pipe_size (either diameter or width, height), 17 mannings_rougness, 16 Input: domain, Two points 18 17 """ 19 18 … … 74 73 75 74 # FIXME (SR): Might be nice to spread the over the inlet so that it is flat 76 new_inlet_ height = self.inlet.get_average_height() + (Q*timestep/self.inlet.get_area())77 self.inlet.set_ heights(new_inlet_height)75 new_inlet_depth = self.inlet.get_average_depth() + (Q*timestep/self.inlet.get_area()) 76 self.inlet.set_depths(new_inlet_depth) 78 77 79 78 -
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 -
trunk/anuga_core/source/anuga/structures/test_boyd_box_operator.py
r8056 r8073 24 24 def tearDown(self): 25 25 pass 26 26 27 28 def _create_domain(self,d_length, 29 d_width, 30 dx, 31 dy, 32 elevation_0, 33 elevation_1, 34 stage_0, 35 stage_1): 36 37 points, vertices, boundary = rectangular_cross(int(d_length/dx), int(d_width/dy), 38 len1=d_length, len2=d_width) 39 domain = Domain(points, vertices, boundary) 40 domain.set_name('Test_Outlet_Inlet') # Output name 41 domain.set_store() 42 domain.set_default_order(2) 43 domain.H0 = 0.01 44 domain.tight_slope_limiters = 1 45 46 #print 'Size', len(domain) 47 48 #------------------------------------------------------------------------------ 49 # Setup initial conditions 50 #------------------------------------------------------------------------------ 51 52 def elevation(x, y): 53 """Set up a elevation 54 """ 55 56 z = numpy.zeros(x.shape,dtype='d') 57 z[:] = elevation_0 58 59 numpy.putmask(z, x > d_length/2, elevation_1) 60 61 return z 62 63 def stage(x,y): 64 """Set up stage 65 """ 66 z = numpy.zeros(x.shape,dtype='d') 67 z[:] = stage_0 68 69 numpy.putmask(z, x > d_length/2, stage_1) 70 71 return z 72 73 #print 'Setting Quantities....' 74 domain.set_quantity('elevation', elevation) # Use function for elevation 75 domain.set_quantity('stage', stage) # Use function for elevation 76 77 return domain 27 78 28 79 def test_boyd_non_skew(self): … … 37 88 elevation_0 = 10.0 38 89 elevation_1 = 10.0 90 91 domain_length = 200.0 92 domain_width = 200.0 39 93 40 94 culvert_length = 20.0 … … 46 100 culvert_apron = 0.0 47 101 enquiry_gap = 10.0 48 49 expected_Q = 4.55 50 expected_v = 2.3 51 expected_d = 0.54 52 53 54 # Probably no need to change below here 55 56 domain_length = 200. #x-Dir 57 domain_width = 200. #y-dir 58 dx = dy = 5.0 # Resolution: Length of subdivisions on both axes 59 60 61 points, vertices, boundary = rectangular_cross(int(domain_length/dx), int(domain_width/dy), 62 len1=domain_length, len2=domain_width) 63 domain = Domain(points, vertices, boundary) 64 domain.set_name('Test_Outlet_Inlet') # Output name 65 domain.set_default_order(2) 66 domain.H0 = 0.01 67 domain.tight_slope_limiters = 1 68 69 print 'Size', len(domain) 70 71 #------------------------------------------------------------------------------ 72 # Setup initial conditions 73 #------------------------------------------------------------------------------ 74 75 def elevation(x, y): 76 """Set up a elevation 77 """ 78 79 z = numpy.zeros(x.shape,dtype='d') 80 z[:] = elevation_0 81 82 numpy.putmask(z, x > domain_length/2, elevation_1) 83 84 return z 85 86 def stage(x,y): 87 """Set up stage 88 """ 89 z = numpy.zeros(x.shape,dtype='d') 90 z[:] = stage_0 91 92 numpy.putmask(z, x > domain_length/2, stage_1) 93 94 return z 95 96 print 'Setting Quantities....' 97 domain.set_quantity('elevation', elevation) # Use function for elevation 98 domain.set_quantity('stage', stage) # Use function for elevation 99 100 101 print 'Defining Structures' 102 103 104 expected_Q = 6.23 105 expected_v = 2.55 106 expected_d = 0.66 107 108 109 domain = self._create_domain(d_length=domain_length, 110 d_width=domain_width, 111 dx = 5.0, 112 dy = 5.0, 113 elevation_0 = elevation_0, 114 elevation_1 = elevation_1, 115 stage_0 = stage_0, 116 stage_1 = stage_1) 117 118 119 #print 'Defining Structures' 102 120 103 121 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) … … 118 136 verbose=False) 119 137 120 culvert.determine_inflow_outflow()138 #culvert.determine_inflow_outflow() 121 139 122 140 ( Q, v, d ) = culvert.discharge_routine() 123 141 124 print 'test_boyd_non_skew'125 print 'Q: ', Q, 'expected_Q: ', expected_Q142 #print 'test_boyd_non_skew' 143 #print 'Q: ', Q, 'expected_Q: ', expected_Q 126 144 127 145 … … 142 160 elevation_0 = 10.0 143 161 elevation_1 = 10.0 162 163 domain_length = 200.0 164 domain_width = 200.0 144 165 145 166 culvert_length = 20.0 … … 152 173 enquiry_gap = 10.0 153 174 154 expected_Q = 4.55 155 expected_v = 2.3 156 expected_d = 0.54 157 158 159 # Probably no need to change below here 160 161 domain_length = 200. #x-Dir 162 domain_width = 200. #y-dir 163 dx = dy = 5.0 # Resolution: Length of subdivisions on both axes 164 165 166 points, vertices, boundary = rectangular_cross(int(domain_length/dx), int(domain_width/dy), 167 len1=domain_length, len2=domain_width) 168 domain = Domain(points, vertices, boundary) 169 domain.set_name('Test_Outlet_Inlet') # Output name 170 domain.set_default_order(2) 171 domain.H0 = 0.01 172 domain.tight_slope_limiters = 1 173 174 print 'Size', len(domain) 175 176 #------------------------------------------------------------------------------ 177 # Setup initial conditions 178 #------------------------------------------------------------------------------ 179 180 def elevation(x, y): 181 """Set up a elevation 182 """ 183 184 z = numpy.zeros(x.shape,dtype='d') 185 z[:] = elevation_0 186 187 numpy.putmask(z, x > domain_length/2, elevation_1) 188 189 return z 190 191 def stage(x,y): 192 """Set up stage 193 """ 194 z = numpy.zeros(x.shape,dtype='d') 195 z[:] = stage_0 196 197 numpy.putmask(z, x > domain_length/2, stage_1) 198 199 return z 200 201 print 'Setting Quantities....' 202 domain.set_quantity('elevation', elevation) # Use function for elevation 203 domain.set_quantity('stage', stage) # Use function for elevation 204 205 206 print 'Defining Structures' 175 expected_Q = 6.23 176 expected_v = 2.55 177 expected_d = 0.66 178 179 180 domain = self._create_domain(d_length=domain_length, 181 d_width=domain_width, 182 dx = 5.0, 183 dy = 5.0, 184 elevation_0 = elevation_0, 185 elevation_1 = elevation_1, 186 stage_0 = stage_0, 187 stage_1 = stage_1) 188 189 #print 'Defining Structures' 207 190 208 191 a = domain_length/2 - culvert_length/2 … … 225 208 verbose=False) 226 209 227 culvert.determine_inflow_outflow()210 #culvert.determine_inflow_outflow() 228 211 229 212 ( Q, v, d ) = culvert.discharge_routine() 230 213 231 print 'test_boyd_skew'232 print 'Q: ', Q, 'expected_Q: ', expected_Q214 #print 'test_boyd_skew' 215 #print 'Q: ', Q, 'expected_Q: ', expected_Q 233 216 234 217 assert numpy.allclose(Q, expected_Q, rtol=1.0e-2) #inflow … … 248 231 elevation_0 = 10.0 249 232 elevation_1 = 10.0 233 234 domain_length = 200.0 235 domain_width = 200.0 250 236 251 237 culvert_length = 20.0 … … 258 244 enquiry_gap = 10.0 259 245 260 expected_Q = 4.55261 expected_v = 2. 3262 expected_d = 0. 54246 expected_Q = 6.23 247 expected_v = 2.55 248 expected_d = 0.66 263 249 264 250 265 251 # Probably no need to change below here 266 252 267 domain_length = 200. #x-Dir 268 domain_width = 200. #y-dir 269 dx = dy = 5.0 # Resolution: Length of subdivisions on both axes 270 271 272 points, vertices, boundary = rectangular_cross(int(domain_length/dx), int(domain_width/dy), 273 len1=domain_length, len2=domain_width) 274 domain = Domain(points, vertices, boundary) 275 domain.set_name('Test_Outlet_Inlet') # Output name 276 domain.set_default_order(2) 277 domain.H0 = 0.01 278 domain.tight_slope_limiters = 1 279 280 print 'Size', len(domain) 281 282 #------------------------------------------------------------------------------ 283 # Setup initial conditions 284 #------------------------------------------------------------------------------ 285 286 def elevation(x, y): 287 """Set up a elevation 288 """ 289 290 z = numpy.zeros(x.shape,dtype='d') 291 z[:] = elevation_0 292 293 numpy.putmask(z, x > domain_length/2, elevation_1) 294 295 return z 296 297 def stage(x,y): 298 """Set up stage 299 """ 300 z = numpy.zeros(x.shape,dtype='d') 301 z[:] = stage_0 302 303 numpy.putmask(z, x > domain_length/2, stage_1) 304 305 return z 306 307 print 'Setting Quantities....' 308 domain.set_quantity('elevation', elevation) # Use function for elevation 309 domain.set_quantity('stage', stage) # Use function for elevation 310 311 312 print 'Defining Structures' 253 domain = self._create_domain(d_length=domain_length, 254 d_width=domain_width, 255 dx = 5.0, 256 dy = 5.0, 257 elevation_0 = elevation_0, 258 elevation_1 = elevation_1, 259 stage_0 = stage_0, 260 stage_1 = stage_1) 261 262 263 #print 'Defining Structures' 313 264 314 265 a = domain_length/2 - culvert_length/2 … … 334 285 verbose=False) 335 286 336 culvert.determine_inflow_outflow()287 #culvert.determine_inflow_outflow() 337 288 338 289 ( Q, v, d ) = culvert.discharge_routine() 339 290 340 print test_boyd_non_skew_enquiry_points 341 print 'Q: ', Q, 'expected_Q: ', expected_Q 291 #print 'test_boyd_non_skew_enquiry_points' 292 #print 'Q: ', Q, 'expected_Q: ', expected_Q 293 #print 'v: ', v, 'expected_v: ', expected_v 294 #print 'd: ', d, 'expected_d: ', expected_d 342 295 343 296 assert numpy.allclose(Q, expected_Q, rtol=1.0e-2) #inflow -
trunk/anuga_core/source/anuga/structures/testing_open_slot_wide_bridge.py
r7980 r8073 154 154 end_point0=[40.0, 75.0], 155 155 end_point1=[50.0, 75.0], 156 width=50.0, height=5.0,156 width=50.0,depth=5.0, 157 157 culvert_routine=boyd_generalised_culvert_model, 158 158 number_of_barrels=1, -
trunk/anuga_core/source/anuga/structures/testing_outlet_control.py
r8067 r8073 150 150 # end_point1=[50.0, 75.0], 151 151 # width=50.0, 152 # height=10.0,152 # depth=10.0, 153 153 # apron=5.0, 154 154 # verbose=False) … … 164 164 culvert_width = 50.0/number_of_culverts 165 165 y = 100-i*culvert_width - culvert_width/2.0 166 ep0 = [40.0, y] 167 ep1 = [50.0, y] 166 ep0 = num.array([40.0, y]) 167 ep1 = num.array([50.0, y]) 168 168 169 losses = {'inlet':0.5, 'outlet':1, 'bend':0, 'grate':0, 'pier': 0, 'other': 0} 169 170 # culverts.append(Boyd_pipe_operator(domain, … … 181 182 182 183 183 Boyd_pipe_operator(domain, 184 end_point0=ep0, 185 end_point1=ep1, 186 losses=losses, 187 diameter=1.5, #culvert_width, #3.658, 188 apron=6.0, 189 use_momentum_jet=True, 190 use_velocity_head=True, 191 manning=0.013, 192 logging=True, 193 label='pipe_culvert', 194 verbose=False) 184 185 195 186 196 187 Boyd_box_operator(domain, 197 end_point0=ep0, 198 end_point1=ep1, 188 end_points=[ep0,ep1], 199 189 losses=losses, 200 190 width=culvert_width, 201 height=10.0,191 depth=10.0, 202 192 apron=6.0, 203 193 use_momentum_jet=True, … … 216 206 #losses, 217 207 #width=25.0, 218 # height=10.0,208 #depth=10.0, 219 209 #apron=5.0, 220 210 #manning=0.013, -
trunk/anuga_core/source/anuga/structures/testing_wide_bridge.py
r8008 r8073 171 171 # end_point1=[50.0, 75.0], 172 172 # width=50.0, 173 # height=10.0,173 # depth=10.0, 174 174 # apron=5.0, 175 175 # verbose=False) … … 191 191 losses=1.5, 192 192 width=3.658, 193 height=3.658,193 depth=3.658, 194 194 apron=5.0, 195 195 use_momentum_jet=True, … … 206 206 # end_point1=[50.0, 62.5], 207 207 # width=25.0, 208 # height=10.0,208 # depth=10.0, 209 209 # apron=5.0, 210 210 # manning=0.013, … … 219 219 end_point0=[40.0, 75.0], 220 220 end_point1=[50.0, 75.0], 221 width=50.0, height=5.0,221 width=50.0,depth=5.0, 222 222 culvert_routine=boyd_generalised_culvert_model, #culvert_routine=weir_orifice_channel_culvert_model, 223 223 number_of_barrels=1, -
trunk/anuga_core/source/anuga/structures/testing_wide_bridge_old.py
r7980 r8073 168 168 end_point0=[40.0, 75.0], 169 169 end_point1=[50.0, 75.0], 170 width=50.0, height=5.0,170 width=50.0,depth=5.0, 171 171 culvert_routine=boyd_generalised_culvert_model, #culvert_routine=weir_orifice_channel_culvert_model, 172 172 number_of_barrels=1, -
trunk/anuga_core/source/anuga/utilities/numerical_tools.py
r7690 r8073 251 251 A: String. Array of ASCII values (numpy can't handle this) 252 252 253 A:None. Return None 254 253 255 typecode: numeric type. If specified, use this in the conversion. 254 256 If not, let numeric package decide. … … 264 266 # msg = 'Sorry, cannot handle strings in ensure_numeric()' 265 267 # raise Exception, msg 268 269 if A is None: 270 return None 266 271 267 272 if typecode is None: -
trunk/anuga_core/source/anuga_parallel/run_parallel_sw_merimbula.py
r8014 r8073 47 47 48 48 #mesh_filename = "merimbula_10785_1.tsh" ; x0 = 756000.0 ; x1 = 756500.0 49 mesh_filename = "merimbula_43200.tsh" ; x0 = 756000.0 ; x1 = 756500.050 #mesh_filename = "test-100.tsh" ; x0 = 0.25 ; x1 = 0.549 #mesh_filename = "merimbula_43200.tsh" ; x0 = 756000.0 ; x1 = 756500.0 50 mesh_filename = "test-100.tsh" ; x0 = 0.25 ; x1 = 0.5 51 51 yieldstep = 5 52 52 finaltime = 200
Note: See TracChangeset
for help on using the changeset viewer.