How to extract force-displacement data and how to generate stress output in paraview

Asked by Anay Joshi

Hi,
I am working on uniaxial compression of a concrete column.
I have two basic questions about the code I am using.
1. How do I extract the force and displacement data in a text format?
2. How can I see the stresses in Paraview?

My Running script is,

from yade import pack, plot

################# SIMULATIONS DEFINED HERE

#### packing (previously constructed)
OUT='compressionTest_JCFPM'

#### Simulation Control
rate=-0.05 #deformation rate
iterMax=300000 # maximum number of iterations
saveVTK=4000 # saving output files for paraview

#### Material microproperties
intR=1.1 # allows near neighbour interaction (can be adjusted for every packing)
DENS=2400
YOUNG=17e9
FRICT=34.25
ALPHA=0.15
TENS=3.163e6
COH=2.99e6

#### material definition
def sphereMat(): return JCFpmMat(type=1,density=DENS,young=YOUNG,poisson=ALPHA,frictionAngle=radians(FRICT),tensileStrength=TENS,cohesion=COH)

#### create the specimen
pred=pack.inCylinder((0,0,0),(0,0,0.10),0.025)
O.bodies.append(pack.regularHexa(pred,radius=0.00125,gap=0.,material=sphereMat))

R=0
Rmax=0
nbSpheres=0.
for o in O.bodies:
 if isinstance(o.shape,Sphere):
   nbSpheres+=1
   R+=o.shape.radius
   if o.shape.radius>Rmax:
     Rmax=o.shape.radius
Rmean=R/nbSpheres

print ('nbSpheres=',nbSpheres,' | Rmean=',Rmean)

#### boundary condition (see utils.uniaxialTestFeatures
bb=utils.uniaxialTestFeatures()
negIds,posIds,longerAxis,crossSectionArea=bb['negIds'],bb['posIds'],bb['axis'],bb['area']

################# ENGINES DEFINED HERE

O.engines=[
 ForceResetter(),
        InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=intR,label='Saabb')]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=intR,label='SSgeom')],
  [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys(cohesiveTresholdIteration=1,label='interactionPhys')],
  [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(recordCracks=True,Key=OUT,label='interactionLaw')]
 ),
 UniaxialStrainer(strainRate=rate,axis=longerAxis,asymmetry=0,posIds=posIds,negIds=negIds,crossSectionArea=crossSectionArea,blockDisplacements=1,blockRotations=1,setSpeeds=0,stopStrain=0.1,dead=1,label='strainer'),
 GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=10,timestepSafetyCoefficient=0.5, defaultDt=utils.PWaveTimeStep()),
 NewtonIntegrator(damping=0.4,label='newton'),
 PyRunner(iterPeriod=int(100),initRun=True,command='recorder()',label='data'),
        VTKRecorder(iterPeriod=int(saveVTK),initRun=True,fileName=OUT+'-',recorders=['spheres','jcfpm','cracks','stress'],Key=OUT,label='vtk')
]

################# RECORDER DEFINED HERE

def recorder():
    yade.plot.addData({'i':O.iter,
         'eps':strainer.strain,
         'sigma':strainer.avgStress,
        #'tc':interactionLaw.nbTensCracks,
        #'sc':interactionLaw.nbShearCracks,
        #'te':interactionLaw.totalTensCracksE,
        #'se':interactionLaw.totalShearCracksE,
         'unbF':utils.unbalancedForce()})
    plot.saveDataTxt(OUT)

################# PREPROCESSING

#### manage interaction detection factor during the first timestep and then set default interaction range
O.step();
### initializes the interaction detection factor
SSgeom.interactionDetectionFactor=-1.
Saabb.aabbEnlargeFactor=-1.

#### coordination number verification
numSSlinks=0
numCohesivelinks=0
for i in O.interactions:
    if isinstance(O.bodies[i.id1].shape,Sphere) and isinstance(O.bodies[i.id2].shape,Sphere):
      numSSlinks+=1
    if i.phys.isCohesive :
      numCohesivelinks+=1

print ("nblinks=", numSSlinks, " | nbCohesivelinks=", numCohesivelinks, "|| Kcohesive=", 2.0*numCohesivelinks/nbSpheres)

################# SIMULATION REALLY STARTS HERE
strainer.dead=0
O.run(iterMax)

I would really appreciate any help I can get.

Thanks,
Anay

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
Jérôme Duriez (jduriez) said :
#1

Hi,

1.
Since you're using plot.addData() [*] and plot.saveDataTxt() functions, it seems you know how to save YADE variables in a text file.
Is your question rather about "which YADE variables correspond to force and displacement (instead of stress and strain)" ?

