Forces...

Asked by Arthur Mercier

Hi,

I'm using Yade Bzr2811 and Ubuntu 10.10.

I'd like to plot it:
http://img11.hostingpics.net/pics/477562force.jpg

How can I do that ?

I'd like to increment a force on bodies, how can I do that ?
"forcetest=0

O.engines=[
[...]
 ForceEngine(force=(0,0,0),ids=[233,234,235,236],label='fEngine'),
[...]
        PyRunner(command="print O.iter", realPeriod=1),
 PyRunner(command="forcetest= O.iter", realPeriod=1),
 PyRunner(command="print forcetest", realPeriod=1),
]

fEngine.force[1] = -forcetest"
I tried to run it but nothing happens.

Thanks !

Question information

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

Hi Arthur,

could you please attach the whole script (or a link to the script)? but you can change the force of fEngine by PyRunner:

O.engines=[
  [...]
  ForceEngine(force=(0,0,0),ids=[233,234,235,236],label='fEngine'),
  [...]
  PyRunner(command="fEngine.force[1]=someNewValue", iterPeriod=100),
  [...]
]

Jan

______________________________________________________________
> Od: "Arthur Mercier" <email address hidden>
> Komu: <email address hidden>
> Datum: 06.05.2011 23:42
> Předmět: [Yade-users] [Question #156330]: Forces...
>
>New question #156330 on Yade:
>https://answers.launchpad.net/yade/+question/156330
>
>Hi,
>
>I'm using Yade Bzr2811 and Ubuntu 10.10.
>
>I'd like to plot it:
>http://img11.hostingpics.net/pics/477562force.jpg
>
>How can I do that ?
>
>I'd like to increment a force on bodies, how can I do that ?
>"forcetest=0
>
>O.engines=[
>[...]
> ForceEngine(force=(0,0,0),ids=[233,234,235,236],label='fEngine'),
>[...]
> PyRunner(command="print O.iter", realPeriod=1),
> PyRunner(command="forcetest= O.iter", realPeriod=1),
> PyRunner(command="print forcetest", realPeriod=1),
>]
>
>fEngine.force[1] = -forcetest"
>I tried to run it but nothing happens.
>
>Thanks !
>
>--
>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
Arthur Mercier (mercier-arthur) said :
#2

http://www.2shared.com/file/fiSpFcHN/probcrack.html

"could you please attach the whole script (or a link to the script)? but you can change the force of fEngine by PyRunner:

O.engines=[
  [...]
  ForceEngine(force=(0,0,0),ids=[233,234,235,236],label='fEngine'),
  [...]
  PyRunner(command="fEngine.force[1]=someNewValue", iterPeriod=100),
  [...]
]"
Yeah but no incrementation is done, isn't it ?

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

>Yeah but no incrementation is done, isn't it ?

In your original script nothing change, you are right :-) you set

fEngine.force[1] = -forcetest # forcestest=0 initially

__before__ the simulation, and because forcestest=0, it is indeed no change. After the simulation starts, the only thing is printing O.iter and 10*O.iter (=forcetest) into stdout every 1s.

If you want to change force (let's say) each 100 iteration, add

PyRunner(command="fEngine.force[1]=someNewValue", iterPeriod=100),

line into your O.engines.

Jan

Revision history for this message
Janek Kozicki (cosurgi) said :
#4

look at examples/simple-scene/simple-scene-plot.py, there you have
forces being plotted.

--
Janek Kozicki http://janek.kozicki.pl/ |

Revision history for this message
Arthur Mercier (mercier-arthur) said :
#5

"If you want to change force (let's say) each 100 iteration, add

PyRunner(command="fEngine.force[1]=someNewValue", iterPeriod=100),

line into your O.engines."
It just means "at every 100 iterations, the fEngine.force[1] = someNewValue", but no value is added, right ?

Ok, but here again, no incrementation is done, isn't it ?... I'd like to do something like
At iteration = 0, force applied = 0,
At iteration = 50, force applied = 100,
At iteration = 100, force applied = 200,
[...]

"look at examples/simple-scene/simple-scene-plot.py, there you have
forces being plotted."
I checked in but I didn't find any force plotted, the only plotted values are:
"plot.addData(t=O.time,i=O.iter,z_sph=sph.state.pos[2],z_sph_half=.5*sph.state.pos[2],v_sph=sph.state.vel.norm())", which are not forces, aren't they?

Thanks!

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

>It just means "at every 100 iterations, the fEngine.force[1] = someNewValue", but no value is added, right ?
>
>Ok, but here again, no incrementation is done, isn't it ?... I'd like to do something like
>At iteration = 0, force applied = 0,
>At iteration = 50, force applied = 100,
>At iteration = 100, force applied = 200,
>[...]
Well, for given example you could write in the same manner
PyRunner(command="fEngine.force[1] += 100", iterPeriod=50),
or
PyRunner(command="fEngine.force[1] +=2 ", iterPeriod=1),
:-)
according how often and how much you want to increment the applied force

Jan

Revision history for this message
Anton Gladky (gladky-anton) said :
#7

Do you need to apply a force or to plot a force, affecting on body?

Anton

Revision history for this message
Arthur Mercier (mercier-arthur) said :
#8

"Well, for given example you could write in the same manner
PyRunner(command="fEngine.force[1] += 100", iterPeriod=50),
or
PyRunner(command="fEngine.force[1] +=2 ", iterPeriod=1),"

Thank you, this is really what I wanted !

"Do you need to apply a force or to plot a force, affecting on body?"
I know how to apply a force on a body but I don't know how to plot forces ou torques that we could see there http://img11.hostingpics.net/pics/477562force.jpg

Revision history for this message
Best Anton Gladky (gladky-anton) said :
#9

Try so:

def myAddPlotData():
    plot.addData(t=O.time,F=O.forces.f(id_of_your_body).norm(),T=O.forces.t(id_of_your_body).norm())

plot.plots={'t':('F','T')}

I did not check that, but it should work.

Revision history for this message
Arthur Mercier (mercier-arthur) said :
#10

Thanks Anton Gladky, that solved my question.