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

Diff of /trunk/doc/examples/cookbook/example07a.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 43  from esys.escript.linearPDEs import Line Line 43  from esys.escript.linearPDEs import Line
43  ########################################################MPI WORLD CHECK  ########################################################MPI WORLD CHECK
44  if getMPISizeWorld() > 1:  if getMPISizeWorld() > 1:
45      import sys      import sys
46      print "This example will not run in an MPI world."      print("This example will not run in an MPI world.")
47      sys.exit(0)      sys.exit(0)
48    
49  #################################################ESTABLISHING VARIABLES  #################################################ESTABLISHING VARIABLES
# Line 63  csq=c*c #square of c Line 63  csq=c*c #square of c
63  # Time related variables.  # Time related variables.
64  testing=True  testing=True
65  if testing:  if testing:
66      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.')
67      print "Try changing testing to False for more iterations."      print("Try changing testing to False for more iterations.")
68      tend=0.004      tend=0.004
69  else:  else:
70      tend=1.5    # end time      tend=1.5    # end time
# Line 74  h=0.001     # time step Line 74  h=0.001     # time step
74  rtime=0.0 # first time to record  rtime=0.0 # first time to record
75  rtime_inc=tend/20.0 # time increment to record  rtime_inc=tend/20.0 # time increment to record
76  #Check to make sure number of time steps is not too large.  #Check to make sure number of time steps is not too large.
77  print "Time step size= ",h, "Expected number of outputs= ",tend/h  print("Time step size= ",h, "Expected number of outputs= ",tend/h)
78    
79  U0=0.005 # amplitude of point source  U0=0.005 # amplitude of point source
80  # want a spherical source in the middle of area  # want a spherical source in the middle of area
# Line 92  mypde.setValue(D=1.) # set the value of Line 92  mypde.setValue(D=1.) # set the value of
92  ############################################FIRST TIME STEPS AND SOURCE  ############################################FIRST TIME STEPS AND SOURCE
93  # define small radius around point xc  # define small radius around point xc
94  src_radius = 30  src_radius = 30
95  print "src_radius = ",src_radius  print("src_radius = ",src_radius)
96  # set initial values for first two time steps with source terms  # set initial values for first two time steps with source terms
97  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)
98  u_m1=u  u_m1=u
# Line 126  while t<tend: Line 126  while t<tend:
126          rtime=rtime+rtime_inc #increment data save time          rtime=rtime+rtime_inc #increment data save time
127      # increment loop values      # increment loop values
128      t=t+h; n=n+1      t=t+h; n=n+1
129      print n,"-th time step t ",t      print(n,"-th time step t ",t)

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

  ViewVC Help
Powered by ViewVC 1.1.26