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

Jan Stránský proposed the following answer:
I think there more options how to do it.
Below is one example.
Adjust it according to your needs - the information provided is still not very 
informative (e.g. we can only guess if "i" is O.iter or not, what "t1" and "t2" 
might be etc.)
The example blow is based on O.time

#### saved.txt
# time value
1  1.0
2  0.6
3  0.4
4  0.3
5  0.4
6  0.6
7  0.7
8  0.6
9  0.4
10 0.3
11 0.1
12 0.2
13 0.4
14 0.7
15 0.8
16 1.0
17 0.9
18 0.7
19 0.4
20 0.1
####

#### script.py
from yade import plot
import numpy

saved = numpy.loadtxt("saved.txt") # load saved data
savedTimes = saved[:,0]  # 1st comlumn
savedValues = saved[:,1] # 2nd comlumn

def plotAddData():
    time = O.time
    # simulation vlaue
    value = 0.5 + 0.5 * sin(time)
    # interpolated saved value
    savedValue = numpy.interp(time,savedTimes,savedValues)
    plot.addData(
        time = time,
        value = value,
        savedValue = savedValue,
    )

O.engines = [
    PyRunner(virtPeriod=0.2, command="plotAddData()"),
]

plot.plots = {"time":("value","savedValue")}
plot.plot()

O.stopAtTime = 20

O.dt = 1e-6
O.run()
####

Cheers
Jan

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to     : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to