updating O.bodies

Asked by behzad

There's a problem in O,.bodies when we delete some particles during simulation. Or if we use replaceByClumps() (because in replaceByClumps also a ball is deleted and replaced by a clump).

In these case, if we then want to iterate over bodies we get an error because O.bodies() has not been updates and there're some ids with no physical body.

for example after using replaceByClumps(), I'd like to use calm() function in pyrunner as

def calm():
 for ii in range(1,(len(O.bodies)-1)):
   O.bodies[ii].state.vel=Vector3(0,0,0)

but the function crashes because some bodies are missing. This can be solved by:

1- if there's a function to check the existence of a body
2- if we can update O.bodies

Do you guys have any idea about this?

Thanks
Behzad

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
behzad
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hi Behzad,

In the loop, you can use a check

if not O.bodies[ii]: continue

or

b = O.bodies[ii]
if not b: continue

Or you can just simply use

for b in O.bodies:
   Whatever

It will skip non-existent bodies

Cheers
Jan

Dne 12.12.2014 21:01 "behzad" <email address hidden>
napsal(a):

> New question #258987 on Yade:
> https://answers.launchpad.net/yade/+question/258987
>
>
> There's a problem in O,.bodies when we delete some particles during
> simulation. Or if we use replaceByClumps() (because in replaceByClumps also
> a ball is deleted and replaced by a clump).
>
> In these case, if we then want to iterate over bodies we get an error
> because O.bodies() has not been updates and there're some ids with no
> physical body.
>
> for example after using replaceByClumps(), I'd like to use calm() function
> in pyrunner as
>
> def calm():
> for ii in range(1,(len(O.bodies)-1)):
> O.bodies[ii].state.vel=Vector3(0,0,0)
>
> but the function crashes because some bodies are missing. This can be
> solved by:
>
> 1- if there's a function to check the existence of a body
> 2- if we can update O.bodies
>
> Do you guys have any idea about this?
>
> Thanks
> Behzad
>
> --
> 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 address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
behzad (behzad-majidi) said :
#2

thank you, Jan

O.bodies problem is solved this way.
however, there is problem with calm() function. Although I call it at each time step by pyrunner it seems it's not able to reset the velocity of the balls.
I have created a orthogonal packing of spheres and so normally there shoulf not be overlaps.
But even if there are overlaps calm() is called at each time step. however, balls are having an explosive velocity. Any idea why tbis happen s?

thanks

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#3

Hi,

There is already a calm function in yade, that you can use:

https://yade-dem.org/doc/yade.utils.html?highlight=calm#yade._utils.calm

Regards,

Christian

Revision history for this message
behzad (behzad-majidi) said :
#4

Yes, I tried the built-in function. That's good.

However, in a regular packing we're supposed not to have overlaps!

Revision history for this message
Jan Stránský (honzik) said :
#5

There is probably some misconception in your script, could you send us a
minimal working example? As it is different topic, preferably in new
question/bug..
Cheers
Jan
 Dne 14.12.2014 4:56 "behzad" <email address hidden>
napsal(a):

> Question #258987 on Yade changed:
> https://answers.launchpad.net/yade/+question/258987
>
> behzad posted a new comment:
> Yes, I tried the built-in function. That's good.
>
> However, in a regular packing we're supposed not to have overlaps!
>
> --
> 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 address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
behzad (behzad-majidi) said :
#6

Hi,

I posted a new qustion "Overlaps in regular packings? and calm() function"

Thanks.