Changeset 5244
- Timestamp:
- Apr 27, 2008, 2:30:49 PM (17 years ago)
- Location:
- anuga_core/source/anuga/shallow_water
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/test_tsunami_okada.py
r5239 r5244 1 1 import unittest 2 2 from Numeric import allclose 3 from tsunami_okada _V2import earthquake_tsunami,Okada_func3 from tsunami_okada import earthquake_tsunami,Okada_func 4 4 5 5 class Test_eq(unittest.TestCase): … … 41 41 width =0 42 42 strike = 0.0 43 depth = 15 000.043 depth = 15.0 44 44 slip = 10.0 45 45 dip =15.0 … … 56 56 width =6.0 57 57 strike = 0.0 58 depth = 15 000.058 depth = 15.0 59 59 slip = 10.0 60 60 dip =15.0 … … 73 73 width =[6.0,6.0] 74 74 strike = [0.0,0.0] 75 depth = [15 000.0,15000.0]75 depth = [15.0,15.0] 76 76 slip = [10.0,10.0] 77 77 dip = [15.0,15.0] … … 116 116 zrec0.set_values(topography) 117 117 zrec=zrec0.get_vertex_values(xy=True) 118 print zrec119 118 # call okada 120 119 Ts= Okada_func(ns=ns, NSMAX=NSMAX,length=length, width=width, dip=dip, \ … … 138 137 stage.append(Z[0]) 139 138 k=k+4000 140 141 139 142 140 assert allclose(stage,tmp,atol=1.e-8) 143 144 141 print stage 142 print 'c est fini' 145 143 146 144 def test_earthquake_tsunami(self): … … 153 151 from anuga.utilities.system_tools import get_pathname_from_package 154 152 """ 155 Pick the test you want to do p; T= 0 test a point source,153 Pick the test you want to do; T= 0 test a point source, 156 154 T= 1 test single rectangular source, T= 2 test multiple 157 155 rectangular sources 158 156 """ 159 157 print 'ca commence' 160 158 #get path where this test is run 161 159 path= get_pathname_from_package('anuga.shallow_water') … … 174 172 width =0 175 173 strike = 0.0 176 depth = 15 000.0174 depth = 15.0 177 175 slip = 10.0 178 176 dip =15.0 … … 189 187 width =6.0 190 188 strike = 0.0 191 depth = 15 000.0189 depth = 15.0 192 190 slip = 10.0 193 191 dip =15.0 … … 206 204 width =[6.0,6.0] 207 205 strike = [0.0,0.0] 208 depth = [15 000.0,15000.0]206 depth = [15.0,15.0] 209 207 slip = [10.0,10.0] 210 208 dip = [15.0,15.0] … … 242 240 domain.set_name('test') 243 241 domain.set_quantity('elevation',topography) 244 zrec0 = Quantity(domain)245 zrec0.set_values(topography)246 zrec=zrec0.get_vertex_values(xy=True)247 242 Ts = earthquake_tsunami(ns=ns,NSMAX=NSMAX,length=length, width=width, strike=strike,\ 248 243 depth=depth,dip=dip, xi=x0, yi=y0, slip=slip, rake=rake,\ 249 zrec=zrec,domain=domain, verbose=False)244 domain=domain, verbose=True) 250 245 251 246 #create a variable to store vertical displacement throughout the domain … … 263 258 k=k+4000 264 259 265 266 assert allclose(stage,tmp,atol=1.e-8) 260 print tmp 261 print 'hello' 262 print stage 263 assert allclose(stage,tmp,atol=1.e-3) 267 264 268 265 269 266 #------------------------------------------------------------- 270 267 if __name__ == "__main__": 271 suite = unittest.makeSuite(Test_eq,'test_Okada_func')272 #suite = unittest.makeSuite(Test_eq,'test_earthquake_tsunami')268 #suite = unittest.makeSuite(Test_eq,'test_Okada_func') 269 suite = unittest.makeSuite(Test_eq,'test_earthquake_tsunami') 273 270 runner = unittest.TextTestRunner() 274 271 runner.run(suite) -
anuga_core/source/anuga/shallow_water/tsunami_okada.py
r5240 r5244 21 21 slip metres of fault slip (1) 22 22 rake angle of slip (w.r.t. horizontal) in fault plane (90 degrees) 23 zrec elevation( km)23 zrec elevation(m) 24 24 obtained as followed: 25 25 zrec0 = Quantity(domain) … … 35 35 def earthquake_tsunami(ns,NSMAX,length, width, strike, depth,\ 36 36 dip, xi, yi, slip, rake,\ 37 zrec,domain=None, verbose=False): 38 37 domain=None, verbose=False): 38 39 39 40 from math import sin, radians 40 41 from Numeric import zeros, Float 42 43 #zrec0 = Quantity(domain) 44 zrec0=domain.get_quantity('elevation') 45 zrec=zrec0.get_vertex_values(xy=True) 46 47 41 48 x0= zeros(ns,Float) 42 49 y0= zeros(ns,Float) … … 213 220 if zrec[0][i]==yrec and zrec[1][i]==xrec: 214 221 Z=zrec[2][i] 222 Z=0.001*Z 215 223 break 216 224 else: continue … … 242 250 X=0.001*((xrec[irec]-xs[ist])*csst+(yrec[irec]-ys[ist])*ssst) 243 251 Y=0.001*((xrec[irec]-xs[ist])*ssst-(yrec[irec]-ys[ist])*csst) 244 DEPTH=depths[ist] *0.001252 DEPTH=depths[ist] 245 253 DIP=dips[ist] 246 254 if lengths[ist]==0 and widths[ist]== 0 :
Note: See TracChangeset
for help on using the changeset viewer.