Add a physical regression test and the diagnostics it needs - #9
Merged
Conversation
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.
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.
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.