Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.68 KB | None | 0 0
  1. ################################################################################
  2. #
  3. # Triaxial test. Axial strain rate is prescribed and transverse prestress.
  4. # Test is possible on prism or cylinder
  5. # An independent c++ engine may be created from this script in the future.
  6. #
  7. ################################################################################
  8. import os
  9. import sys
  10. #import cpler2 (mpi binding)
  11. from libyade import *
  12. #cpler2.cpl2.init() (init comm mpi)
  13. class Cplsim():
  14.   def __init__(self):
  15.    
  16.     concMat = O.materials.append(CpmMat(
  17.         young=20e9,frictionAngle=1.2,poisson=0.24,sigmaT=1.5e6,
  18.         epsCrackOnset=1e-04,relDuctility=30
  19.     ))
  20.     frictMat = O.materials.append(FrictMat(
  21.         young=20e9,poisson=0.24,frictionAngle=1.2
  22.     ))
  23.    
  24.     # spheres
  25.     height = 5e-3; width = 2e-3; rParticle = 0.075e-3; nw = 24; nh=15; bcCoeff=5; strainRate = -100
  26.     pred = pack.inCylinder((0,0,0),(0,0,height),.5*width)
  27.     sp=SpherePack()
  28.     sp = pack.randomDensePack(pred,spheresInCell=2000,radius=rParticle,memoizeDb='/tmp/triaxTestOnCylinder.sqlite',returnSpherePack=True)
  29.     spheres=sp.toSimulation(color=(0,1,1),material=concMat)
  30.     self.preStress = -3e6    
  31.     # bottom and top of specimen. Will have prescribed velocity
  32.     bot = [O.bodies[s] for s in spheres if O.bodies[s].state.pos[2]<rParticle*bcCoeff]
  33.     top = [O.bodies[s] for s in spheres if O.bodies[s].state.pos[2]>height-rParticle*bcCoeff]
  34.     vel = strainRate*(height-rParticle*2*bcCoeff)
  35.     for s in bot:
  36.         s.shape.color = (1,0,0)
  37.         s.state.blockedDOFs = 'xyzXYZ'
  38.         s.state.vel = (0,0,-vel)
  39.     for s in top:
  40.         s.shape.color = Vector3(0,1,0)
  41.         s.state.blockedDOFs = 'xyzXYZ'
  42.         s.state.vel = (0,0,vel)
  43.    
  44.     # facets
  45.     self.facets = []
  46.     rCyl2 = .5*width / cos(pi/float(nw))
  47.     for r in xrange(nw):
  48.         for h in xrange(nh):
  49.                 v1 = Vector3( rCyl2*cos(2*pi*(r+0)/float(nw)), rCyl2*sin(2*pi*(r+0)/float(nw)), height*(h+0)/float(nh) )
  50.                 v2 = Vector3( rCyl2*cos(2*pi*(r+1)/float(nw)), rCyl2*sin(2*pi*(r+1)/float(nw)), height*(h+0)/float(nh) )
  51.                 v3 = Vector3( rCyl2*cos(2*pi*(r+1)/float(nw)), rCyl2*sin(2*pi*(r+1)/float(nw)), height*(h+1)/float(nh) )
  52.                 v4 = Vector3( rCyl2*cos(2*pi*(r+0)/float(nw)), rCyl2*sin(2*pi*(r+0)/float(nw)), height*(h+1)/float(nh) )
  53.                 f1 = facet((v1,v2,v3),color=(0,0,1),material=frictMat)
  54.                 f2 = facet((v1,v3,v4),color=(0,0,1),material=frictMat)
  55.                 self.facets.extend((f1,f2))
  56.    
  57.     O.bodies.append(self.facets)
  58.     mass = O.bodies[0].state.mass
  59.     for f in self.facets:
  60.         f.state.mass = mass
  61.         f.state.blockedDOFs = 'XYZz'
  62.        
  63.        
  64.     O.dt=.5*utils.PWaveTimeStep()
  65.     enlargeFactor=1.5
  66.     O.engines=[
  67.         ForceResetter(),
  68.         InsertionSortCollider([
  69.             Bo1_Sphere_Aabb(aabbEnlargeFactor=enlargeFactor,label='bo1s'),
  70.             Bo1_Facet_Aabb()
  71.         ]),
  72.         InteractionLoop(
  73.             [
  74.                 Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=enlargeFactor,label='ss2d3dg'),
  75.                 Ig2_Facet_Sphere_ScGeom(),
  76.             ],
  77.             [
  78.                 Ip2_CpmMat_CpmMat_CpmPhys(cohesiveThresholdIter=O.iter+5),
  79.                 Ip2_FrictMat_CpmMat_FrictPhys(),
  80.                 Ip2_FrictMat_FrictMat_FrictPhys(),
  81.             ],
  82.             [
  83.                 Law2_ScGeom_CpmPhys_Cpm(),
  84.                 Law2_ScGeom_FrictPhys_CundallStrack(),
  85.             ],
  86.         ),
  87.         PyRunner(iterPeriod=1,command="sim1.addForces()"),
  88.         NewtonIntegrator(damping=.3),
  89.         CpmStateUpdater(iterPeriod=50,label='cpmStateUpdater'),
  90.         #PyRunner(command='plotAddData()',iterPeriod=10),
  91.         #PyRunner(iterPeriod=50,command='stopIfDamaged()'),
  92.     ]
  93.  
  94.   # run one step
  95.     O.step()
  96.  
  97.   # reset interaction detection enlargement
  98.     bo1s.aabbEnlargeFactor=ss2d3dg.interactionDetectionFactor=1.0
  99.    
  100.    
  101.   def addForces(self):
  102.         print "stp = ", O.iter
  103.     for f in O.bodies:
  104.         #n = f.shape.normal
  105.         #a = f.shape.area
  106.                 if type(f.shape)==Sphere:
  107.                  fluvel = Vector3(0.001,0.0,0.0) #some dummy variables to show performance loss
  108.                  bvel = f.state.vel#some dummy variables to show performance loss
  109.                  flurot = Vector3(0,0,0.005)#some dummy variables to show performance loss
  110.                  fx = 6*3.14*f.shape.radius*0.001*(fluvel-bvel) #some dummy variables to show performance loss
  111.                  mx = 8*3.14*(f.shape.radius**3)*(flurot-f.state.angVel)  #some dummy variables to show performance loss
  112.                  ### addforce
  113.          O.forces.addF(f.id,fx)  #if you add a constant force things run smmothly with max performance.
  114.                  O.forces.addT(f.id,mx)
  115.  
  116.  
  117.  
  118.   def irun(self,num):
  119.     print O.time
  120.     O.run(num,1)
  121.  
  122.  
  123. if __name__ == "__main__":
  124.   sim1 = Cplsim()
  125.   sim1.irun(5000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement