avg Num Interactions

Asked by Luis Barbosa

Hi,

My code [1] to store the coordination number was working pretty well some months ago, but today I tried again and I got an error [2]

Any idea of what does this error mean?

[1]
def AutoData():
 plot.addData(CN=avgNumInteractions(cutoff=0.0,skipFree=True,considerClumps=False), i=O.iter) #this is line 150
O.run(1000,True)#1700000
plot.plots={'i':('CN')}
plot.plot()
plot.saveDataTxt('CN.txt')

[2]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "size1densoF4.py", line 150, in AutoData
    plot.addData(CN=avgNumInteractions(cutoff=0.0,skipFree=True,considerClumps=False), i=O.iter)
  File "/usr/lib/x86_64-linux-gnu/yadedaily/py/yade/utils.py", line 438, in avgNumInteractions
    nums,counts=bodyNumInteractionsHistogram(aabbExtrema(cutoff))
Boost.Python.ArgumentError: Python argument types in
    yade._utils.bodyNumInteractionsHistogram(list)
did not match C++ signature:
    bodyNumInteractionsHistogram(boost::python::tuple aabb)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "size1densoF4.py", line 150, in AutoData
    plot.addData(CN=avgNumInteractions(cutoff=0.0,skipFree=True,considerClumps=False), i=O.iter)
  File "/usr/lib/x86_64-linux-gnu/yadedaily/py/yade/utils.py", line 438, in avgNumInteractions
    nums,counts=bodyNumInteractionsHistogram(aabbExtrema(cutoff))
Boost.Python.ArgumentError: Python argument types in
    yade._utils.bodyNumInteractionsHistogram(list)
did not match C++ signature:
    bodyNumInteractionsHistogram(boost::python::tuple aabb)

Question information

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

This question was reopened

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

I suspect this is a side effect of a recent improvement to the code [1]. bodyNumInteractionsHistogram [2] just needs to be updated to accept a list instead of a tuple in the same way. I will try to fix as soon as possible.

[1] https://github.com/yade/trunk/commit/1db13fb1183b9e294dc9761da76cfa4fc2791cc1#diff-b419764bcd75202d733c0952ac1fc88f
[2]https://github.com/yade/trunk/blob/c14fd94f6be04f24e45daff0eed6ae6b8e737d4f/py/_utils.cpp#L67

Revision history for this message
Luis Barbosa (luis-pires-b) said :
#2

Ok, let me know when you fix it.

Thanks,
Luis

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

if you want to track the progress:

https://bugs.launchpad.net/yade/+bug/1804621

Revision history for this message
Jérôme Duriez (jduriez) said :
#4

Hi Luis,

This error meant that your call to avgNumInteractions() triggered a call to bodyNumInteractionsHistogram() [1] with a Python list as an argument, whereas the latter bodyNumInteractionsHistogram() (a Python function inherited from C++ world thanks to boost::python) wants Python tuples as arguments [2]. And Python list and Python tuples are different things (but do not ask me why ;-) )

In more details bodyNumInteractionsHistogram had actually been called with the output of aabbExtrema() as an argument [1]. And, because of recent changes in the C++ world [3] (and because of the exact manner the C++ and the Python worlds are connected), the return type of aabbExtrema() in the Python world is now a list, whereas it used to be a tuple.

Hence the error, as my 1st paragraph said.

I just committed changes [4] that solve the bug, as well as the other following example maybe closer to your needs:

#########
O.bodies.append(sphere((0,0,0),1,dynamic=False))
O.bodies.append(sphere((0,0,1.9),1,dynamic=False))
O.bodies.append(sphere((0.7,0,0.7),1,dynamic=False))
# 3 spheres example to avoid the "nan" case in avgNumInteractions(skipFree=True)

O.step()

print ''
print 'Avg Num Interactions', avgNumInteractions(cutoff=0.0,skipFree=True,considerClumps=False)
######### (This could have been your MWE ;-) )

When and how these changes will land in your computer depend on your use of YADE. Thanks for reporting anyway,

Jérôme

