/[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 842 - (show annotations)
Thu Sep 7 05:40:22 2006 UTC (14 years, 7 months ago) by gross
File MIME type: text/x-python
File size: 4803 byte(s)
a little wave propagation simulation
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
25 resolution=4000. # number of elements per m
26 l=80000. # width and length m
27 h=30000. # height in m
28
29 rho_bedrock=8e3
30 mu_bedrock=1.7e11
31 lambda_bedrock=1.7e11
32
33 l_x_water=10000 # length of water in x
34 l_y_water=10000 # length of water in y
35 h_water=max(2000,resolution) # depth of water region
36
37 water_tag=2
38 rho_water=1e3
39 mu_water=0.
40 lambda_water=1.e9
41
42 d0_sand=10000 # thickness of sand region on surface
43 d_sand=max(2000,resolution) # thickness of sand layer under the water
44
45 sand_tag=3
46 rho_sand=5e3
47 mu_sand=1.5e10
48 lambda_sand=1.5e10
49
50
51 # location and geometrical size of event:
52 xc=[30000.,40000.,10000.]
53 src_radius = 0.1*h
54 # direction of event:
55 event=numarray.array([1.,0.,0.])*1.e6
56 # time and length of the event
57 tc_length=2.
58 tc=sqrt(5.*tc_length)
59 print "event location = ",xc
60 print "radius of event = ",src_radius
61 print "time of event = ",tc
62 print "length of event = ",tc_length
63 print "direction = ",event
64
65 t_end=22.
66
67 def getDomain():
68 """
69 this defines a dom as a brick of length and width l and hight h
70
71
72 """
73 ne_l=int(l/resolution+0.5)
74 ne_h=int(h/resolution+0.5)
75 print "grid : %s x %s x %s"%(ne_l,ne_l,ne_h)
76 dom=Brick(ne_l,ne_l,ne_h,l0=l,l1=l,l2=h,order=1)
77
78 fs=Function(dom)
79 x=Function(dom).getX()
80 fs.setTags(sand_tag,wherePositive(x[0]-(l-l_x_water-d0_sand)) \
81 *wherePositive(x[1]-(l-l_y_water-d0_sand)) \
82 *wherePositive(x[2]-(h-h_water-d_sand)))
83 fs.setTags(water_tag,wherePositive(x[0]-(l-l_x_water)) \
84 *wherePositive(x[1]-(l-l_y_water)) \
85 *wherePositive(x[2]-(h-h_water)))
86 return dom
87
88 def getMaterialProperties(dom):
89 rho =Scalar(rho_bedrock,Function(dom))
90 rho.setTaggedValue(sand_tag,rho_sand)
91 rho.setTaggedValue(water_tag,rho_water)
92
93 lame_mu =Scalar(mu_bedrock,Function(dom))
94 lame_mu.setTaggedValue(sand_tag,mu_sand)
95 lame_mu.setTaggedValue(water_tag,mu_water)
96
97 lame_lambda=Scalar(lambda_bedrock,Function(dom))
98 lame_lambda.setTaggedValue(sand_tag,lambda_sand)
99 lame_lambda.setTaggedValue(water_tag,lambda_water)
100
101 return rho,lame_mu,lame_lambda
102
103
104 def wavePropagation(dom,rho,lame_mu,lame_lambda):
105 x=Function(dom).getX()
106 # ... open new PDE ...
107 mypde=LinearPDE(dom)
108 mypde.setSolverMethod(LinearPDE.LUMPING)
109 k=kronecker(Function(dom))
110 mypde.setValue(D=k*rho)
111
112 v_p=sqrt((2*lame_mu+lame_lambda)/rho)
113 print "v_p=",v_p
114 v_s=sqrt(lame_mu/rho)
115 print "v_s=",v_s
116 dt=(1./5.)*inf(dom.getSize()/v_p)
117 print "time step size = ",dt
118 # ... set initial values ....
119 n=0
120 t=0
121 # initial value of displacement at point source is constant (U0=0.01)
122 # for first two time steps
123 u =Vector(0.,Solution(dom))
124 u_last=Vector(0.,Solution(dom))
125
126 while t<t_end:
127 print n+1,"-th time step t ",t+dt," max u and F: ",Lsup(u),
128 # ... get current stress ....
129 eps=symmetric(grad(u))
130 stress=lame_lambda*trace(eps)*k+2*lame_mu*eps
131 # ... force due to event:
132 F=exp(-((t-tc)/tc_length)**2)*exp(-(length(x-xc)/src_radius)**2)*event
133 print Lsup(F)
134 # ... get new acceleration ....
135 mypde.setValue(X=-stress,Y=F)
136 a=mypde.getSolution()
137 # ... get new displacement ...
138 u_new=2*u-u_last+dt**2*a
139 # ... shift displacements ....
140 u_last,u=u,u_new
141 # ... save current acceleration in units of gravity and displacements
142 if n%10==0: saveVTK("disp.%i.vtu"%(n/10),displacement=u, amplitude=length(u))
143
144 t+=dt
145 n+=1
146
147 if __name__ =="__main__":
148 dom=getDomain()
149 rho,lame_mu,lame_lambda=getMaterialProperties(dom)
150 wavePropagation(dom,rho,lame_mu,lame_lambda)

  ViewVC Help
Powered by ViewVC 1.1.26