Skip to content

Add integrated physics-consistency test suite #151

Description

@ergodic-ludwig

Goal

Create an integrated battery of physics-based tests that validates TSADAR model consistency beyond unit, configuration, and plumbing checks.

The tests should detect changes that execute successfully but violate the expected Thomson-scattering physics or produce physically inconsistent corrections.

Scope

  • Identify the highest-value physical invariants, limiting cases, and reference problems.
  • Convert those cases into deterministic integrated tests with explicit tolerances.
  • Cover representative electron- and ion-feature calculations and parameter-recovery behavior where practical.
  • Separate fast tests suitable for GitHub CI from long-running stress/reference tests that may run on NERSC.
  • Document the physical rationale and expected behavior for each test.

Proposed approach

The suite should follow the forward-model layers documented in the anisotropic Thomson-scattering math summary:

distribution → projection/sinogram → susceptibilities → S(k,ω) → averaging/instrument response → inverse recovery

Start with local invariants and analytic reference cases, then compose them into end-to-end synthetic-recovery tests. Every test should state the physical invariant, source equation/reference, parameter regime, numerical tolerance, and whether it belongs in normal CI or the NERSC/nightly suite.

1. Maxwellian susceptibility oracle

Set the electron distribution to the m = 2 Maxwellian limit and compare the arbitrary-electron ratintn susceptibility path against the analytic Fried–Conte Z′ result across the resonance grid. Compare real and imaginary parts separately, including near-pole and large-phase-velocity regimes.

2. Analytic Gaussian projection

Project a normalized isotropic 2D Gaussian over several projection angles. Every projection should:

  • be independent of projection angle;
  • agree with the analytic 1D Gaussian;
  • integrate to unity; and
  • preserve the expected second moment.

3. Rotational covariance

Rotate both an anisotropic distribution and the scattering geometry by the same angle. The projected distribution, susceptibility, and predicted spectrum should remain unchanged within interpolation tolerance.

4. First-harmonic selection rules

For a controlled l = 1 anisotropic perturbation:

  • f₁ ⟂ k should make no contribution after projection;
  • reversing the component of f₁ parallel to k should reverse the odd anisotropic correction; and
  • the isotropic component should remain unchanged.

5. Sinogram validation

Compare the default tabulated/Catmull–Rom sinogram path against the exact n_beta = 0 per-point rotation path. Test:

  • error convergence as n_beta increases;
  • periodic continuity at β = 0/2π;
  • representative distribution shapes and angles; and
  • gradients with respect to β, checked against finite differences away from nonsmooth points.

6. Non-collective limit

As the Salpeter parameter α_TS = 1/(kλ_De) tends to zero, verify that the electron feature approaches the appropriately scaled projected electron distribution and that dielectric-screening and ion-feature corrections vanish as expected.

7. Collective dispersion limits

For Maxwellian inputs, scan density, temperature, ionization, and scattering angle and verify recovery of the expected trends:

  • EPW resonance follows the Bohm–Gross limit where applicable;
  • IAW phase velocity follows the ion-acoustic scaling where applicable; and
  • deviations outside those asymptotic regimes remain consistent with the full kinetic calculation.

These should test trends and documented validity ranges rather than impose asymptotic formulas where they are not accurate.

8. Galilean/Doppler covariance

Apply a common bulk velocity to all species:

  • a component parallel to k should translate the spectrum by k·V without changing its intrinsic shape; and
  • a component perpendicular to k should not shift the spectrum.

Also test electron drift relative to the charge-weighted ion flow separately from common bulk motion.

9. Averaging collapse tests

Verify that:

  • zero density/temperature gradient reproduces the single-condition spectrum;
  • a delta-function angular weight reproduces the corresponding single-angle spectrum; and
  • finite-aperture weights sum to one and reproduce the explicitly weighted sum of raw angle-resolved spectra.

10. Distribution moment invariants

For each generated, rotated, smoothed, and projected distribution, check the applicable invariants:

  • normalization;
  • prescribed second moment/temperature;
  • intended mean drift; and
  • positivity where required.

Include free-form distributions because their moment penalties are not currently included in the returned total loss.

11. Instrument-response conservation

Characterize and lock down the intended IRF convention. Test both integrated spectral area and peak-height behavior before and after convolution so an accidental switch between area-preserving and peak-normalized convolution is detected. Verify that a zero-width IRF approaches the unconvolved spectrum and that bin averaging is conservative under the documented convention.

12. End-to-end synthetic recovery

Generate noiseless synthetic spectra from known:

  • isotropic Maxwellian/DLM distributions;
  • anisotropic bi-DLM distributions; and
  • spherical-harmonic distributions.

Fit them from displaced initial conditions and verify recovery of identifiable parameters and spectrum shape. Add controlled noise in the longer-running suite to assess bias, uncertainty coverage, and known degeneracies rather than requiring exact parameter recovery where the inverse problem is non-identifiable.

Suggested execution split

Fast CI: analytic Gaussian projections, moment invariants, selection rules, small-grid susceptibility comparison, rotational/Doppler covariance, averaging collapse, IRF limiting cases, and a minimal noiseless recovery case.

NERSC/nightly: dense susceptibility scans, sinogram convergence over many resolutions/distributions, broad collective/non-collective parameter scans, anisotropic end-to-end recovery, noisy ensembles, and uncertainty-coverage studies.

Implementation order

  1. Build reusable test helpers for normalized distributions, moment calculations, spectrum comparison, and tolerance reporting.
  2. Establish analytic/reference oracles before testing optimized paths.
  3. Add projection and susceptibility tests.
  4. Add form-factor and detector-response invariants.
  5. Add end-to-end recovery cases.
  6. Introduce one deliberate physical inconsistency and verify that at least one suite test fails with a meaningful diagnostic.
  7. Document how tolerances were selected and how contributors add new physics-validation cases.

Acceptance criteria

  • A reviewed list of physical invariants and reference cases is documented.
  • Each implemented test cites the equation, invariant, or trusted reference result it validates.
  • Tests include meaningful failure messages and justified numerical tolerances.
  • At least one test detects a known or deliberately introduced physically inconsistent result.
  • Fast tests run in normal CI; expensive cases are clearly marked for a separate NERSC/nightly suite.
  • Contributor documentation explains how to add new physics-validation cases.

Provenance

Action item from the Avi / Archis meeting on 2026-09-01. Discussion: transcript at 00:05:58.

The proposed approach was refined from Avi's updated Thomson-Scattering Theory and the TSADAR Forward Model math summary shared with the team on 2026-09-08.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions