← Back to team overview

yade-users team mailing list archive

Re: [Question #682883]: calculate mass content of a group of particles through something like label

 

Question #682883 on Yade changed:
https://answers.launchpad.net/yade/+question/682883

Leonard posted a new comment:
Hi xuesong,
Many thanks for your solution.
Your approach works very well, while one point should be noted that:
--->>The possible way i think is that using different lists to save the sphere's id of different groups and do loop in each list.
--->>## group 1 ##
--->>list1 = []
--->>list1.append(O.append(sphere((x1,y1,z1),radius=radius1)))
In this way, the list1 stores not the id of sphere, but the sphere body, so for the next code:
--->>## calculate the mass of different groups ##
--->>masstotal1 = 0
--->>for each in list1:
    --->>masstotal1 + = O.bodies[each].state.mass
May should be:
masstotal1 = 0
for each in list1:
    masstotal1 + = each.state.mass

Thanks again for your help, I just mention it more clearly for other
beginners.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.