Question #688837 on Yade changed:
https://answers.launchpad.net/yade/+question/688837
Status: Open => Answered
Jan Stránský proposed the following answer:
> I am new to Yade and in the available documents there is not much
information about it.
Yade uses Python as an user interface. In python, you have access to almost any
data in the simulation (tutorial [1] and user's manual [2] is full of this).
So you have access to positions of all particles, then it is easy to check if
they are in a cylinder or not and sum mass of those which are. There are
several options e.g.
###
def isBodyInCylinder(body,center,radius):
d = body.state.pos - center # vector between cylinder center and particle
center
d[2] = 0 # only xy components are relevant
distance = d.norm() # horizontal distance
return distance < radius # particle is inside, if distance < raidus
def masses():
mass1 = mass2 = 0.0 # intially zero
center1 = Vector3(xp1,yp1,0) # center of 1st cylinder
center2 = Vector3(-xp2,yp2,0) # center of 2nd cylinder
for b in O.bodies: # test all particles
if not isinstance(b.shape,Sphere): continue # skip non-spherical
if isBodyInCylinder(b,center1,radius): # if a particle is inside 1st
cylinder ...
mass1 += b.state.mass # ... increase mass1 by the particle mass
if isBodyInCylinder(b,center2,radius): # if a particle is inside 2nd
cylinder ...
mass2 += b.state.mass # ... increase mass2 by the particle mass
return mass1,mass2 # return computed values
###
cheers
Jan
--
You received this question notification because your team yade-users is
an answer contact for Yade.
_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : [email protected]
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp