Question #706560 on Yade changed:
https://answers.launchpad.net/yade/+question/706560
Status: Answered => Open
Carine Tanissa is still having a problem:
Thanks,
For the cubePPscaled.py example where would i add O.bodies.erase(bodyID) to
remove bD once the particles are all deposited in the box?
I was adding O.bodies.erase(bD) after
def removeLid():
global lidID
if (O.bodies[lidID]):
O.bodies.erase(lidID)
but i am getting an error.
Can you please tell me where to incorporate it?
Thanks.
Here s the unedited code:
# -*- encoding=utf-8 -*-
# CWBoon 2015
from yade import pack
import math
# 7-15. The code block is trying to create a directory named "vtk" if it
doesn't exist already. This directory is used for storing VTK files.
import os
import errno
try:
os.mkdir('./vtk/')
except OSError as exc:
if exc.errno != errno.EEXIST:
raise
pass
#Enable the storage of potential particles in the simulation.
Gl1_PotentialParticle().store=True
O.engines=[
ForceResetter(),
InsertionSortCollider([PotentialParticle2AABB()],verletDist=0.01,
avoidSelfInteractionMask=2),
InteractionLoop(
[Ig2_PP_PP_ScGeom(twoDimension=False, unitWidth2D=1.0,
calContactArea=True, areaStep=5)],
[Ip2_FrictMat_FrictMat_KnKsPhys(kn_i=1e8, ks_i=1e7, Knormal =
1e8, Kshear = 1e7, useFaceProperties=False, viscousDamping=0.05)],
[Law2_SCG_KnKsPhys_KnKsLaw(label='law',neverErase=False)]
),
NewtonIntegrator(damping=0.0,exactAsphericalRot=True,gravity=[0,-9.81,0]),
PotentialParticleVTKRecorder(fileName='./vtk/cubePPscaled',label='vtkRecorder',twoDimension=False,iterPeriod=5000,sampleX=50,sampleY=50,sampleZ=50,maxDimension=0.2)
]
#Define the density of the powder material.
powderDensity = 2000
#Define the distance to the center for particles.
distanceToCentre= 0.5
# Define the mean size of particles.
meanSize = 1.
#Calculate the wall thickness based on the mean size.
wallThickness = 0.5*meanSize
#this material represents frictionless particles and sets some parameters such
as density.
O.materials.append(FrictMat(young=-1,poisson=-1,frictionAngle=radians(0.0),density=powderDensity,label='frictionless'))
#The normal and shear stifness values are determined in the IPhys functor,
thus the young, poisson parameters of the FrictMat are not used.
lengthOfBase = 9.0*meanSize
heightOfBase = 14.0*meanSize
# create empty sphere packing
# sphere packing is not equivalent to particles in simulation, it contains only
the pure geometry
sp=pack.SpherePack()
mn,mx=Vector3(-0.5*(lengthOfBase-wallThickness),0.5*meanSize,-0.5*(lengthOfBase-wallThickness)),Vector3(0.5*(lengthOfBase-wallThickness),7.0*heightOfBase,0.5*(lengthOfBase-wallThickness))
R=sqrt(3.0)*distanceToCentre
sp.makeCloud(mn,mx,R,0,100,False)
#initialize the counter variable
count= 0
#Calculate the radius of particles based on the mean size.
r=0.05*meanSize
for s in sp:
b=Body()
b.mask=1
b.aspherical=True
wire=False
color=Vector3(random.random(),random.random(),random.random())
highlight=False
b.shape=PotentialParticle(k=0.2, r=r, R=R, a=[1,-1,0,0,0,0],
b=[0,0,1,-1,0,0], c=[0,0,0,0,1,-1],
d=[distanceToCentre-r,distanceToCentre-r,distanceToCentre-r,distanceToCentre-r,distanceToCentre-r,distanceToCentre-r],
isBoundary=False, color=color, wire=wire, highlight=highlight,
minAabb=sqrt(3)*Vector3(distanceToCentre,distanceToCentre,distanceToCentre),
maxAabb=sqrt(3)*Vector3(distanceToCentre,distanceToCentre,distanceToCentre),
maxAabbRotated=1.02*Vector3(distanceToCentre,distanceToCentre,distanceToCentre),
minAabbRotated=1.02*Vector3(distanceToCentre,distanceToCentre,distanceToCentre),
AabbMinMax=True, id=count)
V=(2*distanceToCentre)**3 # (approximate) Volume of cuboid
geomInert=(1./6.)*V*(2*distanceToCentre)**2 # (approximate) Principal
inertia of cuboid to its centroid
utils._commonBodySetup(b, V, Vector3(geomInert,geomInert,geomInert),
material='frictionless', pos=[0,0,0], fixed=False)
b.state.pos = s[0] #s[0] stores center
b.state.ori =
Quaternion((random.random(),random.random(),random.random()),random.random())
#s[2]
O.bodies.append(b)
count=count+1
#Bottom faces of the box
r=0.1*wallThickness
bbb=Body()
bbb.mask=3
wire=False
color=[0,0.5,1]
highlight=False
bbb.shape=PotentialParticle(k=0.1, r=0.1*wallThickness,
R=0.2*lengthOfBase,a=[1,-1,0,0,0,0], b=[0,0,1,-1,0,0], c=[0,0,0,0,1,-1],
d=[lengthOfBase/6.0-r,lengthOfBase/6.0-r,0.5*wallThickness-r,0.5*wallThickness-r,lengthOfBase/6.0-r,lengthOfBase/6.0-r],
id=count,isBoundary=True,color=color,wire=wire,highlight=highlight,AabbMinMax=True,
minAabb=1.02*Vector3(lengthOfBase/6.0,0.5*wallThickness,lengthOfBase/6.0),maxAabb=1.02*Vector3(lengthOfBase/6.0,0.5*wallThickness,lengthOfBase/6.0),maxAabbRotated=1.02*Vector3(lengthOfBase/6.0,0.5*wallThickness,lengthOfBase/6.0),