Stop condition

Asked by Seti

Hi all,

I trust all is well. I am just trying to do very simple simulation( felling down grains because of their weight).

I have two questions. The first one is regarding stopping conditions : I have used the unbalancedForce to imply this condition, I do not know which is correct or not, if yes why the program does not stop of running although after several hours it seems the grains do not move.

The other question is about the text file which I have used to save the results, when I want to use it , I face with the error which is mentioned " the file you opened has some invalid characters"

Maybe these questions are so simple to answer but I could not find the solutions. Make me glad if you help with these.

Thanks so much

Seti

Here is the script:
#!/usr/bin/python
from yade import pack,utils#, qt
pred = pack.inAlignedBox((0,0,0),(20,200,20))
#create material
soil1 = CohFrictMat(young=1e10,poisson=0.2,frictionAngle=radians(15),density=2500.0,normalCohesion=1e6, shearCohesion=80e6,label='soil')
#color=(1,0,0) ----red color
#soil1 = FrictMat(young=1e6,poisson=0.4,frictionAngle=radians(30),density=2500.0,label='soil')
O.materials.append(soil1)
O.bodies.append(utils.wall(0,axis=1,sense=1))
O.materials.append(CohFrictMat(young=1e9,poisson=0.1, frictionAngle = radians(15) , label='wallmat'))
wallmat = O.materials[-1]

spheres=SpherePack()
spheres=pack.randomDensePack(pred,radius=1.1,material='soil',spheresInCell=1000,color=(1,0,0),returnSpherePack=True)
spheres.toSimulation()
#O.bodies.append(spheres)
#

#
O.engines=[
             ForceResetter(),#reset forces
             InsertionSortCollider([Bo1_Wall_Aabb(),Bo1_Sphere_Aabb()]),
             InteractionLoop(
                            [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Wall_Sphere_ScGeom()], # collision geometry
                            [Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()], # collision "physics"
                            [Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),Law2_ScGeom_FrictPhys_CundallStrack()] # contact law -- apply forces
                                            ),
                      # apply gravity force to particles
                            # damping: numerical dissipation of energy
                            NewtonIntegrator(damping=0.5,gravity=(0,-9.81,0)),
                            #qt.SnapshotEngine(fileBase='3d-',iterPeriod=200,label='snapshot'),
   # this engine will be called after 20000 steps, only once
                            #PyRunner(command='finish()',iterPeriod=20000)
]

# set timestep to a fraction of the critical timestep
# the fraction is very small, so that the simulation is not too fast
# and the motion can be observed
O.dt=1*utils.PWaveTimeStep()
#makeVideo(snapshot.snapshots,'3d.mpeg',fps=10,bps=10000)
# save the simulation, so that it can be reloaded later, for experimentation
#O.saveTmp()
def checkUnbalanced():
   if unbalancedForce()<10:
      O.pause()
#plot.saveDataTxt('modi.data.bz2')
      # plot.saveGnuplot('bbb') is also possible

# collect history of data which will be plotted
def addPlotData():
   # each item is given a names, by which it can be the unsed in plot.plots
   # the **O.energy converts dictionary-like O.energy to plot.addData arguments
   plot.addData(i=O.iter,unbalanced=unbalancedForce(),**O.energy)
O.save('Modified.data.bz2')

#O.save('confinedState'+key+'.yade.gz')
from yade import qt
qt.View()
#O.run()
#from yade import qt
#qt.View()
#O.run()
# this function is called when the simulation is finished
#def finish():
   # snapshot is label of qt.SnapshotEngine
   # the 'snapshots' attribute contains list of all saved files
   #makeVideo(snapshot.snapshots,'3d.mpeg',fps=10,bps=10000)
   #O.pause()

# set parameters of the renderer, to show network chains rather than particles
# these settings are accessible from the Controller window, on the second tab ("Display") as well
#rr=yade.qt.Renderer()
#rr.shape=False
#rr.intrPhys=True

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Klaus Thoeni
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hi Seti,
there might be several reasons. In your script, the unbalanced force check
is never called. Do you use the same script, or you comment/uncomment
something while running? Please next time attach exactly the same script
with which you have problem and also delete unnecessary comments (not used
commands etc., half of your script :-), it will be then more readable and
clear where the problem might be..
Thanks in advance for more information
Jan

