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

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

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

revision 3405 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.weipa import saveVTK Line 45  from esys.weipa import saveVTK
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 64  lam2=vel2**2.*rho2/2.; lam1=vel1**2.*rho Line 64  lam2=vel2**2.*rho2/2.; lam1=vel1**2.*rho
64  ####################################################TESTING SWITCH  ####################################################TESTING SWITCH
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.001      tend=0.001
70      #Model Parameters          #Model Parameters    
71      mx=40.      mx=40.
# Line 86  h=0.00005    # time step Line 86  h=0.00005    # time step
86  rtime=0.0 # first time to record  rtime=0.0 # first time to record
87  rtime_inc=tend/outputs # time increment to record  rtime_inc=tend/outputs # time increment to record
88  #Check to make sure number of time steps is not too large.  #Check to make sure number of time steps is not too large.
89  print "Time step size= ",h, "Expected number of outputs= ",tend/h  print("Time step size= ",h, "Expected number of outputs= ",tend/h)
90    
91  ####################################################CREATING THE SOURCE FUNCTION  ####################################################CREATING THE SOURCE FUNCTION
92  U0=0.1 # amplitude of point source  U0=0.1 # amplitude of point source
# Line 102  a = 2.0 * (np.pi * dfeq)**2.0 Line 102  a = 2.0 * (np.pi * dfeq)**2.0
102  t0 = 5.0 / (2.0 * np.pi * dfeq)  t0 = 5.0 / (2.0 * np.pi * dfeq)
103  srclength = 5. * t0  srclength = 5. * t0
104  ls = int(srclength/h)  ls = int(srclength/h)
105  print 'source length',ls  print('source length',ls)
106  source=np.zeros(ls,'float') # source array  source=np.zeros(ls,'float') # source array
107  ampmax=0  ampmax=0
108  for it in range(0,ls):  for it in range(0,ls):
# Line 141  mypde.setValue(D=rho*kmat) #set the gene Line 141  mypde.setValue(D=rho*kmat) #set the gene
141    
142  ############################################FIRST TIME STEPS AND SOURCE  ############################################FIRST TIME STEPS AND SOURCE
143  # define small radius around point xc  # define small radius around point xc
144  src_rad = 20; print "sourc radius= ",src_rad  src_rad = 20; print("sourc radius= ",src_rad)
145  # set initial values for first two time steps with source terms  # set initial values for first two time steps with source terms
146  xb=FunctionOnBoundary(domain).getX()  xb=FunctionOnBoundary(domain).getX()
147  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 176  while t<tend: Line 176  while t<tend:
176      t=t+h; n=n+1      t=t+h; n=n+1
177      if (n < ls):      if (n < ls):
178          mypde.setValue(y=source[0]*yx*src_dir*stop) #set the source as a function on the boundary          mypde.setValue(y=source[0]*yx*src_dir*stop) #set the source as a function on the boundary
179      print n,"-th time step t ",t      print(n,"-th time step t ",t)

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

  ViewVC Help
Powered by ViewVC 1.1.26