How to inspect the body one by one in the cloud if I have 2 files YADE separately?

Asked by Defri

Dear all,

I have some confusions:
I would like to use the paraview to inspect the stress of the body (because if you see in the graph, that the stress is really big until more than 1 million kN/m^2), I wanna know what caused it to happen, but the problem is I made 2 files separately.
My question is:
  1. Is that the command I need to do is using VTKRecorder only?
  2. If yes, Where I need to put that and how? I made once (not in these files) only like I put VTKRecorder(fileName='tes',recorders=['all'],iterPeriod=100) on the last row of O.engines. Is it correct only like that?
  3. On Which row I have to put the command?

###SCRIPT### FILE 1

##Sphere Cylinder pack
from yade import pack,plot,utils,export
import math
from pylab import rand #for sand color
O.trackEnergy=True

O.engines=[ForceResetter(),
  InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()]),
  InteractionLoop([Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
   [Ip2_FrictMat_FrictMat_FrictPhys()],
   [Law2_ScGeom_FrictPhys_CundallStrack()]),
   NewtonIntegrator(damping=.3,gravity=[0,0,-9.81])]

O.bodies.append(geom.facetBox((0,-1.7,0),(1.7,0,2),wallMask=4))
O.bodies.append(geom.facetBox((0,1.7,0),(1.7,0,2),wallMask=4))
O.bodies.append(geom.facetBox((-1.7,0,0),(0,1.7,2),wallMask=4))
O.bodies.append(geom.facetBox((1.7,0,0),(0,1.7,2),wallMask=4))

bottom=wall((0,0,-2),axis=2)
O.bodies.append(bottom)
sp=pack.SpherePack()
s=200
dmax=0.00050*s
dmin=0.00025*s
rMean=(dmax+dmin)/4
rRelFuzz=(dmax-dmin)/(dmax+dmin)
nums=10000
sp.makeCloud((-1.7,-1.7,-2),(1.7,1.7,1),rMean,rRelFuzz,num=nums)
#sp.makeCloud((-1.7,-1.7,1),(1.7,1.7,5),rMean,rRelFuzz,num=2*nums)

O.materials.append(FrictMat(young=600e6,poisson=.3,density=2700,frictionAngle=radians(17)))

sp.toSimulation(color=(0.6+0.15*rand(),0.5+0.15*rand(),0.15+0.15*rand()))

##Define material of the grains
for i in range(9,len(O.bodies)):
 b=O.bodies[i]
 b.state.blockedDOFs='XYZ'
 b.state.vel=(0,0,0)

O.dt=PWaveTimeStep()

globals().update(locals())

O.saveTmp()

After all the bodies dropped under the gravity, in the Terminal, I typed In [1]: O.save('YADE/(directory and the name of file)')
Then I load it in this SCRIPT FILE 2:

#O.load('YADE/dennis_yade/drop/Sand_2_41794')
O.load('YADE/dennis_yade/drop/Sand_1_33509')

O.materials.append(FrictMat(young=600e6,poisson=0.3,density=2227,frictionAngle=radians(17),label='boulder'))
k=utils.sphere(center=(0,0,.3),radius=.45,color=[0,1,1],material='boulder')
O.bodies.append(k)
height=10
k.state.vel=(0,0,-(2*9.81*height)**.5)

from yade import pack,plot,utils,export

O.engines=O.engines+[PyRunner(command='stress_rad1()',iterPeriod=5)]

def stress_rad1():
 b1=O.bodies[-1]
 rad1=.25
 rad2=.5
 rad3=.75
 area1=pi*rad1**2
 area2=pi*(rad2**2-rad1**2)
 area3=pi*(rad3**2-rad2**2)
 ForceP=0
 StP=0
 ForceP1=0
 StP1=0
 ForceP2=0
 StP2=0
 for i in O.bodies[8].intrs():
  m=O.bodies[i.id2]
  dist=(m.state.pos[0]**2+m.state.pos[1]**2+(m.state.pos[2]+2)**2)**.5
  if dist<=rad1: #1st area
    u=O.interactions[8,m.id]
    ForceP=ForceP+abs(u.phys.normalForce[2])
    StP=ForceP/area1
  if dist>rad1 and dist<=rad2: #2nd area
    u1=O.interactions[8,m.id]
    ForceP1=ForceP1+abs(u1.phys.normalForce[2])
    StP1=ForceP1/area2
  if dist>rad2 and dist<=rad3:#3rd area
    u2=O.interactions[8,m.id]
    ForceP2=ForceP2+abs(u2.phys.normalForce[2])
    StP2=ForceP2/area3
 Force=O.forces.f(b1.id)[2]
 plot.addData(FzB=Force,z=b1.state.pos[2],Stress=StP,Stress1=StP1,Stress2=StP2,i=O.iter,t=O.time,velocity=b1.state.vel.norm())

globals().update(locals())

plot.plots={
 'i':('FzB',),'t':('Stress','Stress1','Stress2'),}

plot.plot(subPlots=True)

What should I do?

Thank you in advance!

Cheers!!

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Defri
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Robert Caulk (rcaulk) said :
#1

Hello,

It is not clear exactly what the problem is. VTKRecorder prints a new file every *iterPeriod* iterations. Each file allows paraview to visualize the desired quantities at each *iterPeriod*th iteration. When you use paraview, you should open the whole set of files at once, paraview will put them in order and allow you to "play" the simulation like a flip-book.

Cheers,

Robert

Revision history for this message
Defri (daredefri) said :
#2

It means I cannot inspect what is the reason behind my stress got that number...because I tried to combine those files into one and put the VTKRecorder command at the last, it could not run..

Thank you for your response.

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

Hello,

please read [1] and provide more information.
You are talking about VTKRecorder, but it is not clear at all how you use it (it is not in the code and the word description is not clear enough).

> It means I cannot inspect ...

no, actually Robert's answer meant that you CAN inspect

> because I tried to combine those files into one and put the VTKRecorder command at the last, it could not run..

What are "those files"?
Why do you want to combine them into one?
What does "put the VTKRecorder command at the last" mean?
What does "could not run" mean? Some errors?
...

Cheers
Jan

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

Revision history for this message
Defri (daredefri) said :
#4

I am sorry in advance if many words are complicated.

I have a problem that I got the wrong result in the graph that is produced in 2nd File...
So to get the result what I mean is in the following:

In the beginning,
If you run the 1st file of code
When the grains already drop under the gravity, I saved using terminal by typing:
O.save('YADE/dennis_yade/drop/Sand_1_33509')

Then load it in the 2nd file
O.load('YADE/dennis_yade/drop/Sand_1_33509')
....
....
....
..... (like I have typed on the above)

Then it will result in the graph, which has the value of stress (the below graph), and I think it is wrong (because more than 1 million kN/m^2)

Anyway
I just wanna inspect that mistake, which might be I can inspect by using paraview
but unfortunately, to inspect it using paraview, I only know using VTKRecorder which I only know by putting/typing the code of VTKRecorder in the last row of 2nd file (when I put them together in 1st and 2nd file into one file)

And the way I put/type the code of VTKRecorder is like this e.g. VTKRecorder(fileName='test',recorders=['all'],iterPeriod=100)

then it becomes failed, it has error

I combined that, because Mr. Robert said, "When you use paraview, you should open the whole set of files at once..." so I thought I need to do that.

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

> which might be I can inspect by using paraview

or you can use Yade directly

> I only know using VTKRecorder which I only know by putting/typing the code of VTKRecorder in the last row of 2nd file (when I put them together in 1st and 2nd file into one file)

If you have O.save / O.load, it it not much different using two or one file

VTKRecorder can be used:
- "standalone" (see below) for one output
- as an engine in O.engines for periodic output

> And the way I put/type the code of VTKRecorder is like this e.g. VTKRecorder(fileName='test',recorders=['all'],iterPeriod=100)

Like this, it does nothing, it just creates the recorder. To get some output, you either need to put it in O.engines (and run to make it output), or you need to call it, something like:
###
vtk = VTKRecorder(...)
vtk() # call
###

> then it becomes failed, it has error

Please be more specific, i.e. copy-paste the full error message here

Please also provide actual code you are using.
The provided code is way better then descriptions like " I put/type the code" which can be easily misinterpreted.

> I combined that, because Mr. Robert said, "When you use paraview, you should open the whole set of files at once..." so I thought I need to do that.

In paraview, open (select) all the VTK files at once. It was not about Yade scripts.

Cheers
Jan

Revision history for this message
Defri (daredefri) said :
#6

Yes..I have found the solution only from YADE..thank you...