QPMS
Electromagnetic multiple scattering library and toolkit.
Loading...
Searching...
No Matches
Functions
pergroups.c File Reference

Implementation of the affine space-group machinery (pergroups.h). More...

#include "pergroups.h"
#include <lapacke.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "groups.h"
#include "indexing.h"
#include "ksym.h"
#include "qpms_error.h"
#include "rayleigh.h"
#include "symmetries.h"
#include "tiny_inlines.h"
Include dependency graph for pergroups.c:

Functions

qpms_errno_t qpms_pergroup_int_rotations (int(*out)[3][3], const qpms_affop_t *ops, size_t nops, const cart3_t *lattice_basis, int latdim, double atol)
 
static int lattice_reduce (int *n, const cart3_t v, const cart3_t *basis, int latdim, double atol)
 
int qpms_pergroup_little_ops (size_t *out, const qpms_affop_t *ops, size_t nops, cart3_t k, const cart3_t *recip_basis, int latdim, double atol)
 
int qpms_pergroup_kcosets (cart3_t *outT, _Complex double *outphase, const cart3_t *lattice_basis, int latdim, cart3_t k, double atol, int nmax)
 Finds the translation cosets of B modulo T_k = {T in B: k·T in 2pi·Z}.
 
qpms_errno_t qpms_pergroup_incell_translation (cart3_t *out, cart3_t t, const cart3_t *lattice_basis, int latdim, double atol)
 In-cell (fractional) part of a translation: t minus its lattice part.
 
qpms_errno_t qpms_pergroup_build_Dk (_Complex double *D, const qpms_scatsys_t *ss, const qpms_affop_t *ops, size_t nops, cart3_t k, const cart3_t *lattice_basis, int latdim, double atol)
 
static int nullspace_rows (_Complex double *ns, size_t *nns, const _Complex double *A, size_t m, size_t n, double stol)
 
static void gram_schmidt_rows (_Complex double *A, size_t k, size_t n)
 
static double prand (unsigned long long *state)
 Deterministic pseudo-random double in [0, 1) (xorshift64*).
 
qpms_errno_t qpms_pergroup_decompose (size_t *nblocks, size_t *blockdims, _Complex double *U, const _Complex double *D, size_t nmat, size_t b)
 
static void block_id_set_name (qpms_pergroup_block_id_t *out, const char *name)
 Copies a representation label into a block-id name buffer (NUL-safe).
 
qpms_errno_t qpms_pergroup_identify_blocks (qpms_pergroup_block_id_t *out, const qpms_scatsys_t *ss, const qpms_finite_group_t *known, const qpms_affop_t *ops, size_t nops, const _Complex double *D, size_t nmat, size_t b, const _Complex double *U, const size_t *blockdims, size_t nblocks, cart3_t k, const cart3_t *lattice_basis, int latdim, double atol, double tol)
 
static int band_contour_nb (double *nb, void *ctx, double omega)
 Constant-background callback for the band contour's anomaly table.
 
qpms_errno_t qpms_pergroup_band_contour (_Complex double *centre, double *ar, double *ai, const cart3_t *lattice_basis, int latdim, cart3_t beta, double n_b, long band_index, double interval_factor, double aspect_ratio, double atol, int nmax)
 

Detailed Description

Implementation of the affine space-group machinery (pergroups.h).

Function Documentation

◆ gram_schmidt_rows()

static void gram_schmidt_rows ( _Complex double *  A,
size_t  k,
size_t  n 
)
static

In-place modified Gram-Schmidt orthonormalisation of k vectors of length n stored as the first k rows of A.

◆ lattice_reduce()

static int lattice_reduce ( int *  n,
const cart3_t  v,
const cart3_t *  basis,
int  latdim,
double  atol 
)
static

Least-squares integer coefficients of v over the basis; returns 0 and fills n (if non-NULL) iff v is a lattice vector within atol.

◆ nullspace_rows()

static int nullspace_rows ( _Complex double *  ns,
size_t *  nns,
const _Complex double *  A,
size_t  m,
size_t  n,
double  stol 
)
static

Right null space of a row-major m x n matrix; orthonormal null vectors are written as the first *nns rows of ns (n columns). Returns 0 or a negative LAPACK error.

◆ qpms_pergroup_band_contour()

qpms_errno_t qpms_pergroup_band_contour ( _Complex double *  centre,
double *  ar,
double *  ai,
const cart3_t *  lattice_basis,
int  latdim,
cart3_t  beta,
double  n_b,
long  band_index,
double  interval_factor,
double  aspect_ratio,
double  atol,
int  nmax 
)

