source: anuga_core/source/anuga/shallow_water/eqf.py @ 4263

Last change on this file since 4263 was 4263, checked in by sexton, 17 years ago

earthquake source function

File size: 3.7 KB
Line 
1#
2# earthquake_tsunami function
3#
4
5"""This function returns a callable object representing an initial water
6   displacement generated by a submarine earthqauke.
7   
8Using input parameters:
9
10Required
11 length  along-stike length of rupture area
12 width   down-dip width of rupture area
13 strike  azimuth (degrees, measured from north) of fault axis
14 dip     angle of fault dip in degrees w.r.t. horizontal
15 depth   depth to base of rupture area
16 
17Optional
18 x0      x origin (0)
19 y0      y origin (0)
20 slip    metres of fault slip (1)
21 rake    angle of slip (w.r.t. horizontal) in fault plane (90 degrees)
22
23The returned object is a callable okada function that represents
24the initial water displacement generated by a submarine earthuake.
25
26"""
27
28def earthquake_tsunami(length, width, strike, dip, x0=0.0, y0=0.0, slip=1.0, rake=90.,\
29                  domain=None,
30                  verbose=False):
31
32    from math import sin, radians, sqrt
33
34    if domain is not None:
35        xllcorner = domain.geo_reference.get_xllcorner()
36        yllcorner = domain.geo_reference.get_yllcorner()
37        x0 = x0 - xllcorner  # fault origin (relative)
38        y0 = y0 - yllcorner
39
40    #a few temporary print statements
41    if verbose is True:
42        print '\nThe Earthquake ...'
43        print '\tLength: ', length
44        print '\tDepth: ', depth
45        print '\tStrike: ', strike
46        print '\tWidth: ', width
47        print '\tDip: ', dip
48        print '\tSlip: ', slip
49        print '\tx0: ', x0
50        print '\ty0: ', y0
51
52
53    return Okada(length=length, width=width, dip=dip, \
54                 x0=x0, y0=y0, strike=strike, depth=depth, \
55                 slip=slip, rake=rake)
56
57
58#
59# Okada class
60#
61
62"""This is a callable class representing the initial water displacment
63   generated by an earthquake.
64
65Using input parameters:
66
67Required
68 length  along-stike length of rupture area
69 width   down-dip width of rupture area
70 strike  azimuth (degrees, measured from north) of fault axis
71 dip     angle of fault dip in degrees w.r.t. horizontal
72 depth   depth to base of rupture area
73 
74Optional
75 x0      x origin (0)
76 y0      y origin (0)
77 slip    metres of fault slip (1)
78 rake    angle of slip (w.r.t. horizontal) in fault plane (90 degrees)
79
80"""
81
82class Okada:
83
84    def __init__(self, length, width, dip, x0, y0, strike, \
85                 depth, slip, rake):
86        self.dip = dip
87        self.length = length
88        self.width = width
89        self.x0 = x0
90        self.y0 = y0
91        self.strike = strike
92        self.depth = depth
93        self.slip = slip
94        self.rake = rake
95
96
97    def __call__(self, x, y):
98        """Make Okada a callable object.
99
100        If called as a function, this object returns z values representing
101        the initial 3D distribution of water heights at the points (x,y)
102        produced by a submarine mass failure.
103        """
104
105        from math import sin, cos, radians, exp, cosh
106        from Numeric import zeros, Float
107        from okada import okada
108
109        #ensure vectors x and y have the same length
110        N = len(x)
111        assert N == len(y)
112
113        depth = self.depth
114        dip = self.dip
115        length = self.length
116        width = self.width
117        x0 = self.x0
118        y0 = self.y0
119        strike = self.strike
120        dip = self.dip
121        rake = self.rake
122        slip = self.slip
123       
124        #double Gaussian calculation assumes water displacement is oriented
125        #E-W, so, for displacement at some angle alpha clockwise from the E-W
126        #direction, rotate (x,y) coordinates anti-clockwise by alpha
127
128        cosa = cos(radians(strike))
129        sina = sin(radians(strike))
130
131        xr = ( (x-x0) * sina + (y-y0) * cosa)
132        yr = (-(x-x0) * cosa + (y-y0) * sina) 
133
134        z = okada(xr,yr,depth,length,width,dip,rake,slip)
135   
136               
137        return z
138
139   
Note: See TracBrowser for help on using the repository browser.