← Back to team overview

yade-users team mailing list archive

Re: [Question #704090]: Positive and negative alternating loading(shear) and program error

 

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

    Status: Open => Answered

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

TLTR: basically you cannot "blindly" copy-paste pieces of code and
expect them to work as you want.

please provide a MWE [1].
M = minimal, e.g. deleted commented parts of code (which is otherwise only confusing)

basically, in [2] (please link directly related questions) the provided MWE is the approach
- run something: O.step() or O.run(N,True)
- do something: O.cell.velGrad = ...

You are here using PyRunner. You then have to use completely different approach.
In PyRunner, first of all, do not use O.step() inside the "command" function.
Rather assign O.cell.velGrad based e.g. on O.iter or some similar condition. E.g.
###
O.engines = [
    ...
    PyRunner(iterPeriod=1,command="checkStress()", ...), # iterPeriod=1 (!!!)
]

def checkStress(): # checkStress name for function setting velGrad ???
    if O.iter == 1000:
        O.cell.velGrad = someValue1
    if O.iter == 2000:
        O.cell.velGrad = someValue2
    ...
###

Or you can use virtPeriod and use some counter, "remembering" which cycle it is in etc.
Or ... many options

a side note: do not use realPeriod for serious simulations

Cheers
Jan

[1] https://www.yade-dem.org/wiki/Howtoask
[2] https://answers.launchpad.net/yade/+question/703791

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