How to export the overlap data

Asked by GUANGYAO LI

Hi everyone,

I'm using TriaxialTest to create a packing of spherical particles, but I do not know how to export the overlap data? The purpose of exporting the overlap data is to verify the numerical stability in terms of the overlap (Because the overlap is required to be smaller as much as possible). Could anybody help me with that? Thanks!

Guangyao

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
GUANGYAO LI
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

###
overlaps = [i.geom.penetrationDepth for i in O.interactions]
with open("overlaps.dat","w") as f: f.writelines(str(o)+"\n" for o in overlaps)
###

cheers
Jan

Revision history for this message
GUANGYAO LI (yaogezuiniu131) said :
#2

Hi Jan,

Thanks! This script works well in this case. However, I am new to YADE, and I still do not know the general method to export the data I need. I mean maybe next time I would like to export other variables. So could you please give me some more suggestions on that?

Regards,
Guangyao

Revision history for this message
GUANGYAO LI (yaogezuiniu131) said :
#3

Actually, I have run another case using the TriaxialCompressionEngine, but it seems that the above script does not work. So I think I really need to learn the general method of exporting data.

Guangyao

Revision history for this message
Jérôme Duriez (jduriez) said :
#4

The doc should help, https://yade-dem.org/doc/tutorial-data-mining.html in particular

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

> but it seems that the above script does not work

please provide the code and what exactly "does not work" mean (errors? no output? output different than expected?...?)

> I really need to learn the general method of exporting data.

there is no "general" method.
The essential part is to GET the data.
Exporting is easy, but very much depends on what data it is.
You can use pure python (like in my code) or some "predefined" methods, e.g. using plot.addData and plot.saveDataTxt [1], VTK export [2,3], "plain text" export [4,5] .....

cheers
Jan

[1] https://yade-dem.org/doc/user.html#tracking-variables
[2] https://yade-dem.org/doc/yade.export.html#yade.export.VTKExporter
[3] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.VTKRecorder
[4] https://yade-dem.org/doc/yade.export.html#yade.export.text
[5] https://yade-dem.org/doc/yade.export.html#yade.export.textExt

Revision history for this message
GUANGYAO LI (yaogezuiniu131) said :
#6

Great!

Please see the code below. Finally a blank overlaps.dat file was generated.
Thanks!

Regards,
Guangyao

from yade import pack
from numpy import arange
import itertools
import random
import yade.plot

## corners of the initial packing
mn,mx=Vector3(0,0,0),Vector3(0.03,0.03,0.03)

## create material #0, which will be used as default
id_Mat=O.materials.append(FrictMat(young=7e7,poisson=.4,frictionAngle=radians(5.8),density=2650,label='spheres'))
O.materials.append(FrictMat(young=7e10,poisson=.4,frictionAngle=0,density=26500,label='frictionless'))
Mat=O.materials[id_Mat]
#create assembly of spheres:
sp=pack.SpherePack()
sp.makeCloud(mn,mx,num=14000,rMean=.0005,rRelFuzz=0.0,periodic=False)#,
#sp.makeCloud(mn,mx,num=14000,psdSizes=psdSizes,psdCumm=psdCumm,distributeMass=True)#,distributeMass=True
O.bodies.append([sphere(center,rad,material='spheres') for center,rad in sp])
print(len(sp),' particles generated.')
#sp.toSimulation()

## create walls around the packing
walls=aabbWalls(material='frictionless')
wallIds=O.bodies.append(walls)

from yade import qt
qt.Controller()
qt.View()

## hope that we got the ids right?!
triax=TriaxialCompressionEngine(
 wall_bottom_id=wallIds[2],
 wall_top_id=wallIds[3],
 wall_left_id=wallIds[0],
 wall_right_id=wallIds[1],
 wall_back_id=wallIds[4],
 wall_front_id=wallIds[5],
 internalCompaction=False,
        autoCompressionActivation=False,
        #autoStopSimulation=True,
        autoUnload=False,
        updatePorosity=True,
 sigmaIsoCompaction=-10e3,
 sigmaLateralConfinement=-10e3,
 strainRate=0.02,
 frictionAngleDegree=5.8,
 StabilityCriterion = 0.001,
 max_vel=1,
)

recorder=TriaxialStateRecorder(
 iterPeriod=20,
 file="./WallStresses-clumps",
 truncate=1
)
#recorder=VTKRecorder(iterPeriod=20,
 #file="./positions",
#)

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_FrictPhys()],
  [Law2_ScGeom_FrictPhys_CundallStrack()]
 ),
 GlobalStiffnessTimeStepper(timestepSafetyCoefficient=0.2),
 triax,
 recorder,
 # you can add TriaxialStateRecorder and such here…
 NewtonIntegrator(damping=.001),
        VTKRecorder(fileName='parclm-',iterPeriod=10000,recorders=['spheres'])
]
O.stopAtIter=200020
#O.run(100000,True)
overlaps = [i.geom.penetrationDepth for i in O.interactions]
with open ("overlaps.dat","w") as f:f.writelines(str(o)+"\n" for o in overlaps)

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

Tanks for the code.
You are calling the export before any step / run, so the interaction list is empty, hence you get empty file
cheers
Jan

Revision history for this message
GUANGYAO LI (yaogezuiniu131) said :
#8

Thanks for the answer Jan! I still don't know where I should call the export? I have tried to put the script in other positions, but still got empty file.

Guangyao

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

> I have tried

please be more specific (show the changes)

e.g. uncomment the O.run command:
###
O.run(100000,True)
overlaps = [i.geom.penetrationDepth for i in O.interactions]
with open ("overlaps.dat","w") as f:f.writelines(str(o)+"\n" for o in overlaps)
###

cheers
Jan

Revision history for this message
GUANGYAO LI (yaogezuiniu131) said :
#10

Thanks Jan! I run the O.run() command as you suggested, and the problem was solved !

Cheers
Guangyao

Revision history for this message
GUANGYAO LI (yaogezuiniu131) said :
#11

Thanks Jérôme!

I will deeply learn the link you provided.

Regards,
Guangyao