force chain in paraview

Asked by Alireza Sadeghi

Hello All,

I want to model force chain in the paraview, but I have problem to do it. I have the error that "NameError: name 'VTKExporter' is not defined". I was wondering if you could give me an example to solve my problem. Thank you very much.

Best Regards

Alireza

P.S. my code is :

from yade import utils, plot
from yade import pack, qt
from datetime import datetime

qtr=qt.Renderer()
qtr.bgColor=(1,1,1)

#===========================================================
#==================set a periodic boundary==================
#===========================================================

O.periodic=True
O.cell.refSize=(2e-1,2e-1,2e-1)

#==============================================================
#================= define the materials =======================
#==============================================================

O.materials.append(CohFrictMat(normalCohesion= 1e20, shearCohesion= 1e20, isCohesive= True, young=6.81e8, density=1377.5, poisson=0.3, frictionAngle= 0.31, fragile=False, label='Coke'))

#===============================================================
#=================== define packing ============================
#===============================================================

nums=['t']

mats=['Coke']

coke=(5e-3,150)

nums=pack.SpherePack()

nums.makeCloud((0,0,0),(2e-1,2e-1,2e-1),rMean=coke[0],rRelFuzz=0,num=coke[1])

O.bodies.append([utils.sphere(c,r,material=mats[0],color=(0,0,1)) for c,r in nums])

sigmaIso=-1e5

#===============================================================
#=============================VTK===============================
#===============================================================

vtkExporter = VTKExporter('VTK_simulatione')

#===============================================================
#=================== define Engine =============================
#===============================================================

O.engines=[
     ForceResetter(),

     InsertionSortCollider([Bo1_Sphere_Aabb()]),
     InteractionLoop(
        [Ig2_Sphere_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()]
     ),

     PeriTriaxController(label='triax',
  goal=(sigmaIso,sigmaIso,sigmaIso),stressMask=7,
  dynCell=True,maxStrainRate=(1,1,1),
  maxUnbalanced=.01,relStressTol=1e-3,
  doneHook='compactionFinished()'
     ),
     NewtonIntegrator(damping=0.4),

     PyRunner(iterPeriod=50, command="vtkExporter.exportInteractions(ids='all',what=[('forceN','i.phys.normalForce().norm()')])")

]

O.dt=1e-6

O.saveTmp()

O.run(200000,True)

def compactionFinished():
 print 'Finished'
 O.pause()

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Alireza Sadeghi
Solved:
Last query:
Last reply:
Revision history for this message
Jérôme Duriez (jduriez) said :
#1

Hello

VTKExporter() being a part of YADE export module, you first need to import that module (like always in Python), in a consistent manner with your exact calls to that function.

E.g.
from yade import export
vtkExporter = export.VTKExporter('VTK_simulatione')

PS: to demonstrate your problem, I guess giving us vtkExporter = VTKExporter('VTK_simulatione') instead of the whole script would have been enough and more in the MWE [*] spirit ;-)

[*] https://www.yade-dem.org/wiki/Howtoask

Revision history for this message
Alireza Sadeghi (asadeghime) said :
#2

Hello Jerome,

Thank you very much for your response. I added the sentences which you told. Now, I have this error "TypeError: 'Vector3' object is not callable". The program gave me a file with name "VTK_simulatione-intrs-00000000.vtk". I don't know where did the zeros come from. However, when I deleted the zeroes I could open the file with Paraview.

In the Paraview, I can't select Cell Data to Point Data. In addition, all the tube has the same radius and I can't set the color by forceN.
I was wondering if you could help me. If there is an example which is similar to my problem, I will be grateful if you could share it with me.

Thank you very much

Alireza

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

Hello,

> TypeError: 'Vector3' object is not callable
> i.phys.normalForce().norm()

should be
i.phys.normalForce.norm()
because, as the error says, i.phys.normalForce is Vector3 and is not callable, i.e. adding () has undefined behavior.

> The program gave me a file with name "VTK_simulatione-intrs-00000000.vtk". I don't know where did the zeros come from.

zeros mean the very first output. If you output more times in the simulations, you would get, 001, 002 ...

> However, when I deleted the zeroes I could open the file with Paraview.

if I understand correctly, the deletion is not necessary as it is just file name and Paraview does not care how the file is named.

> In the Paraview ...

it is probably because of the error

cheers
Jan

Revision history for this message
Alireza Sadeghi (asadeghime) said :
#4

Dear Jan,

