← Back to team overview

yade-users team mailing list archive

Re: [Question #251510]: Loop - array -->Find out the strength needed to move each particle

 

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

Jan Stránský proposed the following answer:
Hi Laura,


>
> I tried your suggestion and now I have a new error:
>
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call last)
> /usr/bin/yadedaily in <module>()
>
> /usr/bin/yadedaily in identificacion()
>     226                 Xforce=0
>     227                 O.forces.addF(id_piedra,(fuerzax,fuerzay,fuerzaz))
> --> 228                 if id_clump.state.displ()[0]>0:
>     229                         value=Xforce/array1[xx][2]
>     230                         value2=2*value*array1[xx][3]*array1[xx][3]
>
> AttributeError: 'int' object has no attribute 'state'
> ---------------------------------------------------------------------------
>
>
The problem is, as the error message says, that you have id_clump, id of a
body, i.e. int value, and you want to access its state, which can't work.
You need actual body (not id) to access its state.

I would suggest to return to your original version, but rename id_clump
(since it is not ID and thus is confusing) to e.g. clump. On the next line
you can define
id_clump=clump.id

So you have both body instance and its id and use them in correct
positions, e.g. accessing state.displ() on clump (clump.state.displ()) and
using id in addForce (O.forces.addF(id_clump,force))

I will try to read your explanation later when I have time :-)

cheers
Jan

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.