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

Per-k resonance solving machinery (libnles); see resonance_k.hpp. More...

#include <complex.h>
#include "resonance_k.hpp"
#include <cstring>
#include <format>
#include <lapacke.h>
#include <memory>
#include <print>
#include <stdexcept>
#include <string>
#include <vector>
#include <nles.h>
#include "scatspec.h"
#include "scatsystem.h"
#include "groups.h"
#include "ksym.h"
#include "spgsym.h"
#include "pergroups.h"
#include "tolerances.h"
#include "vectors.h"
Include dependency graph for resonance_k.cpp:

Namespaces

namespace  qpms
 

Functions

void qpms::resonance::spec_recip_basis (cart3_t recip[3], const qpms_scatspec_t *spec, int ldim)
 
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); see resonance_k.hpp.

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).

◆ spec_recip_basis()

void qpms::resonance::spec_recip_basis ( cart3_t  recip[3],
const qpms_scatspec_t *  spec,
int  ldim 
)
inline

2pi-included reciprocal basis of the spec's lattice (throws on degenerate/unsupported lattices; xy-planar restriction for 2D).