Thank you very much. You comment works great. But my question doesn't solve completely.
Now, the program run successfully, but I have a warning "Warning (yade.export.VTKExporter): no interactions"

The particles hit to each other and compaction process is completed. but the VTKExporter says that no interactions. I don't know what should I do now.

Thank you very much for your help.

Best Regards

Alireza

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

If YADE (VTKExporter) says there is no interactions, a first bet is to consider he is right and that there is no interaction, regardless your visual impressions
Did you first try to check what O.interactions.countReal() says ?

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

I tried your script with 3D view. The packing is very loose and there are visually no interactions.. so I guess Yade is right :-)
let us know
Jan

Revision history for this message
Alireza Sadeghi (asadeghime) said :
#7

Dear Jerome and Dear Jan,

Thank you very much for your help. I increased the confining pressure to -1e8 Pa. the particles go through each other. but in the ParaView there is no interaction. in addition, I added

PyRunner(command='history()',iterPeriod=10,label='recorder'),

to my engine and added

def history():
 plot.addData(szz2=-triax.stress[2], ezz=-triax.strain[2], i=O.iter,)

O.run()

plot.plots={'ezz':('szz2')}
plot.plot()

to my code, and the diagram shows the stress versus strain and it is not zero. All in all, my problem does bot solve.
Thank you very much for your help.

Best Regards

Alireza

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

Please provide a new version of complete script.
It is possible that that the vtk export is done at the time when the particles are already gone through each other?
thanks
Jan

Revision history for this message
Alireza Sadeghi (asadeghime) said :
#9

Hello Jan,

Thank you very much for your response. I think the vtk export express just the initial interaction, because at the beginning there is no interaction between the particles.
This is my complete code:

from yade import utils, plot
from yade import pack, qt
from datetime import datetime
from yade import export

qtr=qt.Renderer()
qtr.bgColor=(1,1,1)

#===========================================================
#==================set a periodic boundary==================
#===========================================================

O.periodic=True
O.cell.refSize=(2e-1,2e-1,2e-1)

#==============================================================
#================= define the materials =======================
#==============================================================

O.materials.append(CohFrictMat(normalCohesion= 1e20, shearCohesion= 1e20, isCohesive= True, young=6.81e8, density=1377.5, poisson=0.3, frictionAngle= 0.31, fragile=False, label='Coke'))

#===============================================================
#=================== define packing ============================
#===============================================================

nums=['t']

mats=['Coke']

coke=(5e-3,150)

nums=pack.SpherePack()

nums.makeCloud((0,0,0),(2e-1,2e-1,2e-1),rMean=coke[0],rRelFuzz=0,num=coke[1])

O.bodies.append([utils.sphere(c,r,material=mats[0],color=(0,0,1)) for c,r in nums])

sigmaIso=-1e8

#===============================================================
#=============================VTK===============================
#===============================================================

vtkExporter = export.VTKExporter('VTK_simulatione')

#===============================================================
#=================== define Engine =============================
#===============================================================

O.engines=[
     ForceResetter(),

     InsertionSortCollider([Bo1_Sphere_Aabb()]),
     InteractionLoop(
        [Ig2_Sphere_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()]
     ),

     PeriTriaxController(label='triax',
  goal=(sigmaIso,sigmaIso,sigmaIso),stressMask=7,
  dynCell=True,maxStrainRate=(1,1,1),
  maxUnbalanced=.01,relStressTol=1e-3,
  doneHook='compactionFinished()'
     ),
     NewtonIntegrator(damping=0.4),

     PyRunner(iterPeriod=100, command="vtkExporter.exportInteractions(ids='all',what=[('forceN','i.phys.normalForce.norm()')])"),
     PyRunner(command='history()',iterPeriod=10,label='recorder'),
]

O.dt=1e-6

O.saveTmp()

def history():
 plot.addData(unbalanced=unbalancedForce(),
              szz=-triax.stress[2],ezz=-triax.strain[2],i=O.iter,)

        print 'porosity:', porosity()
        print 'iteration', O.iter

O.run()

plot.plots={'ezz':('szz')}
plot.plot()

def compactionFinished():
 print 'Finished'
 O.pause()

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

I got syntax error in history() function..

What is the problem now?
I have tried the script without the function. It prints the warnings (apparently when there are no interactions), but it also saved a few files with interactions..

cheers
Jan

Revision history for this message
Alireza Sadeghi (asadeghime) said :
#11

YESSSSS, Thank you Jan, Thank you very much. It solved.