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

Diff of /trunk/doc/examples/cookbook/example07b.py

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

revision 3891 by caltinay, Thu Nov 25 07:09:23 2010 UTC revision 3892 by jfenwick, Tue Apr 10 08:57:23 2012 UTC
# Line 44  from esys.escript.linearPDEs import Line Line 44  from esys.escript.linearPDEs import Line
44  ########################################################MPI WORLD CHECK  ########################################################MPI WORLD CHECK
45  if getMPISizeWorld() > 1:  if getMPISizeWorld() > 1:
46      import sys      import sys
47      print "This example will not run in an MPI world."      print("This example will not run in an MPI world.")
48      sys.exit(0)      sys.exit(0)
49    
50  #################################################ESTABLISHING VARIABLES  #################################################ESTABLISHING VARIABLES
# Line 64  csq=c*c #square of c Line 64  csq=c*c #square of c
64  # Time related variables.  # Time related variables.
65  testing=True  testing=True
66  if testing:  if testing:
67      print 'The testing end time is currently selected. This severely limits the number of time iterations.'      print('The testing end time is currently selected. This severely limits the number of time iterations.')
68      print "Try changing testing to False for more iterations."      print("Try changing testing to False for more iterations.")
69      tend=0.004      tend=0.004
70  else:  else:
71      tend=1.0    # end time      tend=1.0    # end time
# Line 75  h=0.0005     # time step Line 75  h=0.0005     # time step
75  rtime=0.0 # first time to record  rtime=0.0 # first time to record
76  rtime_inc=tend/20.0 # time increment to record  rtime_inc=tend/20.0 # time increment to record
77  #Check to make sure number of time steps is not too large.  #Check to make sure number of time steps is not too large.
78  print "Time step size= ",h, "Expected number of outputs= ",tend/h  print("Time step size= ",h, "Expected number of outputs= ",tend/h)
79    
80  U0=0.005 # amplitude of point source  U0=0.005 # amplitude of point source
81  # want a spherical source in the middle of area  # want a spherical source in the middle of area
# Line 95  mypde.setValue(D=1.) # set the value of Line 95  mypde.setValue(D=1.) # set the value of
95  ############################################FIRST TIME STEPS AND SOURCE  ############################################FIRST TIME STEPS AND SOURCE
96  # define small radius around point xc  # define small radius around point xc
97  src_radius = 25.  src_radius = 25.
98  print "src_radius = ",src_radius  print("src_radius = ",src_radius)
99  # set initial values for first two time steps with source terms  # set initial values for first two time steps with source terms
100  u=U0*(cos(length(x-xc)*3.1415/src_radius)+1)*whereNegative(length(x-xc)-src_radius)  u=U0*(cos(length(x-xc)*3.1415/src_radius)+1)*whereNegative(length(x-xc)-src_radius)
101  u_m1=u  u_m1=u
# Line 137  while t<tend: Line 137  while t<tend:
137      u_rec0.append(rec.getValue(u)) #location specific recording      u_rec0.append(rec.getValue(u)) #location specific recording
138      # increment loop values      # increment loop values
139      t=t+h; n=n+1      t=t+h; n=n+1
140      print n,"-th time step t ",t      print(n,"-th time step t ",t)
141    
142  # save location specific recording to file  # save location specific recording to file
143  pl.savetxt(os.path.join(savepath,'u_rec.asc'),u_rec0)  pl.savetxt(os.path.join(savepath,'u_rec.asc'),u_rec0)

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

  ViewVC Help
Powered by ViewVC 1.1.26