Skip to content

Add electrostatic no-op benchmark case with unconverged-reference finding#181

Closed
krystophny wants to merge 7 commits into
mainfrom
feat/flux-pumping/wp5-benchmark
Closed

Add electrostatic no-op benchmark case with unconverged-reference finding#181
krystophny wants to merge 7 commits into
mainfrom
feat/flux-pumping/wp5-benchmark

Conversation

@krystophny

@krystophny krystophny commented Jul 12, 2026

Copy link
Copy Markdown
Member

Benchmark slice of #175 (no-op comparison against the hat basis), with the
honest outcome: the benchmark cannot gate anything yet, and the committed
case documents why.

KIM/tests/test_data/benchmark_electrostatic/ contains a self-contained
electrostatic case (Krook, the profile set of the golden electromagnetic
case), a periodic-solver twin configuration whose layer covers the widest
admissible window for these profiles, compare_phi.py (raw and
gauge-offset-removed L2/Linf on a common window, threshold 5 percent, exit
nonzero on failure), the two windowed profiles, and a README with the
measured numbers and the manual two-command procedure.

Stack: parent feat/flux-pumping/wp5-driver at fb07a293 (#180).

Finding

Both solves are unconverged on this case, so no agreement threshold is
meaningful:

  • hat 128-grid vs periodic 128-mode on the flat layer: max |Phi| differs
    by ~11 orders (1.741e10 vs 2.132e-1 statV); offset-removed relative L2
    0.975; an optimal complex rescaling still leaves 0.976, so the shapes
    are uncorrelated, not misnormalized.
  • Mode doubling 128 -> 256 changes the periodic solution by relative L2
    1.072 (not converged).
  • Grid doubling 128 -> 256 changes the hat reference by relative L2 1.0
    with the peak growing by 3.6e3: the Krook hat solve diverges under
    refinement at omega = 0, consistent with the configuration file's own
    "Krook (unstable)" annotation. There is currently no refinement-stable
    reference.

No ctest is wired: a threshold on two unconverged solutions either always
fails or encodes the defect. The comparison script and case stay as the
review surface and as the ready harness for the follow-up.

Follow-up this defines

Either a Krook case in a parameter regime where the hat solve is
refinement-stable (finite frequency or higher collisionality), or
continuum FokkerPlanck-form kernels for the periodic side, before the
no-op condition of #175 can be tested. Solver code is deliberately
untouched here.

Verification

$ ctest --test-dir build
100% tests passed, 0 tests failed out of 30
$ python3 compare_phi.py <hat>/fields/Phi.dat <periodic>/fields/Phi_periodic.dat
exit 1, relative L2 0.975 (threshold 0.05)

Relation to Markus's Fokker-Planck periodic branch

This PR is retained as a negative benchmark record and reusable common-grid comparison harness. It proves that the packaged Krook hat solution is not a converged no-op reference; it does not validate either periodic implementation. Do not tune this case further. The accepted matched FP/Vaclavik benchmark is #190.

@marjohma

Copy link
Copy Markdown
Member

Closing: the wp5 flux-pumping stack is retired. This work is superseded by the forced-periodicity lineage on feature/kim-forced-periodicity (issue #175): the oracle-verified Fokker-Planck Fourier kernel (#187/#216/#217), vendored background/geometry periodization, the periodic deviation solver with gauge policy (#219), and the numerical trust gates (#215). The Krook Fourier kernel deliberately remains reference-only in git history per the FP-not-Krook design decision.

@marjohma marjohma closed this Jul 15, 2026
marjohma added a commit that referenced this pull request Jul 15, 2026
)

## Summary

Extracts the two salvageable pieces of the retired wp5 flux-pumping
stack onto the forced-periodicity lineage. The rest of that stack
(#177#181, #184) is closed as superseded.

## Krook argument `z0` (was #183)

`interpolate_plasma_backs` interpolated the **derived** `z0` alongside
the primitives. `z0` carries a `1/|k_parallel|` singularity at the
resonance, so a four-point Lagrange stencil spanning `k_parallel = 0`
returns values that violate its own defining formula. The fix
interpolates primitives only and recomputes

    z0 = -(omega_E - omega - i nu) / (|k_parallel| sqrt(2) v_T)

on the target grid — the same invariant the periodized-background path
already follows.

**Scope:** `z0` is consumed only by `Krook_kernel_plasma_prefacs.f90`.
The Fokker-Planck path recomputes `x1/x2/A1/A2/I^{kl}` after
interpolation and never reads `z0`, so **FP results are bit-unchanged**.
This repairs the Krook hat path, whose nml still marks it `(unstable)` —
plausibly part of why.

## Collision-frequency scale (was #182)

New positive `&KIM_CONFIG` key `collision_frequency_scale` multiplying
the calculated electron and ion collision frequencies before `z0` and
the FP susceptibility inputs are assembled. Default `1.0` leaves every
collision formula, profile, unit, and output unchanged. Non-positive
values are rejected at startup; the value is displayed when it differs
from 1.0 and stored in HDF5 provenance. Same shape as the existing
`ion_flr_scale_factor` knob. No benchmark-acceptance claim — it is a
sensitivity parameter.

## Tests

`test_collision_scale_z0` (new) asserts the `z0` invariant on a stencil
straddling `k_parallel = 0` and away from it, and that the scale reaches
both `nu` and `z0` (including the imaginary part of `z0` tracking it).

Developed red-first: against the pre-fix code the test fails with a
**36% relative `z0` error at k_par = 2e-4** (`got (-0.0983, 0.0129)` vs
`want (-0.4543, 0.0599)`), growing without bound toward the resonance.

## Validation

- `make` — clean build
- `ctest -E
'test_rhs_balance|test_periodic_convergence|test_periodic_vs_global'` —
**32/32 passed**

Known red gates excluded as usual: the pre-existing `test_rhs_balance`
baseline failure, the periodization-deformation gate, and the
periodic-vs-global 5% gate — none touched by this change.

Supersedes #182, #183.
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.

2 participants