Changeset 5988
 Timestamp:
 Nov 20, 2008, 2:35:29 PM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r5879 r5988 2478 2478 # Setup only one forcing term, constant rainfall restricted to a polygon enclosing triangle #1 (bce) 2479 2479 domain.forcing_terms = [] 2480 R = Rainfall(domain, rate=2.0, polygon = [[1,1], [2,1], [2,2], [1,2]]) 2480 R = Rainfall(domain, 2481 rate=2.0, 2482 polygon = [[1,1], [2,1], [2,2], [1,2]]) 2481 2483 2482 2484 assert allclose(R.exchange_area, 1) … … 2487 2489 #print domain.quantities['stage'].explicit_update 2488 2490 2489 assert allclose(domain.quantities['stage'].explicit_update[1], 2.0/1000) 2491 assert allclose(domain.quantities['stage'].explicit_update[1], 2492 2.0/1000) 2490 2493 assert allclose(domain.quantities['stage'].explicit_update[0], 0) 2491 2494 assert allclose(domain.quantities['stage'].explicit_update[2:], 0) … … 2519 2522 # Setup only one forcing term, time dependent rainfall restricted to a polygon enclosing triangle #1 (bce) 2520 2523 domain.forcing_terms = [] 2521 R = Rainfall(domain, rate=lambda t: 3*t + 7, polygon = [[1,1], [2,1], [2,2], [1,2]]) 2524 R = Rainfall(domain, 2525 rate=lambda t: 3*t + 7, 2526 polygon = [[1,1], [2,1], [2,2], [1,2]]) 2522 2527 2523 2528 assert allclose(R.exchange_area, 1) … … 2531 2536 #print domain.quantities['stage'].explicit_update 2532 2537 2533 assert allclose(domain.quantities['stage'].explicit_update[1], (3*domain.time+7)/1000) 2538 assert allclose(domain.quantities['stage'].explicit_update[1], 2539 (3*domain.time+7)/1000) 2534 2540 assert allclose(domain.quantities['stage'].explicit_update[0], 0) 2535 2541 assert allclose(domain.quantities['stage'].explicit_update[2:], 0) 2536 2542 2543 2544 2545 2546 def test_time_dependent_rainfall_using_starttime(self): 2547 2548 a = [0.0, 0.0] 2549 b = [0.0, 2.0] 2550 c = [2.0, 0.0] 2551 d = [0.0, 4.0] 2552 e = [2.0, 2.0] 2553 f = [4.0, 0.0] 2554 2555 points = [a, b, c, d, e, f] 2556 #bac, bce, ecf, dbe 2557 vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]] 2558 2559 2560 domain = Domain(points, vertices) 2561 2562 #Flat surface with 1m of water 2563 domain.set_quantity('elevation', 0) 2564 domain.set_quantity('stage', 1.0) 2565 domain.set_quantity('friction', 0) 2566 2567 Br = Reflective_boundary(domain) 2568 domain.set_boundary({'exterior': Br}) 2569 2570 # Setup only one forcing term, time dependent rainfall restricted to a polygon enclosing triangle #1 (bce) 2571 domain.forcing_terms = [] 2572 R = Rainfall(domain, 2573 rate=lambda t: 3*t + 7, 2574 polygon = [[1,1], [2,1], [2,2], [1,2]]) 2575 2576 assert allclose(R.exchange_area, 1) 2577 2578 domain.forcing_terms.append(R) 2579 2580 # This will test that time used in the forcing function takes 2581 # startime into account. 2582 domain.starttime = 5.0 2583 2584 domain.time = 7. 2585 2586 domain.compute_forcing_terms() 2587 #print domain.quantities['stage'].explicit_update 2588 2589 #print domain.get_time() 2590 assert allclose(domain.quantities['stage'].explicit_update[1], 2591 (3*domain.get_time()+7)/1000) 2592 assert allclose(domain.quantities['stage'].explicit_update[1], 2593 (3*(domain.time + domain.starttime)+7)/1000) 2594 2595 # Using internal time her should fail 2596 assert not allclose(domain.quantities['stage'].explicit_update[1], 2597 (3*domain.time+7)/1000) 2598 2599 assert allclose(domain.quantities['stage'].explicit_update[0], 0) 2600 assert allclose(domain.quantities['stage'].explicit_update[2:], 0) 2601 2602 2603 2537 2604 2538 2605 … … 2574 2641 2575 2642 domain.forcing_terms = [] 2576 R = Rainfall(domain, rate=main_rate, polygon = [[1,1], [2,1], [2,2], [1,2]], 2643 R = Rainfall(domain, 2644 rate=main_rate, 2645 polygon = [[1,1], [2,1], [2,2], [1,2]], 2577 2646 default_rate=5.0) 2578 2647 … … 6168 6237 #suite = unittest.makeSuite(Test_Shallow_Water,'test_tight_slope_limiters') 6169 6238 #suite = unittest.makeSuite(Test_Shallow_Water,'test_get_maximum_inundation_from_sww') 6170 #suite = unittest.makeSuite(Test_Shallow_Water,'test_time_dependent_rainfall_ restricted_by_polygon')6239 #suite = unittest.makeSuite(Test_Shallow_Water,'test_time_dependent_rainfall_using_starttime') 6171 6240 6172 6241
Note: See TracChangeset
for help on using the changeset viewer.