Skip to content

Fix specific energy spectrum when PDA and MRW are used, as well as dust sublimation capping - #267

Merged
astrofrog merged 4 commits into
hyperion-rt:mainfrom
astrofrog:specific-energy-spectrum
Jul 31, 2026
Merged

Fix specific energy spectrum when PDA and MRW are used, as well as dust sublimation capping#267
astrofrog merged 4 commits into
hyperion-rt:mainfrom
astrofrog:specific-energy-spectrum

Conversation

@astrofrog

Copy link
Copy Markdown
Contributor

The optional frequency-resolved specific energy spectrum (a per-cell, per-dust histogram of absorbed energy binned by photon frequency) is filled during normal photon propagation, but three code paths modify the cell energy without going through propagation and left the spectrum stale or wiped it, breaking the invariant that the spectrum summed over frequency bins equals the scalar specific energy:

  • MRW: diffusion-step energy deposits only updated the scalar, so cells heated mainly via the Modified Random Walk had a near-empty spectrum. The energy is now also deposited in the spectrum, with the frequency sampled from the local emissivity (in the diffusion regime where MRW is valid, the radiation field is Planckian, so the absorbed energy is distributed as kappa_nu * B_nu).
  • PDA: the Partial Diffusion Approximation overwrites the scalar in poorly sampled cells but left the spectrum untouched. The spectrum is now rescaled by the ratio of the new to old specific energy, preserving its shape.
  • Dust sublimation: capping the specific energy at the sublimation value reset the spectrum to the minimum specific energy, destroying the spectral information. It is now rescaled by the cap ratio instead.

Includes a test suite that asserts the sum-over-bins invariant per cell (plain, PDA, and AMR runs, plus custom frequency grids) and that enabling the feature does not change the scalar specific energy.

Models that do not enable the frequency-resolved spectrum are unaffected (the scalar code paths are unchanged, and the full bit-level suite passes against the existing reference files).

…ent with the diffusion-updated specific energy
…um by distributing it over the frequency bins according to the local emissivity
…tead of resetting it to the minimum in sublimation modes 2 and 3
@astrofrog
astrofrog force-pushed the specific-energy-spectrum branch from 17f0a26 to 48b5b83 Compare July 28, 2026 22:28
@astrofrog

Copy link
Copy Markdown
Contributor Author

@dnarayanan - just FYI this fixes some issues related to the frequency-dependent specific energy, though this might be in modes you don't depend on.

@dnarayanan

Copy link
Copy Markdown
Contributor

thanks! i hadn't tested those modes so appreciate the fix!

@astrofrog

Copy link
Copy Markdown
Contributor Author

@dnarayanan while I think of it, I've been meaning to ask is there a reason you didn't have it so that users define bins rather than the 'centres' of the bins? Having played around with this I feel that having the definition be based on bibs might be more explicit, so that users don't think that the values are being computed at an exact frequency. For instance if a user specifies two frequencies, the results will be huge averages rather than just the value at two frequencies.

Anyway I'm curious if switching things would be a no go for you, or if there's a reason you decided against this?

One option would be to have the Python method to set the bins take both bin_edges and bin_centers as kwarg only arguments so that users have to explicitly use one or the other, and handle it via bins internally.

@dnarayanan

Copy link
Copy Markdown
Contributor

this is a really good idea! i have to admit i just didn't think about it because i was doing this for my own purposes and wasn't really thinking through a general use-case. i think this would be a useful addition.

i could try to implement this though i have to admit it i may not have time to look until mid-fall (i'm about to go into a multi-month proposal writing frenzy for a series of grants...)

@astrofrog
astrofrog merged commit b0f270e into hyperion-rt:main Jul 31, 2026
22 checks passed
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