Advertisement
linkos

stop condition asking

Mar 12th, 2013
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.14 KB | None | 0 0
  1.  
  2.  
  3. from yade import pack
  4.  
  5. # Data definition
  6.  
  7. nRead=utils.readParamsFromTable(
  8.     num_spheres=3000,# number of spheres
  9.     compFricDegree = 10, # contact friction during the confining phase
  10.     unknownOk=True,
  11.     isoForce=100000
  12. )
  13. from yade.params import table
  14.  
  15. num_spheres=table.num_spheres# number of spheres
  16. targetPorosity = 0.387 #the porosity we want for the packing
  17. compFricDegree = table.compFricDegree
  18. finalFricDegree = 35 # contact friction during the deviatoric loading
  19. rate=0.002 # loading rate (strain rate)
  20. damp=0.2 # damping coefficient
  21. stabilityThreshold=0.1 # 0.01
  22. key='_triax_draine_e618_100_psd' # put you simulation's name here
  23. young=356e6 # contact stiffness
  24. mn,mx=Vector3(-0.1,-0.1,-0.1),Vector3(0.1,0.1,0.1) # corners of the initial packing
  25. thick = 0.01 # thickness of the plates
  26.  
  27.  
  28. ## create materials for spheres and plates
  29. O.materials.append(FrictMat(young=young,poisson=0.42,frictionAngle=radians(compFricDegree),density=3000,label='spheres'))
  30. O.materials.append(FrictMat(young=young,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=1.5,material='walls')
  34. wallIds=O.bodies.append(walls)
  35.  
  36. ## use a SpherePack object to generate a random loose particles packing
  37. sp=pack.SpherePack()
  38. 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)
  39. psdCumm=[0.01,0.09,0.25,0.50,0.69,0.90,0.95,1.00] # for the code do not use percentage
  40.  
  41. sp.makeCloud(mn,mx,-1,0,num_spheres,False, 0.95,psdSizes,psdCumm,False,seed=1) #"seed" make the "random" generation always the same
  42.  
  43. sp.toSimulation(material='spheres')
  44.  
  45. # engine
  46.  
  47. triax=TriaxialStressController(
  48.     maxMultiplier=1.001, # spheres growing factor (fast growth)
  49.     finalMaxMultiplier=1.01, # spheres growing factor (slow growth)
  50.     thickness = thick,
  51.     stressMask = 7,
  52.     #the value of confining stress for the intitial (growth) phase
  53.     goal1=table.isoForce,
  54.     goal2=table.isoForce,
  55.     goal3=table.isoForce,
  56.     max_vel=0.05,
  57.     internalCompaction=True, # If true the confining pressure is generated by growing particles
  58. #   Key=key # passed to the engine so that the output file will have the correct name
  59. )
  60.  
  61. newton=NewtonIntegrator(damping=damp)
  62.  
  63. O.engines=[
  64.     ForceResetter(),
  65.     InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
  66.     InteractionLoop(
  67.         [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  68.         [Ip2_FrictMat_FrictMat_FrictPhys()],
  69.         [Law2_ScGeom_FrictPhys_CundallStrack()]
  70.     ),
  71.     GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=25,timestepSafetyCoefficient=0.8),
  72.     triax,
  73.     TriaxialStateRecorder(iterPeriod=50,file='WallStresses'+key),
  74.     newton
  75. ]
  76.  
  77.  
  78. # compaction
  79.  
  80. while 1:
  81.   O.run(1000, True)
  82.   unb=unbalancedForce()
  83.   meanS=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3
  84.   print 'unbalanced force:',unb,' mean stress: ',meanS, 'void ratio=', triax.porosity/(1-triax.porosity), 'porosity=', triax.porosity
  85.   if unb<stabilityThreshold and abs(meanS-table.isoForce)/table.isoForce<0.01: #0.001
  86.     break
  87.  
  88. O.save('confinedState'+key+'.yade.gz')
  89. print "###      Isotropic state saved      ###"
  90. print 'current porosity=',triax.porosity
  91. print 'current void ratio=',triax.porosity/(1-triax.porosity)
  92.  
  93. # porosity satisfy
  94.  
  95. import sys
  96. while triax.porosity>targetPorosity:
  97.     compFricDegree = 0.95*compFricDegree
  98.     setContactFriction(radians(compFricDegree))
  99.     print "\r Friction: ",compFricDegree," porosity:",triax.porosity,
  100.     sys.stdout.flush()
  101.     O.run(500,1)
  102.  
  103. O.save('compactedState'+key+'.yade.gz')
  104. print "###    Compacted state saved      ###"
  105. print 'current porosity=',triax.porosity
  106. print 'current void ratio=',triax.porosity/(1-triax.porosity)
  107.  
  108. # applying load
  109. triax.goal1=triaxgoal2=triax.goal3=100000
  110. triax.internalCompaction=False
  111. setContactFriction(radians(35))
  112. triax.stressMask = 5
  113. #strain rate
  114. triax.goal2=-rate
  115. #confinement stress
  116. triax.goal1=100000
  117. triax.goal3=100000
  118.  
  119. newton.damping=0.1
  120.  
  121. ##Save temporary state in live memory. This state will be reloaded from the interface with the "reload" button.
  122. O.saveTmp()
  123.  
  124. # PSD Plotter
  125.  
  126. #import matplotlib; matplotlib.rc('axes',grid=True)
  127. #from yade import pack
  128. #import pylab
  129. #pylab.plot(psdSizes,psdCumm,label='precribed mass PSD')
  130. #sp0=pack.SpherePack();
  131. #sp0.makeCloud(mn,mx,psdSizes=psdSizes,psdCumm=psdCumm,distributeMass=True)
  132. #sp1=pack.SpherePack();
  133. #sp1.makeCloud(mn,mx,psdSizes=psdSizes,psdCumm=psdCumm,distributeMass=True,num=10000)
  134. #sp2=pack.SpherePack();
  135. #sp2.makeCloud(mn,mx,psdSizes=psdSizes,psdCumm=psdCumm,distributeMass=True,num=20000)
  136. #pylab.semilogx(*sp0.psd(bins=30,mass=True),label='Mass PSD of (free) %d random spheres'%len(sp0))
  137. #pylab.semilogx(*sp1.psd(bins=30,mass=True),label='Mass PSD of (imposed) %d random spheres'%len(sp1))
  138. #pylab.semilogx(*sp2.psd(bins=30,mass=True),label='Mass PSD of (imposed) %d random spheres (scaled down)'%len(sp2))
  139.  
  140. #pylab.legend()
  141.  
  142. ## uniform distribution of size (sp3) and of mass (sp4)
  143. #sp3=pack.SpherePack(); sp3.makeCloud(mn,mx,rMean=0.005635,rRelFuzz=0,distributeMass=False);
  144. #sp4=pack.SpherePack(); sp4.makeCloud(mn,mx,rMean=0.005635,rRelFuzz=0,distributeMass=True);
  145. #pylab.figure()
  146. #pylab.plot(*(sp3.psd(mass=True)+('g',)+sp4.psd(mass=True)+('r',)))
  147. #pylab.legend(['Mass PSD of size-uniform distribution','Mass PSD of mass-uniform distribution'])
  148.  
  149. #pylab.figure()
  150. #pylab.plot(*(sp3.psd(mass=False)+('g',)+sp4.psd(mass=False)+('r',)))
  151. #pylab.legend(['Size PSD of size-uniform distribution','Size PSD of mass-uniform distribution'])
  152. #pylab.show()
  153.  
  154. #pylab.show()
  155.  
  156. # Plot
  157.  
  158. from yade import plot
  159.  
  160. ## a function saving variables
  161. def history():
  162.     plot.addData(e11=triax.strain[0], e22=triax.strain[1], e33=triax.strain[2],
  163.             ev=-triax.strain[0]-triax.strain[1]-triax.strain[2],
  164.             s11=triax.stress(triax.wall_right_id)[0],
  165.             s22=triax.stress(triax.wall_top_id)[1],
  166.             s33=triax.stress(triax.wall_front_id)[2],
  167.             p=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3000,
  168.             q=(triax.stress(triax.wall_top_id)[1]-triax.stress(triax.wall_front_id)[2])/1000,
  169.             i=O.iter)
  170.  
  171. if 1:
  172.   # include a periodic engine calling that function in the simulation loop
  173.   O.engines=O.engines[0:5]+[PyRunner(iterPeriod=20,command='history()',label='recorder')]+O.engines[5:7]
  174.   O.engines.insert(4,PyRunner(iterPeriod=20,command='history()',label='recorder'))
  175. else:
  176.   # With the line above, we are recording some variables twice. We could in fact replace the previous
  177.   # TriaxialRecorder
  178.   # by our periodic engine. Uncomment the following line:
  179.   O.engines[4]=PyRunner(iterPeriod=20,command='history()',label='recorder')
  180.  
  181. O.run(100,True)
  182.  
  183. ### declare what is to plot. "None" is for separating y and y2 axis
  184. #plot.plots={'i':('e11','e22','e33',None,'s11','s22','s33')}
  185. ### the traditional triaxial curves would be more like this:
  186. plot.plots={'e22':('q')}
  187.  
  188. ## display on the screen (doesn't work on VMware image it seems)
  189. plot.plot()
  190.  
  191. ##or even generate a script for gnuplot. Open another terminal and type  "gnuplot plotScriptKEY.gnuplot:
  192. plot.saveGnuplot('plotScript'+key)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement