How to get resultant contact force of each sphere

Asked by Chu on 2019-05-16

Hello,

I'd like to know how to get resultant contact force of each sphere.I believe that O.interaction[id1,id2].phys.normalForce can get the contact force between id1 and id2,but the direction is not sure[1].Whether O.force.f() can get the resultant contact force of sphere?

Thanks for any suggestions.

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

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Bruno Chareyre
Solved:
2019-05-20
Last query:
2019-05-20
Last reply:
2019-05-16
Jérôme Duriez (jduriez) said : #1

Hi,

Above [1] says that you can not really predict *beforehand* which body would be labelled as 1 (or 2) in the contact treatment, however, for a given body and a given contact the body participates into, you still can

* check whether that body is id1 or id2 for that interaction
* then, know without ambiguity the "direction" of the force since that force is usually in YADE (if not always) "from id1 to id2". It is like that in particular for NormShearPhys and derived classes [*,**]

So it's possible to measure resultant contact force looping over contacts. If the body sustains only contact forces (no gravity), the resulting contact force also corresponds to O.forces.f(idOfBody)

[*] https://yade-dev.gitlab.io/trunk/yade.wrapper.html#yade.wrapper.NormShearPhys.normalForce
[**] https://yade-dev.gitlab.io/trunk/yade.wrapper.html#yade.wrapper.NormShearPhys.shearForce

The question and answer #1 are misleading on some aspects in my opinion. For the record:

> the direction is not sure[1]

The direction _is_ sure. Simply there is no reason to access interactions by ids.
The normal force (a vector) is exerted on id2. An opposite force is exerted on id1.
Same for shear force.
Hence for resultant forces on all bodies you can do simply:

for i in O.interactions:
    force[id2]+= i.phys.normalForce
    force[id1]-= i.phys.normalForce

> O.force.f() can get the resultant contact force of sphere?

Yes, absolutely.
** even if Newton::gravity is not zero **
Weight is not included in O.forces.

Bruno

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

In the code above it should be O.forces.f(i.id1), the «i.» was missing.
Same for id2.
B.

Le jeu. 16 mai 2019 15:22, Bruno Chareyre <
<email address hidden>> a écrit :

> Question #680868 on Yade changed:
> https://answers.launchpad.net/yade/+question/680868
>
> Bruno Chareyre proposed the following answer:
> The question and answer #1 are misleading on some aspects in my opinion.
> For the record:
>
> > the direction is not sure[1]
>
> The direction _is_ sure. Simply there is no reason to access interactions
> by ids.
> The normal force (a vector) is exerted on id2. An opposite force is
> exerted on id1.
> Same for shear force.
> Hence for resultant forces on all bodies you can do simply:
>
> for i in O.interactions:
> force[id2]+= i.phys.normalForce
> force[id1]-= i.phys.normalForce
>
>
> > O.force.f() can get the resultant contact force of sphere?
>
> Yes, absolutely.
> ** even if Newton::gravity is not zero **
> Weight is not included in O.forces.
>
> Bruno
>
> --
> 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
>
>
>

Chu (arcoubuntu) said : #4

Thanks for Bruno and Jérôme.
I used a sample to caculate the contact force by i.phys.normalForce and O.forces.f(),but I find the result of O.forces.f() is different from the vector sum of i.phys.normalForce.I think I must have made a mistake.Could you give me some suggestions?

Chu (arcoubuntu) said : #6

Oh I know.I did make a mistake.I didn't consider the shear force.Now they are equal.

Chu (arcoubuntu) said : #7

Thanks Bruno Chareyre, that solved my question.

Chu (arcoubuntu) said : #8

Thanks Jérôme Duriez,that solved my question.

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

Hello,

(I know the aswer is late, but I leave it here for future reference)

there might be 2 issues:

1) sum not only i.phys.nomralForce, but i.phys.normalForce + i.phys.shearForce

2) summation must be done with correct sign (the same i.phys.normalForce acts on 2 dirrefent bodies with opposite orientation

### MWE
def i2f(i,b):
   sign = +1 if b.id == i.id2 else -1
   return sign * (i.phys.normalForce + i.phys.shearForce)

for b in O.bodies:
   print
   print b.id,b.shape
   f1 = O.forces.f(b.id)
   f2 = sum((i2f(i,b) for i in b.intrs()), Vector3.Zero)
   df = (f1-f2).norm()
   print f1
   print f2
   print df
   assert df < 1e-9
###

cheers
Jan

Chu (arcoubuntu) said : #10

Thanks Jan Stránský.Actually, you solved my another question that how to check whether the body is id1 or id2.

@Jan
That loop in #9 is a bit overkill since it's very easy and faster (not visiting every iteration twice) to compute the same thing by a loop on interactions, and in that case there is no need to check id1/id2.
That was my main point.

Bruno