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

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

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

revision 3891 by ahallam, Wed Dec 8 01:09:06 2010 UTC revision 3892 by jfenwick, Tue Apr 10 08:57:23 2012 UTC
# Line 45  from esys.finley import ReadMesh Line 45  from esys.finley import ReadMesh
45  ########################################################MPI WORLD CHECK  ########################################################MPI WORLD CHECK
46  if getMPISizeWorld() > 1:  if getMPISizeWorld() > 1:
47      import sys      import sys
48      print "This example will not run in an MPI world."      print("This example will not run in an MPI world.")
49      sys.exit(0)      sys.exit(0)
50    
51  #################################################ESTABLISHING VARIABLES  #################################################ESTABLISHING VARIABLES
# Line 63  nlayers=9  #number of layers in layercak Line 63  nlayers=9  #number of layers in layercak
63  ####################################################TESTING SWITCH  ####################################################TESTING SWITCH
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.001      tend=0.001
69      #Model Parameters          #Model Parameters    
70      mx=40.      mx=40.
# Line 85  h=0.00001    # time step Line 85  h=0.00001    # time step
85  rtime=0.0 # first time to record  rtime=0.0 # first time to record
86  rtime_inc=tend/outputs # time increment to record  rtime_inc=tend/outputs # time increment to record
87  #Check to make sure number of time steps is not too large.  #Check to make sure number of time steps is not too large.
88  print "Time step size= ",h, "Expected number of outputs= ",tend/h  print("Time step size= ",h, "Expected number of outputs= ",tend/h)
89    
90  ####################################################CREATING THE SOURCE FUNCTION  ####################################################CREATING THE SOURCE FUNCTION
91  U0=0.1 # amplitude of point source  U0=0.1 # amplitude of point source
# Line 101  a = 2.0 * (np.pi * dfeq)**2.0 Line 101  a = 2.0 * (np.pi * dfeq)**2.0
101  t0 = 5.0 / (2.0 * np.pi * dfeq)  t0 = 5.0 / (2.0 * np.pi * dfeq)
102  srclength = 5. * t0  srclength = 5. * t0
103  ls = int(srclength/h)  ls = int(srclength/h)
104  print 'source length',ls  print('source length',ls)
105  source=np.zeros(ls,'float') # source array  source=np.zeros(ls,'float') # source array
106  ampmax=0  ampmax=0
107  for it in range(0,ls):  for it in range(0,ls):
# Line 142  mypde.setValue(D=rho*kmat) #set the gene Line 142  mypde.setValue(D=rho*kmat) #set the gene
142    
143  ############################################FIRST TIME STEPS AND SOURCE  ############################################FIRST TIME STEPS AND SOURCE
144  # define small radius around point xc  # define small radius around point xc
145  src_rad = 20; print "src radius= ",src_rad  src_rad = 20; print("src radius= ",src_rad)
146  # set initial values for first two time steps with source terms  # set initial values for first two time steps with source terms
147  xb=FunctionOnBoundary(domain).getX()  xb=FunctionOnBoundary(domain).getX()
148  yx=(cos(length(xb-xc)*3.1415/src_rad)+1)*whereNegative(length(xb-xc)-src_rad)  yx=(cos(length(xb-xc)*3.1415/src_rad)+1)*whereNegative(length(xb-xc)-src_rad)
# Line 177  while t<tend: Line 177  while t<tend:
177      t=t+h; n=n+1      t=t+h; n=n+1
178      if (n < ls):      if (n < ls):
179          mypde.setValue(y=source[n]*yx*src_dir*stop) #set the source as a function on the boundary          mypde.setValue(y=source[n]*yx*src_dir*stop) #set the source as a function on the boundary
180      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