/[escript]/trunk/finley/test/python/seismic_wave.py
ViewVC logotype

Contents of /trunk/finley/test/python/seismic_wave.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 843 - (show annotations)
Thu Sep 7 05:55:12 2006 UTC (13 years, 6 months ago) by gross
File MIME type: text/x-python
File size: 5221 byte(s)
some timing added
1 """
2 seismic wave propagation
3
4 @var __author__: name of author
5 @var __licence__: licence agreement
6 @var __url__: url entry point on documentation
7 @var __version__: version
8 @var __date__: date of the version
9 """
10
11 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
12 http://www.access.edu.au
13 Primary Business: Queensland, Australia"""
14 __license__="""Licensed under the Open Software License version 3.0
15 http://www.opensource.org/licenses/osl-3.0.php"""
16 __author__="Lutz Gross, l.gross@uq.edu.au"
17 __url__="http://www.iservo.edu.au/esys/escript"
18 __version__="$Revision$"
19 __date__="$Date$"
20
21 from esys.escript import *
22 from esys.escript.linearPDEs import LinearPDE
23 from esys.finley import Brick
24 import time
25
26 output=False
27 n_end=100
28
29 resolution=4000. # number of elements per m
30 l=80000. # width and length m
31 h=30000. # height in m
32
33 rho_bedrock=8e3
34 mu_bedrock=1.7e11
35 lambda_bedrock=1.7e11
36
37 l_x_water=10000 # length of water in x
38 l_y_water=10000 # length of water in y
39 h_water=max(2000,resolution) # depth of water region
40
41 water_tag=2
42 rho_water=1e3
43 mu_water=0.
44 lambda_water=1.e9
45
46 d0_sand=10000 # thickness of sand region on surface
47 d_sand=max(2000,resolution) # thickness of sand layer under the water
48
49 sand_tag=3
50 rho_sand=5e3
51 mu_sand=1.5e10
52 lambda_sand=1.5e10
53
54
55 # location and geometrical size of event:
56 xc=[30000.,40000.,10000.]
57 src_radius = 0.1*h
58 # direction of event:
59 event=numarray.array([1.,0.,0.])*1.e6
60 # time and length of the event
61 tc_length=2.
62 tc=sqrt(5.*tc_length)
63 if output:
64 print "event location = ",xc
65 print "radius of event = ",src_radius
66 print "time of event = ",tc
67 print "length of event = ",tc_length
68 print "direction = ",event
69
70 t_end=20.
71
72 def getDomain():
73 """
74 this defines a dom as a brick of length and width l and hight h
75
76
77 """
78 global netotal
79 ne_l=int(l/resolution+0.5)
80 ne_h=int(h/resolution+0.5)
81 netotal=ne_l*ne_l*ne_h
82 if output: print "grid : %s x %s x %s"%(ne_l,ne_l,ne_h)
83 dom=Brick(ne_l,ne_l,ne_h,l0=l,l1=l,l2=h,order=1)
84
85 fs=Function(dom)
86 x=Function(dom).getX()
87 fs.setTags(sand_tag,wherePositive(x[0]-(l-l_x_water-d0_sand)) \
88 *wherePositive(x[1]-(l-l_y_water-d0_sand)) \
89 *wherePositive(x[2]-(h-h_water-d_sand)))
90 fs.setTags(water_tag,wherePositive(x[0]-(l-l_x_water)) \
91 *wherePositive(x[1]-(l-l_y_water)) \
92 *wherePositive(x[2]-(h-h_water)))
93 return dom
94
95 def getMaterialProperties(dom):
96 rho =Scalar(rho_bedrock,Function(dom))
97 rho.setTaggedValue(sand_tag,rho_sand)
98 rho.setTaggedValue(water_tag,rho_water)
99
100 lame_mu =Scalar(mu_bedrock,Function(dom))
101 lame_mu.setTaggedValue(sand_tag,mu_sand)
102 lame_mu.setTaggedValue(water_tag,mu_water)
103
104 lame_lambda=Scalar(lambda_bedrock,Function(dom))
105 lame_lambda.setTaggedValue(sand_tag,lambda_sand)
106 lame_lambda.setTaggedValue(water_tag,lambda_water)
107
108 return rho,lame_mu,lame_lambda
109
110
111 def wavePropagation(dom,rho,lame_mu,lame_lambda):
112 x=Function(dom).getX()
113 # ... open new PDE ...
114 mypde=LinearPDE(dom)
115 mypde.setSolverMethod(LinearPDE.LUMPING)
116 k=kronecker(Function(dom))
117 mypde.setValue(D=k*rho)
118
119 v_p=sqrt((2*lame_mu+lame_lambda)/rho)
120 if output: print "v_p=",v_p
121 v_s=sqrt(lame_mu/rho)
122 if output: print "v_s=",v_s
123 dt=(1./5.)*inf(dom.getSize()/v_p)
124 if output: print "time step size = ",dt
125 # ... set initial values ....
126 n=0
127 t=0
128 # initial value of displacement at point source is constant (U0=0.01)
129 # for first two time steps
130 u =Vector(0.,Solution(dom))
131 u_last=Vector(0.,Solution(dom))
132
133 starttime = time.clock()
134 while t<t_end and n<n_end:
135 if output: print n+1,"-th time step t ",t+dt," max u and F: ",Lsup(u),
136 # ... get current stress ....
137 eps=symmetric(grad(u))
138 stress=lame_lambda*trace(eps)*k+2*lame_mu*eps
139 # ... force due to event:
140 F=exp(-((t-tc)/tc_length)**2)*exp(-(length(x-xc)/src_radius)**2)*event
141 if output: print Lsup(F)
142 # ... get new acceleration ....
143 mypde.setValue(X=-stress,Y=F)
144 a=mypde.getSolution()
145 # ... get new displacement ...
146 u_new=2*u-u_last+dt**2*a
147 # ... shift displacements ....
148 u_last,u=u,u_new
149 # ... save current acceleration in units of gravity and displacements
150 if output:
151 if n%10==0: saveVTK("disp.%i.vtu"%(n/10),displacement=u, amplitude=length(u))
152
153 t+=dt
154 n+=1
155
156 endtime = time.clock()
157 totaltime = endtime-starttime
158 global netotal
159 print ">>number of elements: %s, total time: %s, per time step: %s <<"%(netotal,totaltime,totaltime/n)
160 if __name__ =="__main__":
161 dom=getDomain()
162 rho,lame_mu,lame_lambda=getMaterialProperties(dom)
163 wavePropagation(dom,rho,lame_mu,lame_lambda)

  ViewVC Help
Powered by ViewVC 1.1.26