← Back to team overview

yade-users team mailing list archive

Re: [Question #182459]: wrap a simulation to a class

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hi Ning,

The problem is that PyRunner calls functions in global namespace, so
variable self is not defined. I found this workaround - in shear
function do following:

   def shear(self, strain=-1.e-2):
      import __builtin__
      __builtin__.__dict__['saveAddData'] = self.saveAddData
      self.__O.engines=[
         ...
         PyRunner(command='saveAddData()',iterPeriod=500)
      ]

This approach should work. You can also try something with 'global'
statement or globals() dictionary.

Good luck and let us know if it works or not :-)

Jan


ceguo píše v Čt 02. 02. 2012 v 14:20 +0000:
> Question #182459 on Yade changed:
> https://answers.launchpad.net/yade/+question/182459
> 
>     Status: Answered => Open
> 
> ceguo is still having a problem:
> Thanks Jan,
> 
> r3015 solves the problem of NameError.
> Another thing is how can we export the results stored in `biax` in this case, as I find we cannot use PyRunner to execute saveAddData(). Or how can we get stress, strain, fabric tensors which may be used further in the simulation?
> 
> Regards,
> Ning
>

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.