← 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

    Status: Open => Answered

gaoxuesong proposed the following answer:
Hi,

    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)))
... 
## group 2 ## 
list2 = [] 
list2.append(O.append(sphere((x2,y2,z2),radius=radius2)))
... 
## calculate the mass of different groups ## 
masstotal1 = 0 
for each in list1:
    masstotal1 + = O.bodies[each].state.mass 
masstotal2 = 0 
for each in list2:
    masstotal2 + = O.bodies[each].state.mass 

## ends ##

Cheers, 
Xuesong

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