2015-08-10 8:07 GMT+02:00 Seti <email address hidden>:

> New question #270178 on Yade:
> https://answers.launchpad.net/yade/+question/270178
>
> Hi all,
>
> I trust all is well. I am just trying to do very simple simulation(
> felling down grains because of their weight).
>
> I have two questions. The first one is regarding stopping conditions : I
> have used the unbalancedForce to imply this condition, I do not know which
> is correct or not, if yes why the program does not stop of running although
> after several hours it seems the grains do not move.
>
> The other question is about the text file which I have used to save the
> results, when I want to use it , I face with the error which is mentioned "
> the file you opened has some invalid characters"
>
> Maybe these questions are so simple to answer but I could not find the
> solutions. Make me glad if you help with these.
>
> Thanks so much
>
> Seti
>
> Here is the script:
> #!/usr/bin/python
> from yade import pack,utils#, qt
> pred = pack.inAlignedBox((0,0,0),(20,200,20))
> #create material
> soil1 =
> CohFrictMat(young=1e10,poisson=0.2,frictionAngle=radians(15),density=2500.0,normalCohesion=1e6,
> shearCohesion=80e6,label='soil')
> #color=(1,0,0) ----red color
> #soil1 =
> FrictMat(young=1e6,poisson=0.4,frictionAngle=radians(30),density=2500.0,label='soil')
> O.materials.append(soil1)
> O.bodies.append(utils.wall(0,axis=1,sense=1))
> O.materials.append(CohFrictMat(young=1e9,poisson=0.1, frictionAngle =
> radians(15) , label='wallmat'))
> wallmat = O.materials[-1]
>
> spheres=SpherePack()
>
> spheres=pack.randomDensePack(pred,radius=1.1,material='soil',spheresInCell=1000,color=(1,0,0),returnSpherePack=True)
> spheres.toSimulation()
> #O.bodies.append(spheres)
> #
>
>
> #
> O.engines=[
> ForceResetter(),#reset forces
> InsertionSortCollider([Bo1_Wall_Aabb(),Bo1_Sphere_Aabb()]),
> InteractionLoop(
>
> [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Wall_Sphere_ScGeom()], # collision
> geometry
> [Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()],
> # collision "physics"
>
> [Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),Law2_ScGeom_FrictPhys_CundallStrack()]
> # contact law -- apply forces
> ),
> # apply gravity force to particles
> # damping: numerical dissipation of energy
>
> NewtonIntegrator(damping=0.5,gravity=(0,-9.81,0)),
>
> #qt.SnapshotEngine(fileBase='3d-',iterPeriod=200,label='snapshot'),
> # this engine will be called after 20000 steps, only once
> #PyRunner(command='finish()',iterPeriod=20000)
> ]
>
> # set timestep to a fraction of the critical timestep
> # the fraction is very small, so that the simulation is not too fast
> # and the motion can be observed
> O.dt=1*utils.PWaveTimeStep()
> #makeVideo(snapshot.snapshots,'3d.mpeg',fps=10,bps=10000)
> # save the simulation, so that it can be reloaded later, for
> experimentation
> #O.saveTmp()
> def checkUnbalanced():
> if unbalancedForce()<10:
> O.pause()
> #plot.saveDataTxt('modi.data.bz2')
> # plot.saveGnuplot('bbb') is also possible
>
> # collect history of data which will be plotted
> def addPlotData():
> # each item is given a names, by which it can be the unsed in plot.plots
> # the **O.energy converts dictionary-like O.energy to plot.addData
> arguments
> plot.addData(i=O.iter,unbalanced=unbalancedForce(),**O.energy)
> O.save('Modified.data.bz2')
>
> #O.save('confinedState'+key+'.yade.gz')
> from yade import qt
> qt.View()
> #O.run()
> #from yade import qt
> #qt.View()
> #O.run()
> # this function is called when the simulation is finished
> #def finish():
> # snapshot is label of qt.SnapshotEngine
> # the 'snapshots' attribute contains list of all saved files
> #makeVideo(snapshot.snapshots,'3d.mpeg',fps=10,bps=10000)
> #O.pause()
>
> # set parameters of the renderer, to show network chains rather than
> particles
> # these settings are accessible from the Controller window, on the second
> tab ("Display") as well
> #rr=yade.qt.Renderer()
> #rr.shape=False
> #rr.intrPhys=True
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Seti (seti) said :
#2

