← Back to team overview

yade-users team mailing list archive

[Question #707137]: Resetting and starting simulations from the beginning

 

New question #707137 on Yade:
https://answers.launchpad.net/yade/+question/707137

Hello,

I would like to ask that if there is a way to run simulations like batch mode but without using the actual batch mode function.
In more details:
1. I would like to run a simulation which will stop at a given time. 
2. Then I would like to save a data.
3. After, I would like to reload/reset the simulation and change one thing (ie. density of a particle).
4. Then run the simulation again and save the same data.

I have created an MWE using the bouncing sphere example. In this example, I don't change any parameter. I just run the simulation for 1 sec, then I print the number of the current run, then reset and start again.
My problem is that the simulation won't reload and won't start automatically again. I have tried O.loadTmp() instead of O.reload() but had no success.

-----------MWE-----------

O.bodies.append(
        [
                # fixed: particle's position in space will not change (support)
                sphere(center=(0, 0, 0), radius=.5, fixed=True),
                # this particles is free, subject to dynamics
                sphere((0, 0, 2), .5)
        ]
)


O.engines = [
        ForceResetter(),
        InsertionSortCollider([Bo1_Sphere_Aabb()]),
        InteractionLoop(
                [Ig2_Sphere_Sphere_ScGeom()],  # collision geometry
                [Ip2_FrictMat_FrictMat_FrictPhys()],  # collision "physics"
                [Law2_ScGeom_FrictPhys_CundallStrack()]  # contact law -- apply forces
        ),
        # Apply gravity force to particles. damping: numerical dissipation of energy.
        NewtonIntegrator(gravity=(0, 0, -9.81), damping=0.1),
        PyRunner(command='stop()',realPeriod=.5)
]

O.dt = .5e-4 * PWaveTimeStep()

index=0
def stop():
   global index
   if O.time>1:
       index=index+1
       print(str(index)+'. run')
       O.reload()
       #O.loadTmp()
       O.run()

# save the simulation, so that it can be reloaded later, for experimentation
O.saveTmp()
O.run()

-----------End of MWE----------

Thank you in advance for your help !
D

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