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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3374 - (show annotations)
Tue Nov 23 00:30:20 2010 UTC (8 years, 9 months ago) by ahallam
File MIME type: text/x-python
File size: 2952 byte(s)
Fixes to example scripts.
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 for a Gravity Well.
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 Brick # This imports the rectangle domain function from finley
36 from esys.weipa import saveVTK # This imports the VTK file saver from weipa
37 import os, sys #This package is necessary to handle saving our data.
38
39 ########################################################MPI WORLD CHECK
40 if getMPISizeWorld() > 1:
41 import sys
42 print "This example will not run in an MPI world."
43 sys.exit(0)
44
45 #################################################ESTABLISHING VARIABLES
46 #Domain related.
47 mx = 2000*m #meters - model length
48 my = 2000*m #meters - model width
49 mz = -2000*m
50 ndx = 100 # mesh steps in x direction
51 ndy = 100 # mesh steps in y direction - one dimension means one element
52 ndz = 100
53 #PDE related
54 rho=100.0
55 rholoc=[0,0,-0]
56 G=6.67300*10E-11
57
58 ################################################ESTABLISHING PARAMETERS
59 #the folder to put our outputs in, leave blank "" for script path
60 save_path= os.path.join("data","example10")
61 #ensure the dir exists
62 mkDir(save_path)
63
64 ####################################################DOMAIN CONSTRUCTION
65 domain = Brick(l0=mx,l1=my,n0=ndx, n1=ndy,l2=mz,n2=ndz)
66 x=Solution(domain).getX()
67 x=x-[mx/2,my/2,mz/2]
68 domain.setX(x)
69 mask=wherePositive(100-length(x-rholoc))
70 rho=rho*mask
71 kro=kronecker(domain)
72
73 q=whereZero(x[2]-inf(x[2]))
74 ###############################################ESCRIPT PDE CONSTRUCTION
75
76 mypde=LinearPDE(domain)
77 mypde.setValue(A=kro,Y=4.*3.1415*G*rho,q=q,r=0)
78 mypde.setSymmetryOn()
79 sol=mypde.getSolution()
80 saveVTK(os.path.join(save_path,"ex10b.vtu"),\
81 grav_pot=sol,\
82 g_field=-grad(sol),\
83 g_fieldz=-grad(sol)*[0,0,1],\
84 gz=length(-grad(sol)*[0,0,1]))
85

  ViewVC Help
Powered by ViewVC 1.1.26