linkos

[YADE] Cube sample generation

Oct 15th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.39 KB | None | 0 0
  1.   # -*- coding: utf-8 -*-
  2. from yade import pack
  3. from yade import utils
  4. import math
  5. import os
  6. #from utils import *
  7.  
  8. num_spheres= 10000
  9. mn,mx=Vector3(-0.1,-0.1,-0.1),Vector3(0.1,0.1,0.1) # Top a bottom point of the cube
  10. thick = 0.01
  11. compFricDegree = table.compFricDegree
  12. finalFricDegree=35
  13. #targetPorosity=0.382
  14. rate=0.01
  15. damp=0.06
  16. stabilityThreshold=1e-3 # leave it too low can have a super stable state, but will eat onion for waiting so long
  17.  
  18. key='_sample' # just used for adding name to the output, kind of boring
  19.  
  20. ## create material #0, which will be used as default
  21. O.materials.append(FrictMat(young=356e6,poisson=0.42,frictionAngle=radians(compFricDegree),density=3000,label='spheres')) # hat
  22. O.materials.append(FrictMat(young=356e6,poisson=0.5,frictionAngle=0,density=0,label='walls')) # boundary
  23.  
  24. ## create walls around the packing
  25. walls=utils.aabbWalls([mn,mx],thickness=thick,oversizeFactor=3,material='walls')
  26. wallIds=O.bodies.append(walls)
  27.  
  28. sp=pack.SpherePack()
  29. #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)
  30. #psdCumm=[0.01,0.09,0.25,0.50,0.69,0.90,0.95,1] # the correspondent amount (percentage) of each diameter
  31. #psdSizes,psdCumm=[0.001978,0.00218,0.00249,0.002744,0.002894,0.002999,0.003162,0.003305,0.003455,0.00358,0.003709,0.003911,0.004016,0.004273,0.004427,0.004669,0.004968,0.005193,0.005476,0.005826,0.006036,0.00631,0.006595,0.006833,0.007079,0.007335,0.007532,0.007943,0.008526,0.0092],[0.001,0.002,0.005,0.026385,0.047493,0.068602,0.092348,0.12372,0.150396,0.174142,0.200528,0.242744,0.261214,0.311346,0.356201,0.401055,0.469657,0.522427,0.583113,0.654354,0.71504,0.770449,0.823219,0.878628,0.926121,0.968338,0.98153,0.992084,0.997361,1]
  32. #---------------------------------------------
  33. #sp.makeCloud(mn,mx,-1,0,num_spheres,False, 0.95,psdSizes,psdCumm,False,seed=1)
  34. if num_spheres==1000:
  35.   sp.makeCloud(mn,mx,0.005,0.65,num_spheres,False,0.8,seed=1) #initial 0.001 for 1000 particle use 0.005
  36. elif num_spheres==10000:
  37.   sp.makeCloud(mn,mx,0.001,0.65,num_spheres,False,0.8,seed=1)
  38.   #sp.makeCloud(mn,mx,-1,0,-1,False, 0.95,psdSizes,psdCumm,False,seed=1)
  39. sp.toSimulation(material='spheres')
  40.  
  41. volume = (mx[0]-mn[0])*(mx[1]-mn[1])*(mx[2]-mn[2])
  42. mean_rad = pow(0.09*volume/num_spheres,0.3333)
  43.  
  44. #clumps=False
  45. #if clumps:
  46. #   c1=pack.SpherePack([((-0.2*mean_rad,0,0),0.5*mean_rad),((0.2*mean_rad,0,0),0.5*mean_rad)])
  47. #   sp.makeClumpCloud((-0.24,0.24,-0.24),(0.24,0.24,0.24),[c1],periodic=False)
  48. #   O.bodies.append([utils.sphere(center,rad,material='spheres') for center,rad in sp])
  49. #   standalone,clumps=sp.getClumps()
  50. #   for clump in clumps:
  51. #       O.bodies.clump(clump)
  52. #       for i in clump[1:]: O.bodies[i].shape.color=O.bodies[clump[0]].shape.color
  53. #   #sp.toSimulation()
  54. #else:
  55. #   O.bodies.append([utils.sphere(center,rad,material='spheres') for center,rad in sp])
  56.  
  57. O.dt=.5*utils.PWaveTimeStep() # initial timestep, to not explode right away
  58. O.usesTimeStepper=True
  59.  
  60. triax=TriaxialStressController(
  61.     maxMultiplier=1.001,
  62.     finalMaxMultiplier=1.0001,
  63.     thickness = thick,
  64.     radiusControlInterval=10
  65. #   stressMask = 7,
  66. #   max_vel=0.01,
  67. #   strainDamping=0.99, #0.99
  68. #   stressDamping=0.25
  69. )
  70.  
  71. newton=NewtonIntegrator(damping=damp)
  72.  
  73. O.engines=[
  74.     ForceResetter(),
  75.     InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()],verletDist=-mean_rad*0.06),
  76.     InteractionLoop(
  77.         [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  78.         [Ip2_FrictMat_FrictMat_FrictPhys()],
  79.         [Law2_ScGeom_FrictPhys_CundallStrack(label='law')]
  80.     ),
  81.     GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8, defaultDt=4*utils.PWaveTimeStep()),
  82.     triax,
  83.     TriaxialStateRecorder(iterPeriod=50,file='WallStresses'+key,addIterNum=False,initRun=False),
  84.     newton
  85. ] #timestep update interval is 100 by default
  86.  
  87. #O.save('initial'+key+'.xml')
  88. #Display spheres with 2 colors for seeing rotations better
  89. #Gl1_Sphere.stripes=0
  90. #if nRead==0: yade.qt.Controller(), yade.qt.View()
  91. print 'Number of elements: ', len(O.bodies)
  92. print 'Box Volume: ',  triax.boxVolume
  93. print 'Box Volume calculated: ', volume
  94. #Display spheres with 2 colors for seeing rotations better
  95. Gl1_Sphere.stripes=1
  96. #yade.qt.Controller(), yade.qt.View()
  97.  
  98. #########################################
  99. # Phase 1: ISOTROPIC GENERATOR OF 20kPa #
  100. #########################################
  101. while 1:
  102.   triax.internalCompaction=True # Growing the particles is what we use in this step
  103.   setContactFriction(radians(compFricDegree))
  104.   triax.stressmask=7
  105.   triax.goal1=10000
  106.   triax.goal2=10000
  107.   triax.goal3=10000
  108.   O.run(10,True)
  109.   #the global unbalanced force on dynamic bodies, thus excluding boundaries, which are not at equilibrium
  110.   unb=unbalancedForce()
  111.   meanS=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3
  112.   print 'unbalanced force:',unb,' mean stress: ',meanS
  113. #  print 'void ratio=',triax.porosity/(1-triax.porosity), 'porosity=', triax.porosity
  114.   print 'mean stress engine', triax.meanStress, 'kineticE=', utils.kineticEnergy()
  115.   print '-----State_01: Isotropic compression 10kPa-----'
  116.   if unb<stabilityThreshold and abs(meanS-table.isoForce)/table.isoForce<0.001:
  117.     break
  118.  
  119. O.save('confinedState20'+key+'.xml') # remember this impotant part, will load is later
  120. print "##   Isotropic state saved (20 kPa)  ##"
  121. print 'current porosity=',triax.porosity
  122. print 'current void ratio=',triax.porosity/(1-triax.porosity)
Advertisement
Add Comment
Please, Sign In to add comment