QPMS
Electromagnetic multiple scattering library and toolkit.
Loading...
Searching...
No Matches
Data Structures | Namespaces | Functions
resonance_k.hpp File Reference

Per-k resonance solving machinery (libnles), shared by the kind: resonances runner and the k-swept kind: bandstructure runner and exposed to the Python bindings through the C ABI in resonance_c.h. More...

#include <complex>
#include <memory>
#include <string>
#include <vector>
#include "simspec.h"
#include "spgsym.h"
#include "vectors.h"
Include dependency graph for resonance_k.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  qpms::resonance::ResonanceContour
 The effective contour of a resonance solve (all values in SI rad/s). More...
 
struct  qpms::resonance::ResonanceBlockResult
 Results of one block solve. More...
 
struct  qpms::resonance::ResonanceKResult
 Results of the per-k solve over all blocks. More...
 
struct  qpms::resonance::ResonanceKSetup
 
struct  qpms::resonance::ResonanceKSetup::Block
 

Namespaces

namespace  qpms
 

Functions

void qpms::resonance::resonance_validate_solver (const qpms_scatspec_t *spec, const qpms_simspec_resonances_t *r)
 
ResonanceContour qpms::resonance::resonance_effective_contour (const qpms_scatspec_t *spec, const cart3_t &k, const qpms_simspec_resonances_t *r)
 Derives the effective contour at the Bloch vector k.
 
std::unique_ptr< ResonanceKSetup > qpms::resonance::resonance_setup_at_k (const qpms_scatspec_t *spec, const cart3_t &k, const qpms_simspec_resonances_t *r, const ResonanceContour &contour)
 
void qpms::resonance::resonance_solve_setup (const ResonanceKSetup &setup, const cart3_t &k, const qpms_simspec_resonances_t *r, const ResonanceContour &contour, bool verbose, ResonanceKResult &out)
 
void qpms::resonance::solve_resonances_at_k (const qpms_scatspec_t *spec, const cart3_t &k, const qpms_simspec_resonances_t *r, const ResonanceContour &contour, bool verbose, ResonanceKResult &out)
 Convenience: setup + solve at one k (the resonances runner's flow).
 
void qpms::resonance::evaluate_eigenmode_fields (const ResonanceKSetup &setup, const cart3_t &k, const qpms_simspec_resonances_t *r, ResonanceKResult &res, bool verbose)
 

Detailed Description

Per-k resonance solving machinery (libnles), shared by the kind: resonances runner and the k-swept kind: bandstructure runner and exposed to the Python bindings through the C ABI in resonance_c.h.

The mode problem M(ω, k) v = 0 is the multiple-scattering matrix I − T(ω)·S(ω, k). The libnles problem callbacks are

solve(z, B) → X : LU-factorise M(z) at the complex angular frequency z and solve M(z) x = b per column; eval(z, M) : assemble M(z) and transpose it into libnles' column-major convention, so that the reported right null vectors are the physical mode patterns.

The block decomposition (per small representation of the little group of k) follows the same dispatch as the mode_svd runner:

The callbacks are currently invoked with a single worker (the qpms generator/translation stack is not guaranteed reentrant yet; the callback path itself was audited reentrant 2026-11-10 — fresh per-call allocations, const context reads, thread-safe LAPACKE; only the scuffgen generator serialises behind a mutex — so concurrent independent solves are admissible).

Function Documentation

◆ evaluate_eigenmode_fields()

void qpms::resonance::evaluate_eigenmode_fields ( const ResonanceKSetup &  setup,
const cart3_t &  k,
const qpms_simspec_resonances_t *  r,
ResonanceKResult &  res,
bool  verbose = false 
)

Evaluates the eigenmode field maps of a solved setup (the resonances experiment fields: option). Fills the fields_* members of res.blocks (index-aligned with setup.blocks). The block vectors are unpacked to the full excitation basis (via the little-group irrep projection on the point-image path, via the SA basis lift v = Uᴴ·u on the affine path); the fields are the scattered ones, valid in the background medium only. Throws std::runtime_error on failures of the per-eigenfrequency system snapshots.

◆ resonance_effective_contour()

ResonanceContour qpms::resonance::resonance_effective_contour ( const qpms_scatspec_t *  spec,
const cart3_t &  k,
const qpms_simspec_resonances_t *  r 
)

Derives the effective contour at the Bloch vector k.

The band contour sugar (has_band) is evaluated at k with the two-pass scheme (vacuum estimate, then the background index at the estimated centre); an explicit contour is carried verbatim. Throws std::runtime_error if the sugar cannot be derived at k.

◆ resonance_setup_at_k()

std::unique_ptr< ResonanceKSetup > qpms::resonance::resonance_setup_at_k ( const qpms_scatspec_t *  spec,
const cart3_t &  k,
const qpms_simspec_resonances_t *  r,
const ResonanceContour &  contour 
)

Builds the scattering system + block structure at k (the little-group decomposition follows the mode_svd dispatch). Serial: the system build and the numerical decomposition are not guaranteed reentrant. Throws std::runtime_error on error.

◆ resonance_solve_setup()

void qpms::resonance::resonance_solve_setup ( const ResonanceKSetup &  setup,
const cart3_t &  k,
const qpms_simspec_resonances_t *  r,
const ResonanceContour &  contour,
bool  verbose,
ResonanceKResult &  out 
)

Runs the libnles solver per block of a prepared setup and appends one ResonanceBlockResult per block to out.blocks. May run concurrently for independent setups (the callback path is reentrant, cf. resonance_k.cpp); the setup must outlive the call. Throws std::runtime_error on hard failures; NLES_BUDGET_EXHAUSTED is tolerated per block (flagged in the result).

◆ resonance_validate_solver()

void qpms::resonance::resonance_validate_solver ( const qpms_scatspec_t *  spec,
const qpms_simspec_resonances_t *  r 
)

Validates the solver specification against the system; throws std::runtime_error on error (mutual exclusivity of the contour forms, periodic-only band sugar, band sugar vs recursive_beyn).