Skip to content

Integrated Greens Function implementation for 2D, 2.5D, slice-by-slice, and 3D FFT-based Poisson solvers - #154

Draft
woodtp wants to merge 5 commits into
PyORBIT-Collaboration:mainfrom
woodtp:feature/poisson-fft-solvers-integrated-greens-function
Draft

woodtp wants to merge 5 commits into
PyORBIT-Collaboration:mainfrom
woodtp:feature/poisson-fft-solvers-integrated-greens-function

Conversation

@woodtp

@woodtp woodtp commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Adds optional integrated Green’s Function (IGF) kernels to the 2D and 3D FFT Poisson solvers, following the implementation as described in [1].

The existing point-sampled kernel treats the charge deposited at each grid point as a point source. This method instead integrates the free-space Green’s function over the finite source cell, which may improve accuracy when the grid cells' aspect ratios are large.

Qiang et al. propose four strategies for mitigating cancellation in terms such as $\log(x+r)$. When $x<0$ and $\lvert x\rvert\approx r$, direct evaluation of $x+r$ subtracts two nearly equal numbers and can become limited by numerical precision. The same issue applies independently to the $y+r$ and $z+r$ terms.

I chose the algebraic rewrite from Equation (11). From the included benchmark, the resulting maximum normalized field error remained below 0.1%, including the case where direct evaluation of the logarithm failed.

double stableLogArgument(double coordinate, double other_a, double other_b, double radius)
{
	if (coordinate >= 0.0) {
		return std::log(coordinate + radius);
	}
	return std::log((other_a * other_a + other_b * other_b) / (radius - coordinate));
}
  • Added GreensFunction2D and GreensFunction3D helpers for finite-cell Green’s-function evaluation.
  • Added setUseIntegratedGreenFunction(bool) and getUseIntegratedGreenFunction() to PoissonSolver* and PoissonSolverFFT3D.
  • Builds the selected kernel directly into the solver’s FFTW kernel buffer; removes the obsolete intermediate double** double*** kernel storage.
  • Exposed the option through Python for:
    • PoissonSolverFFT2D
    • PoissonSolverFFT3D
    • SpaceChargeCalc3D
    • SpaceChargeCalc2p5D
    • SpaceChargeCalc2p5Drb
    • SpaceChargeCalcSliceBySlice2D

[1] Qiang, J., Mitchell, C., Lehe, R., & Formenti, A. (2024). Implementation of the Integrated Green’s Function Method for 3D Poisson’s Equation in a Large Aspect Ratio Computational Domain. Journal of Software Engineering and Applications, 17(9), 740–749. https://doi.org/10.4236/jsea.2024.179039

woodtp added 5 commits October 6, 2026 12:14
Marked a few getters `const` where appropriate. Deleted copy/move
constructors for FFT-based solvers to prevent accidental
double-allocation of FFTW buffers. No longer allocate
BunchExtremaCalculator and Calculator instances into dynamic memory.
@woodtp woodtp self-assigned this Oct 6, 2026
@woodtp woodtp added the enhancement New feature or request label Oct 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant