<!-- prettier-ignore-start -->

## Phase 124: Kalika Spectroscopy Simulation — XAS/XANES/EXAFS, Photoemission, Vibrational Spectroscopy, NMR, Mossbauer & Electron Energy Loss

Simulation of all major experimental spectroscopies from first principles,
enabling direct comparison between computed and measured spectra. This phase
covers X-ray absorption (XANES/EXAFS), photoemission (XPS/ARPES), vibrational
(IR/Raman), nuclear magnetic resonance, Mossbauer, electron energy loss, and
auxiliary spectroscopies (EPR, RIXS, XES, PL). Targets parity with FEFF (XAS),
OCEAN (BSE-XAS), exciting (optics), Gaussian/ORCA (NMR), and WIEN2k spectroscopy
modules. Tech stack: Rust (~35%) for compute-intensive kernels (multiple
scattering, Raman tensors, EELS cross-sections), TypeScript (~55%) for
orchestration/types/API, Python (~10%) for legacy format I/O and prototyping.

---

### 124.1 Scaffolding & Core Types (`@kalika/spectroscopy`)

#### 124.1.1 Library Scaffolding

- [x] **124.1.1.1** Create `libs/kalika/spectroscopy/` directory with
      `project.json`, `package.json`, `tsconfig.json`, and `tsconfig.lib.json`.
      Add `@kalika/spectroscopy` path mapping to `tsconfig.base.json`
- [x] **124.1.1.2** Create barrel export `src/index.ts` exporting all public
      types, classes, and factory functions from the library
- [x] **124.1.1.3** Set up Rust workspace member
      `libs/kalika/spectroscopy/rust/` with `Cargo.toml`, configure `napi-rs`
      bindings for TypeScript interop, and add `wasm-pack` target for browser
      builds
- [x] **124.1.1.4** Create vitest configuration for the library with test
      fixtures directory `__fixtures__/` containing sample spectra in common
      formats (XDI, VAMAS, JCAMP-DX, CSV)

#### 124.1.2 Core Spectrum Types

- [x] **124.1.2.1** Define `Spectrum` base interface: `energy: Float64Array`,
      `intensity: Float64Array`, `metadata: SpectrumMetadata` (source, date,
      units, broadening applied, edge/nucleus info), `peaks: Peak[]`,
      `clone(): Spectrum`, `slice(eMin, eMax): Spectrum`
- [x] **124.1.2.2** Define `Peak` type: `position: number`, `height: number`,
      `fwhm: number`, `area: number`, `shape: PeakShape`, `assignment: string`,
      `confidence: number`
- [x] **124.1.2.3** Define `PeakShape` enum and associated parameter types:
      `Gaussian`, `Lorentzian`, `Voigt`, `PseudoVoigt`, `DoniachSunjic`,
      `AsymmetricGaussian`, each with shape-specific parameters (mixing ratio
      eta for pseudo-Voigt, asymmetry alpha for Doniach-Sunjic, etc.)
- [x] **124.1.2.4** Define `XASSpectrum` extending `Spectrum`: `edge: XASEdge`
      (K, L1, L2, L3, M1..M5), `absorberElement: Element`,
      `absorberSite: number`, `mu: Float64Array` (absorption coefficient),
      `chi: Float64Array | null` (EXAFS signal), `chiK: Float64Array | null`,
      `chiR: Float64Array | null`, `e0: number`, `normalization: NormParams`
- [x] **124.1.2.5** Define `XPSSpectrum` extending `Spectrum`:
      `coreLevel: string` (e.g., "C 1s", "O 1s"), `bindingEnergy: Float64Array`,
      `kineticEnergy: Float64Array`, `photonEnergy: number`,
      `workFunction: number`, `shirleyBackground: Float64Array | null`
- [x] **124.1.2.6** Define `RamanSpectrum` extending `Spectrum`:
      `ramanShift: Float64Array` (cm^-1), `excitationWavelength: number` (nm),
      `temperature: number`, `polarization: RamanPolarization | null`,
      `stokesAntiStokes: 'stokes' | 'anti-stokes' | 'both'`
- [x] **124.1.2.7** Define `IRSpectrum` extending `Spectrum`:
      `wavenumber: Float64Array` (cm^-1), `transmittance: Float64Array | null`,
      `absorbance: Float64Array | null`,
      `mode: 'transmission' | 'atr' | 'reflectance'`
- [x] **124.1.2.8** Define `NMRSpectrum` extending `Spectrum`:
      `chemicalShift: Float64Array` (ppm), `nucleus: NMRNucleus`,
      `fieldStrength: number` (Tesla), `referenceCompound: string`,
      `lineShape: 'gaussian' | 'lorentzian' | 'powder' | 'mas'`,
      `spinRate: number | null` (Hz, for MAS)
- [x] **124.1.2.9** Define `EELSSpectrum` extending `Spectrum`:
      `energyLoss: Float64Array` (eV), `region: 'low-loss' | 'core-loss'`,
      `collectionAngle: number` (mrad), `convergenceAngle: number` (mrad),
      `beamEnergy: number` (keV),
      `zeroLossPeak: { position: number; fwhm: number } | null`
- [x] **124.1.2.10** Define `MossbauerSpectrum` extending `Spectrum`:
      `velocity: Float64Array` (mm/s), `transmission: Float64Array`,
      `nucleus: MossbauerNucleus`, `sourceIsotope: string`,
      `temperature: number` (K),
      `hyperfineParams: MossbauerHyperfineParams | null`

#### 124.1.3 Core Enums and Constants

- [x] **124.1.3.1** Define `XASEdge` enum with all standard edges: `K`, `L1`,
      `L2`, `L3`, `M1`..`M5`, `N1`..`N7`, `O1`..`O5`. Include
      `edgeEnergy(element: Element, edge: XASEdge): number` lookup from
      tabulated X-ray edge energies (Henke/Elam database values)
- [x] **124.1.3.2** Define `NMRNucleus` type covering common nuclei: `H1`,
      `C13`, `N15`, `O17`, `F19`, `Na23`, `Al27`, `Si29`, `P31`, `V51`, `Fe57`,
      `Cu63`, `Sn119`, `Pt195`, etc. Include `spin: number`,
      `gyromagneticRatio: number`, `naturalAbundance: number`,
      `quadrupoleMoment: number | null` for each
- [x] **124.1.3.3** Define `MossbauerNucleus` enum: `Fe57`, `Sn119`, `Eu151`,
      `Dy161`, `Au197`, `Np237`, etc. Include `excitedStateEnergy: number`
      (keV), `groundStateSpin: number`, `excitedStateSpin: number`,
      `naturalLinewidth: number` (mm/s) for each isotope
- [x] **124.1.3.4** Define photoionization cross-section tables: implement
      `photoionizationCrossSection(element: Element, orbital: string,     photonEnergy: number): number`
      using Yeh-Lindau or Scofield tabulated values for XPS and valence band
      cross-section weighting

#### 124.1.4 Spectrum Container and Registry

- [x] **124.1.4.1** Implement `SpectrumCollection` container: store multiple
      spectra with labels, group by type/edge/element, provide iteration,
      filtering by metadata, and merge operations (sum, average, weighted sum)
- [x] **124.1.4.2** Implement `SpectrumRegistry` singleton: register computed
      spectra by structure ID + spectroscopy type, cache results, provide lookup
      by structure hash, invalidate on structure change
- [x] **124.1.4.3** Implement spectrum serialization: `toJSON()` / `fromJSON()`
      for all spectrum types, with Float64Array encoded as base64 for compact
      storage. Include format version for forward compatibility

---

### 124.2 X-ray Absorption Spectroscopy — XAS (`@kalika/xas`)

#### 124.2.1 XAS Library Scaffolding

- [x] **124.2.1.1** Create `libs/kalika/xas/` directory with `project.json`,
      `package.json`, `tsconfig.json`. Add `@kalika/xas` path mapping to
      `tsconfig.base.json`
- [x] **124.2.1.2** Create Rust crate `libs/kalika/xas/rust/` for
      performance-critical scattering computations: muffin-tin potentials, phase
      shifts, Green's function calculations. Configure napi-rs bindings

#### 124.2.2 Muffin-Tin Potential Construction

- [x] **124.2.2.1** Implement muffin-tin potential construction: given atomic
      positions and species, partition space into non-overlapping atomic spheres
      and interstitial region. Compute spherically-averaged potential inside
      each sphere from overlapping free-atom charge densities (Mattheiss
      prescription). Average potential in interstitial to define muffin-tin zero
- [x] **124.2.2.2** Implement self-consistent muffin-tin potential iteration:
      solve radial Schrodinger equation inside each sphere for the initial
      potential, compute new charge density from wavefunctions, mix old and new
      potentials (linear or Anderson mixing), iterate to self-consistency with
      convergence threshold on potential change (< 10^-4 Ry)
- [x] **124.2.2.3** Implement Hedin-Lundqvist self-energy correction: add
      complex self-energy to the muffin-tin potential to account for inelastic
      losses and finite photoelectron lifetime. Compute energy-dependent
      imaginary part from the electron gas model

#### 124.2.3 Phase Shift Computation (Rust)

- [x] **124.2.3.1** Implement radial Schrodinger equation solver (Rust): Numerov
      method for regular and irregular solutions inside each muffin-tin sphere
      at complex energy E + iGamma. Compute radial wavefunctions R_l(r) for
      angular momentum l = 0..l_max (l_max ~ 4 for K-edge, ~6 for L-edge)
- [x] **124.2.3.2** Implement scattering phase shift extraction: match radial
      wavefunction at sphere boundary to spherical Bessel/Neumann functions to
      extract complex phase shifts delta_l(E). Store as
      `PhaseShiftTable { element: Element, lMax: number, energies: Float64Array, phases: Complex64Array[] }`
- [x] **124.2.3.3** Implement scattering t-matrix from phase shifts: t_l =
      -sin(delta_l) exp(i\*delta_l) / k, for use in multiple scattering
      equations. Handle complex phase shifts for absorptive potentials

#### 124.2.4 XANES — Multiple Scattering Theory (Real-Space)

- [x] **124.2.4.1** Implement free-electron propagator G0 between two sites:
      G0*{LL'}(R_i, R_j) = -i*k * sum_L'' C*{LL'L''} h*l''(kR*{ij})
      Y_L''(R_ij_hat), where C are Gaunt coefficients, h_l are spherical Hankel
      functions, and L = (l,m) are angular momentum indices
- [x] **124.2.4.2** Implement full multiple scattering (FMS) matrix inversion
      (Rust): construct the matrix M = [t^{-1} - G0] for all sites within the
      FMS cluster (typically 50-200 atoms around absorber), invert to get full
      Green's function G = [t^{-1} - G0]^{-1}. Use LU decomposition or iterative
      Lanczos method for large clusters
