How to plot energy variables, breaks and contacts in a JCFpm model?

Asked by alma

Hi all,
I want to plot from energy variables (e.g. dissipated energy, kinetic energy and etc), kind of contacts (cohesive and frictional), and shear and tension breaks in specific period of time-steps in trunk-master/examples/jointedCohesiveFrictionalPM/gravityLoading.py example. How can I get it?
As second question, is there any way to save this variables to text files directly (without plotting)?
Any help would be appreciated.
Best regards,
Yashar

here is a part of my script that it isn't work correctly for my opinions:
O.trackEnergy=True

interactionRadius=1.1 # to set initial contacts to larger neighbours
O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Facet_Aabb(),Bo1_Sphere_Aabb(aabbEnlargeFactor=interactionRadius,label='is2aabb'),]),
    InteractionLoop(
        [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=interactionRadius,label='ss2d3dg'),Ig2_Facet_Sphere_ScGeom()],
        [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys(cohesiveTresholdIteration=1,label='interactionPhys')],
     [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(smoothJoint=smoothContact,recordCracks=True,label='interactionLaw')]
    ),
    GlobalStiffnessTimeStepper(timestepSafetyCoefficient=0.8),
    PyRunner(iterPeriod=1000,initRun=False,command='jointStrengthDegradation()'),
    VTKRecorder(iterPeriod=1000,initRun=True,fileName=(output+'-'),recorders=['spheres','velocity','intr','jcfpm','cracks','bstresses','all']),
    PyRunner(iterPeriod=500,initRun=True,command='addPlotData()',label='energy'),
    PyRunner(iterPeriod=500,initRun=True,command='recorder()'),
    PyRunner(iterPeriod=10,initRun=True,command='dataCollector()'),
    NewtonIntegrator(damping=0.7,gravity=(0.,-9.82,0.)),

]

#### dataCollector
plot.plots={'iterations':('p',)}
def dataCollector():
    R=O.bodies[refPoint]
    plot.addData(v=R.state.vel[1],p=R.state.pos[1]-p0,iterations=O.iter,t=O.realtime)
    plot.saveDataTxt(output)

####energy (it's the global energy plotting command that I've founded it!)
def addPlotData():
   # each item is given a names, by which it can be the unsed in plot.plots
   # the **O.energy converts dictionary-like O.energy to plot.addData arguments
   plot.addData(i=O.iter,unbalanced=unbalancedForce(),**O.energy)
   plot.saveDataTxt('/home/yashar/Desktop/Untitled Folder/energy.txt')

####recorder()
tensCks=shearCks=cks=cks0=0
def recorder():
    global tensCks, shearCks
    tensCks=0
    shearCks=0
    for o in O.bodies:
        if isinstance(o.shape,Sphere):
            tensCks+=o.state.tensBreak
            shearCks+=o.state.shearBreak
    yade.plot.addData({ 't':O.time,'i':O.iter,'tc':tensCks,'sc':shearCks,'unbF':utils.unbalancedForce()})
    plot.saveDataTxt('/home/yashar/Desktop/Untitled Folder/intrs.txt')

#### joint strength degradation
stableIter=2000
stableVel=0.001
degrade=True
def jointStrengthDegradation():
    global degrade
    if degrade and O.iter>=stableIter and abs(O.bodies[refPoint].state.vel[1])<stableVel :
    print '!joint cohesion total degradation!', ' | iteration=', O.iter
    degrade=False
    for i in O.interactions:
        if i.phys.isOnJoint :
        if i.phys.isCohesive:
          i.phys.isCohesive=False
          i.phys.FnMax=0.
          i.phys.FsMax=0.

#### YADE windows
from yade import qt
v=qt.Controller()
v=qt.View()

#### time step definition (low here to create cohesive links without big changes in the assembly)
O.dt=0.1*utils.PWaveTimeStep()

#### set cohesive links with interaction radius>=1
O.step();
O.bodies.append(facet([( 0.5, 0.15,-0.5),( 0.5,0.15, 0.5),( -0.5, 0.15, -0.5)],wire=True,material=mat))
O.bodies.append(facet([( -0.5, 0.15,-0.5),( -0.5,0.15, 0.5),( 0.5, 0.15, 0.5)],wire=True,material=mat))
O.bodies[-1].blockedDOF='xyzXYZ'
O.bodies[-2].blockedDOF='xyzXYZ'
 =
ss2d3dg.interactionDetectionFactor=-1.
is2aabb.aabbEnlargeFactor=-1.

#### RUN!!!
O.dt=-0.1*utils.PWaveTimeStep()
O.run(maxIter)

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Robert Caulk
Solved:
Last query:
Last reply:
Revision history for this message
Best Robert Caulk (rcaulk) said :
#1

Hello Yashar,

You can use the 'jcfpm' and 'cracks' [1] recorders to collect most of this information. You will need to activate 'recordCracks'[2] in the argument of Law2_SCGeom_JCFpmPhys_JointedCohesiveFrictional. These settings will generate .vtu/.vtk/.vtp files for paraview's consumption.

As for energy: I do not use it, but I have seen the energyTracker [3] hanging around the class reference. It might be of use to you if you are looking for total energy changes in the system. However, this other thread [4] makes an important point. Different laws dissipate energy in different ways, and therefore the laws themselves would need to compute the dissipated energy. And you are in luck, Luc just 3 days ago added some really easy functionality for getting the energy dissipated by shear and tensile breaks in JCFpm[5].

Best,

Robert

[1]https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.VTKRecorder.recorders
[2]https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM.recordCracks
[3]https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.EnergyTracker
[4]https://answers.launchpad.net/yade/+question/271596
[5]https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM.totalShearCracksE

Revision history for this message
alma (alma6748) said :
#2

Thanks Robert Caulk, that solved my question.