![]() |
QPMS
Electromagnetic multiple scattering library and toolkit.
|
Declarative YAML specification of simulation runs and their outputs. More...
#include "scatspec.h"

Go to the source code of this file.
Data Structures | |
| struct | qpms_simspec_axis_t |
| An expanded experiment axis. More... | |
| struct | qpms_simspec_tmatrix_t |
kind: tmatrix experiment data. More... | |
| struct | qpms_simspec_cross_sections_t |
kind: cross_sections experiment data. More... | |
| struct | qpms_simspec_driving_t |
kind: driving experiment data. More... | |
| struct | qpms_simspec_resonances_t |
kind: resonances experiment data. More... | |
| struct | qpms_simspec_bandstructure_svd_t |
kind: bandstructure_svd experiment data. More... | |
| struct | qpms_simspec_bandstructure_t |
| struct | qpms_simspec_mode_svd_t |
kind: mode_svd experiment data. More... | |
| struct | qpms_simspec_transmission_t |
kind: transmission experiment data. More... | |
| struct | qpms_simspec_experiment_t |
| One experiment of the run half. More... | |
| struct | qpms_simspec_output_t |
| Global output policy of the run half. More... | |
Typedefs | |
| typedef struct qpms_simspec_t | qpms_simspec_t |
| An opaque, resolved simulation specification. | |
Functions | |
| const char * | qpms_simspec_kind_name (qpms_simspec_kind_t kind) |
| Name of an experiment kind ("tmatrix", ...), or NULL for invalid values. | |
| qpms_simspec_t * | qpms_simspec_parse_file (const char *path, const qpms_scatspec_var_t *overrides, size_t noverrides, char *errbuf, size_t errlen) |
| Parses and validates a simspec file (system half + run half). | |
| qpms_simspec_t * | qpms_simspec_parse_string (const char *yaml, ssize_t len, const qpms_scatspec_var_t *overrides, size_t noverrides, char *errbuf, size_t errlen) |
| As qpms_simspec_parse_file(), but parses from a NUL-terminated string. | |
| void | qpms_simspec_free (qpms_simspec_t *s) |
| const qpms_scatspec_t * | qpms_simspec_system (const qpms_simspec_t *s) |
| The system half of the spec (borrowed pointer; owned by the simspec). | |
| size_t | qpms_simspec_experiment_count (const qpms_simspec_t *s) |
| Number of experiments. | |
| const qpms_simspec_experiment_t * | qpms_simspec_experiment (const qpms_simspec_t *s, size_t i) |
| The i'th experiment (borrowed pointer), or NULL if i is out of range. | |
| const qpms_simspec_output_t * | qpms_simspec_output (const qpms_simspec_t *s) |
| The global output policy (borrowed pointer; owned by the simspec). | |
| const char * | qpms_simspec_path (const qpms_simspec_t *s) |
| The path the spec was parsed from (borrowed; NULL for parse_string()). | |
| int | qpms_simspec_solver_fingerprint (const qpms_simspec_resonances_t *r, char hex[65]) |
| Computes a SHA-256 fingerprint of the k-independent solver specification. | |
| qpms_errno_t | qpms_simspec_resonances_resolve_kdep (const qpms_simspec_t *sim, const qpms_simspec_resonances_t *r, cart3_t k, qpms_simspec_resonances_t *out, char *errbuf, size_t errlen) |
| Resolves the k-dependent contour expressions of a solver spec. | |
Declarative YAML specification of simulation runs and their outputs.
This module implements the run half of the unified simspec format (ai_notes/simspec_draft.md): the experiments and output sections of a YAML file whose system half (vars, materials, particles, places, system) follows the scatspec grammar (scatspec.h). One file describes the whole simulation; this loader parses the experiments, expands the frequency/direction axes and validates everything up front, so that the runner application can work with a fully resolved model.
version: 1
# ... system half (scatspec grammar) ...
experiments:
- name: extinction
kind: cross_sections
omega: {start: 1.5*eV/hbar, stop: 3*eV/hbar, step: 2e-3*eV/hbar}
incidence:
theta: {start: 0, stop: pi/2, step: pi/200}
phi: 0
polarisation: {psi: 0, chi: 0}
irreps: all
output:
file: rect30x40.qpms.h5 # default: <simspec-stem>.qpms.h5
overwrite: false
Every axis accepts a scalar, an explicit sequence, or a {start, stop, step} mapping (stop inclusive, matching the --omega-seq convention of qpms-tmatrix-compose); see qpms_simspec_axis_t.
The lifetime rule mirrors scatspec: the parsed qpms_simspec_t owns the system half (a qpms_scatspec_t), which in turn owns the T-matrix generators used by any qpms_scatsys_t built from it; keep the simspec alive as long as the built systems are used.
| typedef struct qpms_simspec_t qpms_simspec_t |
An opaque, resolved simulation specification.
Owns the system half (sys) and the parsed experiments.
| enum qpms_simspec_kind_t |
Experiment kinds of the simspec format.
| enum qpms_simspec_pol_t |
| void qpms_simspec_free | ( | qpms_simspec_t * | s | ) |
Frees a simspec. Any qpms_scatsys_t built from its system half becomes invalid afterwards.
| qpms_simspec_t * qpms_simspec_parse_file | ( | const char * | path, |
| const qpms_scatspec_var_t * | overrides, | ||
| size_t | noverrides, | ||
| char * | errbuf, | ||
| size_t | errlen | ||
| ) |
Parses and validates a simspec file (system half + run half).
The overrides semantics match qpms_scatspec_parse_file(): they are applied on top of (and take precedence over) the file's vars section, and are shared by both halves.
| path | Path to the YAML file. |
| overrides | Optional variable overrides (may be NULL). |
| noverrides | Number of entries in overrides. |
| errbuf | Buffer for a human readable error message (may be NULL). |
| errlen | Size of errbuf. |
| qpms_errno_t qpms_simspec_resonances_resolve_kdep | ( | const qpms_simspec_t * | sim, |
| const qpms_simspec_resonances_t * | r, | ||
| cart3_t | k, | ||
| qpms_simspec_resonances_t * | out, | ||
| char * | errbuf, | ||
| size_t | errlen | ||
| ) |
Resolves the k-dependent contour expressions of a solver spec.
The kind: bandstructure experiments may parametrise their explicit contour with the Rayleigh-anomaly expressions (the rayleighN constants and the per-G-family rayleigh(i, j[, l]) function; see rayleigh.h): such expressions are stored verbatim in the *_expr fields of the solver spec and evaluated at every Bloch vector of the sweep, so that the contour can follow an anomaly curve \(\omega(\mathbf{k}) = \hbar c |\mathbf{k}+\mathbf{G}| / n_b\) continuously in k. This function evaluates the stored expressions at the Bloch vector k [rad/m] (with the spec's variables and the background phase index of the system) and copies r to out with the expression-derived fields filled in, contour_kdep cleared, and the contour invariants re-validated (positive half-axes; rectangle corners ordered). Fields without an expression are carried over verbatim; the expression strings themselves are borrowed (not set in out), so out is a transient shallow copy — do not free it separately and do not let it outlive r and sim.
errbuf filled in (invalid arguments, contour_kdep not set in r, an expression evaluation failure, or a violated contour invariant). | int qpms_simspec_solver_fingerprint | ( | const qpms_simspec_resonances_t * | r, |
| char | hex[65] | ||
| ) |
Computes a SHA-256 fingerprint of the k-independent solver specification.
Serialises the solver selection, contour/band-sugar specification, solver options, irrep selection and eigenvector-saving policy of a resonances-style experiment struct (also used for the solver part of other k-swept kinds) in a canonical form and hashes it. The Bloch vector is deliberately excluded: the fingerprint identifies the k-independent part of the specification, so that a k sweep over the same solver settings yields one fingerprint.