penetrationDepth calculation

Asked by Andrea Puglisi

Hi, I would like to understand the way "penetrationDepth" is calculated. For instance, in a simple collision between two identical spheres I've seen that it does not correspond to x1-x2-2*r where r is the radius of the spheres. I've been looking into the code and found for instance in Sphere_Sphere_ScGeom https://github.com/yade/trunk/blob/master/pkg/dem/Ig2_Sphere_Sphere_ScGeom.cpp (line 21)
that the distance is shifted by a vector "shift2" which is passed to the function
Vector3r normal=(se32.position+shift2)-se31.position;
but whose definition I cannot trace back

I suspect that this serves the purpose of interlaced force evaluation for runge kutta etc. but I would like to have a confirmation

Thanks for any help

Andrea

Question information

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

Hello Andrea,
shift2 is used for periodic contact detection, have a look at [1]. See [2] for the meaning of Interaction::cellDist.
cheers
Jan

[1] https://github.com/yade/trunk/blob/master/pkg/common/InteractionLoop.cpp#L113
[2] https://yade-dem.org/doc/formulation.html#collision-detection-in-periodic-cell

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

Hi,
It does correspond to x1-x2-2*r.
Cheers
Bruno

Revision history for this message
Andrea Puglisi (andreo73) said :
#3

Thanks Jan and Bruno. From Jan'answer I understand that the variable shift2 should not be a problem in my example (I have no periodicity, it is just a collision between two spheres). From Bruno's answer I learn that there is something wrong in my script where I measure both the quantity overlap=2*r-(x2-x1) (I have x2>x1) and the quantity interaction.geom.penetrationDepth and they do not coincide.

My script is the following. The graph of the two quantity penetrationDepth vs. overlap can be found at this shared link
https://drive.google.com/file/d/1r6YWwbg56jIN3EGB4RzoBRGHgHyHAhir/view?usp=sharing

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

from yade import pack,ymport,export,geom,bodiesHandling,qt,plot
import math

rad = 0.00774

f=open("forces.dat" , "w")
def forces():
 x1 = O.bodies[0].state.pos[0]
 v1 = O.bodies[0].state.vel[0]
 v2 = O.bodies[1].state.vel[0]
 x2 = O.bodies[1].state.pos[0]
        ov = 2*rad-(x2-x1)
        intrs = O.bodies[0].intrs()
        if (len(intrs)):
         nfx = intrs[0].phys.normalForce[0]
         nfy = intrs[0].phys.normalForce[1]
  nfz = intrs[0].phys.normalForce[2]
  sfx = intrs[0].phys.shearForce[0]
                sfy = intrs[0].phys.shearForce[1]
  sfz = intrs[0].phys.normalForce[2]
                dep = intrs[0].geom.penetrationDepth

        else:
                nfx = nfy = nfz = sfx = sfy = sfz = dep = 0
 f.write ("%6d %12.8f %12.8f %12.8f %12.8f %9.6f %9.6f %9.6f %9.6f %9.6f %9.6f %12.8f\n" % (O.iter,O.time,ov,v1,v2,nfx,nfy,nfz,sfx,sfy,sfz,dep))
        f.flush()

O.materials.append(FrictMat(young=0.1e9,poisson=.22,frictionAngle=0,density=2300,label='glass'))
Sph_1 = O.bodies.append([sphere([0,0,0], radius=rad, material = "glass")])
Sph_2 = O.bodies.append([sphere([0.1,0,0], radius=rad, material = "glass")])
O.bodies[1].state.vel = Vector3(-0.3,0,0)
O.bodies[0].state.vel = Vector3(0.3,0,0)

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),
        ],label='collider'),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_MindlinPhys()],
  [Law2_ScGeom_MindlinPhys_Mindlin()],
 ),
 NewtonIntegrator(damping=0.0,exactAsphericalRot=True,gravity=(0,0,0)),
 PyRunner(command='forces()', iterPeriod=1),
]

O.dt=PWaveTimeStep()
try:
 from yade import qt
 qt.Controller()
 qt.View()
except ImportError: pass
O.saveTmp()
O.timingEnabled=True

Revision history for this message
Andrea Puglisi (andreo73) said :
#4

Ahhhh, I've understood my error! The overlap contained in penetrationDepth is the one computed for the force, which corresponds to positions at the previous step! Sorry to make you lose your precious time and thanks for help anyway!