Saving/Loading
Hello,
If I am not mistaken, O.save(namefile) saves engines, interactions, ..., but it does not save parameters or other things.
In the case that I am currently studying, I am obliged to save (O.save) close Yade and then later on open it and load what I have saved. But it seems that all the history is simply disappearing, for example, volumetric strains.
My question is: Is there any technique to save the history of volumetric and axial strains?
Hope my message was clear.
Thanks in advance !
Nabil
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
|
#1 |
Hello,
> O.save(namefile) saves engines, interactions, ..., but it does not save parameters or other things.
> But it seems that all the history is simply disappearing, for example, volumetric strains.
What are "...". "parameters", "other things", "the history", "volumetric strains" etc.?
Please provide a MWE [1] showing what you mean.
> I am obliged to save (O.save) close Yade and then later on open it and load what I have saved.
Just for our information, why and what is the use case?
> My question is: Is there any technique to save the history of volumetric and axial strains?
Definitely yes, there are many options actually.
Which to use depends on what you want to achieve.
> Hope my message was clear.
not really, sorry..
Cheers
Jan
Revision history for this message
|
#2 |
Hey Jan,
Sorry for not being very clear.
> What are "...". "parameters", "other things", "the history", "volumetric strains" etc.?
Basically, I am trying to couple DEM with LBM in order to model partially saturated medias. And LBM is written in C++, and it's the main code in which I call Yade. For example, for some number of LBM iterations (n_LBM), I launch Yade for (n_DEM) iterations. At the end of the Yade cycle (at n_DEM iteration), I save two things:
- I save some physical quantities in a text file, such as volumetric strain, stresses, axial strains, kinetic energy, etc. In each row, I have the number of iterations and the physical parameters mentioned above.
- I save the simulation by using O.save(filename). (Indeed, for loading the simulation again in Yade, I use O.load(filename))
Once Yade is finished and everything is saved, Yade exists and the main code (LBM) has the control again, and so on. This the DEM-LBM coupling algorithm.
The example I am currently studying is Triaxial test in partially saturated media. Indeed, in order to verify that the algorithm works well, I have simulated a dry REV, which means that I commented the LBM block code so that only Yade is used but using my algorithm (cycles of opening and closing Yade). And I compare the results of my algorithm's simulation with a normal Yade simulation.
In both simulations, sigma_zz is increasing (in the saved text file), which means that the upper wall is compressing my REV while maintaining sigma_xx = sigma_yy = sigma_conf (which is a good sign). However, using my algorithm, epsilon_zz, epsilon_vv, and kinetic energy are all zeros while using a normal Yade triaxial simulation, epsilon_zz, epsilon_vv, and kinetic energy are changing.
Somehow, when I load the simulation using O.load() strains and kinetic energy are reset.
Hope my message is more precise now.
Best
Nabil
Revision history for this message
|
#3 |
Thanks for some clarification
> Once Yade is finished ..., Yade exists
Yade exists? Yade exits?
> Hope my message is more precise now.
More, but not fully..
Please provide a MWE [1]
Cheers
Jan
Revision history for this message
|
#4 |
Hi (again),
TriaxialStressC
Nevertheless, it will be re-computed at most TriaxialStressC
As such, I'm not expecting real issues for the strain quantities but you can tell us the contrary with a MWE ;-)
For the kinetic energy, it would also help if you tell us exactly how you're measuring it (which YADE / Python commands).
(I would bet bodies velocities are correctly O.saved and O.loaded)
Revision history for this message
|
#5 |
Hello everyone,
Sorry for replying a bit late..
Here's my MWE:
C/C++ the LBM code in which capillary forces are computed, then YADE is called for n_DEM iterations:
// Code C/C++
Block code 1
// This will call the triax_test.py script (shown below)
system(
Block code 2
When the code reads the command system(
YADE:
# =======
from yade import plot
import os
import sys
import time
import numpy as np
#######
# Specific functions
#######
def check():
"""
Check the convergence of each loading step of the triaxial test and swich to the next
step when converged.
"""
if O.iter % 10000 == 0 and O.iter != 0:
global currentLoad, isoStrain, loadingName
print('I AM IN CHECK AT ITERATION ', O.iter)
print('\n')
if currentLoad==0:
# test=unb<0.001 and \
if test:
# recorder.dead=False
# dataSaver.
# sampleSaver.
elif currentLoad==1:
eta=q/p
if test:
# O.pause()
if X_particles_max > 3e-3 or Y_particles_max > 3e-3 or Z_particles_max > 3e-3 or X_particles_min < -3e-3 or Y_particles_min < -3e-3 or Z_particles_min < -3e-3:
if abs(eps_zz) > 0.3:
# save_data_triax() function that saves multiple parameters
def save_data_triax():
if O.iter % 500 == 0 and O.iter != 0:
if not os.path.
f = open("triax_
else:
f = open("triax_
eta=q/p
# Stresses
# Strains
# Void Index
def Save_data():
print("\n SAVING DATA \n")
# t0_Saving_Data = time.clock()
# O.save(
# tf_Saving_Data = time.clock() - t0_Saving_Data
# print("Time of saving data.xml.bz2 is ", tf_Saving_Data)
t0_Saving_Data = time.clock()
O.save('data.gz')
tf_Saving_Data = time.clock() - t0_Saving_Data
print("Time of saving data.gz is ", tf_Saving_Data)
f = open("LB_data.dat", "w+")
f.write('id r(m) x(m) y(m) z(m) vx(m/s) vy(m/s) vz(m/s)\n')
f.write(
f.write(
for b in O.bodies:
if type(b.
f.write("%d %0.10f %0.10f %0.10f %0.10f %0.10f %0.10f %0.10f \n" % (b.id, b.shape.
f.close()
O.dt = 1e-7
loadingName=
filename = 'TextureTest'
sigmaIso=-1*10**5
mask=[7,3]
strainSpeed=0.01
loadPath=
nbLoads=len(mask)
#currentLoad has the values of 0 for confining the sample and 1 for axial strain while sigma0 is fixed
currentLoad = int(sys.argv[2])
test = 0
# To store the isotropic stain level
isoStrain=[0,0,0]
# Deviatoric states to save
#strainTarget=
etaTarget=
EpsTarget=[0.1]
progress=0
# to keep in memory the number of saved texture
nbTextureSaved=0
# reload the sample from .py file
young=100e6
poisson=0.42
frictAngle=35
density=3000
damp=0.05
O.load('data.gz')
# Enable energy tracking
O.trackEnergy=True
# Stiffness of walls and spheressotropic initial compression
triax=TriaxialS
# Isotropic initial compression
# Comment if internalCompact
# Uncomment if internalCompact
)
O.engines=[
),
# GlobalStiffness
# timestepSafetyC
triax,
]
checker=
O.engines+
O.run(int(
Save_data()
# =======
Once YADE exits, the command line (in C++) will go to Block code 2.
Hope it's better now. Thank you so much in advance.
Nabil
Revision history for this message
|
#6 |
Hello again,
I don't know how to add an attachment, but I will try to explain the obtained results using the coupling that I have already written in the previous answer. All I want to verify is that the coupling is working. Therefore, I will suppose that all capillary forces will be equal to 0 (as if I am studying a dry sample) and I will compare this simulation with a normal YADE simulation without calling it from a C++ code.
I have tested the coupling for 300000 iterations for YADE, it means that the C++ code will open YADE and run it for 300000 iterations. After these iterations, YADE will exit, C++ will take control again and then launch YADE for another 300000 iterations.
From 0 to 300000 iterations, the volumetric strain is increasing (in absolute value, I am making a triaxial test). The volumetric strain at iteration number 300000 is -0.000124, the sigma_zz = -103356.446315, and void ratio is = 0.747134.
Next, YADE exits, and then will be opened via C++, and then O.load() is applied to load the particles and etc.. Therefore, YADE will start from 300001 iteration and finishes at iteration number 600001 to exit and reopen again.
It is interesting to note that at iteration number 300001 (just after re-opening YADE), the volumetric strain becomes -2E-06 (approx 0), sigma_zz =-103362.362661, and void ratio is 0.747133.
So there is a continuity for stresses, but it seems not working for the strains, and this is exactly what I was asking for. How to make the strain continuous when reloading data?
Hope that this time is more clear, thank you so much in advance!
Nabil
..
Revision history for this message
|
#7 |
Hi (again) Nabil,
Trying to rephrasing myself, it is impossible (unless you modify C++ source code, obviously) to get back correct TriaxialStressC
Playing with TriaxialStressC
Can you help with this problem?
Provide an answer of your own, or ask Nabil YOUNES for more information if necessary.