Repository navigation
IBM: opt-in friction slip regularisation for soft-sphere collisions - #2354
sbryngelson wants to merge 4 commits into
Conversation
…ib_friction_slip_eps)
|
Claude Code Review Head SHA: c860387 Files changed:
Findings: |
Lines of Code
|
|
Hand test of c860387 (rebased on current master, double precision, MPI CPU build, Cray Fortran 19, one CPU core per rank).
Not covered: GPU runs (A100, MI250X, MI300A), a 4-rank seam case, a dedicated wall-site test, and the one-step x-force transient of body 2 at step 46 (0.056 between 1 and 2 ranks, identical with friction off), whose cause is unexplained. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2354 +/- ##
==========================================
+ Coverage 65.75% 65.86% +0.11%
==========================================
Files 111 111
Lines 30480 30559 +79
Branches 4663 4673 +10
==========================================
+ Hits 20041 20128 +87
+ Misses 6687 6655 -32
- Partials 3752 3776 +24 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Added a 1-rank wall-site test on d8a43d3: Hand run of the wall case (1 rank, CPU, Cray Fortran),
Not covered: GPU runs of the wall test, other compilers' spread for it (CI lanes will show it). |
|
Re-verified after merging master (merge commit 32086fb, which brings in #2201, the collision optimisation): the friction routine's two call sites in Cray Fortran, MPI CPU build, one CPU core per rank: One more finding on the seam test: listing the two bodies in the opposite order in a 1-rank run gives a bitwise identical result, so the 1-vs-2-rank difference on CPU is not caused by which body's patch is applied last in overlapped cells. Not covered: Frontier and other GPU runs of this tree (not run), a 4-rank seam case, and the one-step x-force transient at step 46 on the seam test (unexplained, identical with friction off). |
Contribution Policy
All contributions are expected to demonstrate:
If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.
Summary
The soft-sphere collision friction direction is the normalised slip velocity, guarded by
f_approx_equal(norm2(v_t), 0), which is an exact-zero test. For a head-on contact the true slip is zero, so a round-off slip (1e-17) becomes a unit vector and the friction force is a fullmu*|F_n|in an arbitrary direction. Two consequences:mu*|F_n|, on a contact that should have no friction.pid1, so a contact split across an MPI seam differs from the 1-rank result.This PR adds an opt-in
ib_friction_slip_eps(velocity, default 0). Witheps > 0the friction force is-mu*|F_n| v_t / max(|v_t|, eps_eff)witheps_eff = max(eps, mu*|F_n|*dt/m_t), applied at both the body-body and the wall site through one shared routine (s_ib_friction_direction). For|v_t| >= eps_effit is the present Coulomb force; below it, it ramps linearly to zero. The floormu*|F_n|*dt/m_t(m_t= effective tangential mass of the contact frommass,moment,radius) is the stick limit: below it the ramp equalsm_t |v_t|/dt, which cannot overshoot, so a too-smallepsis raised to the floor instead of making the contact chatter.eps = 0runs the previous code path unchanged (floor not applied, existing exact-zero guard). The routine readsdtand the body properties it already had access to, so no new arguments were needed. New parameter: definitions, descriptions, validator (>= 0,> 0needscollision_model > 0), default, GPU declaration and update,case.mdtable row and paragraph. Guidance in the docs: about 1e-3 to 1e-2 of the impact speed; in single precision it must stay well above the velocity round-off.Evidence
Machine: one CPU core per rank, MPI CPU build, double precision, base
4cadc3610(rebased onto current master afterwards, not rebuilt). Case: two circles (diameter 1, mass 1) closing head-on at 0.3 each in still gas, periodic 20x20 box, 80x80 cells,mu = 0.1, centres on either side of the x = 10 rank seam (the pair that differed in a scaling study). ComparedD/ib_forces.datfor 1 vs 2 ranks.ib_friction_slip_eps = 0ib_friction_slip_eps = 0.003Chatter (1 rank, a separate oblique head-on pair, not in the test): at
eps = 0the tangential force is 1.000 xmu*|F_n|at every step of the contact (up to 45 of a 150 normal force) and alternates in sign; witheps = 0.005it is below 0.03.Remaining difference, not fixed here: a single-step transient in the x force of body 2 at step 46 (0.056 between 1 and 2 ranks, 0.0275 vs 0.0835). It is identical with friction off (
mu = 0: 0.0560), so it is not the friction direction. Outside that step the 1-rank/2-rank difference is at most about 5e-3. A larger earlier study reported a 2.6e-4 residual with friction off; its cause is not explained.Tests
IBM -> Collision -> Friction slip regularisation across a rank seam(the case above,eps = 0.003; 1 and 2 fluid variants), golden generated from the fixed build and rerun clean;override_tol = 3e-4: the golden was made with Cray Fortran on one host; the GNU, Intel and macOS CI lanes agree with each other to 1e-13 and differ from it by up to 3.2e-5 (1 fluid) and 9.1e-6 (2 fluids), absolute, in the energy, so the tolerance is about 10x that. It is still far below the O(0.1) force sign flip the case guards. The test is sensitive at the contact step. The golden is checked against itself at 2 ranks; the 1-rank/2-rank comparison above is by hand and is not in CI.--single) build: the new test passes against the double golden.eps = 0leaves existing results unchanged:./mfc.sh test --only IBMplus themibm_sphere_head_on_collisionandmibm_particle_cloudexamples: 114 passed, 0 failed, no golden changed (chemistry cases excluded).Limitations
GPU_ROUTINE(seq)pattern with scalar/array arguments likes_cross_product).eps_eff. The change targets resting/sticking contacts and reproducibility.This PR was made with Claude Code (AI).