Advertisement
linkos

Triaxial Test

Jan 8th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.29 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. from yade import pack
  4.  
  5. ############################################
  6. ###   DEFINING VARIABLES AND MATERIALS   ###
  7. ############################################
  8.  
  9. # The following 5 lines will be used later for batch execution
  10. nRead=utils.readParamsFromTable(
  11.     num_spheres=10000,# number of spheres
  12.     compFricDegree = 0, # contact friction during the confining phase
  13.     unknownOk=True
  14. )
  15. from yade.params import table
  16.  
  17. num_spheres=table.num_spheres # number of spheres
  18. targetPorosity = 0.382 #the porosity we want for the packing
  19. compFricDegree = table.compFricDegree # initial contact friction during the confining phase (will be decreased during the REFD compaction process)
  20. finalFricDegree = 35 # contact friction during the deviatoric loading
  21. rate=0.02 # loading rate (strain rate)
  22. damp=0.2 # damping coefficient
  23. stabilityThreshold=0.01
  24. key='_triax_base_' # simulation's name here
  25. young=2e6 # contact stiffness (initial value) =5e6
  26. mn,mx=Vector3(0,0,0),Vector3(0.01,0.01,0.01) # corners of the initial packing
  27. thick = 0.01 # l'épaisseur des plaques
  28.  
  29.  
  30. ## créer les matériaux pour les sphères et plaques
  31. O.materials.append(FrictMat(young=young,poisson=0.3,frictionAngle=radians(compFricDegree),density=3000,label='spheres'))
  32. O.materials.append(FrictMat(young=young,poisson=0.5,frictionAngle=0,density=0,label='walls'))
  33.  
  34. ## create walls around the packing
  35. walls=utils.aabbWalls([mn,mx],thickness=thick,material='walls')
  36. wallIds=O.bodies.append(walls)
  37.  
  38. ## use a SpherePack object to generate a random loose particles packing
  39. sp=pack.SpherePack()
  40.  
  41.  
  42. clumps=False #turn this true for the same example with clumps / on utilisera cette methode dans l'avenir
  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.makeCloud(mn,mx,-1,0.3333,num_spheres,False, 0.95)
  54.  O.bodies.append([utils.sphere(center,rad,material='spheres') for center,rad in sp])
  55.  #or alternatively (higher level function doing exactly the same):
  56.  #sp.toSimulation(material='spheres')
  57.  
  58. ############################
  59. ###   DEFINING ENGINES   ###
  60. ############################
  61.  
  62. triax=ThreeDTriaxialEngine(
  63.     maxMultiplier=1.+2e4/young, # spheres growing factor (fast growth)
  64.     finalMaxMultiplier=1.+2e3/young, # spheres growing factor (slow growth)
  65.     thickness = thick,
  66.     stressControl_1 = False, #switch stress/strain control
  67.     # strainControl_1 = True, temporary switch off because I have no idea what it is about.
  68.     stressControl_2 = False,
  69.     stressControl_3 = False,
  70.     ## The stress used for (isotropic) internal compaction
  71.     sigma_iso = 100000, # Pa
  72.     ## Independant stress values for anisotropic loadings
  73.     sigma1=300000, # to create the q=s11-s33=200kPa=200000
  74.     sigma2=100000,
  75.     sigma3=100000,
  76.     internalCompaction=True, # The confining pressure is generated by growing particles !!!!!!!!!
  77.     Key=key, # passed to the engine so that the output file will have the correct name
  78. )
  79.  
  80. newton=NewtonIntegrator(damping=damp)
  81.  
  82. O.engines=[
  83.     ForceResetter(),
  84.     InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
  85.     InteractionLoop(
  86.         [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  87.         [Ip2_FrictMat_FrictMat_FrictPhys()],
  88.         [Law2_ScGeom_FrictPhys_CundallStrack()]
  89.     ),
  90.     GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8),
  91.     triax,
  92.     TriaxialStateRecorder(iterPeriod=100,file='WallStresses'+key),
  93.     newton
  94. ]
  95.  
  96. #Display spheres with 2 colors for seeing rotations better
  97. Gl1_Sphere.stripes=0
  98. if nRead==0: yade.qt.Controller(), yade.qt.View()
  99.  
  100. #######################################
  101. ###   APPLYING CONFINING PRESSURE   ###
  102. #######################################
  103.  
  104. while 1:
  105.   O.run(1000, True)
  106.   ##the global unbalanced force on dynamic bodies, thus excluding boundaries, which are not at equilibrium
  107.   unb=unbalancedForce()
  108.   ##average stress
  109.   ##note: triax.stress(k) returns a stress vector, so we need to keep only the normal component
  110.   meanS=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3
  111.   print 'unbalanced force:',unb,' mean stress: ',meanS
  112.   if unb<stabilityThreshold and abs(meanS-triax.sigma_iso)/triax.sigma_iso<0.001:
  113.     break
  114.  
  115. O.save('confinedState'+key+'.yade.gz')
  116. print "###      Isotropic state saved      ###"
  117.  
  118. ###################################################
  119. ###   REACHING A SPECIFIED POROSITY PRECISELY   ###
  120. ###################################################
  121.  
  122. import sys #this is only for the flush() below
  123. while triax.porosity>targetPorosity:
  124.     ## we decrease friction value and apply it to all the bodies and contacts
  125.     compFricDegree = 0.95*compFricDegree
  126.     setContactFriction(radians(compFricDegree))
  127.     print "\r Friction: ",compFricDegree," porosity:",triax.porosity,
  128.     sys.stdout.flush()
  129.     ## while we run steps, triax will tend to grow particles as the packing
  130.     ## keeps shrinking as a consequence of decreasing friction. Consequently
  131.     ## porosity will decrease
  132.     O.run(500,1)
  133.  
  134. O.save('compactedState'+key+'.yade.gz')
  135. print "###    Compacted state saved      ###"
  136.  
  137. ##############################
  138. ###   DEVIATORIC LOADING   ###
  139. ##############################
  140.  
  141. ## Deviatoric loading, turn internal compaction off to keep particles sizes constant
  142. triax.internalCompaction=False
  143.  
  144. ## Change contact friction (remember that decreasing it would generate instantaneous instabilities)
  145. triax.setContactProperties(finalFricDegree)
  146.  
  147. ##set independant stress control on each axis
  148. triax.stressControl_1=triax.stressControl_2=triax.stressControl_3=True
  149. ## We turn all these flags true, else boundaries will be fixed
  150. triax.wall_bottom_activated=True
  151. triax.wall_top_activated=True
  152. triax.wall_left_activated=True
  153. triax.wall_right_activated=True
  154. triax.wall_back_activated=True
  155. triax.wall_front_activated=True
  156.  
  157.  
  158. ##If we want a triaxial loading at imposed strain rate, let's assign srain rate instead of stress
  159. triax.stressControl_2=0 #we are tired of typing "True" and "False", we use implicit conversion from integer to boolean
  160. triax.strainRate2=rate
  161. triax.strainRate1=100*rate
  162. triax.strainRate3=100*rate
  163.  
  164. ## Damping (initial value = 0.1)
  165. newton.damping=0.5
  166.  
  167. ##Save temporary state in live memory. This state will be reloaded from the interface with the "reload" button.
  168. O.saveTmp()
  169.  
  170. ###########################
  171. ###    Plot Data        ###
  172. ###########################
  173.  
  174. from yade import plot
  175.  
  176. ### a function saving variables
  177. def history():
  178.     plot.addData(e11=triax.strain[0], e22=triax.strain[1], e33=triax.strain[2],
  179.             ev=-triax.strain[0]-triax.strain[1]-triax.strain[2],
  180.             s11=triax.stress(triax.wall_right_id)[0],
  181.             s22=triax.stress(triax.wall_top_id)[1],
  182.             s33=triax.stress(triax.wall_front_id)[2],
  183.             q=triax.stress(triax.wall_right_id)[0]-triax.stress(triax.wall_front_id)[2],
  184.             i=O.iter)
  185.  
  186. if 1:
  187.   ## include a periodic engine calling that function in the simulation loop
  188.   O.engines=O.engines[0:5]+[PyRunner(iterPeriod=20,command='history()',label='recorder')]+O.engines[5:7]
  189.   ##O.engines.insert(4,PyRunner(iterPeriod=20,command='history()',label='recorder'))
  190. else:
  191.   ## With the line above, we are recording some variables twice. We could in fact replace the previous
  192.   ## TriaxialRecorder
  193.   ## by our periodic engine. Uncomment the following line:
  194.   O.engines[4]=PyRunner(iterPeriod=20,command='history()',label='recorder')
  195.  
  196. O.run(100,True)
  197.  
  198. ### plot 1
  199. # plot.plots={'i':('e11','e22','e33',None,'s11','s22','s33')}
  200. ### the traditional triaxial curves
  201. # plot.plots={'e11':('q')}
  202. plot.plots={'e11':('ev')}
  203. ## display on the screen
  204. plot.plot()
  205.  
  206. #####  PLAY THE SIMULATION HERE WITH "PLAY" BUTTON OR WITH THE COMMAND O.run(N)  #####
  207.  
  208. ## In that case we can still save the data to a text file at the the end of the simulation, with:
  209. #plot.saveDataTxt('results'+key)
  210. ##or even generate a script for gnuplot. Open another terminal and type  "gnuplot plotScriptKEY.gnuplot:
  211. #plot.saveGnuplot('plotScript'+key)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement