Restore Fourier-space KIM kernels with behavioral tests#177
Conversation
|
Follow-up commit: the Debye switch now only zeroes the thermodynamic-force terms and keeps the sign, gyroaverage Gaussian, and Fourier phase of the full expression. The historical branch flipped the sign relative to the adiabatic limit and dropped the phase factor, which would anti-screen and break diagonality once the switch feeds a matrix assembly; the modern hat-basis path (artificial_debye_case with the G0 prefactor) uses the retained convention. The switch test now checks that enabling it removes the force response while reproducing the force-free kernel. |
|
Closing: the wp5 flux-pumping stack is retired. This work is superseded by the forced-periodicity lineage on |
) ## 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.
First split item of #175: restore the continuous-Fourier kernels
kernel_rho_phi_of_kr_krp_rgandkernel_rho_B_of_kr_krp_rgaskernels_m(
KIM/src/kernels/kernel_mod.f90), rewired from the removedplasma_parameter/back_quantsglobals to the currentspecies_mplasma_tstate, and reactivate the kernel tests as ctest-registered behavioral checks.
Stack: parent branch
main, pinned parent commit2341697e.Invariant preserved
kernel_mod.f90at1ae0aeeb~1: Debye branch, large-argument Besselasymptotics,
exp(i (k_r - k_r') r_g)phase,1/(8 pi^2)(rho-phi) andi/(8 pi^2 c)(rho-B) normalizations, CGS-Gaussian units.species_mwith the same defining formulas the deleted
calculate_backsused(
A1,A2,lambda_D,z0,ks,kpverified line-by-line);Lagrange interpolation keeps the historical
binsrc/plag_coeff4-point scheme on
plasma%r_grid.gsl_sf_bessel_In->fortnum_special::bessel_in(same modified Bessel I_n), and the retired
kernel_debye_caseconfig keybecomes a module switch with unchanged default
.false..golden records, and all 25 pre-existing ctests are untouched.
Test changes
The orphaned
KIM/src/tests/programs pinned values of the deletedNRL-rounded background (
vTe = 4.19e7 sqrt(Te), constantbtor); thecurrent pipeline computes
sqrt(T ev/m)andomega_cfromB0(r), sothose pins differ at the 1e-3 level while the tightest tolerance was 1e-5:
they cannot pass against either code state. They are replaced by analytic
and property checks at 1e-12 relative tolerance:
-1/(8 pi^2 lambda_D^2)atk_r = k_r'(the acceptance value named in KIM: revive Fourier-space solver via enforced radial periodicity (localized solutions) #175),
k_r /= k_r',k_r <-> k_r'swap conjugacy andr_gphase translation(the properties the periodic matrix assembly of KIM: revive Fourier-space solver via enforced radial periodicity (localized solutions) #175 relies on),
force-free kernel (the historical branch's flipped sign and dropped
phase are deliberately not restored; see the follow-up comment),
linearity of both kernels in
A1andA2.The dead
KIM/src/tests/directory (empty CMakeLists, brokenkim_init_for_test) and the commented-outKIM_kernelssource group areremoved; the new tests live in
KIM/tests/with the other ctest programs.Verification
Test fails on defective kernel (normalization mutated)
(On
mainthe module and tests do not build at all; the historical testprograms reference modules deleted in
7c1345dc.)Test passes after restore
Full suite
Relation to Markus's Fokker-Planck periodic branch
This PR restores the historical continuous Krook kernels. It is useful for Fourier-phase, Debye-limit, and interpolation comparisons, but it is not the off-diagonal Fokker-Planck kernel implemented on
feature/kim-forced-periodicity. Hold integration until #191 decides whether any generic tests are retained. The independent FP derivation and oracle are #187, #194, and #196.