QPMS
Electromagnetic multiple scattering library and toolkit.
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
simspec.h File Reference

Declarative YAML specification of simulation runs and their outputs. More...

#include "scatspec.h"
Include dependency graph for simspec.h:
This graph shows which files directly or indirectly include this file:

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.
 

Enumerations

enum  qpms_simspec_kind_t {
  QPMS_SIMSPEC_KIND_TMATRIX = 0 , QPMS_SIMSPEC_KIND_CROSS_SECTIONS , QPMS_SIMSPEC_KIND_DRIVING , QPMS_SIMSPEC_KIND_RESONANCES ,
  QPMS_SIMSPEC_KIND_MODE_SVD , QPMS_SIMSPEC_KIND_BANDSTRUCTURE , QPMS_SIMSPEC_KIND_BANDSTRUCTURE_SVD , QPMS_SIMSPEC_KIND_TRANSMISSION
}
 Experiment kinds of the simspec format. More...
 
enum  qpms_simspec_pol_t { QPMS_SIMSPEC_POL_PSICHI = 0 , QPMS_SIMSPEC_POL_ECART , QPMS_SIMSPEC_POL_HELICITY }
 Incident-wave polarisation specification of a cross-sections experiment. More...
 
enum  qpms_simspec_irreps_t { QPMS_SIMSPEC_IRREPS_FULL = 0 , QPMS_SIMSPEC_IRREPS_ALL , QPMS_SIMSPEC_IRREPS_LIST }
 Irrep-selection mode of the finite-system experiments. More...
 
enum  qpms_simspec_driving_basis_t { QPMS_SIMSPEC_DRIVING_BASIS_LMAX = 0 , QPMS_SIMSPEC_DRIVING_BASIS_VSWF , QPMS_SIMSPEC_DRIVING_BASIS_SYMMETRY_ADAPTED }
 Driving basis specification of a driving experiment. More...
 
enum  qpms_simspec_solver_t { QPMS_SIMSPEC_SOLVER_BEYN = 0 , QPMS_SIMSPEC_SOLVER_RECURSIVE_BEYN , QPMS_SIMSPEC_SOLVER_FEAST }
 Contour-integral eigensolver selection (libnles backends). More...
 
enum  qpms_simspec_quadrature_t { QPMS_SIMSPEC_QUADRATURE_TRAPEZOIDAL = 0 , QPMS_SIMSPEC_QUADRATURE_GAUSS_LEGENDRE }
 Contour quadrature rule.
 

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.
 

Detailed Description

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 Documentation

◆ qpms_simspec_t

An opaque, resolved simulation specification.

Owns the system half (sys) and the parsed experiments.

Enumeration Type Documentation

◆ qpms_simspec_driving_basis_t

Driving basis specification of a driving experiment.

Enumerator
QPMS_SIMSPEC_DRIVING_BASIS_LMAX 

all VSWFs up to lmax

QPMS_SIMSPEC_DRIVING_BASIS_VSWF 

explicit VSWF code list

QPMS_SIMSPEC_DRIVING_BASIS_SYMMETRY_ADAPTED 

single-particle group

◆ qpms_simspec_irreps_t

Irrep-selection mode of the finite-system experiments.

Enumerator
QPMS_SIMSPEC_IRREPS_FULL 

no block diagonalisation (full space)

QPMS_SIMSPEC_IRREPS_ALL 

all irreps of the system symmetry

QPMS_SIMSPEC_IRREPS_LIST 

the named irreps only

◆ qpms_simspec_kind_t

Experiment kinds of the simspec format.

Enumerator
QPMS_SIMSPEC_KIND_TMATRIX 

particle T-matrix sweep

QPMS_SIMSPEC_KIND_CROSS_SECTIONS 

plane-wave illumination

QPMS_SIMSPEC_KIND_DRIVING 

direct VSWF driving

QPMS_SIMSPEC_KIND_RESONANCES 

contour-integral mode search

QPMS_SIMSPEC_KIND_MODE_SVD 

mode-problem singular values

QPMS_SIMSPEC_KIND_BANDSTRUCTURE 

complex-omega resonance mode solving swept over a k-path or k mesh (libnles)

QPMS_SIMSPEC_KIND_BANDSTRUCTURE_SVD 

singular values along a k-path

QPMS_SIMSPEC_KIND_TRANSMISSION 

plane-wave-driven transmission measurement swept over (omega, k_parallel)

◆ qpms_simspec_pol_t

Incident-wave polarisation specification of a cross-sections experiment.

Enumerator
QPMS_SIMSPEC_POL_PSICHI 

polarisation-ellipse angles (psi, chi)

QPMS_SIMSPEC_POL_ECART 

Cartesian E-field phasor at the origin.

QPMS_SIMSPEC_POL_HELICITY 

circular polarisation (+1 / -1)

◆ qpms_simspec_solver_t

Contour-integral eigensolver selection (libnles backends).

Enumerator
QPMS_SIMSPEC_SOLVER_BEYN 

classic Beyn

QPMS_SIMSPEC_SOLVER_RECURSIVE_BEYN 

recursive Beyn (region partitioning)

QPMS_SIMSPEC_SOLVER_FEAST 

FEAST-family subspace iteration.

Function Documentation

◆ qpms_simspec_free()

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_parse_file()

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.

Parameters
pathPath to the YAML file.
overridesOptional variable overrides (may be NULL).
noverridesNumber of entries in overrides.
errbufBuffer for a human readable error message (may be NULL).
errlenSize of errbuf.
Returns
A new spec, or NULL on error (with errbuf filled in).

◆ qpms_simspec_resonances_resolve_kdep()

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.

Returns
QPMS_SUCCESS, or QPMS_ERROR with errbuf filled in (invalid arguments, contour_kdep not set in r, an expression evaluation failure, or a violated contour invariant).

◆ qpms_simspec_solver_fingerprint()

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.

Returns
QPMS_SUCCESS, or QPMS_ERROR if the arguments are NULL or on an out of memory error.