Polyhedron interaction with sphere

Asked by Nishant

Hello,

I was understanding how polyhedron interacts with sphere in yade and encountered a problem with the dictionary of the interaction.

I created a system with one sphere and a box (made by polyhedron). The box touches the sphere from the bottom and has a velocity. I look at the interaction between the box and sphere after a time step. Below is the MWE:

#--------------------

from yade import pack,polyhedra_utils
import shutil, sys, imp
import numpy as np

#------------------- System definition ----------------------
rad_p = 0.1
Xl = 0.
Yl = 0.
Xr = 1.
Yr = 1.
Zl = rad_p
Zr = 1.
eps_pos = 1e-5
#--------------------------
O.bodies.append([sphere((0.5*(Xl+Xr)+eps_pos,0.5*(Yl+Yr),0.0),rad_p, fixed = True) ]) # Sphere object

O.bodies.append(polyhedron([(Xl,Yl,Zl),(Xr,Yl,Zl),(Xl,Yr,Zl),(Xr,Yr,Zl),(Xl,Yl,Zr),(Xr,Yl,Zr),(Xl,Yr,Zr),(Xr,Yr,Zr)],wire=False,dynamic=True)) # polyhedron which compresses the sphere
#------------------------------------

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(), Bo1_Box_Aabb(), Bo1_Wall_Aabb(), Bo1_Polyhedra_Aabb()],allowBiggerThanPeriod=True),
 InteractionLoop(
 [Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom(), Ig2_Wall_Sphere_ScGeom(), Ig2_Sphere_Polyhedra_ScGeom()],
 [Ip2_FrictMat_FrictMat_MindlinPhys()],
 [Law2_ScGeom_MindlinPhys_Mindlin()]
 ),
 PyRunner(command = 'load()', iterPeriod = 1, label = "checker"),
 NewtonIntegrator(gravity=(0,0,0.0),damping = 0.0)
]

def load():
 O.bodies[1].state.vel = Vector3(0,0,-1e-5)

 if ( O.iter > 3):
  O.pause()

#---------------------------
O.dt=.5e-0*PWaveTimeStep()
O.stopAtIter= int(1e6)
O.step()

#-------------------
Case I: If the sphere is positioned not at the center of box bottom face (non-zero eps_pos in the code above), O.interactions[0,1].phys.dict() gives correct interaction parameters.

Case II: When the sphere is located just at the center of the box (eps_pos = 0), there is an interaction between the two objects, but without any dictionary.

#Yade [1]: O.interactions[0,1].phys.dict()
#---------------------------------------------------------------------------
#AttributeError Traceback (most recent call last)
#/home/nishantkumar/Desktop/Yade201802b/build/bins/yade-2018.02b in <module>()
#----> 1 O.interactions[0,1].phys.dict()

#AttributeError: 'NoneType' object has no attribute 'dict'

Any reason for this?

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

Thank you for putting together a nice MWE showcasing this problem. I looked into your MWE and I believe you found a bug. I am sharing a more dramatic (and concise) MWE below for others who wish to look into this. In this example, setting eps_pos of 1e-5 results in the sphere interacting with the polyhedra. Then, simply changing eps_pos to 0 results in the sphere passing through the polyhedron.

I will spend some more time sifting through the source code to identify the bug. I suspect it is somewhere in the collision identification [1]. I will let you know if I find anything, otherwise, we might need one of Yade's polyhedra specialists to look at this.

#--------------------

from yade import pack,polyhedra_utils
import shutil, sys, imp
import numpy as np

#------------------- System definition ----------------------
rad_p = 0.1
Xl = 0.
Yl = 0.
Xr = 1.
Yr = 1.
Zl = rad_p
Zr = 1.
eps_pos = 1e-5
#--------------------------
polyMat = PolyhedraMat(young=1e10,poisson=.05)
frictMat = FrictMat(young=1e9,poisson=.2)

O.materials.append((polyMat,frictMat))

O.bodies.append([sphere((0.5*(Xl+Xr)+eps_pos,0.5*(Yl+Yr),-rad_p),rad_p, dynamic=True,material=frictMat) ]) # Sphere object

O.bodies.append(polyhedron([(Xl,Yl,Zl),(Xr,Yl,Zl),(Xl,Yr,Zl),(Xr,Yr,Zl),(Xl,Yl,Zr),(Xr,Yl,Zr),(Xl,Yr,Zr),(Xr,Yr,Zr)],wire=False,dynamic=True,material=polyMat)) # polyhedron which compresses the sphere
#------------------------------------

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Polyhedra_Aabb()]),
 InteractionLoop(
 [Ig2_Sphere_Polyhedra_ScGeom()],
 [Ip2_FrictMat_PolyhedraMat_FrictPhys()],
 [Law2_ScGeom_FrictPhys_CundallStrack()],
 ),
 #PyRunner(command = 'load()', iterPeriod = 1, label = "checker"),
 NewtonIntegrator()
]

O.bodies[1].state.blockedDOFs = 'xyzXYZ'

O.bodies[0].state.vel = Vector3(0,0,1e-1)

#---------------------------
O.dt=.5*PWaveTimeStep()
O.step()

#-------------------

[1]https://github.com/yade/trunk/blob/master/pkg/dem/Polyhedra_Ig2.cpp#L342

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

>When the sphere is located just at the center of the box (eps_pos = 0), there is an interaction between the two objects

