How to restart a simulation from a saved point with restoring geometry movement?
Hi. I want to try some parameters that come into play at a late time point, like 1.0s. So i save the simulation at 0.9s and then restart it by O.load() method, followed by trying new parameters.
I have a roller constructed by facets doing translation and rotation controlled by RotationEngine and TranslationEngine, respectively. The parameter of "ids" in those engines is used to bond the engine to the roller (facets).
I use the pickle module to save the roller factets ids into a file during the first run and load these ids again in the restart run. So in the new run, the engines enable to find those roller facets to control. I have checked those ids of facets and they are right.
The problem is that the roller can not rotate or translate in the restart run.
My MWE is as the following, ( the scenario)
https:/
the first run saves every 0.05s and the restart run loads data at time 0f 0.3s. Because the rotation is active till 0.4s, the roller in the restart run should rotate at the beginning. It's stationary yet.
########## the first run to save at a time point ######## ##
#!/usr/bin/python
#-*- coding: utf-8 -*-
from yade import pack,geom,utils
import numpy as np
from yade import qt
## material
matSph = CohFrictMat(
Mat = O.materials.
## roller
radiusSweeper = 0.3e-3
lengthSweeper = 1.0e-3
numSweeperParts = 20
Sweeper=[]
for i in np.linspace(0, 2*pi, num=numSweeperP
Sweeper.
SweeperP=[Sweeper, [p+Vector3(
SweeperPoly = pack.sweptPolyl
SweeperIDs = O.bodies.
## save roller facets' id for restart ###
import pickle
fd = open('rollerids
pickle.
fd.close()
## platform
O.bodies.
### process parameters
velsw = 2.5e-3 ## translation vel
angvelsw = -50.0 ## rotation vel
t1 = 0.4 ## 0~0.2s, rotation + translation
t2 = 0.8 ## 0.2~0.4, translation
def change_motion():
if O.time < t1:
elif O.time < t2:
else:
## save per 0.05s
svdt = 0.05
saveTime = 0
def svfun():
global svdt, saveTime
if O.time> saveTime:
saveTime += svdt
if O.time>1.2:
O.pause()
O.engines=[
ForceResetter(),
InsertionSortC
InteractionLoop(
),
PyRunner(
RotationEng
Translation
NewtonInteg
PyRunner(
]
## particles
sp=pack.
sp.makeCloud(
sp.toSimulation
O.dt = 0.85*utils.
#O.run()
######## the restart run ########
#######
#!/usr/bin/python
#-*- coding: utf-8 -*-
from yade import pack,geom,utils
import numpy as np
from yade import qt
## load a saved data
O.load('time-0.30')
import pickle
fd = open('rollerids
SweeperIDs = pickle.load(fd)
fd.close()
### process parameters
velsw = 2.5e-3 ## translation vel
angvelsw = -50.0 ## rotation vel
t1 = 0.4 ## 0~0.2s, rotation + translation
t2 = 0.8 ## 0.2~0.4, translation
def change_motion():
if O.time < t1:
elif O.time < t2:
else:
## save per 0.05s
svdt = 0.05
saveTime = 0
def svfun():
global svdt, saveTime
if O.time>saveTime:
saveTime += svdt
if O.time>1.2:
O.pause()
O.engines=[
ForceResetter(),
InsertionSortC
InteractionLoop(
),
PyRunner(
RotationEng
Translation
NewtonInteg
PyRunner(
]
O.dt = 0.85*utils.
#O.run()
#### code finishing ###
Thanks!
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- gaoxuesong
- Solved:
- Last query:
- Last reply: