# How to insert spheres in two times

6 views
from woo.core import *
from woo.dem import *
from minieigen import *
import woo.models, woo

woo.master.usesApi=10102

S=woo.master.scene=Scene(fields=[DemField(gravity=(0,0,-10))])

# contact model plus material for particles
model=woo.models.ContactModelSelector(name='linear',damping=.4,mats=[FrictMat(young=1e7,ktDivKn=.2,tanPhi=.4)])
# same material for walls as for particles, but without friction
S.lab.wallMat=model.mats[0].deepcopy(tanPhi=0.)
# intial box size
box=AlignedBox3((0,0,0),(2,2,3))
subballast=AlignedBox3((0,0,0),(2,2,1.5))
ballast=AlignedBox3((0,0,1.5),(2,2,3))
#boxGeneration=AlignedBox3((0,0,1.5),(3,3,3))
# use something else than spheres here, if you like
gen=PsdSphereGenerator(psdPts=[(.1,0),(.1,.2),(.2,.9),(.3,1)])
ctrlStep=100

# wall box without the top (will be added later)

S.engines=DemField.minimalEngines(model=model)+[
# generate initial particles, until massRate cannot be achieved, then turn yourself off (dead)
# check what's happening periodically
PyRunner(ctrlStep,'checkProgress(S)')
]

S.lab.stage=0
# avoid warning when we change the value
S.lab._setWritable('stage')
# things that we want to look at during the simualtion
S.plot.plots={'dz':('Fz',)}

S.saveTmp()

# callback function from PyRunner
def checkProgress(S):
# if the top wall is there, save its position and acting force
# check progress
# if inlet is off and unbalanced force is already low, go ahead
if S.lab.stage==0 and S.lab.inlet.dead and woo.utils.unbalancedForce(S)<0.05:
S.lab.stage+=1
# find the topmost particle (only spheroids (i.e. Spheres, Ellipsoids, Capsules) have equivRadius)
# place Wall just above the top
S.lab.topWall=Wall.make(z0,axis=2,sense=-1,mat=S.lab.wallMat)
# save the initial z as reference
S.lab.z0=z0
# assign constant velocity to the wall
S.lab.topWall.vel=(0,0,-.05)
# when the wall goes down to z=1, make it move upwards again
elif S.lab.stage==1 and S.lab.topWall.pos[2]<1:
S.lab.stage+=1
S.lab.topWall.vel*=-1
# move until the initial position is reached again
elif S.lab.stage==2 and S.lab.topWall.pos[2]>S.lab.z0:
# everything done, nothing will happen with stage==3
S.lab.stage+=1
# stop the wall
S.lab.topWall.vel=(0,0,0)
# remove the wall
S.dem.par.remove(S.lab.topWall.id)
# find the topmost particle (only spheroids (i.e. Spheres, Ellipsoids, Capsules) have equivRadius)
# create the box
zBox=z0+0.25
S.lab.Box=woo.triangulated.box(dim=(.5,.5,.5),center=(1,1,zBox),which=(1,1,1,1,1,1),fixed=True,mat=S.lab.wallMat,wire=False)
S.lab.boxNode=Node(pos=(1,1,zBox),dem=ClumpData(blocked='xyzXYZ'))
# assign velocity to the box
S.lab.boxNode.dem.impose=HarmonicOscillation(freq=100.,amp=.02,dir=(0,0,1))



So... If you run this code, you'll a box with sphere generated and an axial compression after the forces are balanced.

Well, I need to generate the spheres in two times. But the way I did this code I don't know how to make it. I need to insert the spheres from 0 - 1.5 (subballast) and them make a compression on it, after that, insert the spheres from 1.5 - 3.0 (ballast) and them make a compression on it, after that I insert the other box upon the spheres, like it is writen there.

If you guys have any tips for me, please, feel free to help haha

FYI i'm a begginer on programing

commented 5 days ago by (44,890 points)

Hi Alan, I was away for a longer time, sorry for the delay. I need some clarification. You need to have 2-layer compact packing, with gravity compaction? Predefined thicknesses of the layer, or it is enough for you to have the ratio between them something given? Are they different material or do they differ in the PSD only? Thanks for clarifications, I will then look for the best way to do it. Cheers! Vaclav