Changeset 8404
- Timestamp:
- Apr 18, 2012, 4:51:48 PM (13 years ago)
- Location:
- trunk/anuga_core/source/anuga
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/config.py
r8402 r8404 55 55 # values from centroid values 56 56 ################################################################################ 57 58 # Betas [0;1] control the allowed steepness of gradient for second order 59 # extrapolations. Values of 1 allow the steepes gradients while 60 # lower values are more conservative. Values of 0 correspond to 61 # 1'st order extrapolations. 62 # 63 64 # There are separate betas for the w, uh, and vh limiters 65 # I think these are better SR but they conflict with the unit tests! 66 beta_w = 1.0 67 beta_w_dry = 0.2 68 beta_uh = 1.0 69 beta_uh_dry = 0.2 70 beta_vh = 1.0 71 beta_vh_dry = 0.2 57 # Note the individual beta values are set in domain.set_flow_method which also sets 58 # the timestepping method 59 60 beta_w = 1.0 72 61 73 62 # Alpha_balance controls how limiters are balanced between deep and shallow. … … 113 102 ################################################################################ 114 103 115 sloped_mannings_function = False104 sloped_mannings_function = True 116 105 117 106 ################################################################################ … … 121 110 CFL = 1.0 # CFL condition assigned to domain.CFL - controls timestep size 122 111 123 # Choose type of timestepping, 124 #timestepping_method = 'rk2' # 2nd Order TVD scheme 125 timestepping_method = 'euler' # 1st order euler 112 # Choose type of timestepping and spatial reconstruction method 113 114 timestepping_method = 1 115 116 # For shallow water we have a method that sets both timestepping and spatial reconstruction and 117 # beta values. In this case the settings for timestepping_method will be overriden 118 119 #flow_algorithm = 1 # 1st order euler and conservative piecewise constant spatial reconstruction 120 flow_algorithm = 1.5 # 1st order euler and conservative piecewise linear spatial reconstruction 121 #flow_algorithm = 2 # 2nd order TVD scheme and more aggressive piecewise linear spatial reconstruction 122 #flow_algorithm = 2.5 # 3rd order TVD scheme and more aggressive piecewise linear spatial reconstruction 123 124 125 126 126 127 127 # rk2 is a little more stable than euler, so rk2 timestepping … … 191 191 ################################################################################ 192 192 193 use_psyco = True # Use psyco optimisations193 use_psyco = False # Use psyco optimisations 194 194 195 195 optimise_dry_cells = True # Exclude dry and still cells from flux computation -
trunk/anuga_core/source/anuga/file_conversion/asc2dem.py
r8150 r8404 147 147 raise Exception, msg 148 148 149 NODATA_value = int( lines[5].split()[1].strip())149 NODATA_value = int(float(lines[5].split()[1].strip())) 150 150 151 151 assert len(lines) == nrows + 6 -
trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r8402 r8404 217 217 from anuga.config import minimum_storable_height 218 218 from anuga.config import minimum_allowed_height, maximum_allowed_speed 219 from anuga.config import g , beta_w, beta_w_dry, \220 beta_uh, beta_uh_dry, beta_vh, beta_vh_dry,tight_slope_limiters219 from anuga.config import g 220 from anuga.config import tight_slope_limiters 221 221 from anuga.config import extrapolate_velocity_second_order 222 222 from anuga.config import alpha_balance … … 227 227 from anuga.config import compute_fluxes_method 228 228 from anuga.config import sloped_mannings_function 229 from anuga.config import flow_algorithm 229 230 230 231 … … 232 233 self.maximum_allowed_speed = maximum_allowed_speed 233 234 234 self.set_extrapolate_velocity(extrapolate_velocity_second_order) 235 235 236 237 self.minimum_storable_height = minimum_storable_height 236 238 self.g = g 237 self.beta_w = beta_w 238 self.beta_w_dry = beta_w_dry 239 self.beta_uh = beta_uh 240 self.beta_uh_dry = beta_uh_dry 241 self.beta_vh = beta_vh 242 self.beta_vh_dry = beta_vh_dry 239 243 240 self.alpha_balance = alpha_balance 244 245 241 self.tight_slope_limiters = tight_slope_limiters 246 242 self.optimise_dry_cells = int(optimise_dry_cells) 247 248 249 self.minimum_storable_height = minimum_storable_height 250 251 # Limiters 243 self.set_extrapolate_velocity(extrapolate_velocity_second_order) 244 245 252 246 self.set_use_edge_limiter(use_edge_limiter) 253 247 self.optimised_gradient_limiter = optimised_gradient_limiter … … 255 249 256 250 self.set_sloped_mannings_function(sloped_mannings_function) 257 258 251 self.set_compute_fluxes_method(compute_fluxes_method) 252 self.set_flow_algorithm(flow_algorithm) 253 254 255 def get_algorithm_parameters(self): 256 """Get the standard parameter that arecurently set (as a dictionary) 257 """ 258 259 parameters = {} 260 261 parameters['minimum_allowed_height'] = self.minimum_allowed_height 262 parameters['maximum_allowed_speed'] = self.maximum_allowed_speed 263 parameters['minimum_storable_height'] = self.minimum_storable_height 264 parameters['g'] = self.g 265 parameters['alpha_balance'] = self.alpha_balance 266 parameters['tight_slope_limiters'] = self.tight_slope_limiters 267 parameters['optimise_dry_cells'] = self.optimise_dry_cells 268 parameters['use_edge_limiter'] = self.use_edge_limiter 269 parameters['use_centroid_velocities'] = self.use_centroid_velocities 270 parameters['use_sloped_mannings'] = self.use_sloped_mannings 271 parameters['compute_fluxes_method'] = self.get_compute_fluxes_method() 272 parameters['flow_algorithm'] = self.get_flow_algorithm() 273 274 parameters['optimised_gradient_limiter'] = self.optimised_gradient_limiter 275 parameters['extrapolate_velocity_second_order'] = self.extrapolate_velocity_second_order 276 277 return parameters 278 279 def print_algorithm_parameters(self): 280 """Print the standard parameters that are curently set (as a dictionary) 281 """ 282 283 print '#============================' 284 print '# Domain Algorithm Parameters ' 285 print '#============================' 286 from pprint import pprint 287 pprint(self.get_algorithm_parameters(),indent=4) 288 289 print '#----------------------------' 259 290 260 291 … … 310 341 311 342 Currently 312 'original'313 'well_balanced_1343 original 344 wb_1 314 345 """ 315 346 316 347 return self.compute_fluxes_method 317 348 349 350 def set_flow_algorithm(self, flag=1.5): 351 """Set combination of slope limiting and time stepping 352 353 Currently 354 1 355 1.5 356 2 357 2.5 358 """ 359 360 flag = str(flag) 361 362 flow_algorithms = ['1', '1.5', '2', '2.5'] 363 364 if flag in flow_algorithms: 365 self.flow_algorithm = flag 366 else: 367 msg = 'Unknown flow_algorithm. \nPossible choices are:\n'+ \ 368 ', '.join(flow_algorithm)+'.' 369 raise Exception(msg) 370 371 372 if self.flow_algorithm == '1': 373 self.set_timestepping_method(1) 374 self.set_default_order(1) 375 376 if self.flow_algorithm == '1.5': 377 self.set_timestepping_method(1) 378 self.set_default_order(2) 379 beta_w = 1.0 380 beta_w_dry = 0.2 381 beta_uh = 1.0 382 beta_uh_dry = 0.2 383 beta_vh = 1.0 384 beta_vh_dry = 0.2 385 self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry) 386 387 388 if self.flow_algorithm == '2': 389 self.set_timestepping_method(2) 390 self.set_default_order(2) 391 beta_w = 1.5 392 beta_w_dry = 0.2 393 beta_uh = 1.5 394 beta_uh_dry = 0.2 395 beta_vh = 1.5 396 beta_vh_dry = 0.2 397 self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry) 398 399 if self.flow_algorithm == '2.5': 400 self.set_timestepping_method(3) 401 self.set_default_order(2) 402 beta_w = 1.5 403 beta_w_dry = 0.2 404 beta_uh = 1.5 405 beta_uh_dry = 0.2 406 beta_vh = 1.5 407 beta_vh_dry = 0.2 408 self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry) 409 410 411 412 def get_flow_algorithm(self): 413 """Get method used for timestepping and spatial discretisation 414 415 Currently 416 1, 1.5, 2, 2.5 417 """ 418 419 return self.flow_algorithm 420 318 421 319 422 def set_gravity_method(self): … … 393 496 self.beta_vh_dry = beta 394 497 self.quantities['ymomentum'].beta = beta 498 499 500 def set_betas(self, beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry): 501 """Assign beta values in the range [0,2] to all limiters. 502 0 Corresponds to first order, where as larger values make use of 503 the second order scheme. 504 """ 505 506 self.beta_w = beta_w 507 self.beta_w_dry = beta_w_dry 508 self.quantities['stage'].beta = beta_w 509 510 self.beta_uh = beta_uh 511 self.beta_uh_dry = beta_uh_dry 512 self.quantities['xmomentum'].beta = beta_uh 513 514 self.beta_vh = beta_vh 515 self.beta_vh_dry = beta_vh_dry 516 self.quantities['ymomentum'].beta = beta_vh 517 518 395 519 396 520 -
trunk/anuga_core/source/anuga/shallow_water/test_forcing.py
r8387 r8404 1982 1982 domain = Domain(points, vertices) 1983 1983 1984 # Use the old function which doesn't take into account the extra 1985 # wetted area due to slope of bed 1986 domain.set_sloped_mannings_function(False) 1987 1984 1988 B = Reflective_boundary(domain) 1985 1989 domain.set_boundary( {'exterior': B}) -
trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r8390 r8404 409 409 assert num.alltrue(domain.get_conserved_quantities(0, edge=1) == 0.) 410 410 411 412 413 def test_algorithm_parameters(self): 414 a = [0.0, 0.0] 415 b = [0.0, 2.0] 416 c = [2.0, 0.0] 417 d = [0.0, 4.0] 418 e = [2.0, 2.0] 419 f = [4.0, 0.0] 420 421 points = [a, b, c, d, e, f] 422 # bac, bce, ecf, dbe 423 vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]] 424 425 #from anuga.abstract_2d_finite_volumes.domain import Domain as Generic_domain 426 #msg = 'The class %s is not a subclass of the generic domain class %s'\ 427 # %(DomainClass, Domain) 428 #assert issubclass(DomainClass, Domain), msg 429 430 domain = Domain(points, vertices) 431 domain.check_integrity() 432 433 for name in ['stage', 'xmomentum', 'ymomentum', 434 'elevation', 'friction']: 435 assert domain.quantities.has_key(name) 436 437 438 439 parameters = domain.get_algorithm_parameters() 440 441 442 443 444 assert parameters['minimum_allowed_height'] == domain.minimum_allowed_height 445 assert parameters['maximum_allowed_speed'] == domain.maximum_allowed_speed 446 assert parameters['minimum_storable_height'] == domain.minimum_storable_height 447 assert parameters['g'] == domain.g 448 assert parameters['alpha_balance'] == domain.alpha_balance 449 assert parameters['tight_slope_limiters'] == domain.tight_slope_limiters 450 assert parameters['optimise_dry_cells'] == domain.optimise_dry_cells 451 assert parameters['use_edge_limiter'] == domain.use_edge_limiter 452 assert parameters['use_centroid_velocities'] == domain.use_centroid_velocities 453 assert parameters['use_sloped_mannings'] == domain.use_sloped_mannings 454 assert parameters['compute_fluxes_method'] == domain.get_compute_fluxes_method() 455 assert parameters['flow_algorithm'] == domain.get_flow_algorithm() 456 457 assert parameters['optimised_gradient_limiter'] == domain.optimised_gradient_limiter 458 assert parameters['extrapolate_velocity_second_order'] == domain.extrapolate_velocity_second_order 459 460 461 462 411 463 def test_boundary_conditions(self): 412 464 a = [0.0, 0.0] … … 2670 2722 2671 2723 2672 print domain.quantities['xmomentum'].explicit_update2673 print domain.quantities['ymomentum'].explicit_update2724 #print domain.quantities['xmomentum'].explicit_update 2725 #print domain.quantities['ymomentum'].explicit_update 2674 2726 2675 2727 assert num.allclose(domain.quantities['stage'].explicit_update, 0) 2676 2728 assert num.allclose(domain.quantities['xmomentum'].explicit_update, 2677 [ -2.94, -2.94, - 10.29, -10.29])2729 [ -2.94, -2.94, -2.94, -2.94]) 2678 2730 assert num.allclose(domain.quantities['ymomentum'].explicit_update, 2679 [ 7.35, 0.0, 0.0, -7.35])2731 [ 0.0, 0.0, 0.0, 0.0]) 2680 2732 2681 2733 … … 5232 5284 pass 5233 5285 5286 # print domain.quantities['stage'].centroid_values[:4] 5287 # print domain.quantities['xmomentum'].centroid_values[:4] 5288 # print domain.quantities['ymomentum'].centroid_values[:4] 5234 5289 assert num.allclose(domain.quantities['stage'].centroid_values[:4], 5235 [ 0.00206836, 0.01296714, 0.00363415, 0.01438924])5290 [ 0.001362, 0.01344294, 0.00308829, 0.01470289]) 5236 5291 assert num.allclose(domain.quantities['xmomentum'].centroid_values[:4], 5237 [ 0.01360154, 0.00671133, 0.01264578, 0.00648503])5292 [ 0.01300239, 0.00537933, 0.01214676, 0.00515825]) 5238 5293 assert num.allclose(domain.quantities['ymomentum'].centroid_values[:4], 5239 [-1.19201077e-003, -7.23647546e-004, 5240 -6.39083123e-005, 6.29815168e-005]) 5294 [ -1.13165691e-03, -6.55330189e-04, 5295 -6.62804076e-05, 5.26313051e-05]) 5296 5297 # old values pre revision 8402 5298 # assert num.allclose(domain.quantities['stage'].centroid_values[:4], 5299 # [0.00206836, 0.01296714, 0.00363415, 0.01438924]) 5300 # assert num.allclose(domain.quantities['xmomentum'].centroid_values[:4], 5301 # [0.01360154, 0.00671133, 0.01264578, 0.00648503]) 5302 # assert num.allclose(domain.quantities['ymomentum'].centroid_values[:4], 5303 # [-1.19201077e-003, -7.23647546e-004, 5304 # -6.39083123e-005, 6.29815168e-005]) 5241 5305 5242 5306 os.remove(domain.get_name() + '.sww') … … 7904 7968 if __name__ == "__main__": 7905 7969 #suite = unittest.makeSuite(Test_Shallow_Water, 'test_rainfall_forcing_with_evolve') 7906 suite = unittest.makeSuite(Test_Shallow_Water, 'test_ compute_fluxes_')7970 suite = unittest.makeSuite(Test_Shallow_Water, 'test_') 7907 7971 runner = unittest.TextTestRunner(verbosity=1) 7908 7972 runner.run(suite) -
trunk/anuga_core/source/anuga/shallow_water/test_sww_interrogate.py
r7778 r8404 85 85 location = get_maximum_inundation_location(swwfile) 86 86 #print 'Runup, location', runup, location 87 assert num.allclose(runup, 11) or num.allclose(runup, 12) # old limiters88 assert num.allclose(location[0], 15) or num.allclose(location[0], 10)87 assert num.allclose(runup, 6) or num.allclose(runup, 12) # old limiters 88 assert num.allclose(location[0], 40.0) or num.allclose(location[0], 10) 89 89 90 90 # Check final runup … … 153 153 runup = get_maximum_inundation_elevation(swwfile) 154 154 location = get_maximum_inundation_location(swwfile) 155 assert num.allclose(runup, 11) or num.allclose(runup, 12) # old limiters 156 assert num.allclose(location[0], 15+E) or num.allclose(location[0], 10+E) 155 156 #print runup, location 157 158 assert num.allclose(runup, 6) or num.allclose(runup, 12) # old limiters 159 assert num.allclose(location[0], 40+E) or num.allclose(location[0], 10+E) 157 160 158 161 # Check final runup
Note: See TracChangeset
for help on using the changeset viewer.