yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #11111
Re: [Question #265693]: Change sphere material for specific number of iterations and then restore previous one
Question #265693 on Yade changed:
https://answers.launchpad.net/yade/+question/265693
Jan Stránský proposed the following answer:
>
>
> could it be done using pyRunner somehow? To call function
> changeMaterial(), run for 50 iters, call changeMaterialBack() and continue
> untill pyRunner calls function again.
>
sure:
def changeMaterial():
if O.iter % 1050 != 1000: return # do nothing at wrong iterations
...
def changeMaterialBack():
if O.iter % 1050 != 0: return # do nothing at wrong iterations
...
O.engines = [
...
PyRunner(iterPeriod=1,command="changeMaterial()", # iterPeriod is 1, but
the function itself determine if something needs to be done
PyRunner(iterPeriod=1,command="changeMaterialBack()", # iterPeriod is 1,
but the function itself determine if something needs to be done
...
]
> I forgot to mention that I used similar approach, but my problem is that I
> don’t know for how long my simulation is going to run, since I need to
> iterate until stop criterion isn’t met.
>
instead for loop you can use while loop:
while not someStopCondition():
O.run(1000,True)
changeMaterial()
O.run(50,True)
changeMaterialBack()
cheers
Jan
--
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.