Epic: Fourier consolidation and public API (one N-D Helmholtz kernel, one grid, one derivative class)

Open
#83 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
jupyter-notebook, python
Domain
api, backend, tooling

Research direction

This is an epic consolidating the Fourier module. Start by reading spectraldiffx/_src/fourier/solvers.py to understand the current duplication. The work is broken into child issues (#106-#111) that must be tackled in order. First, implement the N-D Helmholtz kernel and per-axis BC spec table as described in #106, using existing tests to verify bit-compatibility. This requires deep familiarity with the codebase and spectral methods.

Written by the indexing model from the issue text.

Description

enhancement epic

Scope

spectraldiffx/_src/fourier/solvers.py is 2523 lines of which roughly 85% is copies of one N-D kernel: 30 same-BC solvers are a 12-line skeleton × {fft, dst1, dst2, dct1, dct2} × {1d, 2d, 3d} × {helmholtz, poisson}, and 15 solve_poisson_* are forwarders. solve_helmholtz_3d (solvers.py:597-747) is already the generic per-axis loop. The three grid classes, three derivative classes and three filter classes are likewise hand-unrolled per dimension, with feature drift between them (only 1D has k_dealias, only 2D/3D have K2, only 1D has __call__(u, order)). exponential_filter and hyperviscosity are implemented seven times across Fourier, Chebyshev and spherical.

The public surface has 116 exports (38 solve_*, 18 eigenvalue builders, 8 transforms, 3 modify_rhs_*, 46 classes), two overlapping solver APIs neither of which is a superset of the other, four calling conventions, and lambda_ vs alpha.

Goal: one solve_helmholtz_nd kernel driven by a static per-axis BC spec table; one HelmholtzSolver module; N-D FourierGrid and SpectralDerivative; shared filter formulas; the existing names kept as thin aliases so nothing breaks. Expected reduction: ~1500–2000 lines. The existing "matches the monolithic solver to 1e-10" tests guard bit-compatibility.

Child issues (in suggested order)

  • #106 refactor(solvers): one N-D Helmholtz kernel + per-axis spec table (2523 → ~600 lines; fixes 2D transform ordering; mixed BCs gain approximation) — high
  • #107 refactor(solvers): one HelmholtzSolver(grid, bc, approximation) replacing nine classes; unify lambda_/alpha and BC vocabulary — high
  • #108 refactor(fourier): N-D FourierGrid and SpectralDerivative, rfft path, spectral-in/spectral-out (1.5–1.75x) — medium
  • #109 refactor(filters): one implementation of the filter formulas (currently seven) — medium
  • #110 feat(operators): missing operators (3/2-rule product, iterated Laplacian, vorticity helpers, spectra, IMEX inverse) — medium
  • #111 refactor(api): move eigenvalue builders and modify_rhs_* under spectraldiffx.fourier; deprecate un-numbered aliases — low
  • #122 docs(solvers): state where the boundary node sits for each transform type, with a staggered-grid example — requested by finitevolX (jejjohnson/finitevolX#300)

Do this after #80 so the consolidation preserves fixed behaviour, and after #102 so the new modules are born with static fields. #119 (dense-Kronecker sweep) is the regression net for #106.

Related

  • #65 (scan-based time stepping) depends on #108's spectral-in/spectral-out RHS.
  • #114 (express solvers through gaussx.DiagonalisedOperator) builds on #106/#107.
  • Downstream consumer: jejjohnson/finitevolX#315 (adapter over solve_helmholtz_nd/HelmholtzSolver).
Dominant language
Python
Stars
2
Forks
0
Avg merge
8h 13m
Merged PRs (30d)
8

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jejjohnson/spectraldiffx

All issues in jejjohnson/spectraldiffx

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.