yasfpy.fmm.treecode =================== .. py:module:: yasfpy.fmm.treecode .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: yasfpy.fmm.treecode.numba yasfpy.fmm.treecode.prange Classes ------- .. autoapisummary:: yasfpy.fmm.treecode.HelmholtzTreecode Functions --------- .. autoapisummary:: yasfpy.fmm.treecode.helmholtz_greens_function Module Contents --------------- .. py:data:: numba :value: None .. py:data:: prange .. py:function:: 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) / d`` where ``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. .. py:class:: 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. .. py:attribute:: k .. py:attribute:: order :value: 4 .. py:attribute:: leaf_size :value: 32 .. py:attribute:: theta .. py:attribute:: max_depth :value: 30 .. py:attribute:: last_profile :type: dict[str, float] | None :value: None .. py:method:: build(sources_pos) Build the tree over the provided sources. :param sources_pos: Source positions with shape ``(N, 3)``. .. rubric:: Notes This populates both the recursive node structure and a flattened representation used for faster traversal. .. py:method:: apply(q, *, targets_pos = None, parallel_mode = 'auto', profile = False) Apply the treecode to evaluate potentials at targets. :param q: Source strengths with shape ``(N,)``. :param targets_pos: Target positions with shape ``(M, 3)``. If omitted, targets are the sources (self-interaction is skipped). :param parallel_mode: Selects the main parallel region when Numba is available. :param profile: If True, populate ``last_profile`` with timing information. :returns: Complex potentials at the targets. :rtype: numpy.ndarray