the output of resultant forces and moments of all bodies

Asked by Fu zuoguang

Dear Prof. Chareyre and all users,

In a special state, the results of resultant forces and moments
of all bodies in simulation need to be output as well as those of
all contacts. But now I failed to do this with the classes of
'ForceRecorder' and 'TorqueRecorder' in the following style:

for b in O.bodies:
    O.engines.Recorder.ForceRecorder[body_id = b].totalForce
    O.engines.Recorder.TorqueRecorder[body_id = b].totalTorque

My questions are that

(1) Do I get the right classes for my purpose ?
(2) If yes, how to access the classes of 'ForceRecorder' and 'TorqueRecorder'
from 'O.engines' (the above sentences exsit errors) with the given body_id ?

Best regards
Zuoguang Fu

Question information

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

Hello Fu,

whenever you get an error, please input it to the question. Also try to
understand it. I guess, that there another problem than body_id:

1) ...[body_id=b] is not valid Python syntax
2) O.engines is list, so O.engines.Recorder makes no sense..

cheers
Jan

2015-06-23 6:11 GMT+02:00 Fu zuoguang <email address hidden>
:

> Question #268448 on Yade changed:
> https://answers.launchpad.net/yade/+question/268448
>
> Description changed to:
> Dear Prof. Chareyre and all users,
>
> In a special state, the results of resultant forces and moments
> of all bodies in simulation need to be output as well as those of
> all contacts. But now I failed to do this with the classes of
> 'ForceRecorder' and 'TorqueRecorder' in the following style:
>
> for b in O.bodies:
> O.engines.Recorder.ForceRecorder[body_id = b].totalForce
> O.engines.Recorder.TorqueRecorder[body_id = b].totalTorque
>
> My questions are that
>
> (1) Do I get the right classes for my purpose ?
> (2) If yes, how to access the classes of 'ForceRecorder' and
> 'TorqueRecorder'
> from 'O.engines' (the above sentences exsit errors) with the given body_id
> ?
>
> Best regards
> Zuoguang Fu
>
> --
> 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
Fu zuoguang (zgfu1985) said :
#2

Dear Jan Stránský and all users,

I am sorry for giving you an ambiguous description of my purpose.

###################################

for b in O.bodies:
    O.engines.Recorder.ForceRecorder[body_id = b].totalForce
    O.engines.Recorder.TorqueRecorder[body_id = b].totalTorque

###################################

The codes that I provided yesterday are not the true python codes but
the pseudo codes that just helps me express logically my desirability.
Of course, These sentences should not be validated by python.(exsit errors)
But they are not very clear for understanding. I improved them as that

###################################
for b in len(O.bodies):
    Engine.GlobalEngine.PeriodicEngine.Recorder.ForceRecorder[body_id = b].totalForce
    Engine.GlobalEngine.PeriodicEngine.Recorder.ForceRecorder[body_id = b].totalTorque
###################################

These codes mean that

(1) b now presents the id of each body(wall and sphere);

(2) the inheritance relationship from totalForce or totalTorque to Engine is expressed
as classes-like format;

(3) all the bodies results should be output while in each loop, only one body
is treated by inputting its id.

The ture python codes are that

####################################

O.engines = [
    ForceResetter (),
    InsertionSortCollider (),
    InteractionLoop (),
    consolidation, # my own loading mode
    NewtonIntegrator (),
    ForceRecorder (
        file = 'force-recorder.csv',
        ids = [id_list], # sphere ids
        iterPeriod = 50 )]

#####################################

Now these codes can be validated successfully in Yade but
only for outputting the resultant force composed by all
members in [id_list].

Are there some methods for outputting the resultant force of
each one member in that list in each loop just like the pseudo codes
describtion? Seeking your help!

Best regards
Zuoguang Fu

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

do you mean something like this, using ForceContainer [1]?

for b in O.bodies:
  f = O.forces.f(b.id)
  t = O.forces.t(b.id)
  doWhatewerWith_f_and_t()

As I understand the documentation (did not use ForceRecorder myself),
totalForce is really the total force, i.e. sum of all forces acting on
engine's ids). So, as I understand your question, I would prefer to use
ForceContainer

cheers
Jan

[1] https://yade-dem.org/doc/yade.wrapper.html#forcecontainer

2015-06-24 11:46 GMT+02:00 Fu zuoguang <<email address hidden>
>:

> Question #268448 on Yade changed:
> https://answers.launchpad.net/yade/+question/268448
>
> Status: Answered => Open
>
> Fu zuoguang is still having a problem:
> Dear Jan Stránský and all users,
>
> I am sorry for giving you an ambiguous description of my purpose.
>
> ###################################
>
> for b in O.bodies:
> O.engines.Recorder.ForceRecorder[body_id = b].totalForce
> O.engines.Recorder.TorqueRecorder[body_id = b].totalTorque
>
> ###################################
>
> The codes that I provided yesterday are not the true python codes but
> the pseudo codes that just helps me express logically my desirability.
> Of course, These sentences should not be validated by python.(exsit errors)
> But they are not very clear for understanding. I improved them as that
>
> ###################################
> for b in len(O.bodies):
> Engine.GlobalEngine.PeriodicEngine.Recorder.ForceRecorder[body_id =
> b].totalForce
> Engine.GlobalEngine.PeriodicEngine.Recorder.ForceRecorder[body_id =
> b].totalTorque
> ###################################
>
> These codes mean that
>
> (1) b now presents the id of each body(wall and sphere);
>
> (2) the inheritance relationship from totalForce or totalTorque to Engine
> is expressed
> as classes-like format;
>
> (3) all the bodies results should be output while in each loop, only one
> body
> is treated by inputting its id.
>
> The ture python codes are that
>
> ####################################
>
> O.engines = [
> ForceResetter (),
> InsertionSortCollider (),
> InteractionLoop (),
> consolidation, # my own loading mode
> NewtonIntegrator (),
> ForceRecorder (
> file = 'force-recorder.csv',
> ids = [id_list], # sphere ids
> iterPeriod = 50 )]
>
> #####################################
>
> Now these codes can be validated successfully in Yade but
> only for outputting the resultant force composed by all
> members in [id_list].
>
> Are there some methods for outputting the resultant force of
> each one member in that list in each loop just like the pseudo codes
> describtion? Seeking your help!
>
> Best regards
> Zuoguang Fu
>
> --
> 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
Fu zuoguang (zgfu1985) said :
#4

Dear Jan Stránský

Yes, it is just I want to do, and ForceContainer is the suitable class I need to choose for my purpose.
Now I can use that

for b in O.bodies:
  f = O.forces.f(b.id)
  t = O.forces.t(b.id)
  doWhatewerWith_f_and_t()

for all the things I desire. Thanks for your suggestion.

Best regards
Zuoguang Fu