Repository navigation
test: cover periodic noise wrap, energy values, driving force, RK runaway, and minimizer failure paths - #1
Merged
Conversation
…away, and minimizer failure paths Adds 10 tests targeting the largest untested behaviors: - FilteredNoise.PeriodicWrapAcrossManyCells: sample() must wrap query coordinates (negative and many periods out) back into the fundamental cell. Load-bearing for depinning/dynamics, which drive h through many periods of Ly; no prior test queried outside [0,Lx)x[0,Ly). - QewModel.ObjectiveFlatLineConstantPotential / ObjectiveSinusoidLinearElastic: pin the absolute value of objective() (dx weighting, noise-value term, driving-force sign) for both models against closed forms. The arclength energy value was previously checked nowhere; the gradient-consistency test is blind to all three. - Dynamics.DrivingForceShiftsEquilibrium: exercises the driving-force term in the integrated gradient (all prior dynamics tests used f=0). - Dynamics.ZeroDiffusionIgnoresSeed: pins that the thermal kick is gated on diff_coeff>0, so the zero-temperature path is deterministic. - RossoKrauth.RunawayFlagSetAboveThreshold: pins the runaway verdict the depinning executable keys f_c bracketing on (prior tests read only .blocked). - RossoKrauth.BlocksArclengthModel: arclength blocking correctness through rk_block (prior arclength coverage was determinism only). - Fire/Lbfgs.ReportsNonConvergence: the converged=false failure path callers branch on. - Lbfgs.ConvergesToHarmonicMinimumArclength: L-BFGS on the arclength model (all other L-BFGS tests used the linear model). 26 -> 36 tests, all passing.
The three simulation executables were hardcoded main()s with no testable seams, so their orchestration and HDF5 output were entirely uncovered. Factor them into reusable, unit-tested units without changing behaviour: - src/qew_runs.h: static_sweep / dynamic_anneal / depinning_ramp -- the pinning-length sweep, annealed-Langevin loop (timestep heuristic + anneal schedule), and Rosso-Krauth force ramp with f_c bracketing. Templated on the Noise functor (like the kernels), HDF5-free, loop bodies copied verbatim from the mains. - src/qew_io.h: write_static / write_dynamic / write_depinning -- the HDF5 dataset-key construction (a documented contract with the Python analysis scripts). Header-only, guarded by QEW_WITH_HDF5, not pulled into core lib. - src/qew_format.h: the fmt() key helper, previously duplicated in all three mains. - The mains are now config + call + write (+ the same console output). tests/test_executables.cpp (7 tests): fmt() specs; static_sweep shape and pinning_length->line_tension map; dynamic_anneal dt heuristic and log-spaced snapshots; depinning_ramp f_c bracketing, runaway verdict, and profile-only-when-blocked; and (HDF5) round-trip of all three writers asserting the exact documented dataset keys and that runaway forces store no profile. Verified qew_static runs end-to-end and writes the documented key layout (driving_force=.../pinning_length=.../h, length nx). 36 -> 43 tests.
…nches These defensive branches are never hit by smooth convex problems, so they were uncovered. To make them observable AND assertable, add two diagnostic counters to LbfgsResult (n_curvature_skips, n_ls_restarts), consistent with the existing n_func_evals, then force each path: - CurvatureSkipForcedByLargeEps: curvature_eps = 1e30 makes the acceptance test sy > eps*sqrt(ss*yy) fail for every pair (Cauchy-Schwarz bounds sy <= sqrt(ss*yy)), so no (s,y) is stored. Asserts the skip counter fired and the solver still degrades gracefully to steepest descent and reaches the minimum. Mathematically robust across backends. - LineSearchGivesUpWithNoHistory: max_ls = 0 -> the first steepest-descent step takes no trial and, with empty history, the solver returns converged=false at iteration 0 (the give-up branch). Deterministic. - LineSearchRestartsOnStepFailure: a rough strong-noise landscape where a unit L-BFGS step overshoots by ~16x (needs ~5 Armijo backtracks) with max_ls clamped to 3 -> after history is built the line search exhausts its budget and hits the restart branch (discard history, retry as steepest descent). The overshoot is decisive (mls=1,2,3 all fire it; failures stop only at mls>=5), so the branch is reached with margin, not on an FP knife-edge. A control run at the normal max_ls=30 converges with zero restarts, confirming the restart is a safety net, not a routine path. 43 -> 46 tests.
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.
Adds 10 tests targeting the largest untested behaviors:
coordinates (negative and many periods out) back into the fundamental
cell. Load-bearing for depinning/dynamics, which drive h through many
periods of Ly; no prior test queried outside [0,Lx)x[0,Ly).
pin the absolute value of objective() (dx weighting, noise-value term,
driving-force sign) for both models against closed forms. The arclength
energy value was previously checked nowhere; the gradient-consistency
test is blind to all three.
in the integrated gradient (all prior dynamics tests used f=0).
diff_coeff>0, so the zero-temperature path is deterministic.
depinning executable keys f_c bracketing on (prior tests read only .blocked).
rk_block (prior arclength coverage was determinism only).
branch on.
(all other L-BFGS tests used the linear model).
26 -> 36 tests, all passing.