yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #15055
Re: A suggestion/contribution regarding bug of Yade-users #694548
-
To:
Yade developers <yade-dev@xxxxxxxxxxxxxxxxxxx>
-
From:
Gaël Lorieul <gael.lorieul@xxxxxxxxxxxxxx>
-
Date:
Tue, 02 Mar 2021 16:31:44 -0300
-
Arc-authentication-results:
i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=woodtechms.com; dmarc=pass action=none header.from=woodtechms.com; dkim=pass header.d=woodtechms.com; arc=none
-
Arc-message-signature:
i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v0i81m0hQ/z0WLs9Ax/KDxEGSrvAoQFhaopB8Wz5bls=; b=nY6NUimo/4PzU2fx2OlnTovD638RxzAzTO8x14EI4QDC3RHLztCPhnQiLgOe8AhIBxMrUjYLMHHVpvT/9d88j9dmx+uEaQVInh1Ms1JRx/Gxunw7VY0JhB+CQmA7AcYJRvn/6jgHEZLzPpk0Ojb1J0lZN8viaFVJFebmReYSpXNfDcQT7DS3siIhnLl+1tCJ6zeVLTCRApZtau3EqahibXXoOVB5CL2rZYvxn7L2XTeRFQsKXi7b0UfRlZ1Ovg2M8k7rp9ifM561dS4yb01w3aumU5omM8A016TCm+DSe+aGqxfSJ96j4Rg2lQCcd7yfx+5x2kzNAwA1R4QgaSmWXA==
-
Arc-seal:
i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LP4gPtVFVNruARx0TRou2kTGS+Krzo8TQdRuiQ7NwvBNXLMN99OfXaQyoAMrR5ajS1t+m8UZTV1NEkJCzB9U7B30xIJkuFNbicS9TU93RnbHeGgLTLlKFn4k/9KrzNRMsJHnq0X+htpmSzPqZMbbUwS4lMdZTj9uueBsD/rZOzvHxEFEVkbeq6/SixVq162stD7BDEpf6d75sPbJEb5wjPFVhFTYurMnVJUslxgjePa9t4ycdg/tXZUiiSOwvYfmBA2xaoPRJJkNHtgCqFKi5MiALvfKI3S7w/O8H7KZeqbbnz0Rgubv1U4ESkVQ/GkbyaHaOGxf407FEEt09t8yYw==
-
Authentication-results:
lists.launchpad.net; dkim=none (message not signed) header.d=none;lists.launchpad.net; dmarc=none action=none header.from=woodtechms.com;
-
In-reply-to:
<PH0PR08MB67254EF39C6C889E601BD1E3E79C9@PH0PR08MB6725.namprd08.prod.outlook.com>
-
Organization:
Woodtech
-
User-agent:
Evolution 3.36.4-0ubuntu1
Hello all,
I think I fixed issue 694548.
Contrary to my initial belief, it was not related to what I had
observed for gridConnection objects (this will be the subject of a
different thread). Instead, it was a bug regarding the calculation of
weights. I'll show that in the case of the MWE posted by Jeffrey
Knowles (issue 694548's original poster).
The motion of PFacet is dictated by that of the 3 gridNode objects it
connects. Each gridNode recieves a different force value calculated
from the force of the interaction. The function
`Law2_ScGridCoGeom_FrictPhys_CundallStrack::go`
(`pkg/common/Grid.cpp:537`) does that using weights:
```
scene->forces.addForce(geom->id3, geom->weight[0] * -force);
scene->forces.addForce(geom->id4, geom->weight[1] * -force);
scene->forces.addForce(geom->id5, geom->weight[2] * -force);
```
Those weights are calculated in `pkg/common/PFacet.cpp`
(`Ig2_Sphere_PFacet_ScGridCoGeom::projection()`) as
‖v₁‖²(v₀·v₂) - (v₁·v₂)(v₀·v₁)
p₁ = ————————————————————————————— (1a)
‖v₀‖²‖v₁‖² - (v₀·v₁)²
‖v₀‖²(v₁·v₂) - (v₀·v₂)(v₀·v₁)
p₂ = ————————————————————————————— (1b)
‖v₀‖²‖v₁‖² - (v₀·v₁)²
p₃ = 1 - p₂ - p₃ (1c)
But actually, it should be:
‖v₁‖²(v₀·v₂) - (v₁·v₂)(v₀·v₁)
p₂ = ————————————————————————————— (2a)
‖v₀‖²‖v₁‖² - (v₀·v₁)²
‖v₀‖²(v₁·v₂) - (v₀·v₂)(v₀·v₁)
p₃ = ————————————————————————————— (2b)
‖v₀‖²‖v₁‖² - (v₀·v₁)²
p₁ = 1 - p₂ - p₃ (2c)
Hence the bug (MWE "passes" after making the permutation).
In the end, it is only a permutation of p₁,p₂ and p₃. However, let me
stress that the fix I propose is not just a "hack" (me randomly
interchanging p1,p2,p3 until I get the result I expected). Instead, I
did the calculations from scratch again, and the equations (2) are the
result of that. The scans of my calculations are available here [1]. If
need be, I can make a LaTeX transcript of those calculations.
However, it uneases me that the consequences of this bug can be seen
fairly easily, and most certainly the original author of the code would
have noticed it straight away. Especially since the rest of the
function seems well written. Hence perhaps things are more complicated
than that? Could I be breaking something else? To make sure of that, I
attempted to compile the first version of the code to feature this
calculation (commit dfec202), but unfortunately without success 🙁️
(and I don't really want to spend more than the 2.5 days I already
spent just to try to compile (old) stuff). Note that commit dfec202 is
the commit that introduced PFacet objects in Yade.
Final point: although the changes to be made are small, I would really
like to submit it personnaly to the git repository so that I learn how
it is done. I would need a bit of guidance for that though 😉️. I also
think I might need the confirmation that the fix I propose indeed is
relevant and safe to be implemented.
Gaël
[1] http://dl.free.fr/mbGj9Moc0
Follow ups
References