Skip to content

Add periodic-Fourier run mode behind config switch#180

Open
krystophny wants to merge 6 commits into
mainfrom
feat/flux-pumping/wp5-driver
Open

Add periodic-Fourier run mode behind config switch#180
krystophny wants to merge 6 commits into
mainfrom
feat/flux-pumping/wp5-driver

Conversation

@krystophny

@krystophny krystophny commented Jul 12, 2026

Copy link
Copy Markdown
Member

Fourth split item of #175: the periodic-Fourier solve wired behind the
existing run-type switch. rt_fourier_periodic_m
(KIM/src/fourier_periodic/rt_fourier_periodic.f90) registers
type_of_run = 'fourier_periodic' in the kim_mod_m factory, runs the
standard init pipeline, replaces the global background with its
periodization around the resonant surface, assembles the kernel matrices
on k_m = 2 pi m / L, solves the screened Poisson system, and writes
/fields/Phi_periodic and /fields/Br_periodic on a one-period grid.

Stack: parent branch feat/flux-pumping/wp5-periodic-solve at ca5d2776
(#179), on top of #178 and #177; the diff is cumulative until the parents
merge.

Config

New KIM_SETUP namelist keys with safe defaults (absent keys keep
defaults, so existing configuration files are unaffected): fp_r_res,
fp_dr_layer, fp_dr_transition (cm; required positive for this run
type, validated with explicit errors), fp_n_modes (128), fp_n_quad
(512), fp_grid_points (2048).

Invariants

  • Periodized-background feed ordering: primitives (per-species n and T;
    Er, B0, q, ks, kp) are periodized onto a uniform grid spanning three
    half-periods on each side of fp_r_res; om_E = -c ks Er / B0 is
    recomputed algebraically; gradients come from differentiating the
    periodized profiles through the existing pipeline stencil; vT, omega_c,
    lambda_D, nu, z0 are recomputed by the existing calculate_plasma_backs;
    A1/A2 use the pipeline's exact formula. Periodizing a gradient is wrong
    in the transition zones and the test proves the feed does not do it.
  • Bounded contracts, stated as errors rather than silent behavior:
    type_br_field = 12 (constant unit Br, matching the hat-basis
    kernel-weighted right-hand side rhs = 4 pi K^{rho B} B_r with
    B_{r,m} = delta_{m,0}) is the only supported perturbation;
    rescale_density is rejected because the second pass through the
    collision-frequency formulas would rescale twice.
  • The hat-basis solver, its cell-center and susceptibility tables, and all
    golden records are untouched; the new mode only reads shared state.

Verification

Test fails on a wrong-period feed (mutated periodization widths)

$ sed -i 's|r_res, dr_layer, ...|r_res, 2.0d0*dr_layer, ...|' rt_fourier_periodic.f90
$ ./build/tests/test_periodized_background_feed.x
 FAIL kernel is not periodic at r =    30.899999999999999
   K(r)   =              (-821.26270790014928,-16.315543599227979)
   K(r+L) =               (-778.66687670516785,35.714701506956338)
ERROR STOP

Test passes after restore

 PASS resonant layer keeps the physical density
 PASS kernels see an L-periodic background
 PASS transition gradient is the centered difference of the periodized density
 PASS transition gradient differs from the physical slope
 PASS A1 matches the stored periodized arrays
 PASS all periodized feed checks

Full suite

$ ctest --test-dir build
100% tests passed, 0 tests failed out of 30

The feed test builds the plasma state directly (linear density, uniform
temperature), so it exercises build_periodized_background without a
configuration file. The end-to-end case run and the hat-basis no-op
benchmark are the next split item: they need a packaged electrostatic
case, which the benchmark scouting identified as new work
(KIM/nmls/KIM_config.nml is the template; golden CI currently carries
only the electromagnetic case).

Relation to Markus's Fokker-Planck periodic branch

This PR contains the strongest reusable integration pieces from the independent stack: run-type registration, explicit configuration, and a per-species periodized-background feed. Its solver still uses the separate Krook kernel path. Compare and port the seams only after #185, #186, #187, and #188 establish the FP physics; #191 owns reconciliation.

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.

1 participant