/[escript]/trunk/doc/examples/usersguide/slip.py
ViewVC logotype

Contents of /trunk/doc/examples/usersguide/slip.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4154 - (show annotations)
Tue Jan 22 09:30:23 2013 UTC (6 years, 9 months ago) by jfenwick
File MIME type: text/x-python
File size: 2378 byte(s)
Round 1 of copyright fixes
1
2 ##############################################################################
3 #
4 # Copyright (c) 2009-2013 by University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development since 2012 by School of Earth Sciences
13 #
14 ##############################################################################
15
16 __copyright__="""Copyright (c) 2009-2013 by University of Queensland
17 http://www.uq.edu.au
18 Primary Business: Queensland, Australia"""
19 __license__="""Licensed under the Open Software License version 3.0
20 http://www.opensource.org/licenses/osl-3.0.php"""
21 __url__="https://launchpad.net/escript-finley"
22
23
24 from esys.escript import *
25 from esys.escript.linearPDEs import LinearPDE
26 from esys.escript.models import FaultSystem
27 from esys.finley import Rectangle
28 from esys.weipa import saveVTK
29 from esys.escript.unitsSI import DEG
30 #... set some parameters ...
31 lam=1.
32 mu=1
33 slip_max=1.
34
35 mydomain = Rectangle(l0=1.,l1=1.,n0=16, n1=16) # n1 need to be multiple of 4!!!
36 # .. create the fault system
37 fs=FaultSystem(dim=2)
38 fs.addFault(V0=[0.5,0.25], strikes=90*DEG, ls=0.5, tag=1)
39 # ... create a slip distribution on the fault:
40 p, m=fs.getParametrization(mydomain.getX(),tag=1)
41 p0,p1= fs.getW0Range(tag=1)
42 s=m*(p-p0)*(p1-p)/((p1-p0)/2)**2*slip_max*[0.,1.]
43 # ... calculate stress according to slip:
44 D=symmetric(grad(s))
45 chi, d=fs.getSideAndDistance(D.getFunctionSpace().getX(),tag=1)
46 sigma_s=(mu*D+lam*trace(D)*kronecker(mydomain))*chi
47 #... open symmetric PDE ...
48 mypde=LinearPDE(mydomain)
49 mypde.setSymmetryOn()
50 #... set coefficients ...
51 C=Tensor4(0.,Function(mydomain))
52 for i in range(mydomain.getDim()):
53 for j in range(mydomain.getDim()):
54 C[i,i,j,j]+=lam
55 C[j,i,j,i]+=mu
56 C[j,i,i,j]+=mu
57 # ... fix displacement in normal direction
58 x=mydomain.getX()
59 msk=whereZero(x[0])*[1.,0.] + whereZero(x[0]-1.)*[1.,0.] \
60 +whereZero(x[1])*[0.,1.] + whereZero(x[1]-1.)*[0.,1.]
61 mypde.setValue(A=C,X=-0.5*sigma_s,q=msk)
62 #... solve pde ...
63 mypde.getSolverOptions().setVerbosityOn()
64 v=mypde.getSolution()
65 # .. write the displacement to file:
66 D=symmetric(grad(v))
67 sigma=(mu*D+lam*trace(D)*kronecker(mydomain))+0.5*sigma_s
68 saveVTK("slip.vtu",disp=v+0.5*chi*s, stress= sigma)

  ViewVC Help
Powered by ViewVC 1.1.26