Advertisement
linkos

Kinetic Energy Asking

May 14th, 2013
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.04 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from yade import pack
  3.  
  4. ############################################
  5. ###   DEFINING VARIABLES AND MATERIALS   ###
  6. ############################################
  7.  
  8. # Batch execution
  9. nRead=utils.readParamsFromTable(
  10.     num_spheres=10000,# number of spheres len(O.bodies) to verify: 10006 = 10000 particles + 6 walls is correct
  11.     compFricDegree = 22, # contact friction
  12.     unknownOk=True,
  13.     isoForce=100000, # stress for the isotropic compression phase (1)
  14.     conStress=100000 # confinement stress, for the deviatoric loading session
  15. )
  16. from yade.params import table
  17.  
  18. num_spheres=table.num_spheres
  19. targetPorosity = 0.387 #the porosity we want for the packing (3 specimens: (Ei,n) = (1,0.382), (2,0.387), (3,0.409) )
  20. compFricDegree = table.compFricDegree   # initial contact friction during the confining phase (will be decreased during the REFD compaction process)
  21. finalFricDegree = 35 # contact friction during the deviatoric loading
  22. rate=0.1 # loading rate (strain rate)
  23. damp=0.06 # damping coefficient
  24. stabilityThreshold=0.001 # initial value: 0.001
  25. key='_triax_draine_e633_100kpa' # simulation's name here
  26. young=356e6 # contact stiffness k_n/<Ds>
  27. mn,mx=Vector3(-0.2,-0.2,-0.2),Vector3(0.2,0.2,0.2) # corners of the initial packing
  28. thick = 0.01 # thickness of the plates
  29.  
  30.  
  31. ## create materials for spheres and plates
  32. O.materials.append(FrictMat(young=young,poisson=0.42,frictionAngle=radians(compFricDegree),density=3000,label='spheres'))
  33. O.materials.append(FrictMat(young=young,poisson=0.5,frictionAngle=0,density=0,label='walls'))
  34.  
  35. ## create walls around the packing
  36. walls=utils.aabbWalls([mn,mx],thickness=thick,oversizeFactor=1.5,material='walls')
  37. wallIds=O.bodies.append(walls)
  38.  
  39. ## use a SpherePack object to generate a random loose particles packing
  40. sp=pack.SpherePack()
  41.  
  42. sp.makeCloud(mn,mx,0.005,0.7,num_spheres,False,0.8,seed=0) #"seed" make the "random" generation always the same
  43.  
  44. sp.toSimulation(material='spheres')
  45.  
  46. ############################
  47. ###   DEFINING ENGINES   ###
  48. ############################
  49.  
  50. triax=TriaxialStressController(
  51.     thickness = thick,
  52.     stressMask = 7,
  53.     radiusControlInterval=15,
  54.     goal1=table.isoForce,
  55.     goal2=table.isoForce,
  56.     goal3=table.isoForce,
  57.     max_vel=2, # validated only when internalCompaction = False length/time
  58.     internalCompaction=False, # If true the confining pressure is generated by growing particles
  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=100,file='WallStresses'+key),
  74.     newton
  75. ]
  76.  
  77. O.save('initial'+key+'.xml')
  78. #Display spheres with 2 colors for seeing rotations better
  79. Gl1_Sphere.stripes=1
  80. if nRead==0: yade.qt.Controller(), yade.qt.View()
  81. print 'Number of elements: ', len(O.bodies)
  82. #print 'Box Volume: ', triax.boxVolume
  83.  
  84. #######################################
  85. ###   APPLYING CONFINING PRESSURE   ###
  86. #######################################
  87.  
  88. while 1:
  89.   O.run(1000, True)
  90.   #the global unbalanced force on dynamic bodies, thus excluding boundaries, which are not at equilibrium
  91.   unb=unbalancedForce()
  92.   #average stress
  93.   #note: triax.stress(k) returns a stress vector, so we need to keep only the normal component
  94.   meanS=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3
  95.   print 'unbalanced force:',unb,' mean stress: ',meanS
  96.   print 'void ratio=',triax.porosity/(1-triax.porosity), 'porosity=', triax.porosity
  97.   print 'mean stress of engine', triax.meanStress
  98.   if unb<stabilityThreshold and abs(meanS-table.isoForce)/table.isoForce<0.001: #0.001
  99.     break
  100.  
  101. O.save('confinedState'+key+'.xml')
  102. print "###  Isotropic state saved  ###"
  103. print 'current porosity=',triax.porosity
  104. print 'current void ratio=',triax.porosity/(1-triax.porosity)
  105.  
  106.  
  107. print 'step that starts the deviatoric loading ', O.iter
  108.  
  109. from yade import plot
  110. from pprint import pprint
  111. plot.reset()
  112. e22Check=triax.strain[1]
  113. plot.addData(CheckpointStep=O.iter,Porosity=triax.porosity,e22=triax.strain[1])
  114. plot.saveDataTxt('checkpoint.txt',vars=('CheckpointStep','Porosity','e22'))
  115.  
  116. ##############################
  117. ###   DEVIATORIC LOADING   ###
  118. ##############################
  119.  
  120. # Change contact friction (remember that decreasing it would generate instantaneous instabilities)
  121. #setContactFriction(radians(finalFricDegree))
  122. setContactFriction(radians(35))
  123.  
  124. #set stress control on x and z, we will impose strain rate on y (5)
  125. triax.stressMask = 5
  126. #now goal2 is the target strain rate
  127. triax.goal2=-rate
  128. #we assign constant stress to the other directions
  129. triax.goal1=table.conStress
  130. triax.goal3=table.conStress
  131.  
  132. ##we can change damping here. What is the effect in your opinion?
  133. #newton.damping=0.1
  134.  
  135. ##Save temporary state in live memory. This state will be reloaded from the interface with the "reload" button.
  136. O.saveTmp()
  137.  
  138.  
  139. while (triax.strain[1]-e22Check) < 0.30: # stop condition: the simulation will stop at epsilon = 0.3
  140.   O.run(50); O.wait()
  141.  
  142. #from yade import plot
  143.  
  144. ### a function saving variables
  145. #def history():
  146. #   plot.addData(e11=triax.strain[0], e22=triax.strain[1], e33=triax.strain[2],
  147. #           ev=-triax.strain[0]-triax.strain[1]-triax.strain[2],
  148. #           s11=triax.stress(triax.wall_right_id)[0],
  149. #           s22=triax.stress(triax.wall_top_id)[1],
  150. #           s33=triax.stress(triax.wall_front_id)[2],
  151. #           p=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3000,
  152. #           q=(triax.stress(triax.wall_top_id)[1]-triax.stress(triax.wall_front_id)[2])/1000,
  153. #           i=O.iter)
  154.  
  155. #if 1:
  156. #  # include a periodic engine calling that function in the simulation loop
  157. #  O.engines=O.engines[0:5]+[PyRunner(iterPeriod=20,command='history()',label='recorder')]+O.engines[5:7]
  158. #  O.engines.insert(4,PyRunner(iterPeriod=20,command='history()',label='recorder'))
  159. #else:
  160. #  # With the line above, we are recording some variables twice. We could in fact replace the previous
  161. #  # TriaxialRecorder
  162. #  # by our periodic engine. Uncomment the following line:
  163. #  O.engines[4]=PyRunner(iterPeriod=20,command='history()',label='recorder')
  164.  
  165. #O.run(100,True)
  166.  
  167. #### declare what is to plot. "None" is for separating y and y2 axis
  168. ##plot.plots={'i':('e11','e22','e33',None,'s11','s22','s33')}
  169. #### the traditional triaxial curves would be more like this:
  170. #plot.plots={'e22':('q')}
  171.  
  172. ### display on the screen (doesn't work on VMware image it seems)
  173. #plot.plot()
  174.  
  175. ######  PLAY THE SIMULATION HERE WITH "PLAY" BUTTON OR WITH THE COMMAND O.run(N)  #####
  176.  
  177. ### In that case we can still save the data to a text file at the the end of the simulation, with:
  178. #plot.saveDataTxt('results'+key)
  179. ###or even generate a script for gnuplot. Open another terminal and type  "gnuplot plotScriptKEY.gnuplot:
  180. #plot.saveGnuplot('plotScript'+key)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement