Unhandled exception in thread started by <function liveUpdate at 0x7f0388a37320>

Asked by Cloud on 2018-11-26

Hi,

I'm trying to simulation triaxial test by using https://github.com/yade/trunk/blob/master/examples/triax-tutorial/script-session1.py wiht some minor modifications. It works well with young = 100e6, but it encountered some problems when I set young = 500e6. Most of this simulation works normally, but then there will be the following prompts in the terminal and the simulation stopped.

In [1]: Unhandled exception in thread started by <function liveUpdate at 0x7f0388a37320>
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/usr/lib/x86_64-linux-gnu/yade/py/yade/plot.py in liveUpdate(timestamp)
    506 for ax in axes:
    507 try:
--> 508 ax.relim() # recompute axes limits
    509 ax.autoscale_view()
    510 except RuntimeError: pass # happens if data are being updated and have not the same dimension at the very moment

/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in relim(self, visible_only)
   1936 for line in self.lines:
   1937 if not visible_only or line.get_visible():
-> 1938 self._update_line_limits(line)
   1939
   1940 for p in self.patches:

/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in _update_line_limits(self, line)
   1799 Figures out the data limit of the given line, updating self.dataLim.
   1800 """
-> 1801 path = line.get_path()
   1802 if path.vertices.size == 0:
   1803 return

/usr/lib/python2.7/dist-packages/matplotlib/lines.pyc in get_path(self)
    955 """
    956 if self._invalidy or self._invalidx:
--> 957 self.recache()
    958 return self._path
    959

/usr/lib/python2.7/dist-packages/matplotlib/lines.pyc in recache(self, always)
    665 y = self._y
    666
--> 667 self._xy = np.column_stack(np.broadcast_arrays(x, y)).astype(float)
    668 self._x, self._y = self._xy.T # views
    669

/usr/lib/python2.7/dist-packages/numpy/lib/stride_tricks.pyc in broadcast_arrays(*args, **kwargs)
    247 args = [np.array(_m, copy=False, subok=subok) for _m in args]
    248
--> 249 shape = _broadcast_shape(*args)
    250
    251 if all(array.shape == shape for array in args):

/usr/lib/python2.7/dist-packages/numpy/lib/stride_tricks.pyc in _broadcast_shape(*args)
    182 # use the old-iterator because np.nditer does not handle size 0 arrays
    183 # consistently
--> 184 b = np.broadcast(*args[:32])
    185 # unfortunately, it cannot handle 32 or more arguments directly
    186 for pos in range(32, len(args), 31):

ValueError: shape mismatch: objects cannot be broadcast to a single shape
axial strain reach Limitation, stop loading!

Has anybody met the same problem? How can I solve it ?

regards

Cloud

The whole code :
from yade import pack

num_spheres=5000
key='_My_triax_'
targetPorosity=0.40
compFricDegree=20
finalFricDegree=30
rate=-0.02
damp=0.2
stabilityThreshold=0.01
young=500e6
mn,mx=Vector3(0,0,0),Vector3(1,1,2)
confiningStress=100000

O.materials.append(FrictMat(young=young,poisson=0.1,frictionAngle=radians(compFricDegree),density=2600,label='spheres'))
O.materials.append(FrictMat(young=young,poisson=0.1,frictionAngle=0,density=0,label='walls'))

walls=aabbWalls([mn,mx],thickness=0,material='walls')
wallIds=O.bodies.append(walls)

sp=pack.SpherePack()
sp.makeCloud(mn,mx,-1,0.1,num_spheres,False, 0.95,seed=1)
O.bodies.append([sphere(center,rad,material='spheres') for center,rad in sp])

triax=TriaxialStressController(
    maxMultiplier=1.+2e4/young,
    finalMaxMultiplier=1.+2e3/young,
    thickness = 0,
    stressMask = 7,
    internalCompaction=True,
)

O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
    InteractionLoop(
        [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()]
    ),
    GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8),
    triax,
    TriaxialStateRecorder(iterPeriod=100,file='WallStresses'+key),
    NewtonIntegrator(damping=damp)
]

Gl1_Sphere.stripes=0

yade.qt.Controller(),yade.qt.View()

triax.goal1=triax.goal2=triax.goal3=-confiningStress

while 1:
    O.run(1000, True)
    unb=unbalancedForce()
    print 'unbalanced force:',unb,' mean stress: ',triax.meanStress
    if unb < stabilityThreshold and abs(-confiningStress-triax.meanStress)/confiningStress<0.001:
        break

O.save('confinedState'+key+'.yade.gz')
print "### Isotropic state saved ###"

import sys
while triax.porosity > targetPorosity:
    compFricDegree = 0.95*compFricDegree
    setContactFriction(radians(compFricDegree))
    print "\r Friction: ", compFricDegree,"porosity:", triax.porosity,
    sys.stdout.flush()
    O.run(500,1)

O.save('compactedState'+key+'.yade.gz')
print "### Compacted state saved ###"

triax.internalCompaction=False

setContactFriction(radians(finalFricDegree))

triax.stressMask = 3
triax.goal3 = rate
triax.goal1=-confiningStress
triax.goal2=-confiningStress

newton.damping=0.1

O.saveTmp()

from yade import plot

def history():
    plot.addData(
            e11=-triax.strain[0],
            e22=-triax.strain[1],
            e33=-triax.strain[2],
            ev=triax.strain[0]+triax.strain[1]+triax.strain[2],
            s11=-triax.stress(triax.wall_right_id)[0],
            s22=-triax.stress(triax.wall_top_id)[1],
            s33=-triax.stress(triax.wall_front_id)[2],
            devi = -triax.stress(triax.wall_front_id)[2] + triax.stress(triax.wall_top_id)[1],
            i=O.iter)

def stoploading():
    axial_strain = abs(triax.strain[2])
    if axial_strain > 0.2:
        print 'axial strain reach Limitation, stop loading!'
        O.pause()

if 1:
    O.engines=O.engines[0:5]+[PyRunner(iterPeriod=20,command='history()',label='recorder')]+O.engines[5:7]
    O.engines=O.engines+[PyRunner(command='stoploading()',iterPeriod=10)]
else:
    O.engines[4]=PyRunner(iterPeriod=20,command='history()',label='recorder')

O.run(100,True)

plot.plots={'e33':('ev',),' e33 ':('devi')
}
plot.plot()

plot.saveDataTxt('results'+key)
plot.saveGnuplot('plotScript'+key)

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Cloud
Solved:
2018-11-29
Last query:
2018-11-29
Last reply:
2018-11-29
Jérôme Duriez (jduriez) said : #1

Hello,

What if you put your 'recorder' PyRunner at the end of O.engines ?

>script-session1.py wiht some minor modifications. It works well with young = 100e6, but it encountered some problems when I set young = 500e6

Hi,
I just grabbed script-session1.py, changed Young to 500e6, then ran the script.
Everything is running smoothly though more slowly (as expected for stiffer problem).
Conclusion: your question is ill-posed, it blames stiffness while the real problem you introduced is hidden behind a vague "some minor modifications".
Bruno

Cloud (strife-cloud) said : #3

Hi, Jérôme,

This modification does not seem to solve my problem, but thank you for your help.

Hi, Bruno,

"some minor modifications" include num_spheres=5000, targetPorosity=0.40, compFricDegree=20, young=500e6, mn,mx=Vector3(0,0,0),Vector3(1,1,2), confiningStress=100000 and defining a funtion stoploading() used to stop loading when axis strain reach a target value. These are the data I need to modify for comparative simulations. Young's modulus is a quantity for comparison. I feel that these changes are not a big problem. Everything is the same except for Young's modulus. When it is 100e6, the simulation works normally, but when I only modify it to 500e6, it appears the problem I described. This is where I don't understand.

Cloud

Cloud (strife-cloud) said : #4

By the way , this problem does not occur at the beginning of the simulation, but runs normally for a while before the problem occurs.

Robert Caulk (rcaulk) said : #5

It seems updating too frequently can cause matplotlib to throw this error. Why are you asking matplotlib to update every 20 iterations during a simulation that runs 500k iterations?

We "solved" this problem in [1]. Will you please read through [1], confirm the problem is the same, try the solution, and then tell us if it works?

Meanwhile, I am running your script out for a "while" to reproduce the problem.

Thank you,

Robert

[1]https://answers.launchpad.net/yade/+question/670492

Robert Caulk (rcaulk) said : #6

Your "Axial strain reach limitation, stop loading!" message appeared and the simulation paused.

I guess that is a "while" without the error?

It seems this is a matplotlib problem. Please post your matplotlib version, your linux distro+version, and your social security number :-)

Cheers,

Robert

Cloud (strife-cloud) said : #7

Hi, Robert

Thank you very much for your reply!

>Why are you asking matplotlib to update every 20 iterations during a simulation that runs 500k iterations?

This is just the value in script-session1.py, I don't modify it for I want to record accurate data, but I have never thought that there will be problems at this point.

>We "solved" this problem in [1]. Will you please read through [1], confirm the problem is the same, try the solution, and then tell us if it works?

Yes, it works. IterPeriod is set to a very large value ( iterperiod=10000 as you say), if so, I can't record accurate data any more.

>I guess that is a "while" without the error?

Yes.

matplotlib.__version__ '2.1.1'
Yade 2018.02b
Ubuntu 18.04.1 LTS

Regards,

Cloud

Robert Caulk (rcaulk) said : #8

Did you try iterperiod=1000? That would give you 500 data points, is that still too few for your needs?

Chareyre (bruno-chareyre-9) said : #9

If you need more points you can store the values in you own python list and
dump it to a file at the end.
Bruno

Le jeu. 29 nov. 2018 09:37, Robert Caulk <
<email address hidden>> a écrit :

> Question #676370 on Yade changed:
> https://answers.launchpad.net/yade/+question/676370
>
> Robert Caulk posted a new comment:
> Did you try iterperiod=1000? That would give you 500 data points, is
> that still too few for your needs?
>
> --
> You received this question notification because your team yade-users 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
>
>

Cloud (strife-cloud) said : #10

Thank you, Robert and Bruno, you help me a lot!