← Back to team overview

yade-users team mailing list archive

Re: Storing variables with python

 

> Say that I am storing variables with python. So I make use of
> PeriodicEngine. But I want to start storing some of them only after
> that a certain condition is satisfied. How would you do that once
> using plot.addData() function? 
You want to start storing history of some variables for plotting only
after satisfying some condition, is that what you ask?

If so, just add a global variable for storing the condition test (see in
examples/concrete/uniax.py how mode is used: it must be declared "global
mode" at the beginning of the function where it is being used). Now if
your condition has not yet been satisfied, you check for that
contidition; is not satisfied, then return without storing any values.
If it is satisfied, modify that that global variable and store data.
Something like this:

global conditionOk
conditionOk=False

def funcThatYouCallPeriodically:
	global conditionOk
	if not conditionOk:
		if (check what you need here): conditionOk=True
	if conditionOk:
		# store data here

HTH, Vaclav




Follow ups

References