Skip to content

Add DRESS Monte Carlo integration for DT and DD thermal neutron spectra#59

Merged
aidancrilly merged 6 commits intodress_integrationfrom
copilot/sub-pr-58
Mar 1, 2026
Merged

Add DRESS Monte Carlo integration for DT and DD thermal neutron spectra#59
aidancrilly merged 6 commits intodress_integrationfrom
copilot/sub-pr-58

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

Integrates pydress as an optional backend for computing primary neutron spectra, complementing the existing Ballabio/Brysk analytical fits with a full Monte Carlo treatment. Supports separate deuteron and triton temperatures for DT — not possible with the scalar Ballabio moments.

Changes

  • dress_interface.py — Replaces the preliminary stub with three functions:

    • DRESS_DT_spec(T_D, T_T, n_samples, bins) — DT spectrum with independent D/T temperatures
    • DRESS_DD_spec(T, n_samples, bins) — DD thermal spectrum
    • DRESS_DT_spec_single_T — thin backward-compatible wrapper
    • Fixes in-place mutation bug (bins /= 1e3) from the original stub; adds type hints; raises a clear ImportError when pydress is absent
  • core.py — Two new public routines (eV throughout, matching NeSST conventions):

    • QDress_DT(Ein, T_D, T_T=None, n_samples=1e6)T_T defaults to T_D
    • QDress_DD(Ein, Tion, n_samples=1e6)
  • __init__.py — dress import wrapped in try/except; NeSST loads normally without pydress.

  • pyproject.toml — pydress added as optional [dress] extra.

  • tests/test_dress.py — Five new tests comparing DRESS moments (mean ±1 %, σ ±5 %) against Ballabio for DT and DD, plus a check that asymmetric T_D ≠ T_T produces a different spectrum.

Usage

import numpy as np
import NeSST as nst

Tion = 5e3  # eV
mean, stddev, _ = nst.DTprimspecmoments(Tion)
Ein = np.linspace(mean - 10*stddev, mean + 10*stddev, 500)

# Equal temperatures — equivalent to single-T Ballabio case
spec_eq = nst.QDress_DT(Ein, Tion)

# Separate D and T temperatures (not possible with Ballabio)
spec_asym = nst.QDress_DT(Ein, T_D=5e3, T_T=10e3)

# DD
spec_dd = nst.QDress_DD(Ein_dd, Tion)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: aidancrilly <20111148+aidancrilly@users.noreply.github.com>
Copilot AI changed the title [WIP] Integrate PyDress as primary source in NeSST Add DRESS Monte Carlo integration for DT and DD thermal neutron spectra Feb 28, 2026
@aidancrilly aidancrilly marked this pull request as ready for review February 28, 2026 19:22
@aidancrilly aidancrilly merged commit 56cbc20 into dress_integration Mar 1, 2026
2 checks passed
aidancrilly added a commit that referenced this pull request Mar 1, 2026
* Initial DRESS integration

* Add DRESS Monte Carlo integration for DT and DD thermal neutron spectra (#59)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aidancrilly <20111148+aidancrilly@users.noreply.github.com>
Co-authored-by: aidancrilly <a.crilly16@imperial.ac.uk>

* Updated guide etc.

* DRESS in CI install

---------

Co-authored-by: aidancrilly <a.crilly16@imperial.ac.uk>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants