yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #23380
Re: [Question #691171]: add uniform fibers to the cylinder-shape specimen
Question #691171 on Yade changed:
https://answers.launchpad.net/yade/+question/691171
Status: Open => Answered
Jan Stránský proposed the following answer:
Concerning random orientation, you can try the approach from [3]
###
def randomOrientation():
# from the source code of Quaternion::UnitRandom()
# https://eigen.tuxfamily.org/dox-devel/Quaternion_8h_source.html
from random import random as r
u1 = r()
u2 = r() * pi
u3 = r() * pi
a = sqrt(1 - u1)
b = sqrt(u1)
return Quaternion(a*sin(u2),a*cos(u2),b*sin(u3),b*cos(u3))
# test
O.bodies.append([box((0,0,0),(10,1,.1),orientation=randomOrientation()) for _ in range(50)])
O.step()
###
> i still wonder how same codes turn out to be "create some spheres,
meant to be actual spheres in simulation" and "create some spheres
("fibre-spheres"), meant just to reserve space for fibres (not added to
the simulation)"
this I did not get..
what is "same code"?
> ……and i need to calculate two mass of spheres and cylinders, how can i
distinguish them with codes.
spheres = [b for b in O.bodies if isisntance(b.shape,Sphere)]
massSpheres = sum(b.state.mass for b in spheres)
(facet)cylinders - depends if sum is needed etc..
You can also have the two lists directly from the code:
###
cyls = []
sphs = []
for i,(pos,radius) in enumerate(sp):
if i < nCyls: # add cylinder
cyl = geom.facetCylinder(...)
O.bodies.append(cyl)
cyls.append(cyl)
else: # add sphere
sph = sphere(pos,radius)
O.bodies.append(sph)
sphs.append(sph)
# do whetever with sphs and cyls lists
###
If you need specific masses for spheres and cylinders, you can modify the procedure a bit:
1) create spheres, add them to simulation, compute their mass if needed
2) create "fibre-spheres"
3) replace "fibre-spheres" by fibres one by one (also add them to simulation one by one). If the desired fibre mass matches desired value, stop replacing and adding fibres.
cheers
Jan
--
You received this question notification because your team yade-users is
an answer contact for Yade.