Skip to content

Port the AtomicLine2 and ElectronImpact1 rates; fix atdb.fits reading - #7

Merged
barrettp merged 2 commits into
mainfrom
electronimpact1
Oct 2, 2026
Merged

barrettp merged 2 commits into
mainfrom
electronimpact1

Conversation

@barrettp

@barrettp barrettp commented Oct 2, 2026

Copy link
Copy Markdown
Member

Summary

  • AtomicLine2 (XSTAR ucalc type 50, 730k records): rate(coef, cell; levels, mass, vturb) orders the two levels by energy, returns the decay rate (A), emitted power and line-centre opacity. irate is always 0, as in ucalc (no reverse term). level_table(db) builds the level lookup.
  • ElectronImpact1 (type 56, 87k records): excitation and de-excitation rates from Υ interpolated in log T, related by detailed balance. Levels with equal energies are skipped as in ucalc.
  • Cell gains ntot (XSTAR xpx). Cell holds only the local gas state; level data stay in tables and the radiation field will be a separate object.
  • Loader fix: Radix.load now calls fits(io; scale=false). FITSFiles.jl <= 0.3.2 rounds unscaled Int32 columns through Float32, which corrupted the pointers to the reals beyond 2^24 for about 1M of the 1.2M records (values read from the wrong place). Fixed upstream in Don't scale binary table columns without TSCAL/TZERO FITSFiles.jl#50; the keyword can be removed once a release containing it is required.

Tests

  • Unit tests check each rate against the ucalc formulas.
  • Opt-in database tests (RADIX_ATDB=/path/to/atdb.fits): levels read correctly, all 730,369 AtomicLine2 records resolve to two known levels with finite results and downward decays, all 87,231 ElectronImpact1 records give finite, non-negative rates that obey detailed balance at 1e3, 1e4 and 1e5 K.

Notes

  • For 339 AtomicLine2 records with no wavelength (λ = 0), where ucalc would divide by zero, the emitted power uses the level energy difference.
  • Two commits (atomicline2) are included because electronimpact1 is stacked on it.

🤖 Generated with Claude Code

barrettp and others added 2 commits October 2, 2026 17:08
- rate(::AtomicLine2, cell; levels, mass, vturb) follows XSTAR ucalc type 50:
  orders the two levels by energy, returns the decay rate (A), emitted power
  and line-centre opacity; add level_table(db) for the level lookup
- Load the database with scale=false: FITSFiles.jl <= 0.3.2 rounds unscaled
  Int32 columns through Float32, which corrupted the real-array pointers beyond
  2^24 (fixed in FITSFiles.jl#50)
- Tests: unit tests against the ucalc formulas; opt-in database checks (levels
  read correctly, all 730,369 AtomicLine2 records resolve and are finite)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- rate(::ElectronImpact1, cell; levels) follows XSTAR ucalc type 56: orders the
  levels by energy, interpolates the effective collision strength linearly in
  log T (extrapolating the end segments as ucalc's hunt does) and returns the
  excitation and de-excitation rates, related by detailed balance
- Cell gains ntot (the hydrogen density, XSTAR xpx); level data stay in tables
  and the radiation field will be a separate object (documented)
- Tests: formula check against ucalc; opt-in database check over all 87,231
  records at 1e3, 1e4 and 1e5 K (finite, non-negative, detailed balance; the
  188 degenerate-energy pairs are skipped as in ucalc)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@barrettp
barrettp merged commit 3c5ed6f into main Oct 2, 2026
5 checks passed
@barrettp
barrettp deleted the electronimpact1 branch October 2, 2026 22:36
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.

1 participant