Computes the Beyn ellipse for a diffracted-order-specified resonance search (the "band sugar"; the legacy lat2d_modes.py -d/-f/-i flags). The empty-lattice frequencies at the Bloch vector beta, omega_i = |beta + G_i| c / n_b over the reciprocal lattice vectors G_i (sorted ascending, deduplicated; omega_{-1} := 0), define the gaps; the signed band_index selects the gap and the hugging edge: index > 0 hugs the empty-lattice band number |index| from above (the ellipse is placed in the gap to the next order), and index < 0 hugs band |index| from below (the gap below; omega_{-1} := 0). The real half-axis r = (gap width)/2 . interval_factor (clipped below the gap width), the imaginary half-axis = r . aspect_ratio; the centre is anchored at the band edge with the unshrunk radius so that BOTH contour edges sit strictly inside the gap (a branch point of the periodic Green's function at the band edge must stay off the integration path). The lattice vectors are pre-scaled internally (the enumeration uses an integer-coefficient scan of |n_i| <= nmax around beta; pick nmax comfortably above the band index). n_b is the background phase index (constant or evaluated at the band edge; for dispersive backgrounds evaluate it at the vacuum estimate of the centre — a two-pass call). Returns QPMS_SUCCESS or an error code. *‍/

◆ qpms_pergroup_build_Dk()

qpms_errno_t qpms_pergroup_build_Dk ( _Complex double *  D,
const qpms_scatsys_t *  ss,
const qpms_affop_t *  ops,
size_t  nops,
cart3_t  k,
const cart3_t *  lattice_basis,
int  latdim,
double  atol 
)

Builds the k-dependent representation matrices D_k of the affine operations on the full excitation-coefficient space of ss. \p D receives \p nops matrices of size b×b row-major (b = ss->fecv_size). For every operation g and every particle p the code locates the image particle p' of the affine map g·r_p modulo the lattice (the residual lattice translation supplies the Bloch phase factor e^{-i k·T}); the kinds must match. The VSWF blocks are the coefficient transformations of the point operations (the matrices returned by qpms_irot3_uvswfi_dense()); the particles' placement transforms must be the identity (v1).

The operation set must be closed under composition modulo the k-trivial translations (e.g. the little-group operations extended by the translation cosets of qpms_pergroup_kcosets); then D_k is an honest representation, which the caller is expected to verify with the commutation gate.

◆ qpms_pergroup_decompose()

qpms_errno_t qpms_pergroup_decompose ( size_t *  nblocks,
size_t *  blockdims,
_Complex double *  U,
const _Complex double *  D,
size_t  nmat,
size_t  b 
)

Simultaneously decomposes a representation into its irreducible invariant subspaces (numerically, without character tables). \p D holds \p nmat matrices of size b×b row-major forming an honest representation of a finite group (the closure is not checked here; use the commutation gate on the application side). The routine finds the simultaneous invariant subspaces through the commutant/algebra pipeline: the commutant C = {X: XD_g = D_g X}, the span A of the representation matrices, their intersection Z = A∩C (the centre of the algebra), whose joint eigenspaces are the isotypic components.

\p U receives the b×b change-of-basis matrix with the basis vectors of the consecutive blocks in its rows (orthonormal rows; the blocks are the groups of consecutive rows). \p blockdims receives the dimensions of the blocks (at most b; the pointer may be NULL if only \p nblocks is wanted). \p nblocks receives the number of the blocks.

The blocks are the isotypic components: a multidimensional irrep with multiplicity m yields a block of dimension d·m whose singular spectrum is that of the d-dimensional irreducible block repeated m times — sufficient for the spectrum identity and the packing. Scaling: the pipeline solves dense null-space problems of size b²·nmat × b²; keep b·sqrt(nmat) in the low hundreds.

Returns QPMS_SUCCESS or an error code.

◆ qpms_pergroup_identify_blocks()

qpms_errno_t qpms_pergroup_identify_blocks ( qpms_pergroup_block_id_t *  out,
const qpms_scatsys_t *  ss,
const qpms_finite_group_t *  known,
const qpms_affop_t *  ops,
size_t  nops,
const _Complex double *  D,
size_t  nmat,
size_t  b,
const _Complex double *  U,
const size_t *  blockdims,
size_t  nblocks,
cart3_t  k,
const cart3_t *  lattice_basis,
int  latdim,
double  atol,
double  tol 
)

Identifies the numerical isotypic blocks with the irreps of the little group of k via their characters. The blocks come from qpms_pergroup_decompose (U rows = the SA basis, grouped by block). Two identification branches exist, selected by the factor system of the little group of k:

  • Ordinary branch (factor system trivial, e.g. at Gamma and at the zone-boundary points whose twist phases are real +-1): the block character chi_block(g) = Tr(block restriction of D_k(g)) is compared against m . tau_g . chi_beta(g) where m is the candidate multiplicity, chi_beta the character of the candidate irrep beta of known (whose element order must match ops — as produced by qpms_spg_match_pointgroup_ops()), and tau_g = exp(-i k.T_g) the Bloch twist phase of the operation.
  • Projective branch: when no tau gauge trivialises the factor system (the generic zone-boundary case, e.g. the K point of a honeycomb lattice), the blocks are the PROJECTIVE small representations of the little co-group known. These are constructed numerically: the factor system omega(g, h) = (D_g D_h) / D_gh (a well-defined scalar, the Bloch phase of the composition mismatch) defines the twisted group algebra, whose left regular representation (built and decomposed via qpms_pergroup_decompose) yields the projective irreps and their characters; the block characters are then matched against them. The matched blocks get synthetic labels <k-symbol><number> (e.g. "K1", ordered by irrep dimension, then characters; <k-symbol> is the qpms_ksym_path name of the high-symmetry point nearest to k, or "P" for a generic k).

In both branches a block is matched when exactly one candidate representation reaches a residual below tol.

ss supplies the particle positions for the residual extraction (the first particle is used as the representative). ops are the extended generator set in the D-matrix order; known must be the group matched from their POINT parts (with its multiplication table).

Returns QPMS_SUCCESS or an error code. The identification is purely diagnostic: unmatched blocks keep their structural labels.

Parameters
outnblocks entries (caller-allocated).

◆ qpms_pergroup_incell_translation()

qpms_errno_t qpms_pergroup_incell_translation ( cart3_t *  out,
cart3_t  t,
const cart3_t *  lattice_basis,
int  latdim,
double  atol 
)

In-cell (fractional) part of a translation: t minus its lattice part.

The lattice part is subtracted along the latdim basis directions (rounding to the nearest integer coefficients with tolerance atol); the components along the aperiodic direction(s) of a latdim < 3 system are kept verbatim (e.g. the t_z of a horizontal mirror about a stack plane in a 2D-periodic system).

◆ qpms_pergroup_int_rotations()

qpms_errno_t qpms_pergroup_int_rotations ( int(*)  out[3][3],
const qpms_affop_t *  ops,
size_t  nops,
const cart3_t *  lattice_basis,
int  latdim,
double  atol 
)

Derives the integer lattice-basis rotation matrices of the point parts of the operations (spglib convention x'_i = sum_j R_ij x_j). The matrices act on the lattice fractional coordinates (R_ij is the coefficient of a_i in the image of a_j); they are exactly what spglib's reciprocal-space routines (qpms_ksym_irmesh_init) expect. Every entry is verified integral within atol (a non-integral entry means the operation set is not a subgroup of the lattice space group). Supported lattice dimensionalities: 2 (xy-planar bases only, the normal completed with z) and 3. Returns QPMS_SUCCESS or an error code.

◆ qpms_pergroup_kcosets()

int qpms_pergroup_kcosets ( cart3_t *  outT,
_Complex double *  outphase,
const cart3_t *  lattice_basis,
int  latdim,
cart3_t  k,
double  atol,
int  nmax 
)

Finds the translation cosets of B modulo T_k = {T in B: k·T in 2pi·Z}.

The distinct values of exp(i k·T) over the lattice vectors classify the cosets; outT receives one representative Cartesian translation per coset (outT[0] = 0) and outphase the corresponding exp(i k·T). The enumeration scans lattice combinations n with |n_i| <= nmax (choose it comfortably above the denominators of k·a_i / 2pi; 8 is plenty for standard Brillouin-zone points). Returns the number of the cosets d (= |B/T_k|), or a negative value if the scan was exhausted before all phases settled (increase nmax).

◆ qpms_pergroup_little_ops()

int qpms_pergroup_little_ops ( size_t *  out,
const qpms_affop_t *  ops,
size_t  nops,
cart3_t  k,
const cart3_t *  recip_basis,
int  latdim,
double  atol 
)

Selects the operations whose point parts keep k invariant modulo the reciprocal lattice (the little group of k). recip_basis are the 2pi-included reciprocal basis vectors (latdim of them); the selection criterion is R^T k = k + G with G a reciprocal-lattice vector, tested by integer reduction (cf. qpms_ksym_little_group_cart()). The indices of the selected operations are written to out (room for nops entries). Returns the number of the selected operations.