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

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

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

revision 4575 by jfenwick, Tue Jan 22 09:30:23 2013 UTC revision 4576 by sshaw, Mon Dec 9 23:35:30 2013 UTC
# Line 51  import numpy as np Line 51  import numpy as np
51    
52  ########################################################MPI WORLD CHECK  ########################################################MPI WORLD CHECK
53  if getMPISizeWorld() > 1:  if getMPISizeWorld() > 1:
54      import sys          import sys
55      print("This example will not run in an MPI world.")          print("This example will not run in an MPI world.")
56      sys.exit(0)          sys.exit(0)
57    
58  #################################################ESTABLISHING VARIABLES  #################################################ESTABLISHING VARIABLES
59  #set modal to 1 for a syncline or -1 for an anticline structural  #set modal to 1 for a syncline or -1 for an anticline structural
60  #configuration    #configuration
61  modal=-1  modal=-1
62    
63  # the folder to put our outputs in, leave blank "" for script path -  # the folder to put our outputs in, leave blank "" for script path -
# Line 88  lam2=mu2*6.; lam1=mu1*6. #lames constant Line 88  lam2=mu2*6.; lam1=mu1*6. #lames constant
88  # Time related variables.  # Time related variables.
89  testing=True  testing=True
90  if testing:  if testing:
91      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.')
92      print("Try changing testing to False for more iterations.")          print("Try changing testing to False for more iterations.")
93      tend=0.001          tend=0.001
94  else:  else:
95      tend=0.5    # end time          tend=0.5    # end time
96    
97  h=0.0001    # time step  h=0.0001    # time step
98  # data recording times  # data recording times
# Line 144  mysp = Spline(*tuple(x)) Line 144  mysp = Spline(*tuple(x))
144  # Start and end of material boundary.  # Start and end of material boundary.
145  x1=mysp.getStartPoint()  x1=mysp.getStartPoint()
146  x2=mysp.getEndPoint()  x2=mysp.getEndPoint()
147        
148  #  Create TOP BLOCK  #  Create TOP BLOCK
149  # lines  # lines
150  tbl1=Line(p0,x1)  tbl1=Line(p0,x1)
# Line 260  n=0 # iteration counter Line 260  n=0 # iteration counter
260  t=0 # time counter  t=0 # time counter
261  ##############################################################ITERATION  ##############################################################ITERATION
262  while t<tend:  while t<tend:
263      # get current stress      # get current stress
264      g=grad(u); stress=lam*trace(g)*kmat+mu*(g+transpose(g))      g=grad(u); stress=lam*trace(g)*kmat+mu*(g+transpose(g))
265      mypde.setValue(X=-stress*abc) # set PDE values      mypde.setValue(X=-stress*abc) # set PDE values
266      accel = mypde.getSolution() #get PDE solution for accelleration      accel = mypde.getSolution() #get PDE solution for accelleration
267      u_p1=(2.*u-u_m1)+h*h*accel #calculate displacement      u_p1=(2.*u-u_m1)+h*h*accel #calculate displacement
268      u_p1=u_p1*abc       # apply boundary conditions      u_p1=u_p1*abc       # apply boundary conditions
269      u_m1=u; u=u_p1 # shift values by 1      u_m1=u; u=u_p1 # shift values by 1
270      # save current displacement, acceleration and pressure      # save current displacement, acceleration and pressure
271      if (t >= rtime):      if (t >= rtime):

Legend:
Removed from v.4575  
changed lines
  Added in v.4576

  ViewVC Help
Powered by ViewVC 1.1.26