2.
This seems rather a Paraview question. You have general instructions for importing YADE data into Paraview at https://yade-dem.org/doc/user.html#id3.
Looking into "display" options of Paraview, you should be able to color your Paraview glyphs/points (that correspond to YADE spheres) according to some stress quantity defined at the particle scale.

Note that VTKExporter can export two kinds of stress quantities : one "stress" I do not know personally, and another "bstresses" which is used for instance in [Duriez2016] from https://yade-dem.org/doc/publications.html, section 2.4 and elsewhere.

Do not hesitate to precise your questions in case this answer is not precise enough ;-)
But better do it in two separate Launchpad question.

Jérôme

[*] note that you're using a deprecated syntax for this function, see https://yade-dem.org/doc/yade.plot.html#yade.plot.addData

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#2

Hi,
1/ If you want your custom txt format you can just (python-)loop on O.bodies and write whatever you like to a file. Else there are various exporters in yade such as VKTExporter, VtkRecorder, ... that you may check.
A simple one is:
sp=SpherePack()
sp.fromSimulation()
sp.save("pack.txt")

2/ see https://yade-dem.org/doc/user.html#micro-stress-and-micro-strain

Regards
Bruno

Revision history for this message
Anay Joshi (petronas) said :
#3

Hi Jerome,
Thanks for the quick response.

1.
Since you're using plot.addData() [*] and plot.saveDataTxt() functions, it
seems you know how to save YADE variables in a text file.
Is your question rather about "which YADE variables correspond to force and
displacement (instead of stress and strain)"?

--> Yes, that is correct. My question is which yade variables correspond to
force and displacement? I would really appreciate the help. I tried to find
that on my own but I think I did not look properly. If you could guide me,
it would be really helpful.

And I would open a separate question for paraview. But I am going to read
everything first before asking any questions.

Thanks for the help,
Anay

On Wed, Jun 27, 2018 at 3:43 AM, Jérôme Duriez <
<email address hidden>> wrote:

> Your question #670487 on Yade changed:
> https://answers.launchpad.net/yade/+question/670487
>
> Status: Open => Answered
>
> Jérôme Duriez proposed the following answer:
> Hi,
>
> 1.
> Since you're using plot.addData() [*] and plot.saveDataTxt() functions, it
> seems you know how to save YADE variables in a text file.
> Is your question rather about "which YADE variables correspond to force
> and displacement (instead of stress and strain)" ?
>
> 2.
> This seems rather a Paraview question. You have general instructions for
> importing YADE data into Paraview at https://yade-dem.org/doc/user.
> html#id3.
> Looking into "display" options of Paraview, you should be able to color
> your Paraview glyphs/points (that correspond to YADE spheres) according to
> some stress quantity defined at the particle scale.
>
> Note that VTKExporter can export two kinds of stress quantities : one
> "stress" I do not know personally, and another "bstresses" which is used
> for instance in [Duriez2016] from https://yade-
> dem.org/doc/publications.html, section 2.4 and elsewhere.
>
>
> Do not hesitate to precise your questions in case this answer is not
> precise enough ;-)
> But better do it in two separate Launchpad question.
>
>
> Jérôme
>
> [*] note that you're using a deprecated syntax for this function, see
> https://yade-dem.org/doc/yade.plot.html#yade.plot.addData
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/yade/+question/670487/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/yade/+question/670487
>
> You received this question notification because you asked the question.
>

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

Hi,

Resulting force and displacement of YADE bodies can be respectively accessed with :
- O.forces.f(yourBodyId), see [1,2]
- O.bodies [yourBodyId].state.displ(), assuming O.bodies[yourBodyId].state.refPos was correctly initialized (this may be up to you). See [3]

The "problem" is : in your uniaxial configuration using UniaxialStrainer engine you do not have a single boundary element whose such variables would be representative of the mechanics of the sample (there is no loading rigid platen)

Maybe you could use sum/average the above variables on all UniaxialStrainer.posIds bodies but you have to check if this makes sense.

Another possibility is to surround your numerical samples with e.g. YADE boxes that would serve as rigid loading platens (2 surrounding boxes may be enough for uniaxial conditions) as done in [Duriez2016] (see Fig. 3) from https://yade-dem.org/doc/publications.html, and elsewhere. Then you could directly use O.forces.f() and O.bodies[].state.displ()

A last possibility would be to re-derive with continuum mechanics the force and displacement from the stress and strain quantities you already know ;-)

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.Omega.forces
[2] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.ForceContainer.f
[3] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.State.displ

Can you help with this problem?

Provide an answer of your own, or ask Anay Joshi for more information if necessary.

To post a message you must log in.