# Annotation of /trunk/doc/examples/usersguide/wave.py

Revision 2580 - (hide annotations)
Tue Aug 4 08:24:12 2009 UTC (9 years, 11 months ago) by gross
File MIME type: text/x-python
File size: 4138 byte(s)
```another example for the usage of matplot lib added to users guide.
```
 1 ksteube 1215 2 ksteube 1811 ######################################################## 3 # 4 jfenwick 2548 # Copyright (c) 2003-2009 by University of Queensland 5 ksteube 1811 # 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 jfenwick 2549 __copyright__="""Copyright (c) 2003-2009 by University of Queensland 15 ksteube 1811 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 jfenwick 2344 __url__= 21 ksteube 1811 22 jgs 108 from esys.escript import * 23 lkettle 582 from esys.escript.pdetools import Locator 24 gross 327 from esys.escript.linearPDEs import LinearPDE 25 jgs 110 from esys.finley import Brick 26 jfenwick 2455 from numpy import identity,zeros,ones 27 gross 2580 import matplotlib.pyplot as plt 28 lkettle 582 29 gross 2580 30 lkettle 582 ne=32 # number of cells in x_0 and x_1 directions 31 width=10000. # length in x_0 and x_1 directions 32 jgs 110 lam=3.462e9 33 mu=3.462e9 34 rho=1154. 35 gross 2580 tend=10. # to ran a full simulation change tend to 60. 36 gross 2513 alpha=0.7 37 t0=3. 38 jgs 108 39 gross 2580 40 gross 2513 U0=1. # maximum displacement 41 mkDir("data") # create directory data if it does not exist already. 42 jgs 110 43 gross 2513 def wavePropagation(domain,h,tend,lam,mu,rho, xc, src_radius, U0): 44 gross 2580 # lists to collect displacement at point source 45 ts, u_pc0,u_pc1,u_pc2=[], [], [], [] 46 jgs 108 x=domain.getX() 47 # ... open new PDE ... 48 jgs 110 mypde=LinearPDE(domain) 49 gross 2474 mypde.getSolverOptions().setSolverMethod(mypde.getSolverOptions().LUMPING) 50 lkettle 582 kronecker=identity(mypde.getDim()) 51 52 jfenwick 2455 dunit=numpy.array([1.,0.,0.]) # defines direction of point source 53 lkettle 582 54 gross 2502 mypde.setValue(D=kronecker*rho, q=whereNegative(length(x-xc)-src_radius)*dunit) 55 jgs 110 # ... set initial values .... 56 jgs 108 n=0 57 lkettle 582 # for first two time steps 58 gross 2502 u=Vector(0.,Solution(domain)) 59 u_last=Vector(0.,Solution(domain)) 60 jgs 110 t=0 61 lkettle 582 62 # define the location of the point source 63 gross 2502 L=Locator(domain,xc) 64 lkettle 582 # find potential at point source 65 u_pc=L.getValue(u) 66 print "u at point charge=",u_pc 67 gross 2580 ts.append(t); u_pc0.append(u_pc[0]), u_pc1.append(u_pc[1]), u_pc2.append(u_pc[2]) 68 lkettle 582 69 jgs 108 while t

## Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo