yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #11110
Re: [Question #265693]: Change sphere material for specific number of iterations and then restore previous one
>
>
> 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
Follow ups
References