yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #23572
Re: [Question #691907]: How to calculate bond (interaction) breakage ratio
Question #691907 on Yade changed:
https://answers.launchpad.net/yade/+question/691907
Status: Open => Answered
Jan Stránský proposed the following answer:
Hello,
> for i in O.interactions:
> if i.isReal:
"if i.isReal" is not needed, as "i" is guaranteed to be real, because
"iteration silently skips interactions that are not real" [1]
an approach could be using Python sets [2] (efficient, elegant, ...):
###
iniIntrs = set((i.id1,i.id2) for i in O.interactions)
... # some running
curIntrs = set((i.id1,i.id2) for i in O.interactions)
brokenIntrs = iniIntrs - curIntrs
###
cheers
Jan
[1] https://yade-dem.org/doc/yade.wrapper.html#interactioncontainer
[2] https://docs.python.org/3/library/stdtypes.html#set-types-set-frozenset
--
You received this question notification because your team yade-users is
an answer contact for Yade.