Advertisement
nicogodet

Untitled

Jun 29th, 2018
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.99 KB | None | 0 0
  1. ########################################## encoding: utf-8 #######################################
  2. #-*- coding: utf-8 -*-
  3. from yade import plot,qt
  4. from yade.gridpfacet import *
  5. import math
  6.  
  7. O.dt = 0.0000001
  8.  
  9. Rad = 0.1
  10. Factor=1.5
  11. m_viscosity=3
  12. m_roughness=0.02
  13.  
  14. ###############################################################################################
  15. ############################################# Mask ############################################
  16. ###############################################################################################
  17. # mask avec un 1 en commun se voient
  18.  
  19. # 1 -> 0b001 -> Reste - Manilles
  20. # 2 -> 0b010 ->
  21. # 3 -> 0b011 -> Manilles et cable - facets bloc
  22. # 4 -> 0b100 ->
  23. # 5 -> 0b101 ->
  24. # 6 -> 0b110 ->
  25.  
  26.  
  27. # 4 -> 0b100 -> Avoidintaraction -> les objets dans les masks qui ont un 1 en commun ne se voient pas à l'intérieur du mask
  28.  
  29. MaskCyl = 3
  30. MaskCollider = 2
  31.  
  32. E1_1 = 500e6
  33. E2_1 = 1460e6
  34. Ef_1 = 5869.565e6
  35. Defini_1 = 0.0001
  36. Def1_1 = 0.060
  37. Def2_1 = 0.015+Def1_1
  38. Deff_1 = 0.041+Def2_1
  39. SSVal_Simple=[(Defini_1,2*Defini_1*Ef_1),(Def1_1,Def1_1*E1_1),(Def2_1,Def2_1*E2_1),(Deff_1,2*Deff_1*Ef_1)]#[(0.0001,5.09e6),(0.030,50e6),(0.043,155e6),(0.067,1250e6)]
  40.  
  41. O.materials.append( WireMat( young=5e9,poisson=0.3,frictionAngle=radians(10),density=7850,diameter=2*0.006,isDoubleTwist=False,label='gridNodeNetPackSimple',strainStressValues=SSVal_Simple) ) # Material to create the GridNode
  42.  
  43. O.materials.append(
  44.         FrictMat(
  45.             density=2600,
  46.             frictionAngle=math.radians(35.),
  47.             poisson=0.5,
  48.             young=1e8*Rad,
  49.             label='Frict'
  50.         ))
  51. diameterPart=Rad*2
  52. young=1e8
  53. poisson=0.3
  54. kn=young*(diameterPart/2)
  55. ks=kn*poisson
  56. en=0.1      # Restitution coeff in normal direction
  57. es=1.0      # Restitution coeff in tangential direction
  58. damp=0.00
  59. sphFricAng=40
  60. sphVol=4*(math.pi/3)*pow((diameterPart/2),3)
  61. cn=sqrt((pow(math.log(en),2)*2*kn*sphVol*2000)/(pow(math.pi,2)+pow(math.log(en),2)))
  62. cs=0
  63.  
  64.  
  65. material='Frict'
  66. #S1 = O.bodies.append(sphere(center=[0,0,0],radius=Rad,material=material,fixed=True))
  67. S2 = O.bodies.append(sphere(center=[0,0,Factor*2.1*Rad],radius=Rad,material=material,fixed=False))
  68. Stest = O.bodies.append(sphere(center=[0,0,3*Factor*2.1*Rad],radius=Rad,material=material,fixed=False))
  69. #S3 = O.bodies.append(sphere(center=[0,((Factor+0.05)*2*Rad),0],radius=Rad,material=material,fixed=False))
  70. #S4 = O.bodies.append(sphere(center=[0,0,-((Factor+0.05)*2*Rad)],radius=Rad,material=material,fixed=False))
  71. #W1 = O.bodies.append(aabbWalls([(-1,-1,0),(1,1,0)],thickness=0.1,material=material,oversizeFactor=1.0))
  72. #for i in W1[:-1]:
  73. #        O.bodies.erase(i)
  74. G1 = O.bodies.append(gridNode([0,0,0],radius = Rad/4.,material='gridNodeNetPackSimple',fixed=True))
  75. G2 = O.bodies.append(gridNode([+3*Rad,0,0],radius = Rad/4.,material='gridNodeNetPackSimple',fixed=True))
  76. G3 = O.bodies.append(gridNode([+1.5*Rad,-1.5*Rad,0],radius = Rad/4.,material='gridNodeNetPackSimple',fixed=True))
  77. C1 = O.bodies.append(gridConnection(G1,G2,radius = Rad/4.,material=material, mask = MaskCyl))
  78. C2 = O.bodies.append(gridConnection(G2,G3,radius = Rad/4.,material=material, mask = MaskCyl))
  79. C3 = O.bodies.append(gridConnection(G1,G3,radius = Rad/4.,material=material, mask = MaskCyl))
  80. #O.bodies[S1].state.blockedDOFs='xyzXYZ'
  81. #O.bodies[S2].state.blockedDOFs='xyzXYZ'
  82.  
  83. O.bodies[S2].state.vel[2]=-3.
  84. O.bodies[Stest].state.vel[2]=-10.
  85. #O.bodies[S3].state.vel[1]=-5.
  86. #O.bodies[S4].state.vel[2]=5.
  87.  
  88. #O.bodies[S2].state.blockedDOFs='Z'
  89.  
  90.  
  91. theta_method= 0.55  #1 : Euler Backward, 0.5 : trapezoidal rule, 0 : not used, 0.55 : suggested optimum
  92. resolution=1        #Change normal component resolution method, 0: Iterative exact resolution (theta method, linear contact), 1: Newton-Rafson dimentionless resolution (theta method, linear contact), 2: Newton-Rafson with nonlinear surface deflection (Hertzian-like contact)
  93. O.engines=[
  94.     ForceResetter(),
  95.     InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=Factor, label="aabb"),Bo1_Wall_Aabb(),Bo1_Box_Aabb(),Bo1_GridConnection_Aabb()],verletDist=-0.1,allowBiggerThanPeriod=False),
  96.     InteractionLoop(
  97.         [Ig2_Sphere_Sphere_ScGeom6D(interactionDetectionFactor=Factor,label="Ig2"),
  98.          Ig2_Box_Sphere_ScGeom6D(),
  99.          Ig2_GridNode_GridNode_GridNodeGeom6D(),
  100.          Ig2_Sphere_GridConnection_ScGridCoGeom()],
  101.        
  102.         [Ip2_FrictMat_FrictMat_FrictPhys(),
  103.          Ip2_WireMat_WireMat_WirePhys(),
  104.         Ip2_FrictMat_FrictMat_LubricationPhys(eta=m_viscosity,eps=m_roughness),
  105.          
  106.         ],
  107.        
  108.         [Law2_ScGeom_ImplicitLubricationPhys(activateNormalLubrication=True,
  109.                                              activateTangencialLubrication=True,
  110.                                              activateTwistLubrication=False,
  111.                                              activateRollLubrication=False,
  112.                                              theta=theta_method,
  113.                                              resolution=resolution,
  114.                                              warnedOnce=True,
  115.                                              maxSubSteps=20,
  116.                                              debug=False,),
  117.             Law2_ScGeom_WirePhys_WirePM(),
  118.          Law2_ScGeom_FrictPhys_CundallStrack(),
  119.         ]
  120.     ),
  121.     NewtonIntegrator(damping=0.,gravity=[0,0,-9.81]),
  122.     PyRunner(command='addPlotData()',iterPeriod=100),
  123. #   PyRunner(command='maf()',iterPeriod=100),
  124.     #PyRunner(command='print(maxFnL, O.bodies[S2].state.vel[2])',iterPeriod=100000)
  125. ]
  126. collider.avoidSelfInteractionMask = MaskCollider
  127. #def maf():
  128. #   if (O.bodies[S2].state.pos[2]-O.bodies[S1].state.pos[2])<2*Rad+0.02:
  129. #       O.bodies[S2].state.vel[2]=0.
  130. #       O.bodies[S2].state.blockedDOFs='xyzXYZ'
  131.  
  132. #maxFnL=0.
  133. #Ekin=0.5*O.bodies[S2].state.mass*O.bodies[S2].state.vel.norm()**2
  134. #Epot=O.bodies[S2].state.mass*9.81*(O.bodies[S2].state.pos[2]-O.bodies[S1].state.pos[2])
  135. #Etot=Ekin+Epot
  136. def addPlotData():
  137.     global maxFnL,Etot,Ekin,Epot
  138.     try:
  139.         Fnc = O.interactions[0,1].phys.normalContactForce[2]
  140.         FnL = O.interactions[0,1].phys.normalLubricationForce[2]
  141.         maxFnL=max(maxFnL,FnL)      
  142.     except:
  143.         Fnc=0
  144.         FnL=0
  145.     try:
  146.         O.interactions[0,1].isActive
  147.         active=1
  148.     except:
  149.         active=0
  150.     Ekin=0.5*O.bodies[S2].state.mass*O.bodies[S2].state.vel.norm()**2
  151.     Epot=O.bodies[S2].state.mass*9.81*(O.bodies[S2].state.pos[2]-O.bodies[Stest].state.pos[2])
  152.     Etot=Ekin+Epot
  153.     if (O.bodies[S2].state.pos[2]-O.bodies[Stest].state.pos[2]-2*Rad)<0:
  154.         pene=O.bodies[S2].state.pos[2]-O.bodies[Stest].state.pos[2]-2*Rad
  155.     else:
  156.         pene=0
  157.        
  158.  
  159.     delta = (O.bodies[S2].state.pos[2]-O.bodies[Stest].state.pos[2])-(2*Factor*Rad)
  160.     deltaDot = O.bodies[S2].state.vel[2] - O.bodies[Stest].state.vel[2]
  161.     plot.addData(delta=delta, time1=O.time, time2=O.time, time3=O.time, time4=O.time,Fnc = Fnc,FnL = FnL,deltaDot = deltaDot,active=active,Ekin=Ekin,Epot=Epot,Etot=Etot,pene=pene)
  162.  
  163. addPlotData()
  164. plot.plots={'time1':('delta',None,'active'), 'time2':('deltaDot'), 'time3':('Fnc',None,('FnL','g')), 'time4':('pene')}
  165. #plot.plots={'time4':('Fnc',None,('FnL','g')),'time1':'active'};
  166. plot.plot(subPlots=True)
  167. def stopMe():
  168.     if O.iter>10000 and O.bodies[S2].state.pos[2]>((Factor+0.05)*2*Rad):
  169.         O.pause()
  170.         plot.saveGnuplot('graphs/'+O.bodies[S1].material.label+'Lubrication_visco'+str(m_viscosity)+'_rought'+str(m_roughness),term='png',extension='png')
  171.  
  172. qt.View()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement