Use of O.Step and O.Pause when saving Packing

Asked by Gianni Pellegrini

Hi,
I think I did not get how O.Step and O.Pause are supposed to work.

In a basic triaxial testing script, I am using the following function to save the packing. Before doing that , I would like to change some properties of the material or as in the example, the spheres radii:

def DoneHook():
        O.interactions.clear()
        O.cell.velGrad=Matrix3(0,0,0,0,0,0,0,0,0)
        O.cell.trsf=Matrix3.Identity
        ac = O.cell.hSize
        np.save(fname + '.cellSizeCloud',ac)
        O.interactions.clear()
        #O.pause() #DO I NEED TO PAUSE BEFORE SAVING?
        #CHANGING MATERIAL OR GEOMETRICK PROPERTIES
        for b in O.bodies:
            b.shape.radius = R
        #O.step() #DO I NEED IT TO APPLY THE CHANGES?
        for b in O.bodies:
            b.state.pos = O.cell.wrap(b.state.pos)
        export.text(fname+".packing")
        O.pause()

When I used O.pause() before exporting, I have a random occurrence of Python Fatal Error *status is not current* and the file is not exported or exported with errors.
As you can read from my questions in the script's comments, I am unsure of the use of O.pause. Without it, I am able to save the file correctly but I do not know why.
Please let me know if you need a minimal working script to test this behaviour
thank you

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
Robert Caulk (rcaulk) said :
#1

Hello,

Yade reads your script sequentially. If you write O.run(#iters,1), then it will run #iters before moving to the next command in your script. One iteration is one full loop through O.engines. O.step = O.run(1,1). O.pause will pause the simulation no matter what is going on.

>>I have a random occurrence

What does "random" mean? You mean it occurs randomly (i.e. sometimes it works sometimes it does not)? Or do you mean the words in the error appear random and confusing to you?

You do not need O.pause in any of these situations, unless you started to use O.run(1,0).

Cheers,

Robert

Revision history for this message
Gianni Pellegrini (antrox) said (last edit ):
#2

Hello Robert,
thank you for your answer.
Yes, I meant that it occurs randomly so sometimes the file is created, other times not. Without the use of O.pause, it works just fine.
I maybe had understood your explanation. So O.pause will just stop the running of the O.engine but still, python will read the script and hence, it will execute the commands after O.pause. Is it?

Moreover, I wrote this simple example where I import the created packing and the dimension of the cell.
I assigned a new material and just use O.Step() in a loop. Please note I did not define any engine or apply any O.velgrad().
At each loop, I am printing the void ratio (obtaining a constant value) and the isotropic pressure (obtaining a different value every time).
I understand that this could be possible due to the original overlap of particles in the packing, but how O.Step can work if O.engine is not defined? And why the void ratio is not changing where the pressure is?

The code is below but I am not sure how to upload the input files for the cell and packing.
thanks

from __future__ import print_function

from yade import pack, plot, export, ymport
import numpy as np

frictionAngle =0.5
sigmaIso=-1e5
poisson=0.2
R=1e-3
density= 1e12
alphaKr=2.0
alphaKtw=2.0
etaRoll=0.1
young=1e10

#SETTINGS
O.periodic = True
ac = np.load('T1.cellSizeCloud.npy')
O.cell.hSize=ac

pp = O.materials.append(CohFrictMat(
 young=young,
 poisson=poisson,
 frictionAngle=frictionAngle,
 density=density,
 isCohesive=False,
 alphaKr=alphaKr,
 alphaKtw=alphaKtw,
 momentRotationLaw=True,
 etaRoll=etaRoll,
 ))

packing = ymport.text("T1.packing",color=(1,1,0),material=pp)
O.bodies.append(packing)

for i in range(0,100):
    O.step()
    u=utils.porosity()
    ev=u/(1-u)
    print('Isotropic start at initial void-ratio', ev)
    print('Isotropic start at initial pressure:', getStress().trace() / 3.)

Revision history for this message
Gianni Pellegrini (antrox) said :
#3
Revision history for this message
Best Robert Caulk (rcaulk) said :
#4

>>I assigned a new material and just use O.Step() in a loop.

This is not really the reason for O.step, although it works. The best way to collect information during a simulation is highlighted in the documentation: please review our PyRunners [1] and O.run [2].

>> but how O.Step can work if O.engine is not defined?

There is a default engine list assigned to every simulation. Type "O.engines" in your terminal to see.

[1]https://yade-dem.org/doc/user.html#running-python-code
[2]https://yade-dem.org/doc/user.html#stop-conditions

Revision history for this message
Gianni Pellegrini (antrox) said :
#5

Thanks Robert Caulk, that solved my question.