# Contents of /trunk/doc/examples/wave.py

Revision 1161 - (show annotations)
Wed May 23 04:17:52 2007 UTC (14 years, 6 months ago) by jongui
File MIME type: text/x-python
File size: 2702 byte(s)
```Made some minor updates to the test.
```
 1 from esys.escript import * 2 from esys.escript.pdetools import Locator 3 from esys.escript.linearPDEs import LinearPDE 4 from esys.finley import Brick 5 from numarray import identity,zeros,ones 6 7 ne=32 # number of cells in x_0 and x_1 directions 8 width=10000. # length in x_0 and x_1 directions 9 lam=3.462e9 10 mu=3.462e9 11 rho=1154. 12 tend=60 13 h=(1./5.)*sqrt(rho/(lam+2*mu))*(width/ne) 14 print "time step size = ",h 15 16 U0=0.01 # amplitude of point source 17 18 def wavePropagation(domain,h,tend,lam,mu,rho,U0): 19 x=domain.getX() 20 # ... open new PDE ... 21 mypde=LinearPDE(domain) 22 mypde.setSolverMethod(LinearPDE.LUMPING) 23 kronecker=identity(mypde.getDim()) 24 25 # spherical source at middle of bottom face 26 27 xc=[width/2.,width/2.,0.] 28 # define small radius around point xc 29 # Lsup(x) returns the maximum value of the argument x 30 src_radius = 0.1*Lsup(domain.getSize()) 31 print "src_radius = ",src_radius 32 33 dunit=numarray.array([1.,0.,0.]) # defines direction of point source 34 35 mypde.setValue(D=kronecker*rho) 36 # ... set initial values .... 37 n=0 38 # initial value of displacement at point source is constant (U0=0.01) 39 # for first two time steps 40 u=U0*whereNegative(length(x-xc)-src_radius)*dunit 41 u_last=U0*whereNegative(length(x-xc)-src_radius)*dunit 42 t=0 43 44 # define the location of the point source 45 L=Locator(domain,numarray.array(xc)) 46 # find potential at point source 47 u_pc=L.getValue(u) 48 print "u at point charge=",u_pc 49 50 u_pc_x = u_pc[0] 51 u_pc_y = u_pc[1] 52 u_pc_z = u_pc[2] 53 54 # open file to save displacement at point source 55 u_pc_data=open('./data/U_pc.out','w') 56 u_pc_data.write("%f %f %f %f\n"%(t,u_pc_x,u_pc_y,u_pc_z)) 57 58 while t

## Properties

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