Guest User

triax

a guest
Feb 6th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.15 KB | None | 0 0
  1.  
  2. from yade import pack
  3.  
  4. ############################################
  5. ###   DEFINING VARIABLES AND MATERIALS   ###
  6. ############################################
  7.  
  8. # The following 5 lines will be used later for batch execution
  9. nRead=utils.readParamsFromTable(
  10.     num_spheres=10000,# number of spheres
  11.     compFricDegree = 0, # contact friction during the confining phase
  12.     unknownOk=True
  13. )
  14. from yade.params import table
  15.  
  16. num_spheres=table.num_spheres# number of spheres
  17. targetPorosity = 0.409 #the porosity we want for the packing
  18. compFricDegree = table.compFricDegree # initial contact friction during the confining phase (will be decreased during the REFD compaction process)
  19. finalFricDegree = 35 # contact friction during the deviatoric loading
  20. rate=0.05 # loading rate (strain rate) 0.02
  21. damp=0.02 # damping coefficient 0.2
  22. stabilityThreshold=0.1 # we test unbalancedForce against this value in different loops (see below) 0.01
  23. key='_triax_e693_s100kpa' # put you simulation's name here
  24. young=356e6 # contact stiffness
  25. mn,mx=Vector3(0,0,0),Vector3(1,1,1) # corners of the initial packing
  26. thick = 0.001 # thickness of the plates
  27.  
  28.  
  29. ## create materials for spheres and plates
  30. O.materials.append(FrictMat(young=young,poisson=0.42,frictionAngle=radians(compFricDegree),density=3000,label='spheres'))
  31. O.materials.append(FrictMat(young=15e6,poisson=0.5,frictionAngle=0,density=0,label='walls'))
  32.  
  33. ## create walls around the packing
  34. walls=utils.aabbWalls([mn,mx],thickness=thick,material='walls')
  35. wallIds=O.bodies.append(walls)
  36.  
  37. ## use a SpherePack object to generate a random loose particles packing
  38. sp=pack.SpherePack()
  39. psdSizes=[0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.0095] # (sizes or radii of the grains vary from 2mm to 9.5mm)
  40. psdCumm=[1,9,25,50,69,90,95,100] # the correspondent amount (percentage) of each diameter
  41.  
  42. clumps=False #turn this true for the same example with clumps
  43. if clumps:
  44.  ## approximate mean rad of the futur dense packing for latter use
  45.  volume = (mx[0]-mn[0])*(mx[1]-mn[1])*(mx[2]-mn[2])
  46.  mean_rad = pow(0.09*volume/num_spheres,0.3333)
  47.  ## define a unique clump type (we could have many, see clumpCloud documentation)
  48.  c1=pack.SpherePack([((-0.2*mean_rad,0,0),0.5*mean_rad),((0.2*mean_rad,0,0),0.5*mean_rad)])
  49.  ## generate positions and input them in the simulation
  50.  sp.makeClumpCloud(mn,mx,[c1],periodic=False)
  51.  sp.toSimulation(material='spheres')
  52. else:
  53.  sp.particleSD(mn,mx,0.00575,False,'GiaHien',num_spheres,psdSizes,psdCumm,False,0)
  54.  
  55.  #sp.makeCloud(mn,mx,-1,0.00375,num_spheres,False, 0.95) #0.333333
  56.  #O.bodies.append([utils.sphere(center,rad,material='spheres') for center,rad in sp])
  57.  #or alternatively (higher level function doing exactly the same):
  58.  sp.toSimulation(material='spheres')
  59.  
  60. ############################
  61. ###   DEFINING ENGINES   ###
  62. ############################
  63.  
  64. triax=ThreeDTriaxialEngine(
  65.     ## ThreeDTriaxialEngine will be used to control stress and strain. It controls particles size and plates positions.
  66.     ## this control of boundary conditions was used for instance in http://dx.doi.org/10.1016/j.ijengsci.2008.07.002
  67.     maxMultiplier=1.01, # spheres growing factor (fast growth)
  68.     finalMaxMultiplier=1.001, # spheres growing factor (slow growth)
  69.     thickness = thick,
  70.     stressControl_1 = False, #switch stress/strain control
  71.     stressControl_2 = False,
  72.     stressControl_3 = False,
  73.     ## The stress used for (isotropic) internal compaction
  74.     sigma_iso = 50000,
  75.     ## Independant stress values for anisotropic loadings
  76.     sigma1=100000,
  77.     sigma2=100000,
  78.     sigma3=100000,
  79.     internalCompaction=True, # If true the confining pressure is generated by growing particles
  80.     Key=key, # passed to the engine so that the output file will have the correct name
  81. )
  82.  
  83. newton=NewtonIntegrator(damping=damp)
  84.  
  85. O.engines=[
  86.     ForceResetter(),
  87.     InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
  88.     InteractionLoop(
  89.         [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  90.         [Ip2_FrictMat_FrictMat_FrictPhys()],
  91.         [Law2_ScGeom_FrictPhys_CundallStrack()]
  92.     ),
  93.     ## We will use the global stiffness of each body to determine an optimal timestep (see https://yade-dem.org/w/images/1/1b/Chareyre&Villard2005_licensed.pdf)
  94.     GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8),
  95.     triax,
  96.     TriaxialStateRecorder(iterPeriod=100,file='WallStresses'+key),
  97.     newton
  98. ]
  99.  
  100. #Display spheres with 2 colors for seeing rotations better
  101. Gl1_Sphere.stripes=0
  102. if nRead==0: yade.qt.Controller(), yade.qt.View()
  103.  
  104. #######################################
  105. ###   APPLYING CONFINING PRESSURE   ###
  106. #######################################
  107.  
  108. while 1: # 1 state 1: iso compaction
  109.     O.run(1000, True)
  110.     #the global unbalanced force on dynamic bodies, thus excluding boundaries, which are not at equilibrium
  111.     unb=unbalancedForce()
  112.     #average stress
  113.     #note: triax.stress(k) returns a stress vector, so we need to keep only the normal component
  114.     meanS=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3
  115.     print 'unbalanced force:',unb,' mean stress: ',meanS
  116.     if unb<stabilityThreshold and abs(meanS-triax.sigma_iso)/triax.sigma_iso<0.1: #0.001
  117.         break
  118.  
  119. O.save('confinedState'+key+'.yade.gz')
  120. print "###      Isotropic state saved      ###"
  121.  
  122. ###################################################
  123. ###   REACHING A SPECIFIED POROSITY PRECISELY   ###
  124. ###################################################
  125.  
  126. ### We will reach a prescribed value of porosity with the REFD algorithm
  127. ### (see http://dx.doi.org/10.2516/ogst/2012032 and
  128. ### http://www.geosyntheticssociety.org/Resources/Archive/GI/src/V9I2/GI-V9-N2-Paper1.pdf)
  129.  
  130. import sys #this is only for the flush() below
  131. while triax.porosity>targetPorosity:
  132.     # we decrease friction value and apply it to all the bodies and contacts
  133.     compFricDegree = 0.95*compFricDegree
  134.     setContactFriction(radians(compFricDegree))
  135.     print "\r Friction: ",compFricDegree," porosity:",triax.porosity,
  136.     sys.stdout.flush()
  137.     # while we run steps, triax will tend to grow particles as the packing
  138.     # keeps shrinking as a consequence of decreasing friction. Consequently
  139.     # porosity will decrease
  140.     O.run(500,1)
  141.  
  142. O.save('compactedState'+key+'.yade.gz')
  143. print "###    Compacted state saved      ###"
  144.  
  145. ##############################
  146. ###   DEVIATORIC LOADING   ###
  147. ##############################
  148.  
  149. #We move to deviatoric loading, let us turn internal compaction off to keep particles sizes constant
  150. triax.internalCompaction=False
  151.  
  152. # Change contact friction (remember that decreasing it would generate instantaneous instabilities)
  153. triax.setContactProperties(finalFricDegree)
  154.  
  155. #set independant stress control on each axis
  156. triax.stressControl_1=triax.stressControl_2=triax.stressControl_3=True
  157. # We turn all these flags true, else boundaries will be fixed
  158. triax.wall_bottom_activated=True
  159. triax.wall_top_activated=True
  160. triax.wall_left_activated=True
  161. triax.wall_right_activated=True
  162. triax.wall_back_activated=True
  163. triax.wall_front_activated=True
  164.  
  165.  
  166. ##If we want a triaxial loading at imposed strain rate, let's assign srain rate instead of stress
  167. triax.stressControl_2=0 #we are tired of typing "True" and "False", we use implicit conversion from integer to boolean
  168. triax.strainRate2=rate
  169. triax.strainRate1=100*rate
  170. triax.strainRate3=100*rate
  171.  
  172. ##we can change damping here. What is the effect in your opinion?
  173. #newton.damping=0.1
  174.  
  175. ##Save temporary state in live memory. This state will be reloaded from the interface with the "reload" button.
  176. #O.saveTmp()
  177.  
  178. #####################################################
  179. ###    Example of how to record and plot data     ###
  180. #####################################################
  181.  
  182. from yade import plot
  183.  
  184. # a function saving variables
  185. def history():
  186.     plot.addData(e11=triax.strain[0], e22=triax.strain[1], e33=triax.strain[2],
  187.         ev=-triax.strain[0]-triax.strain[1]-triax.strain[2],
  188.         s11=triax.stress(triax.wall_right_id)[0],
  189.         s22=triax.stress(triax.wall_top_id)[1],
  190.         s33=triax.stress(triax.wall_front_id)[2],
  191.         i=O.iter)
  192.  
  193. if 1:
  194.   # include a periodic engine calling that function in the simulation loop
  195.   O.engines=O.engines[0:5]+[PyRunner(iterPeriod=20,command='history()',label='recorder')]+O.engines[5:7]
  196.   #O.engines.insert(4,PyRunner(iterPeriod=20,command='history()',label='recorder'))
  197. else:
  198.   # With the line above, we are recording some variables twice. We could in fact replace the previous
  199.   # TriaxialRecorder
  200.   # by our periodic engine. Uncomment the following line:
  201.   O.engines[4]=PyRunner(iterPeriod=20,command='history()',label='recorder')
  202.  
  203. O.run(100,True)
  204.  
  205. # declare what is to plot. "None" is for separating y and y2 axis
  206. #plot.plots={'i':('e11','e22','e33',None,'s11','s22','s33')}
  207. ### the traditional triaxial curves would be more like this:
  208. plot.plots={'e22':('s22',None,'ev')}
  209.  
  210. ## display on the screen (doesn't work on VMware image it seems)
  211. plot.plot()
  212.  
  213. #####  PLAY THE SIMULATION HERE WITH "PLAY" BUTTON OR WITH THE COMMAND O.run(N)  #####
  214.  
  215. ## In that case we can still save the data to a text file at the the end of the simulation, with:
  216. #plot.saveDataTxt('results'+key)
  217. ##or even generate a script for gnuplot. Open another terminal and type  "gnuplot plotScriptKEY.gnuplot:
  218. #plot.saveGnuplot('plotScript'+key)
Advertisement
Add Comment
Please, Sign In to add comment