Repository navigation
Contact: a smooth tier of the contact potential, for gradients - #16
Merged
Merged
Conversation
build_system(model, contact="smooth") runs the contact potential in a form whose energy is smooth in the positions (contact/in_run.py, TIERS). FEBio's form stays the default and is what the comparisons with FEBio use. The smooth form differs from FEBio's in two ways, each deliberate (decisions K6 and K7 of docs/design/contact_in_run.md): - No normal test w_tol, which switches a pair on or off by the solution. A pair is excluded by topology (elements that share a node) and by the distance of its points in the reference configuration, at least 1.5 R_out, as the original formulation does for self-contact (Kamensky et al. 2018, R_self; FEBio's R0_min). - Weights from the reference configuration, as in the original formulation. FEBio's follow the current configuration and are not differentiated, so its tangent is not the derivative of its force. Measured on sh_self_contact_fold at a state with contact, by central differences: with the smooth form the force is minus the gradient of the contact energy to 2e-8 and the tangent is minus the derivative of the force to 1e-8; with FEBio's form the two are off by 9 and 25 percent. So an adjoint through closure needs the smooth form. On the small cases the smooth form has the same active pairs as FEBio's and results within a few percent of it. On the open mitral input (examples/valve/mitral_closure.py, third argument "smooth") it closes the valve in 248 steps and 857 iterations, 2.3 minutes against 7.8; contact starts at the same time as in FEBio; leaflet stresses are 0.49 percent from FEBio's in the median, the same as with FEBio's form; the contact area is 76.5, which is the part between opposing leaflets (FEBio's 89.6 includes pairs within one leaflet). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
docs/design/contact_in_run.md (v0.5): what the smooth tier is, a table of what was checked for it and for FEBio's form (force against the energy gradient, tangent against the force derivative, the small cases, the open mitral input), piece 5 of the plan marked done, and decisions K6 and K7 updated. docs/design/deviations.md lists the tier among the additions FEBio does not have. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change, and why?
Adds a smooth tier of the contact potential, chosen by a setting (
build_system(model, contact="smooth")), as the form that gradients through leaflet closure will use. FEBio's form stays the default and is what every comparison with FEBio uses. This is piece 5 of the plan in contact_in_run.md (now v0.5).Merged by the author so the work can continue; comments afterwards are welcome. This is a deliberate difference from FEBio and is listed as such (row 14a of
docs/design/deviations.md, decisions K6 and K7 of the contact note). It follows the original formulation (Kamensky et al. 2018) in the two places where FEBio's implementation departs from it:contact="febio", default)contact="smooth")w_tol, a switch that depends on the solutionR_out; neither depends on the solutionMeasured.
sh_self_contact_fold, by central differences at a state with contact: with the smooth tier the force is minus the gradient of the contact energy to 2e-8 and the tangent minus the derivative of the force to 1e-8. With FEBio's form they are off by 9 and 25 percent. An adjoint built on FEBio's form would be wrong by those amounts.examples/valve/mitral_closure.py, third argumentsmooth): closure in 248 steps and 857 iterations, 2.3 minutes against 7.8 with FEBio's form; contact starts at the same time as in FEBio (0.00304); leaflet stresses 0.49 percent from FEBio's in the median, the same as FEBio's form achieves; contact area 76.5, which is the part between opposing leaflets (FEBio's 89.6 includes pairs within one leaflet, pull request 15).Validation
tests/test_contact_in_run.py(SmoothTierTests: the settings; closeness to FEBio's form on the small cases; force against the energy gradient and tangent against the force derivative, for both forms).cuda:0, 238 tests); the mitral run on the same GPU from an environment with nvmath-python. The full tier on CPU was not run locally.Checklist
uvx pre-commit run --all-filespasses.git commit -s).🤖 Generated with Claude Code