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

Jan Stránský proposed the following answer:
Hi Varun,
sorry, I was just stupid, after O.step() the interactions are there :-)

adding following functions at the end of the script (after O.step() )
should do what you want. You can use it also during simulation. Note that
this approach is probably not very efficient, but should work. In case the
inefficiency is too much, a more sophisticated graph theory should give
better answer.

In my case, I got several "aggregates" composed of 4 particles, but always
only 3 of them were connected by cohesively and one was standalone, which
corresponded to the result of aggregs() function.

cheers
Jan

PS: used approach is a nice exercise of recursive function call :-)

#########################################
def addBodyToAggreg(body,aggreg): # auxiliary function, add body [yade.Body
instance] and all its neighbors into aggreg (python set instance)
if body.id in aggreg: # do nothing if b is already in aggreg ...
return
aggreg.add(body.id) # ... otherwise add it to aggreg
intrs = body.intrs()
for i in intrs: # and add also all its neighbors ...
if not isinstance(i.phys,CohFrictPhys): # ... but only that connected with
CohFrictPhys interactions
continue
if i.phys.cohesionBroken: # ... but only not yet broken
continue
i2 = i.id1 if i.id2==body.id else i.id2 # choose the other body of
interaction
b2 = O.bodies[i2]
addBodyToAggreg(b2,aggreg) # and add it and all its neighbors to aggreg

def aggregs(): # actual function to detect standalone aggregates
ids = set(b.id for b in O.bodies if isinstance(b.shape,Sphere)) # first
make a set of all spheres ids
ret = []
while len(ids)>0: # while there are still some particles not assigned to
any aggregate ...
i = ids.pop() # ... choose one random ...
b = O.bodies[i]
a = set() # ... create new aggregate (set of sphere ids)
addBodyToAggreg(b,a) # ... and add the sphere together with all its
neigbors to aggregate
for bid in a: # delete all used ids from ids
ids.discard(bid)
ret.append(a)
return ret

aggs = aggregs()
for a in aggs:
print a
#########################################


2016-05-02 18:27 GMT+02:00 VG <question292...@answers.launchpad.net>:

> Question #292911 on Yade changed:
> https://answers.launchpad.net/yade/+question/292911
>
> VG posted a new comment:
> Hello Jan,
>
> I have defined sample_material as CohFrictMat and also using
>
> Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,label="cohesiveIp")
> in the interaction loop. I am not sure what am I missing here. Could you
> please help me identify the problem in my model set up.
>
> Thanks
> Varun
>
> --
> 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     : yade-users@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~yade-users
> More help   : https://help.launchpad.net/ListHelp
>

-- 
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     : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to