Skip to content

Add optional frequency dependence to PowerLaw#70

Merged
Yurlungur merged 5 commits into
mainfrom
pdmullen/powerlaw-nudep
May 26, 2026
Merged

Add optional frequency dependence to PowerLaw#70
Yurlungur merged 5 commits into
mainfrom
pdmullen/powerlaw-nudep

Conversation

@pdmullen

@pdmullen pdmullen commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

This PR used generative AI.

Adds optional frequency dependence to the PowerLaw opacity.

@pdmullen
pdmullen changed the base branch from main to pdmullen/dBdT-fix April 9, 2026 18:10
@pdmullen pdmullen changed the title Add optional frequency dependence to PowerLaw WIP: Add optional frequency dependence to PowerLaw Apr 9, 2026
@pdmullen pdmullen changed the title WIP: Add optional frequency dependence to PowerLaw Add optional frequency dependence to PowerLaw Apr 9, 2026

@Yurlungur Yurlungur left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

Comment thread singularity-opac/photons/powerlaw_opacity_photons.hpp Outdated
Comment thread singularity-opac/photons/powerlaw_opacity_photons.hpp Outdated
@RyanWollaeger

Copy link
Copy Markdown
Collaborator

LGTM - it'd be nice to have this in soon, for testing in dependent code.

@RyanWollaeger

Copy link
Copy Markdown
Collaborator

Sorry to jump the gun on the dBdT fix - it looks like this PR has to be redirected to main now

+ Add density, temperature, and frequency offsets to power-laws.
+ Add density and temperature references (scales) to power-laws.
+ Add stimulated-emission factor option to absorption power-law.
Comment thread test/test_powerlaw_opacities.cpp
Real OpacityScale_(const Real rho, const Real temp, const Real nu) const {
return OpacityPrefactor_(rho, temp) * std::pow(nu / nu_ref_, nu_exp_);
const Real freq_plaw = std::pow((nu + nu_off_) / nu_ref_, nu_exp_);
const Real stim_fact = do_stim_emit_ ? -std::expm1(-(pc::h * nu / (pc::kb * temp))) : 1.0;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this brings in units... can you double check that all the conversions are threaded through correctly to get the correctly unit-informed Planck and Boltzmann constant?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - will do...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is the CGS side of the class, it seems nu and temp should be in CGS by the time they reach this function, so that leaves the question of whether pc::h and pc::kb are properly non-dimensionalizing the exponential argument (or equivalently, what the actual units of nu is - e.g. energy or 1/time). If the nu here is assumed consistent with the nu taken by the EmissivityPerNuPerOmega function, it seems this should be correct: EmissivityPerNuPerOmega calls ThermalDistributionOfNu which takes nu directly and computes the nondimensional parameter x = pc::h * nu / (pc::kb * temp) as in the stimulated emission formula here. Let me know if this reasoning misses something.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following on this, noticed that the parameters rho_ref and temp_ref must be in CGS when the constructor is invoked. That is maybe a bit cumbersome - noted this in the comments next to these class members in each of the power law classes (also made a note that nu_ref has to have units of 1/s, which I think is true for the same reason unless kappa0 absorbs the unit).

@Yurlungur
Yurlungur changed the base branch from pdmullen/dBdT-fix to main May 26, 2026 21:26
@Yurlungur

Copy link
Copy Markdown
Collaborator

@pdmullen @RyanWollaeger is this good to go? It looks like it is... and apparently I already approved ;)

@RyanWollaeger

Copy link
Copy Markdown
Collaborator

@pdmullen @RyanWollaeger is this good to go? It looks like it is... and apparently I already approved ;)

We're making a few final changes now (adding a test for the scattering power law opacity, minor comment updates)

+ Add comments that reference parameters are in cgs units.
@RyanWollaeger

Copy link
Copy Markdown
Collaborator

It should be ready now, if things look okay - the new test is not exhaustive for the constructor arguments, but maybe that is not too concerning.

@Yurlungur Yurlungur left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine. Thanks @RyanWollaeger !

@Yurlungur
Yurlungur merged commit 60b7411 into main May 26, 2026
1 check 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.

3 participants