Skip to content

[kim-fp-05] Make periodic convergence and solve checks hard gates #189

Description

@krystophny

Stage: KIM periodic linear solve and convergence gates
Source language: Fortran
Manuals to read first: #175; docs/plans/2026-07-10-kim-forced-periodicity-design.md, sections 4, 5, and 7; LAPACK documentation for zgesv and reciprocal condition estimation
Depends on: #185, #186, #187, #188

Goal

Turn the branch's convergence programs into quantitative CI gates and report whether each dense solve is numerically trustworthy. Numerical resolution, background deformation, and cross-method physics agreement must remain separate measurements.

Reproduction and evidence

At d4ac12b0, test_periodic_vs_global prints a warning at 84.3% relative L2 and exits zero. test_periodic_convergence reports deformation residuals 0.3570, 0.3028, 0.7836; its final 78.4% error also exits zero because only two consecutive increases fail. dense_solve checks zgesv's info but no condition estimate or backward residual.

Files to edit

  • KIM/src/electrostatic_poisson/periodic_solve.f90: retain an operator norm, estimate conditioning, and compute the scaled backward residual.
  • KIM/tests/test_periodic_convergence.f90: enforce one-knob-at-a-time numerical and deformation gates.
  • KIM/tests/test_periodic_vs_global.f90: fail on a predeclared matched-problem tolerance after [kim-fp-04] Match the periodic and hat electrostatic boundary-value problem #188.

Behavior to implement

For every solve report rcond and ||A Phi-b||/(||A||||Phi||+||b||) using the unmodified A and b. Reject singular, non-finite, ill-conditioned-beyond-policy, or large-residual solutions with a solver status usable by host applications. Scan N_rg, M, and physical window width independently while keeping the diagnostic interval and all other physical scales fixed. A non-monotone 78% deformation sequence is a failure, not a plateau.

Scaffold

A0 = A
b0 = b
call zgesv(...)
backward_error = norm2(matmul(A0, x)-b0) / &
    (matrix_norm(A0)*norm2(x) + norm2(b0))
call estimate_reciprocal_condition(A0, rcond)
if (backward_error > solve_residual_tolerance) info = KIM_SOLVE_INACCURATE

Positive fixtures to add

Negative fixtures to add

  • Nearly singular matrix with info=0 but unacceptable rcond or backward error: return failure.
  • Non-monotone deformation sequence ending at the current 78% scale: fail CTest.

Makefile target

Extend test_periodic_solve, test_periodic_convergence, and test_periodic_vs_global.

Success criteria

cmake -S . -B build -G Ninja
cmake --build build --target test_periodic_solve.x test_periodic_convergence.x test_periodic_vs_global.x
ctest --test-dir build -R 'test_periodic_(solve|convergence|vs_global)' --output-on-failure

No validation path may convert a failed physical tolerance into a warning followed by exit zero.

Relation to existing work

PR #181 supplies a comparison script and negative Krook evidence but no accepted reference. Reuse its common-grid metrics only. PRs #182 and #183 explain why parameter tuning and derived-quantity interpolation can create misleading results; they do not replace FP convergence gates.

Non-goals

  • Do not weaken a threshold to accommodate the current branch result.
  • Do not mix model-truncation uncertainty into the linear-solver residual.

Verification

cmake --build build -j$(nproc) && ctest --test-dir build --output-on-failure

Metadata

Metadata

Assignees

Labels

P1Urgent: ship this sprintbugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions