yasfpy.fmm.treecode#
Helmholtz treecode / fast multipole prototype.
This module contains an experimental treecode-style accelerator for the Helmholtz kernel used by YASF. It is primarily intended for research and benchmarking.
Attributes#
Classes#
Kernel-independent treecode for scalar Helmholtz interactions. |
Functions#
|
Scalar 3D Helmholtz Green's function |
Module Contents#
- yasfpy.fmm.treecode.numba = None#
- yasfpy.fmm.treecode.prange#
- yasfpy.fmm.treecode.helmholtz_greens_function(k, r, r_src)#
Scalar 3D Helmholtz Green’s function
G(r, r').Uses the outgoing convention
G(r, r') = exp(1j * k * d) / dwhere
d = ||r - r'||.The prefactor (1/4π) is intentionally omitted because YASF’s coupling kernels use their own normalization; the treecode is meant as an algorithmic feasibility prototype.
- class yasfpy.fmm.treecode.HelmholtzTreecode(*, k, order=4, leaf_size=32, theta=0.7, max_depth=30)#
Kernel-independent treecode for scalar Helmholtz interactions.
This is a feasibility prototype for eventually accelerating YASF’s coupling matvecs with hierarchical methods.
Model#
Given sources with complex strengths q_j at positions r_j, evaluate
u(r_i) = sum_{j != i} G(r_i, r_j) q_j
using a hierarchical tree traversal, approximating well-separated node contributions via Chebyshev interpolation inside the source node.
- param k:
Complex wave number.
- param order:
Chebyshev interpolation order per dimension. Equivalent nodes per box are order^3.
- param leaf_size:
Max sources per leaf.
- param theta:
Multipole acceptance criterion. A node is considered well-separated from target r if dist(center, r) > (radius/theta). Larger theta => more aggressive approximation.
- k#
- order = 4#
- leaf_size = 32#
- theta#
- max_depth = 30#
- build(sources_pos)#
Build the tree over the provided sources.
- Parameters:
sources_pos – Source positions with shape
(N, 3).
Notes
This populates both the recursive node structure and a flattened representation used for faster traversal.
- apply(q, *, targets_pos=None, parallel_mode='auto', profile=False)#
Apply the treecode to evaluate potentials at targets.
- Parameters:
q – Source strengths with shape
(N,).targets_pos – Target positions with shape
(M, 3). If omitted, targets are the sources (self-interaction is skipped).parallel_mode – Selects the main parallel region when Numba is available.
profile – If True, populate
last_profilewith timing information.
- Returns:
Complex potentials at the targets.
- Return type: