Changeset 6002


Ignore:
Timestamp:
Nov 26, 2008, 3:39:12 PM (15 years ago)
Author:
ole
Message:

Added test for Rainfall and thus also General forcing to make sure
it works with geo_referencing.

Location:
anuga_core/source/anuga/shallow_water
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r5991 r6002  
    16451645    center [m]: Coordinates at center of flow point
    16461646    radius [m]: Size of circular area
    1647     polygon:    Arbitrary polygon.
     1647    polygon:    Arbitrary polygon
    16481648    default_rate: Rate to be used if rate fails (e.g. if model time exceeds its data)
    16491649                  Admissible types: None, constant number or function of t
     
    16521652    Either center, radius or polygon can be specified but not both.
    16531653    If neither are specified the entire domain gets updated.
     1654    All coordinates to be specified in absolute UTM coordinates (x, y) assuming the zone of domain.   
    16541655   
    1655     See Inflow or Rainfall for examples of use
     1656    Inflow or Rainfall for examples of use
    16561657    """
    16571658
     
    16901691                         # previous timestep in order to obtain rate
    16911692
    1692                          
    1693         bounding_polygon = domain.get_boundary_polygon()
     1693        bounding_polygon = domain.get_boundary_polygon() # Returns absolute coordinates
    16941694
    16951695
  • anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r5988 r6002  
    25452545
    25462546    def test_time_dependent_rainfall_using_starttime(self):
     2547   
     2548        rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], Float)   
    25472549
    25482550        a = [0.0, 0.0]
     
    25722574        R = Rainfall(domain,
    25732575                     rate=lambda t: 3*t + 7,
    2574                      polygon = [[1,1], [2,1], [2,2], [1,2]])
     2576                     polygon=rainfall_poly)                     
    25752577
    25762578        assert allclose(R.exchange_area, 1)
     
    26022604
    26032605
     2606       
     2607    def test_time_dependent_rainfall_using_georef(self):
     2608        """test_time_dependent_rainfall_using_georef
     2609       
     2610        This will also test the General forcing term using georef
     2611        """
     2612       
     2613        #Mesh in zone 56 (absolute coords)
     2614
     2615        x0 = 314036.58727982
     2616        y0 = 6224951.2960092
     2617
     2618       
     2619        rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], Float)
     2620        rainfall_poly += [x0, y0]
     2621
     2622        a = [0.0, 0.0]
     2623        b = [0.0, 2.0]
     2624        c = [2.0, 0.0]
     2625        d = [0.0, 4.0]
     2626        e = [2.0, 2.0]
     2627        f = [4.0, 0.0]
     2628
     2629        points = [a, b, c, d, e, f]
     2630        #bac, bce, ecf, dbe
     2631        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]]
     2632
     2633
     2634        domain = Domain(points, vertices,
     2635                        geo_reference = Geo_reference(56, x0, y0))
     2636
     2637        #Flat surface with 1m of water
     2638        domain.set_quantity('elevation', 0)
     2639        domain.set_quantity('stage', 1.0)
     2640        domain.set_quantity('friction', 0)
     2641
     2642        Br = Reflective_boundary(domain)
     2643        domain.set_boundary({'exterior': Br})
     2644
     2645        # Setup only one forcing term, time dependent rainfall restricted to a polygon enclosing triangle #1 (bce)
     2646        domain.forcing_terms = []
     2647        R = Rainfall(domain,
     2648                     rate=lambda t: 3*t + 7,
     2649                     polygon=rainfall_poly)
     2650
     2651        assert allclose(R.exchange_area, 1)
     2652       
     2653        domain.forcing_terms.append(R)
     2654
     2655        # This will test that time used in the forcing function takes
     2656        # startime into account.
     2657        domain.starttime = 5.0
     2658
     2659        domain.time = 7.
     2660
     2661        domain.compute_forcing_terms()
     2662        #print domain.quantities['stage'].explicit_update
     2663
     2664        #print domain.get_time()
     2665        assert allclose(domain.quantities['stage'].explicit_update[1],
     2666                        (3*domain.get_time()+7)/1000)
     2667        assert allclose(domain.quantities['stage'].explicit_update[1],
     2668                        (3*(domain.time + domain.starttime)+7)/1000)
     2669
     2670        # Using internal time her should fail
     2671        assert not allclose(domain.quantities['stage'].explicit_update[1],
     2672                        (3*domain.time+7)/1000)               
     2673
     2674        assert allclose(domain.quantities['stage'].explicit_update[0], 0)
     2675        assert allclose(domain.quantities['stage'].explicit_update[2:], 0)       
     2676       
     2677
     2678       
     2679       
    26042680
    26052681
     
    61906266
    61916267        data_geo_spatial = Geospatial_data(data_points_rel,
    6192                          geo_reference = Geo_reference(56, x0, y0))
     6268                                           geo_reference = Geo_reference(56, x0, y0))
    61936269        data_points_absolute = data_geo_spatial.get_data_points(absolute=True)
    61946270        attributes = linear_function(data_points_absolute)
     
    62326308
    62336309    suite = unittest.makeSuite(Test_Shallow_Water,'test')
    6234 
    62356310    #suite = unittest.makeSuite(Test_Shallow_Water,'test_get_energy_through_cross_section_with_g')   
    62366311    #suite = unittest.makeSuite(Test_Shallow_Water,'test_fitting_using_shallow_water_domain')   
    62376312    #suite = unittest.makeSuite(Test_Shallow_Water,'test_tight_slope_limiters')
    62386313    #suite = unittest.makeSuite(Test_Shallow_Water,'test_get_maximum_inundation_from_sww')
    6239     #suite = unittest.makeSuite(Test_Shallow_Water,'test_time_dependent_rainfall_using_starttime')   
     6314    #suite = unittest.makeSuite(Test_Shallow_Water,'test_time_dependent_rainfall')   
    62406315   
    62416316
Note: See TracChangeset for help on using the changeset viewer.