Skip to content

Add a physical regression test and the diagnostics it needs - #9

Merged
Maccchiatooo merged 1 commit into
mainfrom
add-regression-test
Aug 10, 2026
Merged

Add a physical regression test and the diagnostics it needs#9
Maccchiatooo merged 1 commit into
mainfrom
add-regression-test

Conversation

@Maccchiatooo

Copy link
Copy Markdown
Owner

CI so far only proved the solver did not crash: a NaN velocity field would
have exited 0 and passed. This adds the two exact invariants of the discrete
dynamics as assertions, plus a check that the answer does not depend on how
the domain is split across ranks.

LBM::Conserved reduces total mass, momentum and kinetic energy across all
ranks. In this pressure-based formulation sum_i f_i = 3p and sum_i f_i e_i = u,
and the equilibrium reproduces both moments exactly, so BGK collision leaves
them untouched; streaming on a periodic domain is a permutation. Mass and
momentum are therefore invariants up to rounding. Cost is one 5-double
Allreduce per reporting interval, next to an MPI_Barrier that was already
there. Output goes on its own line with no "MLUPS" token, because
tools/parse_scaling.sh selects lines with awk '/MLUPS/'.

tests/regression.sh runs 32^3 for 20 steps on 1, 2 and 4 ranks and asserts:
mass drift < 1e-12 relative, |net momentum| < 1e-10, and agreement between
rank counts < 1e-12. Tolerances are ~100x the measured values (1.2e-14,
5.1e-14, 1.4e-14 on Kokkos 5.1.1 OpenMP + Open MPI).

Kinetic-energy monotonicity is deliberately not asserted: the distributions
start at equilibrium with an unrelaxed pressure field, so the opening steps
carry an acoustic transient and ke really does oscillate (9.852 -> 10.219 ->
9.889). That assertion would have been flaky and wrong about the physics.

Verified the test can fail: perturbing pp by a relative 1e-12 in Collision
drives the mass drift to 3.8e-11 and turns all three rank counts red.

CI so far only proved the solver did not crash: a NaN velocity field would
have exited 0 and passed. This adds the two exact invariants of the discrete
dynamics as assertions, plus a check that the answer does not depend on how
the domain is split across ranks.

LBM::Conserved reduces total mass, momentum and kinetic energy across all
ranks. In this pressure-based formulation sum_i f_i = 3p and sum_i f_i e_i = u,
and the equilibrium reproduces both moments exactly, so BGK collision leaves
them untouched; streaming on a periodic domain is a permutation. Mass and
momentum are therefore invariants up to rounding. Cost is one 5-double
Allreduce per reporting interval, next to an MPI_Barrier that was already
there. Output goes on its own line with no "MLUPS" token, because
tools/parse_scaling.sh selects lines with awk '/MLUPS/'.

tests/regression.sh runs 32^3 for 20 steps on 1, 2 and 4 ranks and asserts:
mass drift < 1e-12 relative, |net momentum| < 1e-10, and agreement between
rank counts < 1e-12. Tolerances are ~100x the measured values (1.2e-14,
5.1e-14, 1.4e-14 on Kokkos 5.1.1 OpenMP + Open MPI).

Kinetic-energy monotonicity is deliberately not asserted: the distributions
start at equilibrium with an unrelaxed pressure field, so the opening steps
carry an acoustic transient and ke really does oscillate (9.852 -> 10.219 ->
9.889). That assertion would have been flaky and wrong about the physics.

Verified the test can fail: perturbing pp by a relative 1e-12 in Collision
drives the mass drift to 3.8e-11 and turns all three rank counts red.
@Maccchiatooo
Maccchiatooo merged commit 73cfec2 into main Aug 10, 2026
1 check passed
@Maccchiatooo
Maccchiatooo deleted the add-regression-test branch August 10, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant