/[escript]/trunk/doc/examples/cookbook/example10c_1.py
ViewVC logotype

Contents of /trunk/doc/examples/cookbook/example10c_1.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3135 - (show annotations)
Thu Sep 2 03:28:39 2010 UTC (8 years, 7 months ago) by ahallam
Original Path: trunk/doc/examples/cookbook/example10c.py
File MIME type: text/x-python
File size: 2582 byte(s)
Updates to cookbook scripts. Gravitation Examples.
1
2 ########################################################
3 #
4 # Copyright (c) 2009 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2009 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 """
23 Author: Antony Hallam antony.hallam@uqconnect.edu.au
24 """
25
26 ############################################################FILE HEADER
27 # example10a.py
28 # Model of gravitational Potential.
29
30 #######################################################EXTERNAL MODULES
31 # To solve the problem it is necessary to import the modules we require.
32 from esys.escript import * # This imports everything from the escript library
33 from esys.escript.unitsSI import *
34 from esys.escript.linearPDEs import LinearPDE # This defines LinearPDE as LinearPDE
35 from esys.finley import ReadMesh
36 import os, sys #This package is necessary to handle saving our data.
37
38 ########################################################MPI WORLD CHECK
39 if getMPISizeWorld() > 1:
40 import sys
41 print "This example will not run in an MPI world."
42 sys.exit(0)
43
44 #################################################ESTABLISHING VARIABLES
45 G=6.67300*10E-11
46
47 ################################################ESTABLISHING PARAMETERS
48 #the folder to put our outputs in, leave blank "" for script path
49 save_path= os.path.join("data","example10")
50 #ensure the dir exists
51 mkDir(save_path)
52
53 ####################################################DOMAIN CONSTRUCTION
54 domain=ReadMesh(os.path.join(save_path,'fault.fly')) # create the domain
55 x=Solution(domain).getX()
56 rho=Scalar(0,Function(domain))
57 rho.setTaggedValue("xx",500.)
58 rho.setTaggedValue("limestone",0.0)
59 rho.setTaggedValue("fault",1200.)
60
61 kro=kronecker(domain)
62
63 q=whereZero(x[2])#-sup(x[2]))
64 ###############################################ESCRIPT PDE CONSTRUCTION
65
66 mypde=LinearPDE(domain)
67 mypde.setValue(A=kro,Y=4.*3.1415*G*rho,q=q,r=0)
68 sol=mypde.getSolution()
69 saveVTK(os.path.join(save_path,"ex10c.vtu"),\
70 grav_pot=sol,\
71 g_field=-grad(sol),\
72 g_fieldz=-grad(sol)*[0,0,1],\
73 gz=length(-grad(sol)*[0,0,1]))

  ViewVC Help
Powered by ViewVC 1.1.26