![]() |
QPMS
Electromagnetic multiple scattering library and toolkit.
|
Empty-lattice (Rayleigh/Wood) anomaly enumeration and its specexpr integration. More...
#include <stddef.h>#include "qpms_types.h"#include "vectors.h"#include "scatspec.h"#include "specexpr.h"

Go to the source code of this file.
Data Structures | |
| struct | qpms_rayleigh_anomaly_t |
| One distinct empty-lattice frequency and its contributing families. More... | |
| struct | qpms_rayleigh_table_t |
| The distinct ascending empty-lattice frequencies at a fixed Bloch vector. More... | |
Macros | |
| #define | QPMS_RAYLEIGH_NMAX 6 |
| Default integer scan range \(|n_i|\) of the anomaly enumeration. | |
Typedefs | |
| typedef int(* | qpms_rayleigh_nb_fn) (double *nb, void *ctx, double omega) |
| Background phase-index callback. | |
| typedef struct qpms_rayleigh_ctx_t | qpms_rayleigh_ctx_t |
| Opaque specexpr integration context (fixed Bloch vector). | |
Functions | |
| qpms_errno_t | qpms_rayleigh_table_compute (qpms_rayleigh_table_t *t, const cart3_t *lattice_basis, int latdim, cart3_t k, qpms_rayleigh_nb_fn nb_fn, void *nb_ctx, int nmax, double atol) |
Computes the empty-lattice anomaly table at the Bloch vector k. | |
| void | qpms_rayleigh_table_free (qpms_rayleigh_table_t *t) |
| Frees an anomaly table. NULL and zeroed structures are allowed. | |
| qpms_errno_t | qpms_rayleigh_family_frequency (double *out, const cart3_t *lattice_basis, int latdim, cart3_t k, const int nidx[3], qpms_rayleigh_nb_fn nb_fn, void *nb_ctx, double atol) |
| Evaluates the per-G-family empty-lattice frequency (k-continuous). | |
| qpms_rayleigh_ctx_t * | qpms_rayleigh_ctx_create (const qpms_scatspec_t *spec, cart3_t k) |
| void | qpms_rayleigh_ctx_free (qpms_rayleigh_ctx_t *ctx) |
| Frees a context. NULL is allowed. | |
| int | qpms_rayleigh_ctx_install (qpms_rayleigh_ctx_t *ctx, qpms_specexpr_env_t *env) |
| Installs the Rayleigh-anomaly expressions into a specexpr environment. | |
| qpms_errno_t | qpms_rayleigh_ctx_anomaly (qpms_rayleigh_ctx_t *ctx, long n, double *out) |
| const qpms_rayleigh_table_t * | qpms_rayleigh_ctx_table (qpms_rayleigh_ctx_t *ctx) |
| The anomaly table of the context (computed lazily on the first call). | |
Empty-lattice (Rayleigh/Wood) anomaly enumeration and its specexpr integration.
The empty-lattice frequencies of a periodic system at a Bloch vector \(\mathbf{k}\) are \(\omega_\mathbf{G} = |\mathbf{k}+\mathbf{G}| c / n_b\) over the reciprocal lattice vectors \(\mathbf{G} = \sum_i n_i \mathbf{B}_i\) (the 2pi-included reciprocal basis). They define the Rayleigh/Wood anomaly thresholds: the branch points of the periodic Green's function and the empty-lattice band edges that the resonance searches must not touch (cf. the band contour sugar in pergroups.h).
The same enumeration backs the simspec "Rayleigh-anomaly expressions" (ai_notes/simspec_draft.md, open question 9): in a specexpr environment prepared by qpms_rayleigh_ctx_install() the name rayleighN (N = 1, 2, ...) resolves to the Nth distinct ascending anomaly frequency at the context's Bloch vector, and the function form rayleigh(i, j[, l]) to the per-G-family frequency \(\omega_\mathbf{G}\) with the given integer lattice indices. The index labelling is well-defined at a fixed \(\mathbf{k}\) but is NOT continuous in \(\mathbf{k}\) (at branch crossings rayleighN switches to another family); the per-G-family form is the \(\mathbf{k}\)-continuous object and is what the k-swept experiments should refer to.
The background phase index \(n_b\) is supplied through a callback; the simspec integration evaluates it with a two-pass scheme (the vacuum estimate first, then the medium at that frequency), which is exact for a constant real index and a first-order approximation for dispersive backgrounds (the same convention as the band contour sugar).
| #define QPMS_RAYLEIGH_NMAX 6 |
Default integer scan range \(|n_i|\) of the anomaly enumeration.
The scan finds every reciprocal lattice vector with coefficients up to this bound; with the default of 6 a 2D lattice yields of the order of thirty distinct frequencies, which is comfortably more than the experimentally relevant ones.
| typedef int(* qpms_rayleigh_nb_fn) (double *nb, void *ctx, double omega) |
Background phase-index callback.
Evaluates \(n_b(\omega) > 0\); returns 0 on success, nonzero on failure (the anomaly at that frequency cannot be defined).
| qpms_errno_t qpms_rayleigh_ctx_anomaly | ( | qpms_rayleigh_ctx_t * | ctx, |
| long | n, | ||
| double * | out | ||
| ) |
The Nth (1-based) distinct anomaly frequency [rad/s] at the context's Bloch vector. Returns QPMS_SUCCESS or an error code.
| qpms_rayleigh_ctx_t * qpms_rayleigh_ctx_create | ( | const qpms_scatspec_t * | spec, |
| cart3_t | k | ||
| ) |
Creates a context for the periodic system spec at the Bloch vector k [rad/m]. Returns NULL on error (finite system, memory). spec is borrowed and must stay valid as long as the context.
| int qpms_rayleigh_ctx_install | ( | qpms_rayleigh_ctx_t * | ctx, |
| qpms_specexpr_env_t * | env | ||
| ) |
Installs the Rayleigh-anomaly expressions into a specexpr environment.
Afterwards the environment resolves the rayleighN constants (N = 1, 2, ...) and the per-G-family function rayleigh(...) (with exactly latdim integer arguments) at the context's Bloch vector; the anomaly table is computed lazily on the first use. The context must stay valid as long as the environment is used for evaluation. Returns 0 on success, -1 on error.
| const qpms_rayleigh_table_t * qpms_rayleigh_ctx_table | ( | qpms_rayleigh_ctx_t * | ctx | ) |
The anomaly table of the context (computed lazily on the first call).
Returns a borrowed pointer, or NULL on computation failure.
| qpms_errno_t qpms_rayleigh_family_frequency | ( | double * | out, |
| const cart3_t * | lattice_basis, | ||
| int | latdim, | ||
| cart3_t | k, | ||
| const int | nidx[3], | ||
| qpms_rayleigh_nb_fn | nb_fn, | ||
| void * | nb_ctx, | ||
| double | atol | ||
| ) |
Evaluates the per-G-family empty-lattice frequency (k-continuous).
\(\omega = c|\mathbf{k} + \sum_i \mathrm{nidx}_i\,\mathbf{B}_i| /
n_b\) with \(n_b\) evaluated at the vacuum frequency (two-pass). Unlike the table enumeration there is no deduplication or positive-frequency filtering: a vanishing result (k + G = 0) is returned as 0 without consulting nb_fn.
| qpms_errno_t qpms_rayleigh_table_compute | ( | qpms_rayleigh_table_t * | t, |
| const cart3_t * | lattice_basis, | ||
| int | latdim, | ||
| cart3_t | k, | ||
| qpms_rayleigh_nb_fn | nb_fn, | ||
| void * | nb_ctx, | ||
| int | nmax, | ||
| double | atol | ||
| ) |
Computes the empty-lattice anomaly table at the Bloch vector k.
Enumerates the integer tuples \((n_1, \ldots, n_{\mathrm{latdim}})\) with \(|n_i| \le\) nmax, evaluates the vacuum frequencies \(c|\mathbf{k}+\mathbf{G}|\), keeps the positive ones (above atol), and groups the tuples sharing a frequency (relative deduplication tolerance 1e-13). Each distinct frequency is then divided by \(n_b\) evaluated through nb_fn at its own vacuum frequency (the two-pass scheme described in the module header). The table owns its data; free it with qpms_rayleigh_table_free().
| lattice_basis | The latdim lattice basis vectors. |
| latdim | Lattice dimensionality, 1-3 (2D bases must be xy-planar, as elsewhere in the periodic machinery). |
| nb_fn | Background index callback (may not be NULL; it is not invoked for a vanishing vacuum frequency, which yields 0). |
| nmax | Integer scan range, > 0. |
| atol | Frequency floor for the positive-frequency filter and the basis degeneracy checks. |