Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broadening bug fixes and enhancements #32

Merged
merged 22 commits into from
Jun 11, 2021
Merged

Broadening bug fixes and enhancements #32

merged 22 commits into from
Jun 11, 2021

Conversation

ajwheeler
Copy link
Owner

@ajwheeler ajwheeler commented Apr 20, 2021

This first commit fixes a bug in how broadening parameters are used. The per-particle stark and vdW gamma are now multiplied by the appropriate number densities.

I plan on adding more advanced vdW broadening (ABO theory, see links in #1) in this PR as well. That would take into account the effect of temperature on pressure broadening, at least for lines with data available.

#30 should be merged before this.

@codecov
Copy link

codecov bot commented Apr 20, 2021

Codecov Report

Merging #32 (7519f48) into main (4905240) will increase coverage by 1.92%.
The diff coverage is 69.56%.

❗ Current head 7519f48 differs from pull request most recent head b4a2c77. Consider uploading reports for the commit b4a2c77 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main      #32      +/-   ##
==========================================
+ Coverage   76.25%   78.18%   +1.92%     
==========================================
  Files          13       13              
  Lines         417      463      +46     
==========================================
+ Hits          318      362      +44     
- Misses         99      101       +2     
Impacted Files Coverage Δ
src/SSSynth.jl 100.00% <ø> (ø)
src/partition_func.jl 100.00% <ø> (ø)
src/synthesize.jl 31.14% <0.00%> (-1.06%) ⬇️
src/line_opacity.jl 58.82% <45.45%> (+19.20%) ⬆️
src/linelist.jl 93.67% <90.74%> (-4.33%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a90621...b4a2c77. Read the comment docs.

- the first is some small math tweaks to use multiplication instead of division
  in a couple spots

- the second involves a more significant overhaul.  This commit introduces dynamic
  calculation of line windows. See the docstring of line_absorption for details.
@ajwheeler
Copy link
Owner Author

These commits introduce changes to make line absorption much faster. There are both math tweaks and now, more importantly, line windows are dynamically calculated. This takes us from 15x to 2x slower than MOOG for the example linelist I've been using.

Apologies for the absolute spaghetti going on between theses PRs.

…ydrogen and helium.

This modifies the `Line` type to work with ABO parameters, and uses values of Gamma instead of log(Gamma).
@ajwheeler
Copy link
Owner Author

This commit introduces ABO broadening. It also refactors Line to use Gamma values instead of log(Gamma) values.

@ajwheeler
Copy link
Owner Author

Sorry the github diff is messed up by my PR spaghetti. Would rebasing fix that?

@mabruzzo
Copy link
Collaborator

mabruzzo commented May 1, 2021

Sorry the github diff is messed up by my PR spaghetti. Would rebasing fix that?

I've encountered this type of problem before. It's really annoying! When I encountered it, I ultimately opened a new PR.

It looks like this approach might work (of course, you need to replace feature-branch with broadening). This suggests that whenever a PR branch has been overwritten (by git push --force) the differences from the destination branch will be regenerated. This suggests that rebasing should also achieve the same result (since you would need to use git push --force after the rebase), but this approach is a lot easier.

@ajwheeler
Copy link
Owner Author

ajwheeler commented May 1, 2021

Great, I think that worked. Here's what's remaining for me to do.

  • Use the Unsoeld approximation when vdW broadening info isn't available. done
  • Figure out if the Kurucz and VALD vdW gammas are supposed to be scaled by temperature, and figure out why the scaling is what it is done
  • Default stark broadening?

@codecov-commenter
Copy link

codecov-commenter commented May 4, 2021

Codecov Report

Merging #32 (d77ce9f) into main (d529a94) will increase coverage by 1.42%.
The diff coverage is 63.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #32      +/-   ##
==========================================
+ Coverage   77.55%   78.97%   +1.42%     
==========================================
  Files          13       13              
  Lines         450      509      +59     
==========================================
+ Hits          349      402      +53     
- Misses        101      107       +6     
Impacted Files Coverage Δ
src/statmech.jl 98.43% <ø> (ø)
src/synthesize.jl 30.64% <0.00%> (ø)
src/line_opacity.jl 51.94% <35.71%> (+12.32%) ⬆️
src/linelist.jl 94.78% <97.77%> (+1.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d529a94...d77ce9f. Read the comment docs.

@ajwheeler ajwheeler requested a review from mabruzzo May 5, 2021 16:15
@ajwheeler ajwheeler changed the title Broadening bug fixes and enhancements WIP Broadening bug fixes and enhancements May 5, 2021
This was referenced May 11, 2021
Copy link
Collaborator

@mabruzzo mabruzzo left a comment

Choose a reason for hiding this comment

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

Looks good to me. I've got a handful of minor suggestions, but feel free to merge

src/line_opacity.jl Outdated Show resolved Hide resolved
src/line_opacity.jl Outdated Show resolved Hide resolved
src/linelist.jl Outdated Show resolved Hide resolved
@@ -65,12 +66,16 @@ function synthesize(atm, linelist, λs::AbstractVector{F}; metallicity::F=0.0, v
number_densities = molecular_equilibrium(MEQs, layer.temp, layer.number_density,
layer.electron_density)

α[i, :] = line_absorption(linelist, λs, layer.temp, number_densities, atomic_masses,
partition_funcs, ionization_energies, vmic*1e5)
α_cntm = LinearInterpolation(cntmλs,
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be useful to add a comment explaining that why we are allowing for extrapolation at all (i.e. to serve as as a heuristic for determining the window size of the lines). When I first saw this, I got very concerned (before I realized what was going on).

Copy link
Owner Author

Choose a reason for hiding this comment

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

I've added a comment to explain the interpolation, and I've tweaked the code to make extrapolation unnecessary.

@mabruzzo
Copy link
Collaborator

I think this is ready to be merged. It's not just not obvious to me how to resolve the documentation merge conflict (related to line_profile)

@ajwheeler ajwheeler merged commit 81f86e0 into main Jun 11, 2021
@ajwheeler ajwheeler deleted the broadening branch June 11, 2021 13:01
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