/[escript]/trunk/doc/examples/usersguide/wave.py
ViewVC logotype

Diff of /trunk/doc/examples/usersguide/wave.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3891 by caltinay, Wed Feb 1 06:16:25 2012 UTC revision 3892 by jfenwick, Tue Apr 10 08:57:23 2012 UTC
# Line 69  def wavePropagation(domain,h,tend,lam,mu Line 69  def wavePropagation(domain,h,tend,lam,mu
69     L=Locator(domain,xc)     L=Locator(domain,xc)
70     # find potential at point source     # find potential at point source
71     u_pc=L.getValue(u)     u_pc=L.getValue(u)
72     print "u at point charge=",u_pc     print("u at point charge=",u_pc)
73     ts.append(t); u_pc0.append(u_pc[0]), u_pc1.append(u_pc[1]), u_pc2.append(u_pc[2])     ts.append(t); u_pc0.append(u_pc[0]), u_pc1.append(u_pc[1]), u_pc2.append(u_pc[2])
74    
75     while t<tend:     while t<tend:
# Line 87  def wavePropagation(domain,h,tend,lam,mu Line 87  def wavePropagation(domain,h,tend,lam,mu
87       u_last=u       u_last=u
88       u=u_new       u=u_new
89       n+=1       n+=1
90       print n,"-th time step t ",t       print(n,"-th time step t ",t)
91       u_pc=L.getValue(u)       u_pc=L.getValue(u)
92       print "u at point charge=",u_pc       print("u at point charge=",u_pc)
93       ts.append(t); u_pc0.append(u_pc[0]), u_pc1.append(u_pc[1]), u_pc2.append(u_pc[2])       ts.append(t); u_pc0.append(u_pc[0]), u_pc1.append(u_pc[1]), u_pc2.append(u_pc[2])
94    
95       # ... save current acceleration in units of gravity and displacements       # ... save current acceleration in units of gravity and displacements
# Line 105  mydomain=Brick(ne,ne,10,l0=width,l1=widt Line 105  mydomain=Brick(ne,ne,10,l0=width,l1=widt
105  #  sety time step size:  #  sety time step size:
106  #  #
107  h=inf(1./5.)*inf(sqrt(rho/(lam+2*mu))*mydomain.getSize())  h=inf(1./5.)*inf(sqrt(rho/(lam+2*mu))*mydomain.getSize())
108  print "time step size = ",h  print("time step size = ",h)
109  #  #
110  #  spherical source at middle of bottom face  #  spherical source at middle of bottom face
111  #  #
112  xc=[width/2.,width/2.,0.]  xc=[width/2.,width/2.,0.]
113  # define small radius around point xc  # define small radius around point xc
114  src_radius = 0.03*width  src_radius = 0.03*width
115  print "src_radius = ",src_radius  print("src_radius = ",src_radius)
116  #  #
117  # run it  # run it
118  #  #
# Line 131  if getMPIRankWorld() == 0: Line 131  if getMPIRankWorld() == 0:
131      plt.savefig('u_pc.png', format='png')      plt.savefig('u_pc.png', format='png')
132  # or save displacement  # or save displacement
133  u_pc_data=FileWriter('./data/U_pc.out')  u_pc_data=FileWriter('./data/U_pc.out')
134  for i in xrange(len(ts)) :  for i in range(len(ts)) :
135      u_pc_data.write("%f %f %f %f\n"%(ts[i],u_pc0[i],u_pc1[i],u_pc2[i]))      u_pc_data.write("%f %f %f %f\n"%(ts[i],u_pc0[i],u_pc1[i],u_pc2[i]))
136  u_pc_data.close()  u_pc_data.close()
137    

Legend:
Removed from v.3891  
changed lines
  Added in v.3892

  ViewVC Help
Powered by ViewVC 1.1.26