Question #234676 on Yade changed: https://answers.launchpad.net/yade/+question/234676
Jan Stránský posted a new comment: Hello Alexander, > Yes my question was kind of 'useless'. What I am looking for is the > stress of each particle so I can map it against its position in 3D > space, to develop a 3d 'stress map' for various loads, ball size and > contact parameters. So it sounds like exactly what bodyStressTensors() > returns. But this function returns a tuple of length 1. > Normally the function should behave differently.. the function should return direcltly list of Matrix3. Don't you have some commas around the command? In such a case, stresses would really be tuple of size 1. Compare stresses1 = bodyStressTensors(), # comma at the end stresses2 = bodyStressTensors() # no comma print len(stresses1) # should be 1 (the tuple) print len(stresses2) # should be equal to len(O.bodies) > > I have since found my answer, it turns out it is my amateur python > skills that let me down. No problem, we all know that beginnings are tough, so in case of any questions (even the "useless" once), do not hesitate to ask :-) > The bodyStressTensors() module returns a tuple > of length 1, but that single entry is a list of the stress tensor for > each body (walls and facets included). > > i.e. > stress=utils.bodyStressTensors() > stress=stress[0] > > now 'stress' is a list of tensors (Matrix3) for each body. > see my comment above > > I assume now I can loop through O.bodies and match the list index number > of 'stress' to body id numbers to map the stress to the bodies position > in 3D space. > yes, now you can iterate over bodies stresses = bodyStressTensors() for b in O.bodies: stress = stresses[b.id] # now do whatever you want with the stress or you can access directly specific value stress = stresses[243] # stress of body with id 243 cheers Jan -- You received this question notification because you are a member of yade-users, which 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

