Change sphere material for specific number of iterations and then restore previous one

Asked by velimier

Hi,
here is my problem. I want to change sphere material in my simulation (lets say) after every 1000 iterations, then to run simulation with new material for 50 iterations and finally to restore previous material and continue simulation for another 1000 iterations and so on. It's not how to change material, but how to achieve this 'timing ratio'. Any suggestions?

Veljko

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Luc Sibille (luc-sibille) said :
#1

Hi
I am not sure tu really understand... you can just do the following:

1/ Run simulation for 1000 iterations,
2/ change materials properties and contact physics (in agreement with material properties)
3/ Run simulation for 50 iterations,
4/ change materials properties and contact physics (in agreement with material properties)
5/ Run simulation for 1000 iterations,

Best,
Luc

Revision history for this message
Jan Stránský (honzik) said :
#2

Hi Veljko,

Luc's answer in python words

O.run(1000,True)
changeMaterial()
O.run(50,True)
changeMaterialBack()
O.run(1000,True)

you cold also do it in cycles:

for c in range(20):
    O.run(1000,True)
    changeMaterial()
    O.run(50)
    changeMaterialBack

also be careful with specific implementation of changeMaterial (yes/no
deleting interactions as changing particle material has no effect on
existing interactions and so on)

cheers
Jan

2015-04-22 16:16 GMT+02:00 Luc Sibille <<email address hidden>
>:

> Question #265693 on Yade changed:
> https://answers.launchpad.net/yade/+question/265693
>
> Status: Open => Answered
>
> Luc Sibille proposed the following answer:
> Hi
> I am not sure tu really understand... you can just do the following:
>
> 1/ Run simulation for 1000 iterations,
> 2/ change materials properties and contact physics (in agreement with
> material properties)
> 3/ Run simulation for 50 iterations,
> 4/ change materials properties and contact physics (in agreement with
> material properties)
> 5/ Run simulation for 1000 iterations,
>
> Best,
> Luc
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
velimier (velimier) said :
#3

Thanks for your answers,
could it be done using pyRunner somehow? To call function changeMaterial(), run for 50 iters, call changeMaterialBack() and continue untill pyRunner calls function again.
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.

Revision history for this message
Jan Stránský (honzik) said :
#4

>
>
> 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

Revision history for this message
velimier (velimier) said :
#5

Jan,
thank you for this answer. At first I tried to avoid calling pyrunner for each iteration, but in this manner it doesn't slow simulation much.

Can you help with this problem?

Provide an answer of your own, or ask velimier for more information if necessary.

To post a message you must log in.