Ignore:
Timestamp:
Nov 19, 2009, 5:23:52 PM (14 years ago)
Author:
steve
Message:

Updating the balanced and parallel code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water_balanced/test_swb_forcing_terms.py

    r7559 r7562  
    2424
    2525
    26 
    27 
    28 class Test_swb_clean(unittest.TestCase):
     26# Variable windfield implemented using functions
     27def speed(t, x, y):
     28    """Large speeds halfway between center and edges
     29
     30    Low speeds at center and edges
     31    """
     32
     33    from math import exp, cos, pi
     34
     35    x = num.array(x)
     36    y = num.array(y)
     37
     38    N = len(x)
     39    s = 0*x  #New array
     40
     41    for k in range(N):
     42        r = num.sqrt(x[k]**2 + y[k]**2)
     43        factor = exp(-(r-0.15)**2)
     44        s[k] = 4000 * factor * (cos(t*2*pi/150) + 2)
     45
     46    return s
     47
     48def scalar_func(t, x, y):
     49    """Function that returns a scalar.
     50
     51    Used to test error message when numeric array is expected
     52    """
     53
     54    return 17.7
     55
     56def scalar_func_list(t, x, y):
     57    """Function that returns a scalar.
     58
     59    Used to test error message when numeric array is expected
     60    """
     61
     62    return [17.7]
     63
     64
     65def angle(t, x, y):
     66    """Rotating field
     67    """
     68    from math import atan, pi
     69
     70    x = num.array(x)
     71    y = num.array(y)
     72
     73    N = len(x)
     74    a = 0 * x    # New array
     75
     76    for k in range(N):
     77        r = num.sqrt(x[k]**2 + y[k]**2)
     78
     79        angle = atan(y[k]/x[k])
     80
     81        if x[k] < 0:
     82            angle += pi
     83
     84        # Take normal direction
     85        angle -= pi/2
     86
     87        # Ensure positive radians
     88        if angle < 0:
     89            angle += 2*pi
     90
     91        a[k] = angle/pi*180
     92
     93    return a
     94
     95
     96###############################################################################
     97
     98class Test_swb_forcing_terms(unittest.TestCase):
    2999    def setUp(self):
    30100        pass
     
    17231793
    17241794if __name__ == "__main__":
    1725     suite = unittest.makeSuite(Test_swb_clean, 'test')
     1795    suite = unittest.makeSuite(Test_swb_forcing_terms, 'test')
    17261796    runner = unittest.TextTestRunner(verbosity=1)
    17271797    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.