[1] See File "/usr/lib/x86_64-linux-gnu/yadedaily/py/yade/utils.py", line 438, in avgNumInteractions, the command "nums,counts=bodyNumInteractionsHistogram(aabbExtrema(cutoff)"
[2] https://github.com/yade/trunk/blob/c14fd94f6be04f24e45daff0eed6ae6b8e737d4f/py/_utils.hpp#L29
[3] https://github.com/yade/trunk/commit/1db13fb1183b9e294dc9761da76cfa4fc2791cc1
[4] https://github.com/yade/trunk/commit/7c60d78bd9badfa174fb79a82af7b119abf81d5d

Revision history for this message
Luis Barbosa (luis-pires-b) said :
#5

Nice job Jérôme.

but what do you mean by "When and how these changes will land in your computer depend on your use of YADE" ?
It will be automatically updated or do I need to change something?

Cheers,
Luis

Revision history for this message
Jérôme Duriez (jduriez) said :
#6

I do not know since you did not tell us which YADE you're using ;-)
yadedaily ? compiled from sources ?

If it's yadedaily (looking at your error messages), you will get the update once

1. a new version of yadedaily package (including the changes of today's commit) is released to the world
2. you locally update your packages to adopt this update

Revision history for this message
Luis Barbosa (luis-pires-b) said :
#7

Ok, tanks.

Revision history for this message
Luis Barbosa (luis-pires-b) said :
#8

Hello everyone,

After the last yadedaily update in 12-05, the same initial problem reported here still persists.

Am I doing something wrong or is avgNumInteractions() not working yet?

Cheers,
Luis

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#9

Hi, Could you please provide more accurate version number and a minimal working script?
Bruno

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#10

Can't reproduce:

bchareyre@lt-gmn018:~$ yadedaily
Welcome to Yade 2018.02b-288b5fbefc~xenial
Yade [1]: nums,counts=bodyNumInteractionsHistogram(aabbExtrema(0))
Yade [2]:

Revision history for this message
Luis Barbosa (luis-pires-b) said :
#11

Hi Bruno I am using yadedaily Yade 2018.02b-1786828270~xenial

Here follows the script:

#!/usr/bin/python
# -*- coding: utf-8 -*-

from yade import plot
from yade import pack
from yade import utils
from yade import bodiesHandling
import math
import random

# Spheres############################################################

O.materials.append(JCFpmMat(type=1,young=70e9,poisson=0.3,frictionAngle=radians(30),density=1600,tensileStrength=15e5,cohesion=15e5,jointNormalStiffness=1e5,jointShearStiffness=1e5,jointCohesion=15e5,jointFrictionAngle=radians(30),jointDilationAngle=0.0,label='spheres'))

ag=O.bodies.append(
# pack.regularHexa(
 pack.randomDensePack(
  (pack.inSphere((0,0,0.055),0.055)),radius=rad,color=(0,1,0),rRelFuzz=0,material='spheres') # head
)

###################################################################

O.engines=[
  ForceResetter(),

 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
  [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys(cohesiveTresholdIteration=1)],
  [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(smoothJoint=False, Key="Wei", recordCracks=True)]
 ),

  GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=500,timestepSafetyCoefficient=0.5),
  NewtonIntegrator(damping=0.1,gravity=[0,0,0]),
  PyRunner(command='AutoData()',iterPeriod=500,initRun=True),

]

##########################Coordination Number############################################
def AutoData():
 plot.addData(CN=avgNumInteractions(cutoff=0.,skipFree=True,considerClumps=False), i=O.iter)
O.run(2000,True)#800000
plot.plots={'i':('CN')}
plot.plot()
plot.saveDataTxt('CN.txt')

from yade import qt
qt.View()
qt.Controller()

Thank you,
Luis

Revision history for this message
Luis Barbosa (luis-pires-b) said :
#12

Followed above

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#13

I couldn't trace back 2018.02b-1786828270~xenial I'm sorry.
Could you update yadedaily and report new version number (and confirm the bug)?
Bruno

Revision history for this message
Luis Barbosa (luis-pires-b) said :
#14

Hi Bruno,
Just to confirm, the last version you mean is:

yadedaily_2018.02b-28948d72e6~xenial-1

Right?

Luis

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#15

Yes, it is currently the latest.
Bruno

Revision history for this message
Luis Barbosa (luis-pires-b) said :
#16

Tks