def SpherePack_toSimulation(self,scene,rot=Matrix3.Identity,**kw): ur"""Append spheres directly to the simulation. In addition calling :obj:`woo.dem.ParticleContainer.add`, this method also appropriately sets periodic cell information of the simulation. >>> from woo import pack; from math import *; from woo.dem import *; from woo.core import * >>> sp=pack.SpherePack() Create random periodic packing with 20 spheres: >>> sp.makeCloud((0,0,0),(5,5,5),rMean=.5,rRelFuzz=.5,periodic=True,num=20) 20 Virgin simulation is aperiodic: >>> scene=Scene(fields=[DemField()]) >>> scene.periodic False Add generated packing to the simulation, rotated by 45° along +z >>> sp.toSimulation(scene,rot=Quaternion((0,0,1),pi/4),color=0) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] Periodic properties are transferred to the simulation correctly, including rotation: >>> scene.periodic True >>> scene.cell.size Vector3(5,5,5) >>> scene.cell.hSize Matrix3(3.5355339059327373,-3.5355339059327378,0, 3.5355339059327378,3.5355339059327373,0, 0,0,5) The current state (even if rotated) is taken as mechanically undeformed, i.e. with identity transformation: >>> scene.cell.trsf Matrix3(1,0,0, 0,1,0, 0,0,1) :param Quaternion/Matrix3 rot: rotation of the packing, which will be applied on spheres and will be used to set :obj:`woo.core.Cell.trsf` as well. :param kw: passed to :obj:`woo.utils.sphere` :return: list of body ids added (like :obj:`woo.dem.ParticleContainer.add`) """ if isinstance(rot,Quaternion): rot=rot.toRotationMatrix() assert(isinstance(rot,Matrix3)) if self.cellSize!=Vector3.Zero: scene.periodic=True scene.cell.hSize=rot*Matrix3(self.cellSize[0],0,0, 0,self.cellSize[1],0, 0,0,self.cellSize[2]) scene.cell.trsf=Matrix3.Identity from woo.dem import DemField if not self.hasClumps(): if 'mat' not in kw.keys(): kw['mat']=utils.defaultMaterial() return scene.dem.par.add([woo.dem.Sphere.make(rot*c,r,**kw) for c,r in self]) else: standalone,clumps=self.getClumps() # add standalone ids=scene.dem.par.add([woo.dem.Sphere.make(rot*self[i][0],self[i][1],**kw) for i in standalone]) # add clumps clumpIds=[] for clump in clumps: clumpNode=scene.dem.par.addClumped([utils.sphere(rot*(self[i][0]),self[i][1],**kw) for i in clump]) # make all particles within one clump same color (as the first particle), # unless color was already user-specified clumpIds=[n.dem.parRef[0].id for n in clumpNode.dem.nodes] if not 'color' in kw: c0=clumpNode.dem.nodes[0].dem.parRef[0].shape.color for n in clumpNode.dem.nodes[1:]: n.dem.parRef[0].shape.color=c0 return ids+clumpIds
import sys sys.path.append('.') import clDem from minieigen import * from woo import utils m=utils.defaultMaterial() O.dem.par.append([ utils.wall((0,0,0),axis=2,material=m,fixed=True), utils.sphere((0,0,1.3),radius=1,material=m) ]) O.dem.par[-1].vel=(-1.,0,0) O.dem.par[-1].angVel=(0,1,0) # O.dem.par[-1].material.tanPhi=0. # no friction O.scene.dt=.003*utils.pWaveDt() O.scene.trackEnergy=True from woo.dem import * from woo.core import* O.scene.engines=[ #PyRunner('if len(O.dem.con)>0 and O.dem.con[0].real: O.pause()'), Gravity(gravity=(0,0,-10)), Leapfrog(damping=.05,reset=True), InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Wall_Aabb()]), ContactLoop([Cg2_Sphere_Sphere_L6Geom(),Cg2_Wall_Sphere_L6Geom()],[Cp2_FrictMat_FrictPhys()],[Law2_L6Geom_FrictPhys_IdealElPl()],applyForces=True), ] import woo.qt woo.qt.View() O.scene.clDev=(1,0) # intel sim=woo.cld.CLDemField.wooToClDem(O.scene,stepPeriod=1,relTol=-1)
import woo from woo.dem import * from woo.core import * from woo import * from woo import utils woo.master.usesApi=10101 S=woo.master.scene=Scene(fields=[DemField(gravity=(0,0,-10))]) m=utils.defaultMaterial() S.dem.par.add([ Facet.make([(0,0,0),(1,0,0),(0,1,0)],halfThick=0.3,mat=m), Sphere.make((.2,.2,1),.3,mat=m) ]) S.engines=DemField.minimalEngines(damping=.4) S.dtSafety=.1 S.saveTmp()