Dear Jan,

Thanks for your answer, it was right , I have fixed the first problem. :) however I have problem to save my data as txt. when I want to open the saved file , I face with the error which is mentioned " the file you opened has some invalid characters"
Would you please instruct me in this issue?

Cheers,
Seti

Here is my script.
#!/usr/bin/python
from yade import pack,utils#, qt
pred = pack.inAlignedBox((0,0,0),(20,200,20))
#create material
soil1 = CohFrictMat(young=1e10,poisson=0.2,frictionAngle=radians(15),density=2500.0,normalCohesion=1e6, shearCohesion=80e6,label='soil')
#color=(1,0,0) ----red color
#soil1 = FrictMat(young=1e6,poisson=0.4,frictionAngle=radians(30),density=2500.0,label='soil')
O.materials.append(soil1)
O.bodies.append(utils.wall(0,axis=1,sense=1))
O.materials.append(CohFrictMat(young=1e9,poisson=0.1, frictionAngle = radians(15) , label='wallmat'))
wallmat = O.materials[-1]

spheres=SpherePack()
spheres=pack.randomDensePack(pred,radius=1.1,material='soil',spheresInCell=1000,color=(1,0,0),returnSpherePack=True)
spheres.toSimulation()
#O.bodies.append(spheres)
#

#
O.engines=[
             ForceResetter(),#reset forces
             InsertionSortCollider([Bo1_Wall_Aabb(),Bo1_Sphere_Aabb()]),
             InteractionLoop(
                            [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Wall_Sphere_ScGeom()], # collision geometry
                            [Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()], # collision "physics"
                            [Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),Law2_ScGeom_FrictPhys_CundallStrack()] # contact law -- apply forces
                                            ),
                      # apply gravity force to particles
                            # damping: numerical dissipation of energy
                            NewtonIntegrator(damping=0.5,gravity=(0,-9.81,0)),
                            #qt.SnapshotEngine(fileBase='3d-',iterPeriod=200,label='snapshot'),
   # this engine will be called after 20000 steps, only once
                            #PyRunner(command='finish()',iterPeriod=20000)
                             PyRunner(command='checkUnbalanced()',realPeriod=2,label='checker'),
]

# set timestep to a fraction of the critical timestep
# the fraction is very small, so that the simulation is not too fast
# and the motion can be observed
O.dt=1*utils.PWaveTimeStep()
#makeVideo(snapshot.snapshots,'3d.mpeg',fps=10,bps=10000)

def checkUnbalanced():
   if unbalancedForce()<5e-3:
      print('Reached target , stopping')
      O.pause()

# collect history of data which will be plotted
def addPlotData():
   # each item is given a names, by which it can be the unsed in plot.plots
   # the **O.energy converts dictionary-like O.energy to plot.addData arguments
   plot.addData(i=O.iter,unbalanced=unbalancedForce(),**O.energy)
O.save('Modifiedd.txt.bz2')

#O.save('confinedState'+key+'.yade.gz')
from yade import qt
qt.View()

Revision history for this message
Klaus Thoeni (klaus.thoeni) said :
#3

Hi,

I thing the file you are trying to open is a binary file. Just guessing since your extension is *.txt.bz2. Try to extract the file first.

HTH
Klaus

Revision history for this message
Seti (seti) said :
#4

Hi Klaus,

Thanks for response. I have the same problem even after extracting :(

Revision history for this message
Best Klaus Thoeni (klaus.thoeni) said :
#5

I see, what exactly do you want to save? In the current form you are saving the whole simulation. You can save it as *.xml and it will be a text file, but it will be huge [1]. But I think you want to save your data from the plot, right? In this case you have to use plot.saveDataTxt("filname.txt") [2].

HTH
Klaus

[1] https://yade-dem.org/doc/yade.wrapper.html?highlight=save#yade.wrapper.Omega.save
[2] https://yade-dem.org/doc/yade.plot.html?highlight=save#yade.plot.saveDataTxt

Revision history for this message
Seti (seti) said :
#6

Thanks Klaus Thoeni, that solved my question.