# Contents of /trunk/doc/cookbook/wavesolver2d001.py

Revision 2427 - (show annotations)
Fri May 15 04:29:01 2009 UTC (10 years, 3 months ago) by ahallam
File MIME type: text/x-python
File size: 2042 byte(s)
```Week 7: Work done on wave problem.
```
 1 2 ######################################################## 3 # 4 # Copyright (c) 2003-2008 by University of Queensland 5 # Earth Systems Science Computational Center (ESSCC) 6 7 # 8 # Primary Business: Queensland, Australia 9 # Licensed under the Open Software License version 3.0 10 11 # 12 ######################################################## 13 14 __copyright__="""Copyright (c) 2003-2008 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 20 __url__= 21 22 # You can shorten the execution time by reducing variable tend from 60 to 0.5 23 24 # Importing all the necessary modules required. 25 from esys.escript import * 26 from esys.finley import Rectangle 27 import sys 28 import os 29 from cblib import * 30 31 # Creating a directory automatically to store the output data. 32 if not os.path.isdir("data"): 33 os.mkdir("data") 34 if not os.path.isdir("data/wavesolver2d001"): 35 os.mkdir("data/wavesolver2d001") 36 # Establish a save path. 37 savepath = "data/wavesolver2d001" 38 39 #Geometric and material property related variables. 40 mx = 500 # model lenght 41 my = 500 # model width 42 ndx = 50 # steps in x direction 43 ndy = 50 # steps in y direction 44 lam=3.462e9 #lames constant 45 mu=3.462e9 #bulk modulus 46 rho=1154. #density 47 # Time related variables. 48 tend=0.1 #end time 49 #calculating )the timestep 50 h=(1./5.)*sqrt(rho/(lam+2*mu))*(mx/ndx) 51 #Check to make sure number of time steps is not too large. 52 print "Time step size= ",h, "Expected number of outputs= ",tend/h 53 proceeder = raw_input("Is this ok?(y/n)") 54 #Exit if user thinks too many outputs. 55 if proceeder == "n": 56 sys.exit() 57 58 U0=0.01 # amplitude of point source 59 # spherical source at middle of bottom face 60 61 xc=[mx/2.,0.] 62 63 mydomain=Rectangle(l0=mx,l1=my,n0=ndx, n1=ndy) 64 wavesolver2d(mydomain,h,tend,lam,mu,rho,U0,xc,savepath) 65