← Back to team overview

yade-dev team mailing list archive

evaluating expressions in python

 

A small python question. Anyone got this problem before?

It seems the instruction refstrain=triax.strain[1] inside myFunc is "hardcoded" somehow, assigning always the initial triax.strain[1] (0 at the time myFunc is defined) instead of its current value. Typing refstrain=triax.strain[1] manually in the console will assign the current value correctly.

Thanks.

Bruno

_____________________

refstrain=0.0

def myFunc():
   refstrain=triax.strain[1]

O.run(10)

Yade [1]: triax.strain[1]
->  [1]: -0.026189869682630321
Yade [2]: refstrain
->  [2]: 0.0
Yade [3]: myFunc()
Yade [4]: refstrain
->  [4]: 0.0
Yade [5]: refstrain=triax.strain[1]
 ->  [4]: -0.026189869682630321



--
_______________
Bruno Chareyre
Associate Professor
Grenoble INP
Lab. 3SR
BP 53 - 38041, Grenoble cedex 9 - France
Tél : 33 4 56 52 86 21
Fax : 33 4 76 82 70 43
________________




Follow ups