save and load
Hi,
I want save my code in middle of simulation, save in stopUnloading() have completed. Then load the saved simulation and continue with some other simulation (e.i increasing particle radius over time) on saved packing.
I tried with o.load(
I was wondering, what it the best way to save the simulation in the middle and then load it and continue with simulation.
Here is my code:
from __future__ import print_function
from yade import utils, plot, timing
from yade import pack
import pandas as pd
import numpy as np
from PIL import Image
from yade import pack, export
from scipy.interpolate import interp1d
readParamsFromT
from yade.params.table import *
from scipy.integrate import odeint
import matplotlib.pyplot as plt
import os
import csv
from matplotlib.pyplot import figure
from scipy.interpolate import interp1d
from pylab import *
from scipy.optimize import curve_fit
o = Omega()
# Physical parameters
fr = 0.41
rho = 1561
Diameter = 0.0012/2
D=Diameter
r1 = Diameter/2
#r2 = Diameter/2
k1 = 1.26e5
kp = 12*k1
kc = k1 * 0.1
ks = k1 * 0.1
DeltaPMax = Diameter/3.0
Chi1 = 0.34
PhiF1=0.999
#PhiF1 = DeltaPMax*
o.dt = 1.0e-7
particleMass = 4.0/3.0*
Vi1 = math.sqrt(
m_tot=0.0005
#no_p=m_
no_p=1000
Tab_rad=0.005
Cyl_height=0.015
cross_area=
Comp_press= 1.2e8
Comp_force=
##Single particle swelling model
def model(r,
Q=(
drdt =((D*rho_
return drdt
P=[1.45,
#******
# Add material
mat1 = o.materials.
# Spheres for compression and walls
sp=pack.
sp.makeCloud(
sp.toSimulation
walls=o.
r_save=[]
radius=[]
initial_save=[]
size_save=[]
radius.append(0)
swell_t=
i=0
for b in O.bodies:
if isinstance(b.shape, Sphere):
r_save.
# Add engines
o.engines = [
ForceResetter(),
InsertionSort
InteractionLoop(
[Ig2_
Ig2_
Ig2_
[Ip2_
[Law2_
),
NewtonIntegra
PyRunner(
#DeformContro
]
def checkForce():
# at the very start, unbalanced force can be low as there is only few
# contacts, but it does not mean the packing is stable
if O.iter < 400000:
return
# the rest will be run only if unbalanced is < .1 (stabilized packing)
timing.reset()
if unbalancedForce() > 1:
return
# add plate at upper box side
highSphere = 0.0
for b in O.bodies:
if highSphere < b.state.pos[2] and isinstance(b.shape, Sphere):
else:
pass
o.bodies.
global plate
plate = o.bodies[-1] # the last particles is the plat
plate.state.vel = (0, 0, -2)
fCheck.command = 'unloadPlate()'
def unloadPlate():
# if the force on plate exceeds maximum load, start unloading
# if abs(O.forces.
if abs(o.forces.
# next time, do not call this function anymore, but the next one
# (stopUnloading) instead
def stopUnloading():
if plate.state.pos[2] > Cyl_height/2:
o.engines = o.engines+
def ParticleSwelling():
time_
Liq_
Liq_
radius=[]
radius.
for b in O.bodies:
if isinstance(b.shape, Sphere):
k=b.id
if Liq_pos>=par_pos:
if swell_t[0][k]==0:
t = np.linspace(0,time)
r = odeint(
elif Liq_pos<par_pos:
r_save.
size_
size_
o.load(
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Jan Stránský
- Solved:
- Last query:
- Last reply: