no file output by running yade -n *.py

Asked by Man Yick

Dear all,
I run the follow code '02.py' by using the command 'yade -n 02.py' or 'yade -x 02.py', but there is no file output 'bbb.txt.bz2'.
In contrast, if I run 'yade 02.py' and go into the graphical interface, I click the start bottom and run the simulation, and then I have the file output 'bbb.txt.bz2'.
Is there any way to generate file output by 'yade -n' or 'yade -x' ? Or is there problem in my 02.py file ?
Many thanks and best regards.
Man Yick

02.py reads as"
# gravity deposition in box
from yade import pack, plot
O.bodies.append(geom.facetBox((.5,.5,.5),(.5,.5,.5),wallMask=31))
sp=pack.SpherePack()
sp.makeCloud((0,0,0),(1,1,1),rMean=.05,rRelFuzz=.2)
sp.toSimulation()
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_FrictPhys()],
  [Law2_ScGeom_FrictPhys_CundallStrack()]
 ),
 NewtonIntegrator(gravity=(0,0,-9.81),damping=0.4),
 PyRunner(command='checkUnbalanced()',realPeriod=2),
 PyRunner(command='addPlotData()',iterPeriod=100)
]
O.dt=.5*PWaveTimeStep()
O.trackEnergy=True
def checkUnbalanced():
 if unbalancedForce()<.05:
  O.pause()
  plot.saveDataTxt('bbb.txt.bz2')
def addPlotData():
 plot.addData(i=O.iter,unbalanced=unbalancedForce(),**O.energy)
plot.plots={'i':('unbalanced',None,O.energy.keys)}
plot.plot()
O.saveTmp()
O.run
waitIfBatch()

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
Jan Stránský (honzik) said :
#1

Hello,

> if I run 'yade 02.py' and go into the graphical interface, I click the start bottom and run the simulation, and then I have the file output 'bbb.txt.bz2'.

the difference is that in GUI, you click "run". You have no such command in the script.
Note the difference between
O.run # as in your script
and
O.run() # as was intended?

cheers
Jan

Revision history for this message
Man Yick (manyick) said :
#2

Hallo Jan,
yes, it is 'O.run()'.
But when I type 'yade -x 02.py', there is still no file output 'bbb.txt.bz2'. Waht I want to realize is that, I can get the output file 'bbb.txt.bz2' by typing command line 'yade -x 02.py' without GUI and exiting automatically when the script finishes.
Any tips?
Many thanks.

Man Yick

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

> yes, it is 'O.run()'.

What does "it is" mean? Do you have a new code? If so, please provide it with the information what you have changed, e.g. O.run => O.run().
In the provided script, you have O.run, not O.run(), this is the main reason why you have no output - there is no running at all.

With O.run(), all yade running is finished when python finishes reading and executing the script lines - just after O.run() is executed.
O.run() starts running, but in the background, python continues reading and executing lines, and since there is not much left, it finishes just after O.run(), finishing also all yade running.

Use:
###
O.run()
O.wait() # [1,2], waits for O.pause inside checkUnbalanced()
# waitIfBatch() only works for batch run [3]
###

cheers
Jan

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.Omega.wait
[2] https://yade-dem.org/doc/introduction.html#running-simulation
[3] https://yade-dem.org/doc/yade.utils.html#yade.utils.waitIfBatch

Can you help with this problem?

Provide an answer of your own, or ask Man Yick for more information if necessary.

To post a message you must log in.