Fixing spheres

Asked by mohsen

In the name of God

I want to fixed rotation and position of moving spheres.
 what i do is:

for b in O.bodies:
    if isinstance(b.shape,Sphere):
        b.state.blockedDOFs='xyzXYZ'
        b.vel=(0,0,0);b.angVel=(0,0,0)

But these bodies again move due to new interactions! I expected they should be fixed!

Any idea?!

Thanks
Mohsen

Question information

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

b.state.vel instead of b.vel, same for angVel
Jan

Revision history for this message
mohsen (agha-mohsena) said :
#2

Thanks Jan!

But again the spheres move after this commands!

BWT, why the YADE did not show any error due to b.vel ?!!

Thanks

Revision history for this message
mohsen (agha-mohsena) said :
#3

Also i tried :

b.dynamic=False

but again the same problem!

Revision history for this message
mohsen (agha-mohsena) said :
#4

Oh! It is now working!

the right command was:
for b in O.bodies:
    if isinstance(b.shape,Clump):
        b.state.blockedDOFs='xyzXYZ'
        b.vel=(0,0,0);b.angVel=(0,0,0)

Thanks Jan

Revision history for this message
mohsen (agha-mohsena) said :
#5

Thanks Jan Stránský, that solved my question.

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

Hi Mihsen,

> if isinstance(b.shape,Clump):

yes, I guess this condition could be important :-) next time, please post complete code, this could have been guessed directly from it

> BWT, why the YADE did not show any error due to b.vel ?!!

Becasue in Python, Body is (almost) just a Python object (instance of a class), so you can assign not reserved names. Actually it can be a nice feature, you can e.g. label particles which macrograin they belongs to, like in [1], Body.agglomerate is id of a macro grain.

just some playing:

in Python:
###
class A:
   def __init__(self,a):
      self.a=a
a = A(2)
print a.a # sbould be 2
a.a = "hello"
print a.a # sbould be "hello"
a.whatever = 123 # valid assignment of new "whatever" member
###

the same with Body:
###
b.vel = "aaa" # valid, since Body.vel is nothing yet
b.state.vel = "aaa" # error, because state.vel is defined in c++ and should be Vector3
###

cheers
Jan

[1] https://github.com/yade/trunk/tree/master/examples/agglomerate

Revision history for this message
mohsen (agha-mohsena) said :
#7

Again thanks Jan for your interesting discussion

Mohsen