Changeset 8018
- Timestamp:
- Sep 16, 2010, 2:09:13 PM (14 years ago)
- Location:
- trunk/anuga_core/source/anuga
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
r7967 r8018 1528 1528 raise Exception, msg 1529 1529 1530 # Yield final time and stop1530 # Log and then Yield final time and stop 1531 1531 self.time = finaltime 1532 self.log_operator_timestepping_statistics() 1532 1533 yield(self.time) 1533 1534 break … … 1540 1541 self.delete_old_checkpoints() 1541 1542 1542 # Pass control on to outer loop for more specific actions 1543 # Log and then Pass control on to outer loop for more specific actions 1544 self.log_operator_timestepping_statistics() 1543 1545 yield(self.time) 1544 1546 … … 1860 1862 for operator in self.fractional_step_operators: 1861 1863 operator() 1864 1865 1866 1867 ## 1868 # @brief log_timestepping_statistics. 1869 # Goes through all fractional step operators and logs timestepping statistics 1870 def log_operator_timestepping_statistics(self): 1871 for operator in self.fractional_step_operators: 1872 operator.log_timestepping_statistics() 1873 1874 ## 1875 # @brief print_timestepping_statistics. 1876 # Goes through all fractional step operators and logs timestepping statistics 1877 def print_operator_timestepping_statistics(self): 1878 for operator in self.fractional_step_operators: 1879 operator.print_timestepping_statistics() 1880 1862 1881 1863 1882 ## -
trunk/anuga_core/source/anuga/structures/boyd_box_operator.py
r8008 r8018 12 12 Input: Two points, pipe_size (either diameter or width, height), 13 13 mannings_rougness, 14 """ 14 """ 15 15 16 16 17 def __init__(self, … … 27 28 use_velocity_head=True, 28 29 description=None, 30 label=None, 31 structure_type='boyd_box', 32 logging=False, 29 33 verbose=False): 34 30 35 31 36 anuga.Structure_operator.__init__(self, … … 39 44 enquiry_gap, 40 45 description, 41 verbose) 46 label, 47 structure_type, 48 logging, 49 verbose) 42 50 43 51 … … 57 65 58 66 self.max_velocity = 10.0 59 self.log_filename = None60 67 61 68 self.inlets = self.get_inlets() -
trunk/anuga_core/source/anuga/structures/boyd_pipe_operator.py
r8008 r8018 26 26 use_velocity_head=True, 27 27 description=None, 28 label=None, 29 structure_type='boyd_pipe', 30 logging=False, 28 31 verbose=False): 32 33 29 34 30 35 anuga.Structure_operator.__init__(self, … … 38 43 enquiry_gap=enquiry_gap, 39 44 description=description, 45 label=label, 46 structure_type=structure_type, 47 logging=logging, 40 48 verbose=verbose) 41 49 … … 55 63 56 64 self.max_velocity = 10.0 57 self.log_filename = None58 65 59 66 self.inlets = self.get_inlets() … … 77 84 # Water has risen above inlet 78 85 79 if self.log_filename is not None:80 s = 'Specific energy = %f m' % self.inflow.get_enquiry_specific_energy()81 log_to_file(self.log_filename, s)82 86 83 87 msg = 'Specific energy at inlet is negative' … … 108 112 # Water has risen above inlet 109 113 110 if self.log_filename is not None:111 s = 'Specific energy = %f m' % self.inflow.get_average_specific_energy()112 log_to_file(self.log_filename, s)113 114 114 115 msg = 'Specific energy at inlet is negative' … … 120 121 # Note for to SUBMERGED TO OCCUR self.inflow.get_average_specific_energy() should be > 1.2 x diameter.... Should Check !!! 121 122 122 if self.log_filename is not None: 123 s = 'Q_inlet_unsubmerged = %.6f, Q_inlet_submerged = %.6f' % (Q_inlet_unsubmerged, Q_inlet_submerged) 124 log_to_file(self.log_filename, s) 123 125 124 Q = min(Q_inlet_unsubmerged, Q_inlet_submerged) 126 125 … … 205 204 hyd_rad = flow_area/perimeter 206 205 207 if self.log_filename is not None: 208 s = 'hydraulic radius at outlet = %f' %hyd_rad 209 log_to_file(self.log_filename, s) 206 210 207 211 208 # Outlet control velocity using tail water … … 222 219 anuga.log.critical('VELOCITY = %s' % str(culvert_velocity)) 223 220 anuga.log.critical('Outlet Ctrl Q = %s' % str(Q_outlet_tailwater)) 224 if self.log_filename is not None: 225 s = 'Q_outlet_tailwater = %.6f' %Q_outlet_tailwater 226 log_to_file(self.log_filename, s) 221 227 222 Q = min(Q, Q_outlet_tailwater) 228 223 if local_debug =='true': -
trunk/anuga_core/source/anuga/structures/structure_operator.py
r8008 r8018 4 4 import inlet 5 5 6 from anuga.utilities.system_tools import log_to_file 7 8 6 9 class Structure_operator: 7 10 """Structure Operator - transfer water from one rectangular box to another. … … 14 17 mannings_rougness, 15 18 """ 19 20 counter = 0 16 21 17 22 def __init__(self, … … 25 30 enquiry_gap, 26 31 description, 32 label, 33 structure_type, 34 logging, 27 35 verbose): 28 36 … … 30 38 self.domain.set_fractional_step_operator(self) 31 39 self.end_points = [end_point0, end_point1] 40 41 32 42 33 43 if height is None: … … 42 52 self.manning = manning 43 53 self.enquiry_gap = enquiry_gap 44 self.description = description 54 55 if description == None: 56 self.description = ' ' 57 else: 58 self.description = description 59 60 61 if label == None: 62 self.label = "structure_%g" % Structure_operator.counter 63 else: 64 self.label = label 65 print label 66 67 if structure_type == None: 68 self.structure_type = 'generic structure' 69 else: 70 self.structure_type = structure_type 71 45 72 self.verbose = verbose 46 73 74 75 76 # Keep count of structures 77 Structure_operator.counter += 1 78 79 # Slots for recording current statistics 47 80 self.discharge = 0.0 48 81 self.velocity = 0.0 … … 63 96 self.inlets.append(inlet.Inlet(self.domain, polygon1, exchange_polygon1, outward_vector1)) 64 97 98 self.set_logging(logging) 65 99 66 100 def __call__(self): … … 221 255 222 256 223 def print_stats(self): 224 225 print '=====================================' 226 print 'Generic Culvert Operator' 227 print '=====================================' 228 229 print 'Culvert' 230 print self.culvert 231 232 print 'Culvert Routine' 233 print self.routine 257 def structure_statistics(self): 258 259 260 message = '=====================================\n' 261 message += 'Structure Operator: %s\n' % self.label 262 message += '=====================================\n' 263 264 message += 'Structure Type: %s\n' % self.structure_type 265 266 message += 'Description\n' 267 message += '%s' % self.description 268 message += '\n' 234 269 235 270 for i, inlet in enumerate(self.inlets): 236 print '-------------------------------------' 237 print 'Inlet %i' % i 238 print '-------------------------------------' 239 240 print 'inlet triangle indices and centres' 241 print inlet.triangle_indices 242 print self.domain.get_centroid_coordinates()[inlet.triangle_indices] 243 244 print 'polygon' 245 print inlet.polygon 246 247 print '=====================================' 248 249 250 def structure_statistics(self): 271 message += '-------------------------------------\n' 272 message += 'Inlet %i\n' % i 273 message += '-------------------------------------\n' 274 275 message += 'inlet triangle indices and centres\n' 276 message += '%s' % inlet.triangle_indices 277 message += '\n' 278 279 message += '%s' % self.domain.get_centroid_coordinates()[inlet.triangle_indices] 280 message += '\n' 281 282 message += 'polygon\n' 283 message += '%s' % inlet.polygon 284 message += '\n' 285 286 message += '=====================================\n' 287 288 return message 289 290 291 def print_structure_statistics(self): 292 293 print self.structure_statistics() 294 295 296 def print_timestepping_statistics(self): 251 297 252 298 message = '---------------------------\n' 253 message += 'Structure report for structure %s:\n' % self.description299 message += 'Structure report for %s:\n' % self.label 254 300 message += '--------------------------\n' 301 message += 'Type: %s\n' % self.structure_type 255 302 message += 'Discharge [m^3/s]: %.2f\n' % self.discharge 256 303 message += 'Velocity [m/s]: %.2f\n' % self.velocity … … 258 305 message += 'delta total energy %.2f\n' % self.delta_total_energy 259 306 307 print message 308 309 310 def set_logging(self, flag=True): 311 312 self.logging = flag 313 314 # If flag is true open file with mode = "w" to form a clean file for logging 315 if self.logging: 316 self.log_filename = self.label + '.log' 317 log_to_file(self.log_filename, self.structure_statistics(), mode='w') 318 log_to_file(self.log_filename, 'time,discharge,velocity,driving_energy,delta_total_energy') 319 320 #log_to_file(self.log_filename, self.culvert_type) 321 322 323 def timestepping_statistics(self): 324 325 message = '%.5f, ' % self.domain.get_time() 326 message += '%.5f, ' % self.discharge 327 message += '%.5f, ' % self.velocity 328 message += '%.5f, ' % self.driving_energy 329 message += '%.5f' % self.delta_total_energy 330 260 331 return message 261 332 333 def log_timestepping_statistics(self): 334 335 if self.logging: 336 log_to_file(self.log_filename, self.timestepping_statistics()) 337 262 338 263 339 def get_inlets(self): -
trunk/anuga_core/source/anuga/structures/test_Outlet_Ctrl.py
r7998 r8018 159 159 160 160 culverts = [] 161 number_of_culverts = 1161 number_of_culverts = 2 162 162 for i in range(number_of_culverts): 163 163 culvert_width = 50.0/number_of_culverts … … 175 175 use_velocity_head=True, 176 176 manning=0.013, 177 logging=True, 177 178 verbose=False)) 178 179 … … 204 205 205 206 207 206 208 #------------------------------------------------------------------------------ 207 209 # Evolve system through time … … 210 212 for t in domain.evolve(yieldstep = 1, finaltime = 100): 211 213 print domain.timestepping_statistics() 212 print domain.volumetric_balance_statistics() 213 for culvert in culverts: 214 print culvert.structure_statistics() 215 214 215 domain.print_operator_timestepping_statistics() 216 -
trunk/anuga_core/source/anuga/utilities/system_tools.py
r7486 r8018 21 21 22 22 23 def log_to_file(filename, s, verbose=False ):23 def log_to_file(filename, s, verbose=False, mode='a'): 24 24 """Log string to file name 25 25 """ 26 26 27 fid = open(filename, 'a')27 fid = open(filename, mode) 28 28 if verbose: print s 29 29 fid.write(s + '\n')
Note: See TracChangeset
for help on using the changeset viewer.