Changeset 8833
- Timestamp:
- Apr 16, 2013, 8:32:09 PM (12 years ago)
- Location:
- trunk/anuga_core/source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga_parallel/parallel_boyd_box_operator.py
r8832 r8833 1 1 import anuga 2 2 import math 3 import pypar4 3 5 4 from anuga.structures.boyd_box_operator import boyd_box_function … … 259 258 def discharge_routine(self): 260 259 260 import pypar 261 261 262 local_debug = False 262 263 -
trunk/anuga_core/source/anuga_parallel/parallel_boyd_pipe_operator.py
r8832 r8833 1 1 import anuga 2 2 import math 3 import pypar4 3 5 4 from anuga.structures.boyd_pipe_operator import boyd_pipe_function … … 106 105 107 106 def parallel_safe(self): 107 """ 108 Set that operator is parallel safe 109 """ 108 110 109 111 return True 110 112 111 113 112 113 114 def debug_discharge_routine(self): 115 116 117 118 local_debug = False 119 120 if self.use_velocity_head: 121 self.delta_total_energy = self.inlets[0].get_enquiry_total_energy() - self.inlets[1].get_enquiry_total_energy() 122 else: 123 self.delta_total_energy = self.inlets[0].get_enquiry_stage() - self.inlets[1].get_enquiry_stage() 124 125 self.inflow = self.inlets[0] 126 self.outflow = self.inlets[1] 127 128 self.inflow_index = 0 129 self.outflow_index = 1 130 131 if self.delta_total_energy < 0: 132 self.inflow = self.inlets[1] 133 self.outflow = self.inlets[0] 134 self.delta_total_energy = -self.delta_total_energy 135 self.inflow_index = 1 136 self.outflow_index = 0 137 138 139 if self.inflow.get_enquiry_depth() > 0.01: #this value was 0.01: 140 if local_debug: 141 anuga.log.critical('Specific E & Deltat Tot E = %s, %s' 142 % (str(self.inflow.get_enquiry_specific_energy()), 143 str(self.delta_total_energy))) 144 anuga.log.critical('culvert type = %s' % str(culvert_type)) 145 # Water has risen above inlet 146 147 148 msg = 'Specific energy at inlet is negative' 149 assert self.inflow.get_enquiry_specific_energy() >= 0.0, msg 150 151 if self.use_velocity_head : 152 self.driving_energy = self.inflow.get_enquiry_specific_energy() 153 else: 154 self.driving_energy = self.inflow.get_enquiry_depth() 155 156 depth = self.culvert_height 157 width = self.culvert_width 158 flow_width = self.culvert_width 159 # intially assume the culvert flow is controlled by the inlet 160 # check unsubmerged and submerged condition and use Min Q 161 # but ensure the correct flow area and wetted perimeter are used 162 Q_inlet_unsubmerged = 0.544*anuga.g**0.5*width*self.driving_energy**1.50 # Flow based on Inlet Ctrl Inlet Unsubmerged 163 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 164 165 # FIXME(Ole): Are these functions really for inlet control? 166 if Q_inlet_unsubmerged < Q_inlet_submerged: 167 Q = Q_inlet_unsubmerged 168 dcrit = (Q**2/anuga.g/width**2)**0.333333 169 if dcrit > depth: 170 dcrit = depth 171 flow_area = width*dcrit 172 perimeter= 2.0*(width+dcrit) 173 else: # dcrit < depth 174 flow_area = width*dcrit 175 perimeter= 2.0*dcrit+width 176 outlet_culvert_depth = dcrit 177 self.case = 'Inlet unsubmerged Box Acts as Weir' 178 else: # Inlet Submerged but check internal culvert flow depth 179 Q = Q_inlet_submerged 180 dcrit = (Q**2/anuga.g/width**2)**0.333333 181 if dcrit > depth: 182 dcrit = depth 183 flow_area = width*dcrit 184 perimeter= 2.0*(width+dcrit) 185 else: # dcrit < depth 186 flow_area = width*dcrit 187 perimeter= 2.0*dcrit+width 188 outlet_culvert_depth = dcrit 189 self.case = 'Inlet submerged Box Acts as Orifice' 190 191 dcrit = (Q**2/anuga.g/width**2)**0.333333 192 # May not need this .... check if same is done above 193 outlet_culvert_depth = dcrit 194 if outlet_culvert_depth > depth: 195 outlet_culvert_depth = depth # Once again the pipe is flowing full not partfull 196 flow_area = width*depth # Cross sectional area of flow in the culvert 197 perimeter = 2*(width+depth) 198 self.case = 'Inlet CTRL Outlet unsubmerged PIPE PART FULL' 199 else: 200 flow_area = width * outlet_culvert_depth 201 perimeter = width+2*outlet_culvert_depth 202 self.case = 'INLET CTRL Culvert is open channel flow we will for now assume critical depth' 203 # Initial Estimate of Flow for Outlet Control using energy slope 204 #( may need to include Culvert Bed Slope Comparison) 205 hyd_rad = flow_area/perimeter 206 culvert_velocity = math.sqrt(self.delta_total_energy/((self.sum_loss/2/anuga.g)+(self.manning**2*self.culvert_length)/hyd_rad**1.33333)) 207 Q_outlet_tailwater = flow_area * culvert_velocity 208 209 210 if self.delta_total_energy < self.driving_energy: 211 # Calculate flows for outlet control 212 213 # Determine the depth at the outlet relative to the depth of flow in the Culvert 214 if self.outflow.get_enquiry_depth() > depth: # The Outlet is Submerged 215 outlet_culvert_depth=depth 216 flow_area=width*depth # Cross sectional area of flow in the culvert 217 perimeter=2.0*(width+depth) 218 self.case = 'Outlet submerged' 219 else: # Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity 220 dcrit = (Q**2/anuga.g/width**2)**0.333333 221 outlet_culvert_depth=dcrit # For purpose of calculation assume the outlet depth = Critical Depth 222 if outlet_culvert_depth > depth: 223 outlet_culvert_depth=depth 224 flow_area=width*depth 225 perimeter=2.0*(width+depth) 226 self.case = 'Outlet is Flowing Full' 227 else: 228 flow_area=width*outlet_culvert_depth 229 perimeter=(width+2.0*outlet_culvert_depth) 230 self.case = 'Outlet is open channel flow' 231 232 hyd_rad = flow_area/perimeter 233 234 235 236 # Final Outlet control velocity using tail water 237 culvert_velocity = math.sqrt(self.delta_total_energy/((self.sum_loss/2/anuga.g)+(self.manning**2*self.culvert_length)/hyd_rad**1.33333)) 238 Q_outlet_tailwater = flow_area * culvert_velocity 239 240 Q = min(Q, Q_outlet_tailwater) 241 else: 242 243 pass 244 #FIXME(Ole): What about inlet control? 245 246 culv_froude=math.sqrt(Q**2*flow_width/(anuga.g*flow_area**3)) 247 248 if local_debug: 249 anuga.log.critical('FLOW AREA = %s' % str(flow_area)) 250 anuga.log.critical('PERIMETER = %s' % str(perimeter)) 251 anuga.log.critical('Q final = %s' % str(Q)) 252 anuga.log.critical('FROUDE = %s' % str(culv_froude)) 253 254 # Determine momentum at the outlet 255 barrel_velocity = Q/(flow_area + anuga.velocity_protection/flow_area) 256 257 # END CODE BLOCK for DEPTH > Required depth for CULVERT Flow 258 259 else: # self.inflow.get_enquiry_depth() < 0.01: 260 Q = barrel_velocity = outlet_culvert_depth = 0.0 261 262 # Temporary flow limit 263 if barrel_velocity > self.max_velocity: 264 barrel_velocity = self.max_velocity 265 Q = flow_area * barrel_velocity 266 267 return Q, barrel_velocity, outlet_culvert_depth 268 114 269 115 def discharge_routine(self): 116 """ 117 Get info from inlets and then call sequential function 118 """ 119 120 import pypar 270 121 271 122 local_debug = False -
trunk/anuga_core/source/anuga_parallel/parallel_inlet.py
r8420 r8833 9 9 import numpy as num 10 10 from anuga.structures.inlet import Inlet 11 import pypar 11 12 12 13 13 class Parallel_Inlet(Inlet): … … 38 38 self.procs = procs 39 39 40 import pypar 40 41 self.myid = pypar.rank() 41 42 … … 104 105 # WARNING: requires synchronization, must be called by all procs associated 105 106 # with this inlet 106 107 108 import pypar 107 109 local_area = self.area 108 110 area = local_area … … 145 147 # with this inlet 146 148 149 import pypar 147 150 local_stage = num.sum(self.get_stages()*self.get_areas()) 148 151 global_area = self.get_global_area() … … 184 187 # with this inlet 185 188 189 import pypar 186 190 global_area = self.get_global_area() 187 191 local_xmoms = num.sum(self.get_xmoms()*self.get_areas()) … … 214 218 # with this inlet 215 219 220 import pypar 216 221 global_area = self.get_global_area() 217 222 local_ymoms = num.sum(self.get_ymoms()*self.get_areas()) … … 244 249 # with this inlet 245 250 251 import pypar 246 252 local_volume = num.sum(self.get_depths()*self.get_areas()) 247 253 volume = local_volume … … 353 359 # with this inlet 354 360 361 import pypar 355 362 centroid_coordinates = self.domain.get_full_centroid_coordinates(absolute=True) 356 363 areas = self.get_areas() … … 474 481 # WARNING: requires synchronization, must be called by all procs associated 475 482 # with this inlet 483 484 import pypar 476 485 477 486 message = '' -
trunk/anuga_core/source/anuga_parallel/parallel_inlet_enquiry.py
r8592 r8833 4 4 5 5 import numpy as num 6 import pypar7 6 8 7 import parallel_inlet … … 25 24 parallel_inlet.Parallel_Inlet.__init__(self, domain, polyline, 26 25 master_proc = master_proc, procs = procs, verbose=verbose) 27 26 27 import pypar 28 28 29 self.enquiry_pt = enquiry_pt 29 30 self.outward_culvert_vector = outward_culvert_vector -
trunk/anuga_core/source/anuga_parallel/parallel_inlet_operator.py
r8687 r8833 10 10 from anuga.structures.inlet_operator import Inlet_operator 11 11 import parallel_inlet 12 import pypar 12 13 13 14 14 class Parallel_Inlet_operator(Inlet_operator): … … 44 44 verbose = False): 45 45 46 import pypar 46 47 self.domain = domain 47 48 self.domain.set_fractional_step_operator(self) … … 95 96 def __call__(self): 96 97 98 import pypar 97 99 volume = 0 98 100 -
trunk/anuga_core/source/anuga_parallel/parallel_operator_factory.py
r8825 r8833 2 2 # and open the template in the editor. 3 3 4 import pypar 4 5 5 6 6 import os.path … … 49 49 logging = False, 50 50 master_proc = 0, 51 procs = range(0,pypar.size()),51 procs = None, 52 52 verbose = False): 53 53 … … 65 65 verbose = verbose) 66 66 67 import pypar 68 if procs is None: 69 procs = range(0,pypar.size()) 67 70 68 71 myid = pypar.rank() … … 128 131 verbose=False, 129 132 master_proc=0, 130 procs= range(0,pypar.size())):133 procs=None): 131 134 132 135 # If not parallel domain then allocate serial Boyd box operator … … 151 154 logging=logging, 152 155 verbose=verbose) 156 157 import pypar 158 if procs is None: 159 procs = range(0,pypar.size()) 153 160 154 161 myid = pypar.rank() … … 282 289 verbose=False, 283 290 master_proc=0, 284 procs= range(0,pypar.size())):291 procs=None): 285 292 286 293 # If not parallel domain then allocate serial Boyd box operator … … 305 312 verbose=verbose) 306 313 314 import pypar 315 if procs is None: 316 procs = range(0,pypar.size()) 317 307 318 myid = pypar.rank() 308 319 … … 477 488 478 489 479 def allocate_inlet_procs(domain, line, enquiry_point = None, master_proc = 0, procs = range(0, pypar.size()), verbose = False): 480 490 def allocate_inlet_procs(domain, line, enquiry_point = None, master_proc = 0, procs = None, verbose = False): 491 492 493 import pypar 494 if procs is None: 495 procs = range(0, pypar.size()) 496 481 497 myid = pypar.rank() 482 498 vertex_coordinates = domain.get_full_vertex_coordinates(absolute=True) -
trunk/anuga_core/source/anuga_parallel/parallel_structure_operator.py
r8832 r8833 7 7 from anuga.utilities.numerical_tools import ensure_numeric 8 8 from anuga.structures.inlet_enquiry import Inlet_enquiry 9 import pypar 9 10 10 11 11 class Parallel_Structure_operator(anuga.Operator): … … 57 57 enquiry_proc = None): 58 58 59 import pypar 59 60 self.myid = pypar.rank() 60 61 self.num_procs = pypar.size() … … 180 181 181 182 def __call__(self): 183 184 import pypar 182 185 183 186 timestep = self.domain.get_timestep() … … 392 395 # with this structure 393 396 397 import pypar 398 394 399 message = ' ' 395 400 -
trunk/anuga_core/source/anuga_validation_tests/Case_studies/Merewether
-
Property
svn:ignore
set to
.python_cache
-
Property
svn:ignore
set to
-
trunk/anuga_core/source/anuga_validation_tests/Case_studies/Merewether/merewether.py
r8829 r8833 29 29 import project # Definition of file names and polygons 30 30 31 verbose = project.verbose 32 use_cache = project.use_cache 33 31 34 #------------------------------------------------------------------------------ 32 35 # Preparation of topographic data … … 41 44 if myid == 0: 42 45 # Create DEM from asc data 43 anuga.asc2dem(asc_name, verbose= True) #use_cache=True,46 anuga.asc2dem(asc_name, verbose=verbose, use_cache=use_cache) 44 47 45 48 # Create pts file for onshore DEM 46 anuga.dem2pts(dem_name, verbose= True) #use_cache=True,49 anuga.dem2pts(dem_name, verbose=verbose, use_cache=use_cache) 47 50 48 51 #------------------------------------------------------------------------------ … … 69 72 mesh_filename=meshname, 70 73 interior_regions=interior_regions, 71 use_cache= False,72 verbose= True)74 use_cache=use_cache, 75 verbose=verbose) 73 76 74 77 #------------------------------------------------------------------------------ … … 78 81 domain.set_quantity('friction', 0.02) 79 82 domain.set_quantity('elevation', filename='topography1.pts', 80 use_cache= True,81 verbose= True)83 use_cache=use_cache, 84 verbose=verbose) 82 85 83 86 else: -
trunk/anuga_core/source/anuga_validation_tests/Case_studies/Merewether/project.py
r8829 r8833 7 7 import anuga.utilities 8 8 from os.path import join 9 10 verbose = True 11 use_cache = True 12 9 13 10 14 ###############################
Note: See TracChangeset
for help on using the changeset viewer.