Advertisement
linkos

1st state

Jun 17th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.79 KB | None | 0 0
  1. # coding: utf-8
  2. # loose specimen
  3. from yade import pack
  4. import os
  5. #from utils import *
  6.  
  7. nRead=utils.readParamsFromTable(
  8.     num_spheres=10000,# number of spheres
  9.     compFricDegree = 32, # contact friction during the confining phase the final porosity
  10.     unknownOk=True,
  11.     isoForce=20000,
  12.     conStress=100000
  13. )
  14. from yade.params import table
  15.  
  16. num_spheres=table.num_spheres
  17. mn,mx=Vector3(-0.1,-0.1,-0.1),Vector3(0.1,0.1,0.1)
  18. thick = 0.1
  19. compFricDegree = table.compFricDegree
  20. finalFricDegree=35
  21. #targetPorosity=0.382
  22. rate=0.05
  23. damp=0.06
  24. stabilityThreshold=0.001 # leave it too low can have a super stable state, but will eat onion for waiting so long
  25. #stopStep=160000 # pas de calcul on choisit pour faire calculer travail du second-ordre
  26. key='_probing_envelope_' # just used for adding name to the output, kind of boring
  27.  
  28. ## create material #0, which will be used as default
  29. O.materials.append(FrictMat(young=356e6,poisson=0.42,frictionAngle=radians(compFricDegree),density=3000,label='spheres'))
  30. O.materials.append(FrictMat(young=356e6,poisson=0.5,frictionAngle=0,density=0,label='walls'))
  31.  
  32. ## create walls around the packing
  33. walls=utils.aabbWalls([mn,mx],thickness=thick,oversizeFactor=5,material='walls')
  34. wallIds=O.bodies.append(walls)
  35.  
  36. sp=pack.SpherePack()
  37. #sp.makeCloud(mn,mx,-1,0,num_spheres,False, 0.95,psdSizes,psdCumm,False,seed=1)
  38. sp.makeCloud(mn,mx,0.001,0.65,num_spheres,False,0.8,seed=1)
  39. #sp.makeCloud(mn,mx,-1,0,-1,False, 0.95,psdSizes,psdCumm,False,seed=1)
  40. sp.toSimulation(material='spheres')
  41.  
  42. volume = (mx[0]-mn[0])*(mx[1]-mn[1])*(mx[2]-mn[2])
  43. mean_rad = pow(0.09*volume/num_spheres,0.3333)
  44.  
  45. #clumps=False
  46. #if clumps:
  47. #   c1=pack.SpherePack([((-0.2*mean_rad,0,0),0.5*mean_rad),((0.2*mean_rad,0,0),0.5*mean_rad)])
  48. #   sp.makeClumpCloud((-0.24,0.24,-0.24),(0.24,0.24,0.24),[c1],periodic=False)
  49. #   O.bodies.append([utils.sphere(center,rad,material='spheres') for center,rad in sp])
  50. #   standalone,clumps=sp.getClumps()
  51. #   for clump in clumps:
  52. #       O.bodies.clump(clump)
  53. #       for i in clump[1:]: O.bodies[i].shape.color=O.bodies[clump[0]].shape.color
  54. #   #sp.toSimulation()
  55. #else:
  56. #   O.bodies.append([utils.sphere(center,rad,material='spheres') for center,rad in sp])
  57.  
  58. O.dt=.5*utils.PWaveTimeStep() # initial timestep, to not explode right away
  59. O.usesTimeStepper=True
  60.  
  61. triax=TriaxialStressController(
  62.     maxMultiplier=1.001,
  63.     finalMaxMultiplier=1.0001,     
  64.     thickness = thick,
  65.     radiusControlInterval=10,
  66.     stressMask = 7,
  67.     max_vel=0.01,
  68. )
  69.  
  70. newton=NewtonIntegrator(damping=damp)
  71.  
  72. O.engines=[
  73.     ForceResetter(),
  74.     InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()],verletDist=-mean_rad*0.06),
  75.     InteractionLoop(
  76.         [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  77.         [Ip2_FrictMat_FrictMat_FrictPhys()],
  78.         [Law2_ScGeom_FrictPhys_CundallStrack(label='law')]
  79.     ),
  80.     GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8, defaultDt=4*utils.PWaveTimeStep()),
  81.     triax,
  82.     TriaxialStateRecorder(iterPeriod=50,file='WallStresses'+key,addIterNum=False,initRun=False), # 20 is too small, will make big file size
  83.     newton
  84. ]
  85.  
  86. #O.save('initial'+key+'.xml')
  87. #Display spheres with 2 colors for seeing rotations better
  88. Gl1_Sphere.stripes=1
  89. #if nRead==0: yade.qt.Controller(), yade.qt.View()
  90. print 'Number of elements: ', len(O.bodies)
  91. print 'Box Volume: ',  triax.boxVolume
  92. print 'Box Volume calculated: ', volume
  93.  
  94. # Applying confining force
  95.  
  96.  
  97. #########################################
  98. # Phase 1: ISOTROPIC GENERATOR OF 20kPa #
  99. #########################################
  100. while 1:
  101.   triax.internalCompaction=True # Growing the particles is what we use in this step
  102.   setContactFriction=radians(compFricDegree)
  103.   triax.stressmask=7
  104.   triax.goal1=table.isoForce
  105.   triax.goal2=table.isoForce
  106.   triax.goal3=table.isoForce
  107.   O.run(1000,True)
  108.   #the global unbalanced force on dynamic bodies, thus excluding boundaries, which are not at equilibrium
  109.   unb=unbalancedForce()
  110.   #average stress
  111.   #note: triax.stress(k) returns a stress vector, so we need to keep only the normal component
  112.   meanS=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3
  113.   print 'unbalanced force:',unb,' mean stress: ',meanS
  114. #  print 'void ratio=',triax.porosity/(1-triax.porosity), 'porosity=', triax.porosity
  115.   print 'mean stress engine', triax.meanStress, 'kineticE=', utils.kineticEnergy()
  116.   print '-----State_01: Isotropic compression 20kPa--(^_^)---'
  117.   if unb<stabilityThreshold and abs(meanS-table.isoForce)/table.isoForce<0.001:
  118.     break
  119.  
  120. O.save('confinedState'+key+'.xml') # remember this impotant part, will load is later
  121. print "##   Isotropic state saved (20 kPa)  ##"
  122. print 'current porosity=',triax.porosity
  123. print 'current void ratio=',triax.porosity/(1-triax.porosity)
  124.  
  125. ###### porosity reaching #####
  126. #import sys #this is only for the flush() below
  127. #while triax.porosity>targetPorosity:
  128. #   # we decrease friction value and apply it to all the bodies and contacts
  129. #   compFricDegree = 0.95*compFricDegree
  130. #   setContactFriction(radians(compFricDegree))
  131. #   print "\r Friction: ",compFricDegree," porosity:",triax.porosity,
  132. #   sys.stdout.flush()
  133. #   # while we run steps, triax will tend to grow particles as the packing
  134. #   # keeps shrinking as a consequence of decreasing friction. Consequently
  135. #   # porosity will decrease
  136. #   O.run(500,1)
  137.  
  138. #O.save('compactedState'+key+'.yade.gz')
  139. #print "###    Compacted state saved      ###"
  140.  
  141. ################################################################################
  142. # 2nd phase: Confining the specimen to desired value of stress of confinement,
  143. # reduce the cinetic energy
  144. # will implement in this state the code for generating the granulometric curve
  145. ################################################################################
  146.  
  147. while 1:
  148.   triax.internalCompaction=False
  149.   triax.stressMask=7
  150.   setContactFriction=radians(compFricDegree)
  151.   triax.goal1=table.conStress
  152.   triax.goal2=table.conStress
  153.   triax.goal3=table.conStress
  154.   O.run(1000, True)
  155.   #the global unbalanced force on dynamic bodies, thus excluding boundaries,
  156.   #which are not at equilibrium
  157.   unb=unbalancedForce()
  158.   #average stress
  159.   #note: triax.stress(k) returns a stress vector, so we need to keep only the normal component
  160.   meanS=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3
  161.   print 'unbalanced force:',unb,' mean stress: ',meanS
  162.   print 'void ratio=',triax.porosity/(1-triax.porosity), 'porosity=', triax.porosity
  163.   print 'mean stress engine', triax.meanStress, 'kineticE=', utils.kineticEnergy()
  164.   print '-----Current State_02: Compress 100kPa--v(-___-)v--'
  165.   if unb<stabilityThreshold and abs(meanS-table.conStress)/table.conStress<0.001:
  166.     break
  167.  
  168. O.save('compressState'+key+'.xml') # important, put to meromy this file to start the deviatoric loading later
  169.  
  170. print 'step that starts the deviatoric loading ', O.iter
  171. e22Check=triax.strain[1]
  172. # We will save a check point, to know that from this point the deviatoric loading process begins, so we know where to start the ploting shit
  173. from yade import plot
  174. from pprint import pprint
  175. plot.reset()
  176. plot.addData(CheckpointStep=O.iter,Porosity=triax.porosity,e11=triax.strain[0],e22=triax.strain[1],e33=triax.strain[2],elasticE=law.elasticEnergy(),kineticE=utils.kineticEnergy())
  177. plot.saveDataTxt('checkpoint.txt',vars=('CheckpointStep','Porosity','e11','e22','e33','elasticE','kineticE'))
  178.  
  179. ###############################################
  180. # 3rd phase: DEVIATORIC LOADING (BIG SHOW!!!) #
  181. ###############################################
  182.  
  183. #We move to deviatoric loading, let us turn internal compaction off to keep particles sizes constant
  184. triax.internalCompaction=False
  185.  
  186. # Change contact friction (remember that decreasing it would generate instantaneous instabilities)
  187. setContactFriction=radians(35)
  188. #TriaxialStateRecorder(iterPeriod=20,file='WallStresses_load_deviatoric'+key,addIterNum=True,initRun=True)
  189. while 1:
  190.     triax.stressMask=5
  191.     triax.goal2=-rate
  192.     triax.goal1=triax.goal3=table.conStress
  193.     O.run(100, True)
  194.     #the global unbalanced force on dynamic bodies, thus excluding boundaries, which are not at equilibrium
  195.     unb=unbalancedForce()
  196.     #note: triax.stress(k) returns a stress vector, so we need to keep only the normal component
  197.     axialS=triax.stress(triax.wall_top_id)[1]
  198.     print 'step=', O.iter, 'unbalanced force:',unb,' sigma2: ',axialS, 'q=', axialS-table.conStress
  199.     print 'axial deformation (%)', (triax.strain[1]-e22Check)*100
  200.     if abs((triax.strain[1]-e22Check)-0.01)<=0.001:
  201.         O.save('firstpoint.xml')
  202.     if abs((triax.strain[1]-e22Check)-0.02)<=0.001:
  203.         O.save('secondpoint.xml')
  204.     if abs((triax.strain[1]-e22Check)-0.03)<=0.001:
  205.         O.save('thirdpoint.xml')
  206.     if abs((triax.strain[1]-e22Check)-0.05)<=0.001:
  207.         O.save('fourthpoint.xml')
  208.     if triax.strain[1]-e22Check>=0.3 : #triax.sigma2
  209.         break
  210.  
  211. O.save('final.xml')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement