/[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 6756 - (show annotations)
Thu Nov 29 07:23:43 2018 UTC (21 months, 3 weeks ago) by aellery
File MIME type: text/x-python
File size: 2761 byte(s)
Temporarily undoing last commit.
1 from __future__ import division
2 ##############################################################################
3 #
4 # Copyright (c) 2009-2018 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Apache License, version 2.0
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 __copyright__="""Copyright (c) 2009-2018 by The University of Queensland
18 http://www.uq.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Apache License, version 2.0
21 http://www.apache.org/licenses/LICENSE-2.0"""
22 __url__="https://launchpad.net/escript-finley"
23
24
25 from esys.escript import *
26 from esys.escript.linearPDEs import LinearPDE
27 from esys.escript.models import FaultSystem
28 try:
29 from esys.finley import Rectangle
30 HAVE_FINLEY = True
31 except ImportError:
32 HAVE_FINLEY = False
33 from esys.weipa import saveVTK
34 from esys.escript.unitsSI import DEG
35
36 if not HAVE_FINLEY:
37 print("Finley module not available")
38 else:
39 #... set some parameters ...
40 lam=1.
41 mu=1
42 slip_max=1.
43
44 mydomain = Rectangle(l0=1.,l1=1.,n0=16, n1=16) # n1 need to be multiple of 4!!!
45 # .. create the fault system
46 fs=FaultSystem(dim=2)
47 fs.addFault(V0=[0.5,0.25], strikes=90*DEG, ls=0.5, tag=1)
48 # ... create a slip distribution on the fault:
49 p, m=fs.getParametrization(mydomain.getX(),tag=1)
50 p0,p1= fs.getW0Range(tag=1)
51 s=m*(p-p0)*(p1-p)/((p1-p0)/2)**2*slip_max*[0.,1.]
52 # ... calculate stress according to slip:
53 D=symmetric(grad(s))
54 chi, d=fs.getSideAndDistance(D.getFunctionSpace().getX(),tag=1)
55 sigma_s=(mu*D+lam*trace(D)*kronecker(mydomain))*chi
56 #... open symmetric PDE ...
57 mypde=LinearPDE(mydomain)
58 mypde.setSymmetryOn()
59 #... set coefficients ...
60 C=Tensor4(0.,Function(mydomain))
61 for i in range(mydomain.getDim()):
62 for j in range(mydomain.getDim()):
63 C[i,i,j,j]+=lam
64 C[j,i,j,i]+=mu
65 C[j,i,i,j]+=mu
66 # ... fix displacement in normal direction
67 x=mydomain.getX()
68 msk=whereZero(x[0])*[1.,0.] + whereZero(x[0]-1.)*[1.,0.] \
69 +whereZero(x[1])*[0.,1.] + whereZero(x[1]-1.)*[0.,1.]
70 mypde.setValue(A=C,X=-0.5*sigma_s,q=msk)
71 #... solve pde ...
72 mypde.getSolverOptions().setVerbosityOn()
73 v=mypde.getSolution()
74 # .. write the displacement to file:
75 D=symmetric(grad(v))
76 sigma=(mu*D+lam*trace(D)*kronecker(mydomain))+0.5*sigma_s
77 saveVTK("slip.vtu",disp=v+0.5*chi*s, stress= sigma)

  ViewVC Help
Powered by ViewVC 1.1.26