← Back to team overview

yade-users team mailing list archive

Re: [Question #250783]: some questions about 'O.dt' and 'PyRunner'

 

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

Jan Stránský proposed the following answer:
Hello Fu,


>
> (2). The second question is about using ‘PyRunner’ to output some
> important simulation data for post process. The general use of ‘PyRunner’
> in ‘O.engines’is just like that
>
>
> ####################################################################################
> output_unit_step = constant int
> ...
> PyRunner(command='postprocess()', iterPeriod = output_unit_step)
>
> ####################################################################################
>
> Now, I expect that ‘output_unit_step’ can be changed by stages in whole
> process of simulation and the key factor of determining these different
> stages is the ‘O.iter’. So the codes above can be modified as:
>
>
> ####################################################################################
> if  O.iter <=  certain stage range 1 :
>     output_unit_steps = constant int 1
> elif  certain stage range 1 < O.iter <=  certain stage range 2:
>     output_unit_steps = constant int 2
> .....
> PyRunner(command='postprocess()', iterPeriod = output_unit_step)
>
> ####################################################################################
>
> I hoped ‘iterPeriod’ in ‘PyRunner’ can be updated in accordance with the
> variable ‘output_unit_steps’ but failed. The invariable ‘iterPeriod’ is
> always equal to ‘constant int 1’. This is because at the beginning of
> simulation, ‘O.iter = 0’ and the ‘if’ condition is ‘True’.
> ‘output_unit_steps’ is assigned by ‘constant int 1’ and may not be changed
> any more in the whole process. I wish there are some other codes can
> replace my codes above to achieve my purpose. Please tell me these.
>

use label for the PyRunner

O.engines = [
   ...
   PyRunner(command='postprocess()', iterPeriod = output_unit_step,
label='postprocessorEngine')
]

and change its iterPeriod after certain number of time steps using this
label:

O.run(certain stage range 1,True)
postprocessorEngine.iterPeriod = whatever # [1]

HTH
Jan


[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.PyRunner

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