Hi, just a short comment: it is expected - and perfectly fine - that some interactions accessed with [i,j] operator have no physics (hence no phys.dict either). It is a common feature of all virtual interactions.
This being said I did not test the script, and so I don't know if one should reasonably expect a real interaction with eps=0.
Bruno

Revision history for this message
Nishant (nishantk) said :
#3

@Bruno: The polyhedra and sphere are touching initially, and the polyhedra moves in the direction of the sphere with a prescribed velocity.
So a real interaction is expected to occur at the first time-step.

This indeed happens, when the sphere is positioned not at the center (eps_pos not equal to zero).
When the sphere is located at the center, the phys.dict is empty.

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

Hello,

@Robert, "one of Yade's polyhedra specialists"

I am afraid this "specialist" should be me.. at least this sphere-polyhedra interaction is my code, I will have a look as soon as time allows it..

@Nishat

> The polyhedra and sphere are touching initially, and the polyhedra moves in the direction of the sphere with a prescribed velocity.
> So a real interaction is expected to occur at the first time-step.

If they are exactly touching, it is somewhat indeterminate state whether the interaction should exists or not (some rounding error could make it one or the other state).
The velocity is not relevant here, as the motion evaluation takes place after interaction detection and evaluation.

disclaimer: I haven't tested any code yet..

cheers
Jan

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

@Robert: using almost-newest trunk version and Ubuntu 18.04, I got interaction for both eps_pos=1e-5 and eps_pos=0.0..
Jan

Revision history for this message
Nishant (nishantk) said :
#6

@Jan: following your advice, I installed the newest trunk version (2018-11-05) - not the almost-newest version.

eps_pos = 0.0 does not show interaction on Ubuntu 16.04.
Maybe going 18.04 is the way to go?

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

My comment was to Robert's MWE illustrating problem with no interaction at all

In your case it depends on where the problem is.
1) there is no interaction at the 1st step for exactly touching particles. This is ok, see my comment above
2) there is no interaction at all during the simulation. This definitely would be a problem.

I tested your code and could not reproduce your problem on Ubuntu 18.04 (similar to Robert's example), the interaction is real for both eps_pos=1e-5 and eps_pos=0.0
interesting :-)

Installing 18.04 might help but probably is not necessary, the true reason is somewhere else (CGAL version maybe, on 18.04 "apt show libcgal-dev" shows version 4.11-2build1).

cheers
Jan

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

I don't think «upgrade linux» is a solution to code not doing what it
should, in general. My two cents. :)
Just to save your day.
Bruno

Le mar. 6 nov. 2018 17:52, Jan Stránský <
<email address hidden>> a écrit :

> Question #675879 on Yade changed:
> https://answers.launchpad.net/yade/+question/675879
>
> Jan Stránský proposed the following answer:
> My comment was to Robert's MWE illustrating problem with no interaction
> at all
>
> In your case it depends on where the problem is.
> 1) there is no interaction at the 1st step for exactly touching particles.
> This is ok, see my comment above
> 2) there is no interaction at all during the simulation. This definitely
> would be a problem.
>
> I tested your code and could not reproduce your problem on Ubuntu 18.04
> (similar to Robert's example), the interaction is real for both
> eps_pos=1e-5 and eps_pos=0.0
> interesting :-)
>
> Installing 18.04 might help but probably is not necessary, the true
> reason is somewhere else (CGAL version maybe, on 18.04 "apt show
> libcgal-dev" shows version 4.11-2build1).
>
> cheers
> Jan
>
> --
> You received this question notification because you are subscribed to
> the question.
>
>

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

I can confirm the bug only exists on Ubuntu 16.04. When I run my own MWE (comment #1) on my 18.04 install, I get interaction for both eps_pos = 0 and eps_pos=1e-5.

>>the true reason is somewhere else (CGAL version maybe, on 18.04 "apt show libcgal-dev" shows version >>4.11-2build1).

On my 16.04 install, I run apt show libcgal-dev and see that I am running 4.7-4, which is the newest version for 16.04. I know we had to make some changes in FlowEngine to accommodate the new CGAL version. Was this the case with polyhedra too?

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

@Robert: I don't think there was any changes for polyhedra because of CGAL version (could be checked from git history)
Jan

Revision history for this message
Nishant (nishantk) said :
#11

@Jan: "there is no interaction at all during the simulation. This definitely would be a problem."
--> When the simulation continues, there is an interaction, but without a dictionary. This was an issue for me. I just created the example with O.step() to show the problem.

@ Robert: I also confirm that the problem is gone on 18.04 with latest trunk version, and O.interaction has a dictionary at the first time step. :)

Any suggestions how to make the example working on other os? Do I need to update some libraries?

Thank you

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

I meant no real interaction..

> Any suggestions how to make the example working on other os? Do I need to update some libraries?

I **guess** the problem is in CGAL. Yade code was not changed, CGAL was and currently I see no other reason..

Jan

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

Am I incorrect to point out that Xenial's libcgal 4.7-4 was uploaded in 2015 [1]? It means that polyhedra has had this (extremely rare) bug for the entire duration of the Ubuntu16.04 + libcgal4.7-4 partnership. Right?

[1]https://launchpad.net/ubuntu/+source/cgal/4.7-4

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

@Robert: it seems like that..

Can you help with this problem?

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

To post a message you must log in.