yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #18741
Re: [Question #677828]: creat many polyhedra in a box
Question #677828 on Yade changed:
https://answers.launchpad.net/yade/+question/677828
Status: Open => Answered
Jan Stránský proposed the following answer:
Hello,
> list = ...
although might work, I suggest not to use python built-in types (list,
tuple, set, int...) as variable names
1)
sp.makeCloud(...) modifies the 'sp' object. It returns number of created spheres, but the sp variable (SpherePack instance) is important for you.
2)
you create t=polyhedra only once, so O.bodies.append the same body object would be an error anyway
3)
> i want to creat many polyhedra in a box with same size
then do not use rRelFuzz for makeCloud (controls size distribution of created spheres)
4)
ployhedra_utils.polyhedra: if v parameter is used, size is ignored
a MWE:
###
from yade import pack, polyhedra_utils
polyMat = PolyhedraMat()
O.materials.append(polyMat)
sp=pack.SpherePack()
nSpheres=sp.makeCloud((0,0,0),(2,2,2),rMean=.1,periodic=True)
#replace the sphere with polyhedra
for center,radius in sp:
# note: new polyhedron for each cycle
t = polyhedra_utils.polyhedra(polyMat,(radius,radius,radius))
t.state.pos = center # sets polyhedron position according to sphere position
O.bodies.append(t)
###
cheers
Jan
--
You received this question notification because your team yade-users is
an answer contact for Yade.