- [x] **124.2.4.3** Implement XANES cross-section from FMS Green's function:
      mu(E) proportional to -Im[ sum_{L,L'} M*_L(E) G_{LL'}^{00}(E) M_{L'}(E) ],
      where M_L are dipole matrix elements between core state and final state
      angular momentum channel L, and G^{00} is the on-site (absorber) block of
      the full Green's function
- [x] **124.2.4.4** Implement dipole matrix elements: compute M_l =
      integral_0^{R_mt} R_core(r) _ r _ R_l(r) \* r^2 dr for core state (1s for
      K-edge, 2p for L-edge) to final state angular momentum channels allowed by
      selection rules (Delta_l = +/-1 for dipole)
- [x] **124.2.4.5** Implement quadrupole matrix elements for pre-edge:
      M\_{l,quad} = integral R_core(r) _ r^2 _ R_l(r) * r^2 dr for 1s->3d
      transitions at the K-edge of transition metals (Delta_l = +/-2 for
      quadrupole). Include electric quadrupole operator (k*r) coupling
- [x] **124.2.4.6** Implement cluster generation for FMS: given a crystal
      structure and absorber site, generate spherical cluster of specified
      radius (typically 6-8 Angstrom for XANES). Handle periodic boundary
      conditions, identify unique scattering paths

#### 124.2.5 XANES — Core-Hole DFT Approaches

- [x] **124.2.5.1** Implement full core-hole (FCH) approach: modify the
      pseudopotential/PAW dataset of the absorbing atom to remove one core
      electron, add one electron to the valence, perform self-consistent DFT
      calculation in a supercell. Extract unoccupied DOS projected onto absorber
      site as XANES proxy
- [x] **124.2.5.2** Implement half core-hole (HCH) / transition potential
      approach: Slater transition state with half a core electron removed.
      Compute eigenvalue differences as transition energies. This approximates
      the average of initial and final state effects
- [x] **124.2.5.3** Implement supercell convergence check: test XANES
      convergence with supercell size by computing spectra for 2x2x2, 3x3x3,
      etc. supercells. Core-hole interaction with periodic images must be
      negligible (energy shift < 0.1 eV between consecutive sizes)
- [x] **124.2.5.4** Implement core-hole screening analysis: compare FCH (fully
      screened), HCH (half screened), and unscreened (ground state DOS) to
      quantify screening effects on spectral shape and edge position

#### 124.2.6 XANES — Bethe-Salpeter Equation (BSE) for Core Excitations

- [x] **124.2.6.1** Implement core-level BSE Hamiltonian construction: build the
      electron-hole Hamiltonian H^{BSE}_{vc,v'c'} = (E_c - E_v) delta_{vv'}
      delta*{cc'} + K^{x}*{vc,v'c'} - K^{d}\_{vc,v'c'} where v indexes core
      states and c indexes conduction states. Exchange kernel K^x from bare
      Coulomb, direct (screened) kernel K^d from W (Phase 118 GW)
- [x] **124.2.6.2** Implement screened core-hole interaction: compute the
      screened Coulomb interaction W(r,r') between core hole and excited
      electron using the dielectric function from RPA or GW. Use static
      screening approximation W(omega=0) for efficiency
- [x] **124.2.6.3** Implement BSE eigenvalue solver for core excitations:
      Lanczos/Haydock recursion method to compute the XAS spectrum without full
      diagonalization — only the spectral function Im[<phi_0|G(omega)|phi_0>] is
      needed where phi_0 is the dipole-weighted initial state
- [x] **124.2.6.4** Implement OCEAN-equivalent workflow: integrate GW
      quasiparticle energies (Phase 118), BSE kernel, and core-level matrix
      elements into a single pipeline. Validate against published OCEAN results
      for standard systems (diamond C K-edge, SrTiO3 Ti L-edge)

#### 124.2.7 XANES — Edge Types and Special Effects

- [x] **124.2.7.1** Implement K-edge XANES: 1s core hole, dipole selection rule
      1s->p final states, quadrupole 1s->d pre-edge. Handle elements Z=3..92
      with appropriate core-level energies from tabulated values
- [x] **124.2.7.2** Implement L-edge XANES: L1 (2s->p), L2 (2p1/2->s,d), L3
      (2p3/2->s,d) edges. Include spin-orbit splitting of 2p core level. Handle
      branching ratio L3/L2 and statistical ratio deviation
- [x] **124.2.7.3** Implement M-edge XANES: M4,5 (3d->f) edges relevant for rare
      earths and actinides. Include multiplet effects from 3d-4f Coulomb and
      exchange interactions via atomic multiplet theory (Cowan code approach)
- [x] **124.2.7.4** Implement angular-dependent XANES (X-ray natural linear
      dichroism, XNLD): compute orientation-dependent absorption for anisotropic
      systems by resolving dipole matrix elements along crystal axes. Output
      sigma_x(E), sigma_y(E), sigma_z(E) for polarized measurements
- [x] **124.2.7.5** Implement X-ray magnetic circular dichroism (XMCD): compute
      difference spectrum mu*+(E) - mu*-(E) for left and right circularly
      polarized X-rays. Implement spin and orbital sum rules: m_orb =
      -integral(XMCD _ dE) _ 4q / (3*integral(XAS * dE)), m_spin =
      -integral(XMCD _ dE) _ (6p - 4q) / integral(XAS \* dE) where p and q are
      L3 and L2+L3 integrated XMCD
- [x] **124.2.7.6** Implement pre-edge feature extraction: fit pre-edge region
      to Gaussian/Lorentzian peaks on a polynomial background, compute centroid
      energy and integrated intensity, relate to coordination geometry
      (tetrahedral vs. octahedral for transition metals via 1s->3d intensity)

#### 124.2.8 EXAFS — Scattering Path Expansion

- [x] **124.2.8.1** Implement EXAFS equation: chi(k) = sum_j (N_j _ S0^2 _
      F_j(k)) / (k _ R_j^2) _ sin(2*k*R_j + phi_j(k)) * exp(-2*sigma_j^2*k^2) *
      exp(-2\*R_j/lambda(k)) where the sum runs over scattering paths j, with
      degeneracy N_j, effective scattering amplitude F_j, phase shift phi_j,
      Debye-Waller factor sigma_j^2, and mean free path lambda(k)
- [x] **124.2.8.2** Implement scattering path enumeration: enumerate all
      single-scattering and multiple-scattering paths within a specified maximum
      half-path-length R_max (typically 6-8 Angstrom). Use heap-based path tree
      expansion with early termination for negligible amplitude paths
- [x] **124.2.8.3** Implement path importance filtering: compute curved-wave
      amplitude ratio for each path relative to the strongest single-scattering
      path. Filter paths by importance threshold (default: keep paths
      contributing > 2% of strongest path amplitude). Report path statistics
- [x] **124.2.8.4** Implement effective scattering amplitude F_eff(k) and phase
      phi_eff(k) for each path (Rust): for single scattering, F(k) =
      |f(theta=pi, k)| backscattering amplitude; for multiple scattering,
      compute the product of scattering matrices along the path using the
      plane-wave or curved-wave approximation
- [x] **124.2.8.5** Implement curved-wave multiple scattering for EXAFS paths
      (Rust): expand the scattering amplitude in partial waves, sum products of
      t-matrices and free propagators along each leg of the path. Handle up to
      4-leg paths (single, double, triple, quadruple scattering)
- [x] **124.2.8.6** Implement mean free path lambda(k): energy-dependent
      photoelectron mean free path from the imaginary part of the optical
      potential. Use the empirical formula or compute from the self-energy

#### 124.2.9 EXAFS — Debye-Waller Factors

- [x] **124.2.9.1** Implement correlated Debye model for sigma^2: given a Debye
      temperature Theta_D, compute sigma^2(T) = (3*hbar^2) / (m_reduced * k_B _
      Theta_D) _ [phi_1(Theta_D/T) / (Theta_D/T) + 1/4] where phi_1 is the first
      Debye function and m_reduced is the reduced mass of the absorber-scatterer
      pair
- [x] **124.2.9.2** Implement Einstein model for sigma^2: single-frequency
      approximation sigma^2(T) = hbar / (2*mu*omega_E) * coth(hbar*omega_E /
      (2*k_B*T)) with Einstein frequency omega_E as fitting parameter
- [x] **124.2.9.3** Implement phonon-based Debye-Waller factors: compute sigma^2
      from the phonon density of states projected onto the absorber-scatterer
      bond direction. Use dynamical matrix from Phase 119 (lattice dynamics) or
      AIMD trajectory correlation functions from Phase 120
- [x] **124.2.9.4** Implement third and fourth cumulants C3 and C4 for
      anharmonic EXAFS: C3 accounts for asymmetric pair distribution (skewness),
      C4 for kurtosis. Include these in the EXAFS equation as additional phase
      and amplitude corrections

#### 124.2.10 EXAFS — Fitting Engine

- [x] **124.2.10.1** Implement EXAFS fitting in k-space: minimize sum_i [k^w *
      chi_theory(k_i) - k^w * chi_exp(k_i)]^2 over structural parameters (R_j,
      sigma_j^2, N_j, delta_E0, S0^2). Support multiple k-weights w = 1, 2, 3
      simultaneously
- [x] **124.2.10.2** Implement EXAFS fitting in R-space: Fourier transform both
      theory and experiment, fit in the specified R-range. Handle real and
      imaginary parts or magnitude and phase of chi(R)
- [x] **124.2.10.3** Implement Levenberg-Marquardt optimizer for EXAFS fitting:
      parameter constraints (bounds, fixed parameters, correlated parameters via
      math expressions), covariance matrix estimation, uncertainty propagation
      to structural parameters
- [x] **124.2.10.4** Implement EXAFS fit quality metrics: reduced chi-squared,
      R-factor = sum|chi_exp - chi_theory|^2 / sum|chi_exp|^2, number of
      independent data points N_idp = 2*Delta_k*Delta_R/pi, information
      criterion (AIC, BIC) for model comparison

#### 124.2.11 XAS Spectrum Processing

- [x] **124.2.11.1** Implement XAS background subtraction: pre-edge subtraction
      (linear or Victoreen fit), post-edge normalization (polynomial or spline
      fit to determine mu_0), edge step Delta_mu_0 determination. Follow
      IFEFFIT/Larch conventions
- [x] **124.2.11.2** Implement E0 determination: inflection point method
      (maximum of first derivative), half-edge-step method, or user-specified.
      Handle noisy data with smoothing before derivative
- [x] **124.2.11.3** Implement chi(k) extraction: subtract smooth background
      mu_0(E) using Autobk algorithm (spline with R_bkg parameter controlling
      low-R cutoff), convert to k-space via k = sqrt(2m(E-E0)/hbar^2)
- [x] **124.2.11.4** Implement Fourier transform of chi(k): FT with configurable
      window functions (Hanning, Kaiser-Bessel, Gaussian), k-range selection,
      k-weight, zero-padding. Output magnitude |chi(R)|, real part Re[chi(R)],
      imaginary part Im[chi(R)], phase
- [x] **124.2.11.5** Implement back-Fourier transform (Fourier filtering):
      select R-range window, back-transform to k-space to isolate contribution
      from specific coordination shells

---

### 124.3 X-ray Photoelectron Spectroscopy & Photoemission (`@kalika/photoemission`)

#### 124.3.1 Library Scaffolding

- [x] **124.3.1.1** Create `libs/kalika/photoemission/` directory with
      `project.json`, `package.json`, `tsconfig.json`. Add
      `@kalika/photoemission` path mapping to `tsconfig.base.json`

#### 124.3.2 Core-Level Binding Energies

- [x] **124.3.2.1** Implement initial-state (Koopmans) binding energy
      estimation: E_B approx -epsilon_KS where epsilon_KS is the Kohn-Sham
      eigenvalue of the core state. Include correction for the difference
      between KS eigenvalue and true ionization energy
- [x] **124.3.2.2** Implement Delta-SCF binding energy: compute E_B = E(N-1,
      core hole) - E(N, ground state) from two self-consistent DFT calculations
      — ground state and core-ionized state. Handle fractional occupation for
      convergence
- [x] **124.3.2.3** Implement Slater-Janak transition state: E_B =
      -epsilon(n=1/2) where the core orbital occupation is set to 1/2. Requires
      single SCF calculation, more efficient than full Delta-SCF
- [x] **124.3.2.4** Implement core-level shift (CLS) prediction between
      inequivalent sites: compute relative shifts Delta_E_B between different
      atomic environments in the same structure (e.g., surface vs. bulk atoms,
      different oxidation states). Initial state CLS from electrostatic
      potential differences, final state CLS from Delta-SCF differences

#### 124.3.3 XPS Spectrum Simulation

- [x] **124.3.3.1** Implement XPS chemical shift prediction: map computed
      core-level binding energies to experimental chemical shift scale using
      reference compound calibration (e.g., C 1s of adventitious carbon = 284.8
      eV, Au 4f7/2 = 84.0 eV)
- [x] **124.3.3.2** Implement Auger parameter calculation: alpha' = E_K(KLL) +
      E_B(core) where E_K is the kinetic energy of the Auger line. The modified
      Auger parameter is instrument-independent and more reliable than binding
      energy alone for chemical state identification
- [x] **124.3.3.3** Implement surface core-level shifts: account for reduced
      coordination at surfaces by computing CLS for slab models with distinct
      surface, subsurface, and bulk-like layers. Include surface segregation
      effects for alloys
- [x] **124.3.3.4** Implement valence band XPS simulation: compute DOS(E)
      weighted by element-specific and orbital-specific photoionization
      cross-sections sigma*nl(hv) at the given photon energy. Sum contributions
      from all atoms: I(E) = sum_i sum_l rho*{i,l}(E) \* sigma\_{i,l}(hv)
- [x] **124.3.3.5** Implement satellite structure prediction: estimate shake-up
      (monopole excitation) and shake-off intensities from sudden approximation
      overlap integrals between N-1 electron states

#### 124.3.4 Angle-Resolved Photoemission (ARPES) Simulation

- [x] **124.3.4.1** Implement spectral function A(k,omega) from DFT bands:
      A(k,omega) = sum*n delta(omega - epsilon*{n,k}) broadened by Lorentzian
      (lifetime) and Gaussian (instrumental). Use band structure from Phase 116
      DFT or Phase 118 GW
- [x] **124.3.4.2** Implement GW spectral function for ARPES: A(k,omega) =
      -1/pi \* Im[Sigma(k,omega)] / [(omega - epsilon_k -
      Re[Sigma(k,omega)])^2 + Im[Sigma(k,omega)]^2] showing quasiparticle peaks
      with renormalized dispersion and satellites from GW self-energy
      (Phase 118)
- [x] **124.3.4.3** Implement photoemission matrix elements: compute
      |<f|A.p|i>|^2 where |i> is the initial Bloch state, A is the photon vector
      potential, p is the momentum operator, and |f> is the final photoelectron
      state. Include photon polarization dependence (s-pol, p-pol, circular)
- [x] **124.3.4.4** Implement free-electron final state approximation: model the
      final state as a plane wave |k_f> with k_f determined by energy
      conservation E_f = E_i + h*nu - phi. Map k_parallel from emission angle
      via k_parallel = sqrt(2mE_K)/hbar * sin(theta)
- [x] **124.3.4.5** Implement one-step model of photoemission: time-reversed
      LEED state as the final state, properly matching bulk and vacuum wave
      functions at the surface, including surface barrier effects
- [x] **124.3.4.6** Implement kz broadening for ARPES: account for finite
      photoelectron escape depth (surface sensitivity) which causes intrinsic kz
      uncertainty Delta_kz ~ 1/lambda, broadening features that disperse along
      kz. Convolve spectral function along kz with Lorentzian of width 1/lambda
- [x] **124.3.4.7** Implement resonant photoemission simulation: compute
      enhancement of valence band features when photon energy is tuned to a
      core-level absorption edge (Fano resonance profile). Calculate
      autoionization matrix elements

#### 124.3.5 Spin-Resolved Photoemission

- [x] **124.3.5.1** Implement spin-resolved ARPES: separate spectral function
      into spin-up and spin-down channels for magnetic systems. Compute spin
      polarization P(E,k) = [A_up - A_down] / [A_up + A_down]
- [x] **124.3.5.2** Implement spin-orbit induced spin texture: for topological
      surface states and Rashba systems, compute spin expectation value <S>(k)
      for each band from spinor wavefunctions. Display spin texture on Fermi
      surface

---

### 124.4 Vibrational Spectroscopy (`@kalika/vibrational-spectroscopy`)

#### 124.4.1 Library Scaffolding

- [x] **124.4.1.1** Create `libs/kalika/vibrational-spectroscopy/` directory
      with `project.json`, `package.json`, `tsconfig.json`. Add
      `@kalika/vibrational-spectroscopy` path mapping to `tsconfig.base.json`
- [x] **124.4.1.2** Create Rust crate for Raman tensor and polarizability
      derivative computations. Configure napi-rs bindings

#### 124.4.2 Infrared (IR) Spectroscopy

- [x] **124.4.2.1** Implement IR intensity from Born effective charges: I*IR_s =
      |sum*{kappa,alpha} Z*\_{kappa,alpha,beta} * e\_{kappa,alpha,s}|^2 summed
      over polarization direction beta, where Z* is the Born effective charge
      tensor, e is the phonon eigenvector for mode s, kappa is atom index, alpha
      is Cartesian direction. Use Z* from DFPT (Phase 119)
- [x] **124.4.2.2** Implement symmetry-based IR activity determination: a mode
      is IR-active if it belongs to an irreducible representation that
      transforms as a translation (x, y, or z) in the point group character
      table. Use site symmetry analysis from Phase 117 (crystal symmetry)
- [x] **124.4.2.3** Implement IR spectrum construction: place Lorentzian or
      Gaussian peaks at each IR-active phonon frequency with height proportional
      to computed IR intensity. Handle broadening parameter,
      temperature-dependent occupation via Bose-Einstein factor
- [x] **124.4.2.4** Implement peak assignment engine: for each IR peak, identify
      the phonon mode, compute atomic displacement amplitudes, classify by
      character (stretching, bending, rocking, wagging, twisting) using bond
      angle and bond length changes during vibration
- [x] **124.4.2.5** Implement anharmonic IR from AIMD: compute the IR spectrum
      from the autocorrelation of the total dipole moment time series from AIMD
      trajectories: I(omega) proportional to omega^2 _ integral <M(0).M(t)> _
      exp(-i*omega*t) dt, where M(t) is the cell dipole at time t. Includes all
      anharmonic and temperature effects intrinsically
- [x] **124.4.2.6** Implement ATR-IR simulation: compute attenuated total
      reflectance spectrum from the complex dielectric function using the
      Fresnel equations for the crystal/ATR-element interface at the specified
      angle of incidence and ATR material (diamond, ZnSe, Ge)
- [x] **124.4.2.7** Implement reflectance IR and Kramers-Kronig analysis:
      compute reflectivity R(omega) = |(sqrt(epsilon) - 1)/(sqrt(epsilon) +
      1)|^2 from the dielectric function. Implement Kramers-Kronig transform to
      extract optical constants n(omega), k(omega) from measured R(omega)

#### 124.4.3 Raman Spectroscopy

- [x] **124.4.3.1** Implement Raman tensor computation via finite differences
      (Rust): compute the derivative of the macroscopic dielectric tensor with
      respect to atomic displacements: alpha'_{alpha,beta,s} =
      d(epsilon_{alpha,beta})/d(Q_s) where Q_s is the normal mode coordinate.
      Use central differences: displace atoms +/- delta along each eigenvector,
      compute epsilon at each displacement via DFPT or finite-field DFT
- [x] **124.4.3.2** Implement DFPT Raman via 2n+1 theorem: compute the
      third-order energy derivative d^3E/(dE_i _ dE_j _ du_s) in one shot using
      density-functional perturbation theory, avoiding the 6\*3N finite
      difference calculations. More efficient but requires implementation of
      third-order response
- [x] **124.4.3.3** Implement Raman intensity calculation: I_s proportional to
      |e_i . alpha'\_s . e_s|^2 * (n_BE + 1) / omega_s for Stokes scattering,
      where e_i and e_s are incident and scattered polarization vectors, n_BE =
      1/(exp(hbar*omega_s/k_B\*T) - 1) is the Bose-Einstein factor, and omega_s
      is the phonon frequency
- [x] **124.4.3.4** Implement symmetry-based Raman activity determination: a
      mode is Raman-active if it belongs to an irreducible representation that
      transforms as a quadratic function (x^2, xy, xz, etc.) in the point group
      character table. Complementary to IR activity for centrosymmetric crystals
      (mutual exclusion rule)
- [x] **124.4.3.5** Implement polarization-dependent Raman: compute parallel
      (VV), perpendicular (VH), and depolarization ratio rho = I_VH / I_VV for
      each mode. For single crystals, compute the full angular dependence by
      rotating the Raman tensor with the crystal orientation matrix
- [x] **124.4.3.6** Implement resonant Raman spectroscopy: compute
      frequency-dependent polarizability tensor alpha(omega_L) near an
      electronic transition using sum-over-states expression with
      energy-dependent denominators. Identify modes enhanced by resonance
      (Albrecht A-term and B-term mechanisms)
- [x] **124.4.3.7** Implement temperature-dependent Raman: Stokes/anti-Stokes
      intensity ratio I_AS/I_S = (omega_L + omega_s)^4 / (omega_L - omega_s)^4 *
      exp(-hbar*omega_s/(k_B\*T)) for temperature measurement from Raman.
      Include frequency shifts from anharmonicity
- [x] **124.4.3.8** Implement SERS enhancement factor estimation: compute
      electromagnetic enhancement |E_local/E_0|^4 from the local field
      enhancement at a plasmonic nanoparticle surface (Mie theory for spheres,
      FDTD/BEM reference data for other shapes). Estimate total enhancement
      combining electromagnetic and chemical (charge transfer) mechanisms
- [x] **124.4.3.9** Implement Raman for 2D materials: identify layer breathing
      modes (out-of-plane, frequency depends on number of layers via linear
      chain model) and shear modes (in-plane rigid layer sliding). Compute
      layer-number-dependent frequencies and use as thickness fingerprint

#### 124.4.4 Phonon Mode Visualization and Group Theory

- [x] **124.4.4.1** Implement phonon displacement vector visualization: for each
      phonon mode, generate a 3D representation of atomic displacement vectors
      (arrows on atoms). Export as JSON for WebGL rendering or as XYZ animation
      frames
- [x] **124.4.4.2** Implement group theory analysis of phonon modes at Gamma:
      decompose the 3N-dimensional representation of atomic displacements into
      irreducible representations of the crystal point group. Assign each mode
      its irrep label (e.g., A1g, E2g, T1u). Identify acoustic modes (T1u for
      cubic) and optical modes
- [x] **124.4.4.3** Implement selection rule summary: for each irrep, determine
      IR activity (transforms as x,y,z), Raman activity (transforms as
      quadratic), hyper-Raman activity. Generate a selection rule table
      compatible with standard spectroscopy references

---

### 124.5 Nuclear Magnetic Resonance (`@kalika/nmr`)

#### 124.5.1 Library Scaffolding

- [x] **124.5.1.1** Create `libs/kalika/nmr/` directory with `project.json`,
      `package.json`, `tsconfig.json`. Add `@kalika/nmr` path mapping to
      `tsconfig.base.json`
- [x] **124.5.1.2** Create Rust crate for GIPAW kernel computations
      (current-density response, gauge-origin handling). Configure napi-rs

#### 124.5.2 Chemical Shielding Tensor (GIPAW Method)

- [x] **124.5.2.1** Implement GIPAW chemical shielding tensor calculation:
      sigma*{alpha,beta} = d(B_induced*{alpha}) / d(B*ext*{beta}) computed as
      the linear response of the induced magnetic field at the nuclear site to a
      uniform external field. GIPAW (Gauge-Including Projector Augmented Waves)
      handles the gauge-origin problem for PAW pseudopotentials by including the
      all-electron current density within augmentation spheres
- [x] **124.5.2.2** Implement bare (pseudized) contribution to shielding: the
      current density from smooth pseudo-wavefunctions j*ps(r) responding to
      uniform B field via first-order perturbation theory: |psi_n^(1)> =
      sum*{m!=n} |psi_m^(0)><psi_m^(0)|H^(1)|psi_n^(0)> / (E_n - E_m) where
      H^(1) = (1/2c)(r x p).B + (B x r).p is the perturbation from the external
      magnetic field
- [x] **124.5.2.3** Implement augmentation (PAW reconstruction) contribution:
      reconstruct the all-electron current density within PAW spheres from the
      pseudo-wavefunctions, accounting for the full nodal structure of core and
      semicore states. This correction is critical for accurate absolute
      shieldings
- [x] **124.5.2.4** Implement isotropic chemical shift extraction: delta_iso =
      sigma_ref - sigma_iso where sigma_iso = (sigma_xx + sigma_yy + sigma_zz)/3
      is the isotropic shielding and sigma_ref is the reference compound
      shielding. Compute chemical shift anisotropy (CSA): Delta_sigma =
      sigma_zz - (sigma_xx + sigma_yy)/2 and asymmetry parameter eta =
      (sigma_yy - sigma_xx) / (sigma_zz - sigma_iso) with |sigma_zz -
      sigma_iso| >= |sigma_xx - sigma_iso| >= |sigma_yy - sigma_iso|
- [x] **124.5.2.5** Implement shielding tensor eigenvalue decomposition:
      diagonalize the symmetric part of sigma to get principal components
      (sigma_11, sigma_22, sigma_33) and principal axis orientations. Visualize
      as shielding tensor ellipsoid on atomic site

#### 124.5.3 Electric Field Gradient (EFG) Tensor

- [x] **124.5.3.1** Implement EFG tensor computation: V\_{alpha,beta} =
      d^2(V_Coulomb)/d(r_alpha)\*d(r_beta) evaluated at each nuclear site, where
      V_Coulomb is the total electrostatic potential from electrons and nuclei.
      Subtract the trace (Laplacian = 0 at nuclear site by Poisson equation for
      point charges)
- [x] **124.5.3.2** Implement PAW reconstruction for EFG: the all-electron
      charge density near the nucleus determines the EFG. Reconstruct from PAW:
      V*{ae} = V*{ps} + sum*{ij} (rho^1*{ij} <phi*i|V_op|phi_j> - rho^1*{ij}
      <phi~\_i|V_op|phi~\_j>) where phi and phi~ are AE and PS partial waves
- [x] **124.5.3.3** Implement quadrupolar coupling parameters: compute C_Q =
      e*Q*V_zz/h (quadrupolar coupling constant, in MHz) and eta_Q = (V_xx -
      V_yy)/V_zz (asymmetry parameter, 0 <= eta <= 1) for each nuclear site with
      quadrupole moment Q > 0. Tabulate Q values for all quadrupolar nuclei

#### 124.5.4 J-Coupling and Other NMR Parameters

- [x] **124.5.4.1** Implement indirect nuclear spin-spin coupling (J-coupling)
      from DFT: compute the four contributions — Fermi contact (FC), spin-dipole
      (SD), paramagnetic spin-orbit (PSO), diamagnetic spin-orbit (DSO) — using
      linear response to a nuclear magnetic dipole perturbation. The Fermi
      contact term dominates for light nuclei
- [x] **124.5.4.2** Implement Knight shift for metallic systems: K = K_spin +
      K_orbital + K_dia where K_spin = (8pi/3) _ chi_Pauli _ |psi(0)|^2 / rho is
      the contact Knight shift from the spin susceptibility and the electron
      density at the nucleus
- [x] **124.5.4.3** Implement paramagnetic NMR shifts: Fermi contact shift
      delta_FC proportional to A_iso _ <S_z> / (gamma_N _ B0) where A_iso is the
      isotropic hyperfine coupling and <S_z> is the thermal average of
      electronic spin. Pseudocontact shift (dipolar) delta_PCS from the
      anisotropic magnetic susceptibility tensor

#### 124.5.5 NMR Spectrum Simulation

- [x] **124.5.5.1** Implement powder-averaged NMR spectrum: for each nuclear
      site, convolve the CSA powder pattern (from shielding tensor eigenvalues)
      with quadrupolar splitting pattern (for I > 1/2 nuclei). Use ZCW
      (Zaremba-Conroy-Wolfsberg) angular grid for efficient powder averaging
      over orientations
- [x] **124.5.5.2** Implement MAS (Magic Angle Spinning) NMR simulation: compute
      spinning sideband pattern using Herzfeld-Berger analysis — sideband
      intensities from ratios of CSA principal values at given spinning rate.
      Include second-order quadrupolar broadening for half-integer quadrupolar
      nuclei under MAS
- [x] **124.5.5.3** Implement 2D NMR prediction — HETCOR (heteronuclear
      correlation): compute cross-peaks between pairs of nuclei (e.g., 1H-13C)
      based on spatial proximity (dipolar coupling strength proportional to
      1/r^3). Filter by distance cutoff
- [x] **124.5.5.4** Implement 2D MQMAS (multiple-quantum MAS) simulation: for
      half-integer quadrupolar nuclei, compute isotropic projection (free from
      second-order quadrupolar broadening) vs. MAS dimension. Resolve
      inequivalent sites by their isotropic chemical shift and quadrupolar
      parameters

#### 124.5.6 Reference Compounds and Common Nuclei

- [x] **124.5.6.1** Implement reference compound database: store computed
      absolute shieldings for standard NMR reference compounds — TMS
      (tetramethylsilane) for 1H/13C/29Si, liquid NH3 for 15N, 85% H3PO4 for
      31P, CFCl3 for 19F, NaCl(aq) for 23Na, Al(H2O)6^3+ for 27Al, etc. Include
      basis set / functional / method dependence
- [x] **124.5.6.2** Implement chemical shift scale calibration: given the
      computed absolute shielding sigma_calc and reference shielding sigma_ref,
      convert to chemical shift delta = sigma_ref - sigma_calc. Provide
      empirical linear regression correction: delta_corr = a \* delta_calc + b
      with a, b fitted to benchmark sets for each nucleus/functional combination

---

### 124.6 Mossbauer Spectroscopy (`@kalika/mossbauer`)

#### 124.6.1 Library Scaffolding

- [x] **124.6.1.1** Create `libs/kalika/mossbauer/` directory with
      `project.json`, `package.json`, `tsconfig.json`. Add `@kalika/mossbauer`
      path mapping to `tsconfig.base.json`

#### 124.6.2 Isomer Shift

- [x] **124.6.2.1** Implement isomer shift from contact density: delta =
      alpha \* [rho(0)_absorber - rho(0)_source] where rho(0) is the total
      electron contact density at the Mossbauer nucleus. Compute rho(0) from the
      all-electron charge density at the nuclear position using PAW
      reconstruction. The calibration constant alpha depends on the nuclear
      transition (e.g., alpha = -0.291 mm/s / a0^-3 for 57Fe)
- [x] **124.6.2.2** Implement calibration constant database: store alpha values
      for common Mossbauer isotopes — 57Fe (14.4 keV), 119Sn (23.9 keV), 151Eu
      (21.5 keV), 161Dy (25.7 keV), 197Au (77.3 keV). Include reference source
      rho(0) values (alpha-Fe for 57Fe, BaSnO3 for 119Sn)
- [x] **124.6.2.3** Implement isomer shift validation suite: compute isomer
      shifts for a test set of Fe compounds with known experimental values (Fe
      metal, FeO, Fe2O3, Fe3O4, FeS2, FeCO3) and verify agreement within +/- 0.1
      mm/s using PBE functional

#### 124.6.3 Quadrupole Splitting

- [x] **124.6.3.1** Implement quadrupole splitting from EFG: Delta_E_Q = (1/2) _
      e _ Q _ V_zz _ sqrt(1 + eta^2/3) where V_zz is the largest eigenvalue of
      the EFG tensor, Q is the nuclear quadrupole moment, and eta is the
      asymmetry parameter. Reuse EFG computation from NMR module (124.5.3)
- [x] **124.6.3.2** Implement quadrupole splitting for I=3/2 excited state
      (57Fe): the excited state (I=3/2) splits into m_I = +/-3/2 and +/-1/2
      sublevels with separation Delta_E_Q. The ground state (I=1/2) is unsplit.
      Produce two-line pattern with splitting Delta_E_Q and equal intensity
      ratio (3:2:1:1:2:3 ratios for magnetic splitting)

#### 124.6.4 Magnetic Hyperfine Field

- [x] **124.6.4.1** Implement magnetic hyperfine field B_hf: compute three
      contributions — (1) Fermi contact B_FC = -(8pi/3) _ mu_B _ [rho_up(0) -
      rho_down(0)] from spin-polarized contact density, (2) dipolar B_dip from
      spin-density distribution within atomic sphere, (3) orbital B_orb from
      orbital angular momentum. Total B_hf = B_FC + B_dip + B_orb
- [x] **124.6.4.2** Implement core polarization contribution to B_FC: the
      dominant contribution comes from spin polarization of core s-electrons
      (1s, 2s, 3s for Fe) by the exchange interaction with unpaired d-electrons.
      Requires all-electron or PAW reconstruction to capture core spin density
- [x] **124.6.4.3** Implement six-line magnetic Mossbauer pattern: for
      magnetically ordered systems, the six allowed transitions between I=1/2 (m
      = +/-1/2) and I=3/2 (m = +/-3/2, +/-1/2) states produce a sextet with
      velocity positions determined by B_hf and relative intensities 3:x:1:1:x:3
      where x depends on the angle between B_hf and gamma-ray direction (x=2 for
      powder, x=0 for B parallel to gamma)

#### 124.6.5 Mossbauer Spectrum Simulation

- [x] **124.6.5.1** Implement Mossbauer spectrum line shape: each transition is
      a Lorentzian with natural linewidth Gamma_0 (for 57Fe, Gamma_0 = 0.097
      mm/s = 4.67 neV). Total spectrum is sum of Lorentzians: I(v) = sum_i
      A_i \* (Gamma/2)^2 / [(v - v_i)^2 + (Gamma/2)^2] where v_i are transition
      velocities and A_i are relative intensities
- [x] **124.6.5.2** Implement combined isomer shift + quadrupole + magnetic
      spectrum: handle the general case with all three hyperfine interactions
      present simultaneously. Diagonalize the full nuclear Hamiltonian H = H_M +
      H_Q including off-diagonal quadrupolar terms when the EFG principal axes
      do not coincide with the magnetic field direction
- [x] **124.6.5.3** Implement Lamb-Mossbauer factor (recoil-free fraction): f =
      exp(-k^2 * <u^2>) where k is the gamma-ray wavevector and <u^2> is the
      mean-square displacement of the Mossbauer nucleus. Compute <u^2> from
      phonon calculations (Phase 119) or Debye model: <u^2> =
      (3*hbar^2*T)/(M*k_B*Theta_D^2) * phi_1(Theta_D/T) +
      3*hbar^2/(4*M*k_B*Theta_D)
- [x] **124.6.5.4** Implement oxidation state and spin state identification:
      from computed isomer shift delta and quadrupole splitting Delta_E_Q,
      classify the iron site: Fe(0) metallic, Fe(II) HS/LS, Fe(III) HS/LS,
      Fe(IV), Fe(VI). Use decision boundaries from empirical Mossbauer parameter
      ranges (e.g., Fe(II) HS: delta ~ 0.9-1.4 mm/s, Fe(III) HS: delta ~ 0.3-0.5
      mm/s)

---

### 124.7 Electron Energy Loss Spectroscopy (`@kalika/eels`)

#### 124.7.1 Library Scaffolding

- [x] **124.7.1.1** Create `libs/kalika/eels/` directory with `project.json`,
      `package.json`, `tsconfig.json`. Add `@kalika/eels` path mapping to
      `tsconfig.base.json`
- [x] **124.7.1.2** Create Rust crate for EELS cross-section and energy loss
      function computations. Configure napi-rs bindings

#### 124.7.2 Low-Loss EELS

- [x] **124.7.2.1** Implement energy loss function: compute
      -Im[1/epsilon(q,omega)] from the macroscopic dielectric function
      epsilon(q,omega) obtained from TDDFT or GW/BSE (Phase 118). The loss
      function peaks at collective excitations (plasmons) and interband
      transitions
- [x] **124.7.2.2** Implement plasmon energy and dispersion: locate the energy
      where Re[epsilon(q,omega)] = 0 and Im[epsilon] is small — this defines the
      bulk plasmon energy omega_p(q). For free-electron-like metals, omega_p =
      sqrt(4*pi*n\*e^2/m). Track plasmon dispersion omega_p(q) along
      high-symmetry directions
- [x] **124.7.2.3** Implement q-dependent dielectric function: compute
      epsilon(q,omega) beyond the optical limit (q->0) by including local field
      effects and finite momentum transfer. Use the density-density response
      function chi(q,omega) from TDDFT: epsilon^{-1}(q,omega) = 1 + v(q) \*
      chi(q,omega)
- [x] **124.7.2.4** Implement interband transition identification: decompose the
      loss function into contributions from specific band-to-band transitions by
      computing the joint density of states weighted by matrix elements. Label
      each feature with the contributing bands
- [x] **124.7.2.5** Implement Kramers-Kronig analysis for EELS: extract the real
      and imaginary parts of epsilon from the loss function using KK relations:
      Re[1/epsilon] = 1 - (2/pi) _ P integral [omega' _ Im[-1/epsilon(omega')]]
      / (omega'^2 - omega^2) d(omega'). Validate by checking f-sum rule:
      integral omega _ Im[-1/epsilon] d(omega) = pi/2 _ omega_p^2
- [x] **124.7.2.6** Implement Cerenkov radiation loss subtraction: for
      relativistic electrons (>100 keV beam), compute and subtract the Cerenkov
      loss contribution that appears when electron velocity exceeds the phase
      velocity of light in the material (v > c/sqrt(epsilon)). Relevant for
      low-loss EELS of semiconductors

#### 124.7.3 Core-Loss EELS

- [x] **124.7.3.1** Implement core-loss EELS edge structure (ELNES): compute the
      energy-loss near-edge structure equivalent to XANES using the
      double-differential cross-section d^2sigma/(dE*dOmega) = (4*gamma^2 /
      a0^2*q^4) * S(q,E) where S(q,E) is the dynamic structure factor and gamma
      is the relativistic factor. For small q, ELNES converges to XANES (dipole
      limit)
- [x] **124.7.3.2** Implement EXELFS (extended energy loss fine structure):
      extract oscillatory fine structure beyond the edge onset, analogous to
      EXAFS. Use same scattering path formalism with appropriate scattering
      geometry corrections for the EELS momentum transfer
- [x] **124.7.3.3** Implement collection/convergence angle effects: integrate
      the double-differential cross-section over the experimental collection
      semi-angle beta and convergence semi-angle alpha. This modifies the
      relative weights of dipole and non-dipole transitions, especially
      important for L- and M-edges
- [x] **124.7.3.4** Implement generalized oscillator strength (GOS) database:
      tabulate or compute GOS f(q,E) = (E _ q^2) / (2 _ R) \*
      |<f|exp(iq.r)|i>|^2 for all edges of elements Z=3..92. Store on a (q,E)
      grid for interpolation during cross-section calculation
- [x] **124.7.3.5** Implement white line ratio analysis: for L2,3 edges of
      transition metals, compute the L3/L2 intensity ratio (integrated over the
      white line region). Deviation from the statistical ratio (2:1) indicates
      d-electron count and spin-orbit coupling. Implement the relationship
      between L3/L2 ratio and d-band occupancy
- [x] **124.7.3.6** Implement EELS quantification: compute absolute partial
      cross-sections sigma_k(beta, Delta) for each edge (integrated over energy
      window Delta and collection angle beta). Estimate composition from N_A/N_B
      = (I_A _ sigma_B) / (I_B _ sigma_A) using the k-factor method

#### 124.7.4 Momentum-Resolved and Vibrational EELS

- [x] **124.7.4.1** Implement momentum-resolved EELS: compute the dynamic
      structure factor S(q,omega) from TDDFT as a 2D function of momentum
      transfer q and energy loss omega. Display as an intensity map showing
      plasmon dispersion, particle-hole continuum, and excitonic features
- [x] **124.7.4.2** Implement vibrational EELS (high-resolution EELS): compute
      the dipole scattering cross-section for surface and bulk phonon losses at
      meV-scale resolution. Include impact scattering mechanism for
      dipole-forbidden modes at off-specular angles. Interface with phonon
      calculations from Phase 119

---

### 124.8 Other Spectroscopies (`@kalika/spectroscopy-extended`)

#### 124.8.1 Library Scaffolding

- [x] **124.8.1.1** Create `libs/kalika/spectroscopy-extended/` directory with
      `project.json`, `package.json`, `tsconfig.json`. Add
      `@kalika/spectroscopy-extended` path mapping to `tsconfig.base.json`

#### 124.8.2 Optical Absorption and UV-Vis

- [x] **124.8.2.1** Implement UV-Vis absorption spectrum from dielectric
      function: alpha(omega) = omega _ Im[sqrt(epsilon(omega))] / c, or for thin
      films, absorbance A = alpha _ d. Import epsilon(omega) from Phase 123
      (optical properties) or compute from TDDFT/BSE (Phase 118)
- [x] **124.8.2.2** Implement oscillator strength and transition dipole moments:
      for each optical transition, compute f_n = (2*m*omega_n)/(3*hbar) *
      |<n|r|0>|^2. Sum rule: sum_n f_n = N_electrons. Relate to molar extinction
      coefficient epsilon_M via integration over absorption band

#### 124.8.3 Photoluminescence (PL)

- [x] **124.8.3.1** Implement PL spectrum from configuration coordinate (CC)
      model: given the CC diagram from Phase 122 (defect calculations), compute
      the emission spectrum as a Poisson distribution of phonon sidebands: I(E)
      = sum_n [S^n * exp(-S) / n!] * L(E - E_ZPL + n*hbar\*omega) where S is the
      Huang-Rhys factor, E_ZPL is the zero-phonon line energy, and omega is the
      effective phonon frequency
- [x] **124.8.3.2** Implement Huang-Rhys factor computation: S = Delta_Q^2 *
      omega / (2*hbar) where Delta_Q is the displacement of the equilibrium
      position between ground and excited state potential energy surfaces along
      the generalized configuration coordinate. Compute from Delta_Q =
      sqrt(sum_i m_i \* (R_i^{excited} - R_i^{ground})^2)
- [x] **124.8.3.3** Implement zero-phonon line (ZPL) energy: E_ZPL = E_abs -
      E_relax_excited - E_relax_ground (vertical absorption minus relaxation
      energies in both states). The ZPL is the sharp feature in low-temperature
      PL spectra
- [x] **124.8.3.4** Implement Stokes shift: Delta_Stokes = E_abs - E_em = 2 _ S
      _ hbar \* omega. Compute from CC diagram as the energy difference between
      vertical absorption and vertical emission
- [x] **124.8.3.5** Implement radiative recombination rate: compute the
      radiative lifetime tau_rad = 1 / (n _ e^2 _ omega^2 * |<f|r|i>|^2 /
      (3*pi*epsilon_0*m*c^3*hbar)) from the transition dipole matrix element
      between defect states. Compare with experimental PL decay times
- [x] **124.8.3.6** Implement temperature-dependent PL: broaden phonon sidebands
      with thermal occupation, include non-radiative decay via multi-phonon
      capture (exponential gap law). Simulate PL spectra at different
      temperatures

#### 124.8.4 X-ray Emission Spectroscopy (XES)

- [x] **124.8.4.1** Implement core X-ray emission lines: Kalpha (2p->1s) and
      Kbeta (3p->1s) emission energies and intensities. Kalpha1,2 splitting from
      2p spin-orbit. Compute from the energy differences between core levels and
      transition dipole matrix elements
- [x] **124.8.4.2** Implement valence-to-core (VtC) XES: emission from occupied
      valence states filling the core hole. VtC-XES probes the occupied
      electronic structure (complementary to XANES which probes unoccupied).
      Compute from transition matrix elements <valence|r|1s> weighted by the
      valence DOS
- [x] **124.8.4.3** Implement Kbeta mainline analysis: the Kbeta1,3 and Kbeta'
      splitting in transition metals is sensitive to spin state (exchange
      interaction between 3p core hole and 3d valence). Compute the 3p-3d
      exchange integral and multiplet splitting

#### 124.8.5 Resonant Inelastic X-ray Scattering (RIXS)

- [x] **124.8.5.1** Implement RIXS cross-section (Kramers-Heisenberg formula):
      I(omega_in, omega_out) proportional to |sum_n <f|T|n><n|T|i> / (E_i +
      hbar*omega_in - E_n + i*Gamma_n)|^2 where T is the transition operator,
      |n> are intermediate (core-excited) states, and the sum runs over all
      intermediate states
- [x] **124.8.5.2** Implement RIXS map computation: compute 2D intensity map
      I(excitation_energy, energy_loss) by scanning the incident photon energy
      across an absorption edge. Identify dd excitations (crystal field
      transitions in d-electron systems), charge transfer excitations, and
      magnon excitations as features in the RIXS map
- [x] **124.8.5.3** Implement dd excitations for transition metals: compute
      crystal field excitation energies and RIXS intensities using atomic
      multiplet theory (Tanabe-Sugano diagrams) with crystal field parameters
      10Dq from DFT. Handle octahedral, tetrahedral, and lower-symmetry
      environments

#### 124.8.6 Electron Paramagnetic Resonance (EPR)

- [x] **124.8.6.1** Implement g-tensor from DFT+SOC: g*{ij} = g_e \*
      delta*{ij} + 2 * sum\_{n,occ; m,virt} <psi_n|L_i + g_e*S_i|psi_m> _
      <psi_m|xi _ L_j|psi_n> / (E_n - E_m) where xi is the spin-orbit coupling
      constant, L is orbital angular momentum, S is spin, and the sum runs over
      occupied-virtual pairs. Compute principal g-values (g_xx, g_yy, g_zz) and
      principal axis orientations
- [x] **124.8.6.2** Implement hyperfine coupling constants: isotropic A*iso =
      (8*pi/3) * g_e * mu_B * g_N * mu_N * rho_spin(R_N) (Fermi contact from
      spin density at nucleus), anisotropic A_aniso from the traceless dipolar
      tensor T*{ij} = mu*B * g_N * mu_N * integral rho_spin(r) * (3*r_i*r_j -
      r^2\*delta*{ij}) / r^5 dV
- [x] **124.8.6.3** Implement zero-field splitting (ZFS) parameters: for S >= 1
      systems, compute the ZFS tensor D from spin-orbit and spin-spin coupling.
      Extract axial (D) and rhombic (E) parameters: D = D_zz - (D_xx + D_yy)/2,
      E = (D_xx - D_yy)/2
- [x] **124.8.6.4** Implement EPR spectrum simulation: given g-tensor,
      A-tensor(s), and D-tensor, simulate the EPR spectrum by diagonalizing the
      spin Hamiltonian H = mu_B \* B . g . S + S . D . S + sum_k S . A_k . I_k
      at each field value. Handle powder averaging for polycrystalline samples,
      single-crystal angular dependence

#### 124.8.7 Compton Scattering and Positron Annihilation

- [x] **124.8.7.1** Implement Compton profile J(p_z): compute the electron
      momentum density rho(p) by Fourier transforming the Bloch wavefunctions to
      momentum space, then integrate over p_x and p_y to obtain the 1D Compton
      profile J(p_z) = integral integral rho(p) dp_x dp_y. Compare with
      experimental Compton scattering measurements
- [x] **124.8.7.2** Implement positron annihilation lifetime: solve the
      Schrodinger equation for the positron in the crystal potential (attractive
      at electron-rich regions, repulsive at nuclei). Compute the annihilation
      rate lambda = pi _ r_e^2 _ c _ integral n\_+(r) _ n*-(r) \* gamma(n*-(r))
      dr where n*+ is positron density, n*- is electron density, and gamma is
      the enhancement factor. Lifetime tau = 1/lambda. Sensitive to vacancy
      defects (longer lifetime)

---

### 124.9 Spectrum Processing & Comparison (`@kalika/spectrum-processing`)

#### 124.9.1 Library Scaffolding

- [x] **124.9.1.1** Create `libs/kalika/spectrum-processing/` directory with
      `project.json`, `package.json`, `tsconfig.json`. Add
      `@kalika/spectrum-processing` path mapping to `tsconfig.base.json`

#### 124.9.2 Peak Fitting

- [x] **124.9.2.1** Implement Gaussian peak function: G(x) = A * exp(-(x - x0)^2
      / (2*sigma^2)) with amplitude A, center x0, and width sigma. FWHM =
      2*sqrt(2*ln(2))*sigma. Compute area = A*sigma*sqrt(2*pi)
- [x] **124.9.2.2** Implement Lorentzian peak function: L(x) = A * gamma^2 /
      ((x - x0)^2 + gamma^2) with amplitude A, center x0, and half-width gamma.
      FWHM = 2*gamma. Compute area = A*pi*gamma
- [x] **124.9.2.3** Implement Voigt peak function: convolution of Gaussian and
      Lorentzian. Use Faddeeva function (complex error function) for efficient
      computation: V(x) = Re[w(z)] / (sigma*sqrt(2*pi)) where z = ((x-x0) +
      i*gamma) / (sigma*sqrt(2)). Use the implementations in the Rust kernel for
      speed
- [x] **124.9.2.4** Implement pseudo-Voigt approximation: pV(x) = eta _ L(x) +
      (1-eta) _ G(x) where eta is the mixing parameter (0 = pure Gaussian, 1 =
      pure Lorentzian). Approximate the Voigt FWHM relation: f_V^5 = f_G^5 +
      2.69f_G^4*f_L + 2.43f_G^3*f_L^2 + 4.47f_G^2*f_L^3 + 0.07f_G*f_L^4 + f_L^5
      (Thompson-Cox-Hastings formula)
- [x] **124.9.2.5** Implement Doniach-Sunjic line shape: DS(x) =
      cos(pi*alpha/2 + (1-alpha)*arctan((x-x0)/gamma)) / ((x-x0)^2 +
      gamma^2)^((1-alpha)/2) for metallic XPS core levels with asymmetry
      parameter alpha (0 = symmetric Lorentzian). Relevant for metals where
      electron-hole pair excitations create asymmetric tails
- [x] **124.9.2.6** Implement multi-peak fitting engine: given a spectrum and
      initial peak guesses (positions, widths, shapes), minimize chi^2 = sum_i
      (y_data_i - y_model_i)^2 / sigma_i^2 using Levenberg-Marquardt
      optimization. Support parameter constraints (fixed, bounded, linked
      between peaks). Report fit quality (chi^2_red, R^2), parameter
      uncertainties from covariance matrix, and residual spectrum
- [x] **124.9.2.7** Implement automatic peak detection: identify peaks using
      second derivative method (minima of d^2y/dx^2) or continuous wavelet
      transform (CWT). Provide initial guesses for multi-peak fitting. Handle
      noise with smoothing pre-filter

#### 124.9.3 Background Subtraction

- [x] **124.9.3.1** Implement linear background: fit y = a\*x + b to
      user-specified background regions (before and after spectral features).
      Subtract from spectrum
- [x] **124.9.3.2** Implement Shirley background for XPS: iterative algorithm
      B*n(E) = k \* integral*{E}^{E*max} [I(E') - B*{n-1}(E')] dE' with k set by
      matching endpoint intensities. Iterate until convergence (< 0.1% change).
      Accounts for inelastically scattered photoelectrons
- [x] **124.9.3.3** Implement Tougaard background for XPS: B(E) = lambda _
      integral\_{E}^{infinity} K(E'-E) _ [I(E') - B(E')] dE' using the
      three-parameter universal cross-section K(T) = B\*T / (C + T^2)^2. More
      physically motivated than Shirley, applicable over wider energy range

#### 124.9.4 Smoothing, Deconvolution, and Calibration

- [x] **124.9.4.1** Implement Savitzky-Golay smoothing: fit polynomial of degree
      p to a window of 2m+1 points, use the polynomial value at the center as
      the smoothed value. Compute convolution coefficients analytically. Support
      derivative computation (1st, 2nd, 3rd order) simultaneously with smoothing
- [x] **124.9.4.2** Implement spectral deconvolution: given an instrument
      response function (typically Gaussian), deconvolve the measured spectrum
      to recover the intrinsic spectrum. Use Richardson-Lucy iterative
      deconvolution or Wiener filter with regularization to handle noise
      amplification
- [x] **124.9.4.3** Implement energy calibration and alignment: shift and
      stretch the energy axis to align features with known reference positions.
      Linear correction (offset + scale) or polynomial for non-linear detector
      response. For XPS: align to adventitious C 1s = 284.8 eV

#### 124.9.5 Broadening and Convolution

- [x] **124.9.5.1** Implement Gaussian broadening: convolve spectrum with
      Gaussian of specified FWHM (instrumental resolution). Use FFT-based
      convolution for efficiency on large spectra
- [x] **124.9.5.2** Implement Lorentzian broadening: convolve with Lorentzian
      (core-hole lifetime broadening). Support energy-dependent broadening width
      Gamma(E) that increases with energy above threshold (as final state
      lifetime decreases)
- [x] **124.9.5.3** Implement Voigt broadening: sequential Gaussian and
      Lorentzian convolution, or direct Voigt convolution using FFT. Standard
      for comparison of computed spectra with experiment

#### 124.9.6 Spectrum Import and Comparison

- [x] **124.9.6.1** Implement spectrum file parser: read common spectral data
      formats — multi-column ASCII (energy, intensity), XDI (X-ray Data
      Interchange for XAS), VAMAS (ISO 14976 for XPS), JCAMP-DX (spectroscopy
      interchange), and Athena project files (.prj). Auto-detect format from
      header
- [x] **124.9.6.2** Implement theory-experiment comparison metrics: R-factor R =
      sum|y_exp - y_theory|^2 / sum|y_exp|^2, chi-squared chi^2 = sum((y_exp -
      y_theory)/sigma)^2, cosine similarity cos_sim = (y_exp . y_theory) /
      (|y_exp| \* |y_theory|), and Pearson correlation coefficient. Report all
      metrics for each comparison
- [x] **124.9.6.3** Implement spectrum alignment for comparison: cross-
      correlation based energy shift detection between theory and experiment.
      Optimize shift and scale factor to minimize R-factor. Handle different
      energy grids via interpolation (cubic spline)
- [x] **124.9.6.4** Implement reference spectrum database: store computed
      spectra for common compounds indexed by structure, spectroscopy type,
      computational method, and edge/nucleus. Enable lookup by chemical formula,
      space group, or spectral fingerprint similarity

---

### 124.10 Spectroscopy Visualization (`@kalika/spectroscopy-viz`)

#### 124.10.1 Library Scaffolding

- [x] **124.10.1.1** Create `libs/kalika/spectroscopy-viz/` directory with
      `project.json`, `package.json`, `tsconfig.json`. Add
      `@kalika/spectroscopy-viz` path mapping to `tsconfig.base.json`

#### 124.10.2 1D Spectrum Plots

- [x] **124.10.2.1** Implement interactive spectrum plot renderer: render
      spectrum as a line plot with energy/frequency on x-axis and intensity on
      y-axis. Support zoom (scroll wheel), pan (drag), cursor readout (crosshair
      with x,y values), and peak labels (position, assignment). Output as SVG
      for publication and as JSON scene graph for WebGL
- [x] **124.10.2.2** Implement multi-spectrum overlay: plot multiple spectra on
      the same axes with different colors/line styles. Support vertical offset
      (stacked waterfall plot) for comparing spectra at different conditions
      (temperature, pressure, composition)
- [x] **124.10.2.3** Implement spectral decomposition visualization: display
      individual peak components (from peak fitting) as filled areas beneath the
      total fit curve. Show residual (data - fit) in a separate panel below the
      main spectrum
- [x] **124.10.2.4** Implement theory vs. experiment comparison plot: overlay
      computed spectrum (broadened, aligned) with experimental data points (with
      error bars if available). Display R-factor and other comparison metrics in
      the legend. Highlight spectral regions with largest discrepancy

#### 124.10.3 2D Spectrum Maps

- [x] **124.10.3.1** Implement RIXS map visualization: render 2D intensity map
      with incident energy on one axis and energy loss (or emission energy) on
      the other. Use colormap (viridis, plasma, or custom) with logarithmic
      intensity scaling option. Mark constant emission energy (fluorescence) and
      constant energy loss (Raman) lines
- [x] **124.10.3.2** Implement ARPES visualization: render A(k,omega) as 2D
      intensity map with crystal momentum k on x-axis (along high-symmetry path)
      and binding energy on y-axis. Overlay DFT band structure as lines. Support
      multiple Brillouin zone paths in a single plot with high-symmetry point
      labels
- [x] **124.10.3.3** Implement 2D NMR correlation spectrum plot: render
      cross-peak intensity map for HETCOR/MQMAS spectra with chemical shift on
      both axes. Include contour lines and projections along each axis

#### 124.10.4 Decomposed and Projected Spectra

- [x] **124.10.4.1** Implement orbital-decomposed spectral contribution plot:
      for XAS, EELS, and XPS, show contributions from different angular momentum
      channels (s, p, d, f) as stacked areas or separate traces. Color-coded by
      orbital character
- [x] **124.10.4.2** Implement atom-projected spectral weight: for a multi-site
      structure, show contributions from each inequivalent atomic site to the
      total spectrum. Enable toggling individual site contributions on/off
- [x] **124.10.4.3** Implement band-decomposed optical spectrum: for UV-Vis and
      EELS, show which band-to-band transitions contribute to each spectral
      feature. Display as a heatmap of transition contributions indexed by
      (initial band, final band, energy)

#### 124.10.5 Real-Space Visualization

- [x] **124.10.5.1** Implement core orbital visualization: render the spatial
      distribution of the core state involved in XAS/XPS transitions (1s, 2p, 3d
      orbital shape) as isosurface on the atomic site. Use standard orbital
      shapes with radial function from the atomic calculation
- [x] **124.10.5.2** Implement excited-state (exciton) wavefunction
      visualization: for BSE-computed core excitons, display the electron
      density distribution |psi_e(r)|^2 with the hole fixed at the absorber
      site. Shows the spatial extent and character (localized vs. delocalized)
      of the X-ray excited state as a 3D isosurface on the crystal structure
- [x] **124.10.5.3** Implement NMR shielding tensor ellipsoid visualization:
      display the chemical shielding tensor as an ellipsoid at each nuclear
      site, with principal axes and eigenvalues shown. Orientation relative to
      crystal axes reveals bonding symmetry

---

### 124.11 Cross-Module Integration & Validation (`@kalika/spectroscopy`)

#### 124.11.1 Phases 116 & 118 Integration (Electronic Structure)

- [x] **124.11.1.1** Implement DFT wavefunction interface: read Kohn-Sham
      wavefunctions, eigenvalues, and density from the Phase 116 DFT output
      (HDF5 format). Provide adapters for different DFT implementations
      (plane-wave, LCAO) to the unified wavefunction interface needed by
      spectroscopy modules
- [x] **124.11.1.2** Implement GW quasiparticle energy interface: read GW
      self-energy and quasiparticle corrections from Phase 118 output. Apply
      scissor operator or full quasiparticle corrections to band energies used
      in spectroscopy calculations
- [x] **124.11.1.3** Implement BSE exciton interface: read BSE exciton
      wavefunctions and eigenvalues for optical and core-level excitations.
      Enable reuse of BSE data across optical (Phase 123), EELS, and XAS modules

#### 124.11.2 Phase 119 Integration (Lattice Dynamics)

- [x] **124.11.2.1** Implement phonon mode interface: read phonon frequencies
      and eigenvectors at Gamma from Phase 119 dynamical matrix. Provide to IR
      intensity, Raman tensor, vibrational EELS, and Mossbauer Lamb factor
      calculations
- [x] **124.11.2.2** Implement Born effective charge interface: read Z* tensors
      from Phase 119 DFPT output for IR intensity computation. Validate acoustic
      sum rule: sum_kappa Z*\_kappa = 0
- [x] **124.11.2.3** Implement phonon DOS interface: read total and
      atom-projected phonon DOS for Debye-Waller factor (EXAFS), mean-square
      displacement (Mossbauer), and thermal broadening computations

#### 124.11.3 Phase 122 Integration (Defect Physics)

- [x] **124.11.3.1** Implement defect state interface: read defect formation
      energies, charge transition levels, and relaxed geometries from Phase 122.
      Feed into PL (CC diagram), EPR (spin density at defect), and local
      spectroscopy (site-specific XAS/EELS for defect sites in supercell)
- [x] **124.11.3.2** Implement defect-specific spectroscopy workflow: given a
      defect supercell from Phase 122, automatically set up XAS/XANES
      calculation at the defect site, compute local DOS, predict core-level
      shifts, and compare with surrounding bulk-like sites

#### 124.11.4 Validation Suites

- [x] **124.11.4.1** Implement XAS validation: compute Cu K-edge XANES for bulk
      Cu (FCC) using FMS and compare with experimental spectrum — verify edge
      position within 1 eV, major features (white line, post-edge oscillations)
      reproduced. Validate EXAFS chi(k) against known Cu-Cu distance (2.556 A)
      and coordination number (12)
- [x] **124.11.4.2** Implement XPS validation: compute C 1s binding energies for
      diamond, graphite, C60, and CO2, verify chemical shifts match experimental
      ordering and magnitude within 0.5 eV
- [x] **124.11.4.3** Implement Raman validation: compute Raman spectrum of
      silicon (single peak at 520 cm^-1, T2g symmetry), diamond (1332 cm^-1,
      T2g), and alpha-quartz (multiple modes at 128, 206, 265, 355, 394, 401,
      464, 697, 795, 808, 1072, 1085 cm^-1). Verify frequencies within 5 cm^-1
      of experiment
- [x] **124.11.4.4** Implement NMR validation: compute 29Si chemical shifts for
      quartz, cristobalite, and coesite; verify ordering and magnitude against
      experimental solid-state NMR data within 3 ppm. Compute 27Al EFG for
      corundum and verify C_Q within 0.5 MHz of experiment
- [x] **124.11.4.5** Implement Mossbauer validation: compute isomer shift and
      quadrupole splitting for alpha-Fe (delta=0, Delta_E_Q=0), FeO (wustite,
      delta~0.93, Delta_E_Q~0.8), alpha-Fe2O3 (hematite, delta~0.37,
      Delta_E_Q~-0.20). Verify within 0.1 mm/s of experiment
- [x] **124.11.4.6** Implement EELS validation: compute low-loss EELS for bulk
      Al (free-electron plasmon at ~15 eV), Si (plasmon at ~16.7 eV), and
      diamond (band gap at 5.5 eV visible in loss function). Verify plasmon
      energies within 0.5 eV of experiment
- [x] **124.11.4.7** Implement EPR validation: compute g-tensor for Cu(II) in
      tetragonal coordination (g_parallel ~ 2.2-2.4, g_perp ~ 2.05-2.10) and
      verify against experimental EPR data. Compute hyperfine coupling A(63Cu)
      and verify order of magnitude
- [x] **124.11.4.8** Implement end-to-end spectroscopy pipeline test: starting
      from a CIF file for SrTiO3 (perovskite), run complete workflow: DFT ground
      state -> phonons -> XAS (Ti K-edge) -> EELS (Ti L-edge) -> Raman
      (zone-center modes) -> NMR (47/49Ti) -> verify all spectra are internally
      consistent and match known experimental data

<!-- prettier-ignore-end -->
