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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3195 - (hide annotations)
Wed Sep 22 00:28:04 2010 UTC (9 years ago) by ahallam
File MIME type: text/x-python
File size: 2871 byte(s)
Shortened runtime of cookbook examples to aid testing.
1 ahallam 3135
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 ahallam 3195 # Model of gravitational Potential for a Gravity Well.
29 ahallam 3135
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     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     #Domain related.
46     mx = 500*m #meters - model length
47     my = 500*m #meters - model width
48     mz = -500*m
49     ndx = 50 # mesh steps in x direction
50     ndy = 50 # mesh steps in y direction - one dimension means one element
51     ndz = 50
52     #PDE related
53     rho=1000.0
54     rholoc=[0,0,-0]
55     G=6.67300*10E-11
56    
57     ################################################ESTABLISHING PARAMETERS
58     #the folder to put our outputs in, leave blank "" for script path
59     save_path= os.path.join("data","example10")
60     #ensure the dir exists
61     mkDir(save_path)
62    
63     ####################################################DOMAIN CONSTRUCTION
64     domain = Brick(l0=mx,l1=my,n0=ndx, n1=ndy,l2=mz,n2=ndz)
65     x=Solution(domain).getX()
66     x=x-[mx/2,my/2,mz/2]
67     domain.setX(x)
68     mask=wherePositive(100-length(x-rholoc))
69     rho=rho*mask
70     kro=kronecker(domain)
71    
72     q=whereZero(x[2]-inf(x[2]))
73     ###############################################ESCRIPT PDE CONSTRUCTION
74    
75     mypde=LinearPDE(domain)
76     mypde.setValue(A=kro,Y=4.*3.1415*G*rho,q=q,r=0)
77     mypde.setSymmetryOn()
78     sol=mypde.getSolution()
79     saveVTK(os.path.join(save_path,"ex10b.vtu"),\
80     grav_pot=sol,\
81     g_field=-grad(sol),\
82     g_fieldz=-grad(sol)*[0,0,1],\
83     gz=length(-grad(sol)*[0,0,1]))
84    

  ViewVC Help
Powered by ViewVC 1.1.26