the direction of O.interactions.geom.normal

Asked by Leonard on 2019-08-19

Hi,
In yade, O.interactions.geom.normal gives the unit vector oriented along the interaction, from particle #1, towards particle #2
(https://yade-dev.gitlab.io/trunk/yade.wrapper.html?highlight=o%20interaction#yade.wrapper.ChCylGeom6D.normal).
My question is that the directions seems not always from Id1 towards Id2, for example:
O.bodies.append(sphere((0,0,0),radius=1,color=[1,1,1]))
O.bodies.append(sphere((0,0,1.5),radius=0.5,color=[0,0,1]))
Gl1_Sphere.quality=3
O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb()]),
    InteractionLoop(
        [Ig2_Sphere_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()]
    ),
    NewtonIntegrator(damping=0.4),

]
##run for one step to generate interactions
O.step()
After this, I use O.interactions[0,1].geom.normal and obtain the result as:
In [2]: O.interactions[0,1].geom.normal
Out[2]: Vector3(0,0,1).
This is reasonable, however, when I change the Id of the two spheres like:
O.bodies.append(sphere((0,0,1.5),radius=0.5,color=[0,0,1]))
O.bodies.append(sphere((0,0,0),radius=1,color=[1,1,1]))
Gl1_Sphere.quality=3
O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb()]),
    InteractionLoop(
        [Ig2_Sphere_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()]
    ),
    NewtonIntegrator(damping=0.4),

]
##run for one step to generate interactions
O.step()
I use O.interactions[0,1].geom.normal again to check the normal vector and obtain:
In [2]: O.interactions[0,1].geom.normal
Out[2]: Vector3(0,0,1)
which is the same as before, that means the vector normal isn't from Id1 towards Id2. I think it should be Vector3(0,0,-1).
Could you please point out where is the problem?
My yade version is 2018.02b on Ubuntu 18.04
Thanks in advance!

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2019-08-19
Last query:
2019-08-19
Last reply:
2019-08-19
Best Jan Stránský (honzik) said : #1

Hello,

> from particle #1, towards particle #2

it means #1 and #2 of the interaction.
It has no trivial dependency on bodies IDs.

Apart from geom.normal, try to print also
O.interactions[0,1].id1
O.interactions[0,1].id2

cheers
Jan

Leonard (z2521899293) said : #2

Hi Jan,
Many thanks for your quick answer. It really solved my problem.
However, following your explanation, is there any rule or order between O.interactions[0,1].id1 and O.interactions[0,1].id2?
Thanks,
Leonard

Leonard (z2521899293) said : #3

Thanks Jan Stránský, that solved my question.

Jan Stránský (honzik) said : #4

> is there any rule or order between O.interactions[0,1].id1 and O.interactions[0,1].id2?

interactions are created:
- "manually" with createInteraction function. Then the order is defined by the order of createInteraction arguments
- "automatically" by the collider. Then the order is ruled by the collider (the no trivial dependency I referred in #1).

So let's say that from user's point of view, the order is "random", "upredictable" or some word like this.
But note that through id1 and id2 you have access to the bodies and their positions, so you can treat some directions as negated e.g. to have all directions pointing in x+ direction.

cheers
Jan

Leonard (z2521899293) said : #5

Hi everyone,
For the choose of interaction id1 and id2 of two contact particles, we can find similar answers from [1] if there is no update.

Cheers
Leonard

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

Leonard (z2521899293) said : #6

Hi Jan,
Thank you again for your reply.
And for my own experience, if the contact particles are spheres with different R, i.geom.normal seems always from sphere with bigger R towards another sphere with smaller R.

Cheers
Leonard

Leonard (z2521899293) said : #7

Hi everyone,
Just comment that what I said in #6: "i.geom.normal seems always from sphere with bigger R towards another sphere with smaller R" is wrong.
Cheers
Leonard