yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #02380
Re: Python history forces
> I would like to have the history of the contact forces between two
> bodies (say to test a contact law with the Mindlin formulation for kn
> and ks) and I would like to know if it is possible to do that with
> python or if I need c++. I see the following command in python (being
> i a specific interaction);
>
> i.phys.normalForce
>
> Could you suggest me how to use this command to get the history and
> not just the value at a specific iteration?
Much easier with python. Add this to engines
(https://www.yade-dem.org/sphinx/yade.wrapper.html#yade.wrapper.PeriodicPythonRunner)
PeriodicPythonRunner(command="someFunction()",iterPeriod=...) # see docs
then define someFunction which will be called.
Actually, have a look at scripts/simple-scene-plot.py, it does exactly
that (and more); you add that engine*, then define the function
def myAddPlotData():
plot.addData(fn=O.interactions[34,55].phys.normalForce,step=O.iter) # save data you need, their names ('fn' and 'step') are used below
and finally**
plot.plots={'step':('fn',)} ## define x-y plot step-fn
After you run simulation, you will have the data in graphs (if you call
plot.plot(), which you can also save to png/pdf...), in file (if you
call plot.saveGnuplot('something')) and in memory (as an array in
plot.data['fn']).
HTH, Vaclav
*) The admonition about 'plotDataCollector' label no longer applies; you
don't have to label the engine at all.
**) If you don't define plot.plots, data will still be saved in memory,
but it is needed for plot.plot() and plot.saveGnuplot(...).
References