Changeset 5206


Ignore:
Timestamp:
Apr 11, 2008, 3:34:48 PM (16 years ago)
Author:
herve
Message:

modification of test_tsunami_okada.py to make txt file available.

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

Legend:

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

    r5204 r5206  
    1818        from anuga.shallow_water import Domain
    1919        from anuga.abstract_2d_finite_volumes.quantity import Quantity
    20 
    21         """
    22         Pick the test you want to dop; T= 0 test a point source,
     20        from anuga.utilities.system_tools import get_pathname_from_package
     21        """
     22        Pick the test you want to do; T= 0 test a point source,
    2323        T= 1  test single rectangular source, T= 2 test multiple
    2424        rectangular sources
    2525        """
    26 
     26        #get path where this test is run
     27        path= get_pathname_from_package('anuga.shallow_water')
    2728        #choose what test to proceed
    28         T=2
    29 
    30         home = getenv('INUNDATIONHOME') + sep +'sandpits'+sep+'hdamlami'+sep+'test_okada'+sep
     29        T=1
     30       
     31
    3132
    3233        if T==0:
    3334            # fotran output file
    34             filename = home+'fullokada_SP.txt'
     35           
     36            filename = path+sep+'fullokada_SP.txt'
    3537        # initial condition of earthquake for multiple source
    3638            x0 = 7000.0
     
    4749        elif T==1:
    4850        # fotran output file
    49             filename = home+'fullokada_SS.txt'
     51            filename = path+sep+'fullokada_SS.txt'
    5052        # initial condition of earthquake for multiple source
    5153            x0 = 7000.0
     
    6466
    6567        # fotran output file
    66             filename = home+'fullokada_MS.txt'
     68            filename = path+sep+'fullokada_MS.txt'
    6769        # initial condition of earthquake for multiple source
    6870            x0 = [7000.0,10000.0]
     
    115117       
    116118        # call okada
    117         Ts= Okada_func(ns, NSMAX,length=length, width=width, dip=dip, \
     119        Ts= Okada_func(ns=ns, NSMAX=NSMAX,length=length, width=width, dip=dip, \
    118120                       x0=x0, y0=y0, strike=strike, depth=depth, \
    119121                       slip=slip, rake=rake,zrec=zrec)
     
    148150        from anuga.shallow_water import Domain
    149151        from anuga.abstract_2d_finite_volumes.quantity import Quantity
    150 
     152        from anuga.utilities.system_tools import get_pathname_from_package
    151153        """
    152154        Pick the test you want to dop; T= 0 test a point source,
     
    154156        rectangular sources
    155157        """
    156 
     158       
     159        #get path where this test is run
     160        path= get_pathname_from_package('anuga.shallow_water')
     161       
    157162        #choose what test to proceed
    158         T=2
    159 
    160         home = getenv('INUNDATIONHOME') + sep +'sandpits'+sep+'hdamlami'+sep+'test_okada'+sep
     163        T=1
    161164
    162165        if T==0:
    163             # fotran output file
    164             filename = home+'fullokada_SP.txt'
     166        # fotran output file
     167           
     168            filename = path+sep+'fullokada_SP.txt'
    165169        # initial condition of earthquake for multiple source
    166170            x0 = 7000.0
     
    177181        elif T==1:
    178182        # fotran output file
    179             filename = home+'fullokada_SS.txt'
     183            filename = path+sep+'fullokada_SS.txt'
    180184        # initial condition of earthquake for multiple source
    181185            x0 = 7000.0
     
    194198
    195199        # fotran output file
    196             filename = home+'fullokada_MS.txt'
     200            filename = path+sep+'fullokada_MS.txt'
    197201        # initial condition of earthquake for multiple source
    198202            x0 = [7000.0,10000.0]
     
    237241        domain.set_name('test')
    238242        domain.set_quantity('elevation',topography)
    239        
    240         earthquake_tsunami(ns,NSMAX,length, width, strike, depth, \
    241                        dip, x0, y0, slip=1.0, rake=90.,\
    242                        domain=domain, verbose=False)
    243 
     243        zrec = Quantity(domain)
     244        zrec.set_values(topography)
     245       
     246        Ts = earthquake_tsunami(ns=ns,NSMAX=NSMAX,length=length, width=width, strike=strike,\
     247                                depth=depth,dip=dip, xi=x0, yi=y0, slip=slip, rake=rake,\
     248                                zrec=zrec,domain=domain, verbose=False)
     249       
     250        #create a variable to store vertical displacement throughout the domain
     251        tsunami = Quantity(domain)
     252        tsunami.set_values(Ts)
    244253        k=0.0
    245254        for i in range(0,6):
  • anuga_core/source/anuga/shallow_water/tsunami_okada.py

    r5204 r5206  
    2727"""
    2828
    29 def earthquake_tsunami(ns,NSMAX,length, width, strike, depth, \
    30                        dip, x0, y0, slip=1.0, rake=90.,\
    31                        domain=None, verbose=False):
     29def earthquake_tsunami(ns,NSMAX,length, width, strike, depth,\
     30                       dip, xi, yi, slip, rake,\
     31                       zrec,domain=None, verbose=False):
    3232
    3333    from math import sin, radians
    34    
     34    from Numeric import zeros, Float
     35    x0= zeros(ns,Float)
     36    y0= zeros(ns,Float)
     37    if ns ==1:
     38        x0[0]=xi
     39        y0[0]=yi
     40    else:
     41        x0=xi
     42        y10=yi
    3543    if domain is not None:
    3644        xllcorner = domain.geo_reference.get_xllcorner()
    3745        yllcorner = domain.geo_reference.get_yllcorner()
    38         x0 = x0 - xllcorner  # fault origin (relative)
    39         y0 = y0 - yllcorner
    40         zrec=Quantity(domain)
    41         zrec.set_values(topography)
     46        for i in range(0,ns):
     47            x0[i] = x0[i] - xllcorner  # fault origin (relative)
     48            y0[i] = y0[i] - yllcorner
    4249    #a few temporary print statements
    4350    if verbose is True:
     
    6269        raise Exception, msg
    6370
    64     return Okada_func(ns,NSMAX,length=length, width=width, dip=dip, \
     71    return Okada_func(ns=ns,NSMAX=NSMAX,length=length, width=width, dip=dip, \
    6572                      x0=x0, y0=y0, strike=strike, depth=depth, \
    6673                      slip=slip, rake=rake, zrec=zrec)
     
    105112        self.ns=ns
    106113        self.zrec=zrec
    107         print 'hello'
    108114       
    109115    def __call__(self, x, y):
     
    118124        from math import sin, cos, radians, exp, cosh
    119125        from Numeric import zeros, Float
    120         #from anuga.abstract_2d_finite_volumes.quantity import Quantity
    121         #from okada import okadatest
    122126        #ensure vectors x and y have the same length
    123127        N = len(x)
     
    128132        length = self.length
    129133        width = self.width
    130         y1 = self.x0
    131         x1 = self.y0
     134        y0 = self.x0
     135        x0 = self.y0
    132136        strike = self.strike
    133137        dip = self.dip
     
    164168            widths[0]=width
    165169            dips[0]=dip
    166             xs[0]=x1
    167             ys[0]=y1
     170            xs[0]=x0
     171            ys[0]=y0
    168172        else:
    169173            dislocations=dislocation
     
    173177            widths=width
    174178            dips=dip
    175             xs=x1
    176             ys=y1
     179            xs=x0
     180            ys=y0
    177181            depths=depth
    178182        #double Gaussian calculation assumes water displacement is oriented
     
    199203            for ist in range(0,ns):
    200204                #st = radians(strikes[ist])
    201                 st=strikes[ist]*rad
     205                st=radians(strikes[ist])
    202206                csst = cos(st)
    203207                ssst = sin(st)
     
    206210#
    207211                #di = radians(dips[ist])
    208                 di=rad*dips[ist]
     212                di=radians(dips[ist])
    209213                csdi =cos(di)
    210214                ssdi=sin(di)
    211215#
    212216                #ra= radians(rakes[ist])
    213                 ra=rad*rakes[ist]
     217                ra=radians(rakes[ist])
    214218                csra=cos(ra)
    215219                ssra=sin(ra)
Note: See TracChangeset for help on using the changeset viewer.