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

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

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

revision 3891 by ahallam, Wed Dec 1 23:03:35 2010 UTC revision 3892 by jfenwick, Tue Apr 10 08:57:23 2012 UTC
# Line 39  from esys.escript.linearPDEs import Line Line 39  from esys.escript.linearPDEs import Line
39  ########################################################MPI WORLD CHECK  ########################################################MPI WORLD CHECK
40  if getMPISizeWorld() > 1:  if getMPISizeWorld() > 1:
41      import sys      import sys
42      print "This example will not run in an MPI world."      print("This example will not run in an MPI world.")
43      sys.exit(0)      sys.exit(0)
44    
45  #################################################ESTABLISHING VARIABLES  #################################################ESTABLISHING VARIABLES
# Line 59  rho=1154.   #density Line 59  rho=1154.   #density
59  # Time related variables.  # Time related variables.
60  testing=True  testing=True
61  if testing:  if testing:
62      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.')
63      print "Try changing testing to False for more iterations."      print("Try changing testing to False for more iterations.")
64      tend=0.001      tend=0.001
65  else:  else:
66      tend=0.5    # end time      tend=0.5    # end time
# Line 70  h=0.0005     # time step Line 70  h=0.0005     # time step
70  rtime=0.0 # first time to record  rtime=0.0 # first time to record
71  rtime_inc=tend/20.0 # time increment to record  rtime_inc=tend/20.0 # time increment to record
72  #Check to make sure number of time steps is not too large.  #Check to make sure number of time steps is not too large.
73  print "Time step size= ",h, "Expected number of outputs= ",tend/h  print("Time step size= ",h, "Expected number of outputs= ",tend/h)
74    
75  U0=0.01 # amplitude of point source  U0=0.01 # amplitude of point source
76  # will introduce a spherical source at middle left of bottom face  # will introduce a spherical source at middle left of bottom face
# Line 90  mypde.setValue(D=kmat*rho) #set the gene Line 90  mypde.setValue(D=kmat*rho) #set the gene
90    
91  ############################################FIRST TIME STEPS AND SOURCE  ############################################FIRST TIME STEPS AND SOURCE
92  # define small radius around point xc  # define small radius around point xc
93  src_length = 20; print "src_length = ",src_length  src_length = 20; print("src_length = ",src_length)
94  # set initial values for first two time steps with source terms  # set initial values for first two time steps with source terms
95  y=U0*(cos(length(x-xc)*3.1415/src_length)+1)*whereNegative(length(x-xc)-src_length)  y=U0*(cos(length(x-xc)*3.1415/src_length)+1)*whereNegative(length(x-xc)-src_length)
96  src_dir=numpy.array([0.,-1.]) # defines direction of point source as down  src_dir=numpy.array([0.,-1.]) # defines direction of point source as down
# Line 119  while t<tend: Line 119  while t<tend:
119          rtime=rtime+rtime_inc #increment data save time          rtime=rtime+rtime_inc #increment data save time
120      # increment loop values      # increment loop values
121      t=t+h; n=n+1      t=t+h; n=n+1
122      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