![]() |
QPMS
Electromagnetic multiple scattering library and toolkit.
|
Implementation of the empty-lattice anomaly enumeration (see rayleigh.h). More...
#include "rayleigh.h"#include <ctype.h>#include <errno.h>#include <math.h>#include <stdarg.h>#include <stdlib.h>#include <string.h>
Data Structures | |
| struct | rayl_rec_t |
| An enumeration record (vacuum frequency + integer tuple). More... | |
| struct | qpms_rayleigh_ctx_t |
Macros | |
| #define | RAYLEIGH_DEDUP_TOL 1e-13 |
Functions | |
| static qpms_errno_t | rayleigh_recip_basis (cart3_t B[3], const cart3_t *ab, int latdim, double atol) |
| The 2pi-included reciprocal basis of a 1-3 dimensional lattice. | |
| static int | rayl_rec_cmp (const void *pa, const void *pb) |
| 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). | |
| static int | rayleigh_ctx_nb (double *nb, void *vctx, double omega) |
| static qpms_errno_t | rayleigh_ensure_table (qpms_rayleigh_ctx_t *ctx) |
| static void | rayleigh_seterr (char *errbuf, size_t errlen, const char *fmt,...) __attribute__((format(printf |
| static int | rayleigh_dyn_const (void *vctx, const char *name, _Complex double *out, char *errbuf, size_t errlen) |
| Resolves the "rayleighN" constants (N = 1, 2, ...). | |
| static int | rayleigh_dyn_call (void *vctx, const char *name, const _Complex double *args, size_t nargs, _Complex double *out, char *errbuf, size_t errlen) |
| Resolves the per-G-family function rayleigh(i, j[, l]). | |
| 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). | |
Implementation of the empty-lattice anomaly enumeration (see rayleigh.h).
| #define RAYLEIGH_DEDUP_TOL 1e-13 |
Relative tolerance of the frequency deduplication (as in the band contour sugar).
| 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. |
|
static |
Background index of the context's system (real part convention, as in the band contour sugar).