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

solve for ne instead of using atmospheric value #179

Merged
merged 15 commits into from
May 19, 2023
Merged

Conversation

ajwheeler
Copy link
Owner

@ajwheeler ajwheeler commented Apr 28, 2023

This branch is an experiment where Korg solves for the electron number density self-consistently, rather than assuming the model-atmospheric value is correct. For the MARCS solar atmosphere, this adds about 0.1s to synthesis time, which is roughly double for a small wavelength range.

Notably, this implementation doesn't crash on any model atmospheres (at least at solar metallicity). Contrast with the current method (#129), which sometimes fails for cool stars.

Here's the reletive difference in the $n_e$ that Korg infers using the old method and this one. Solar atmosphere on the left, cool star (Teff = 3200K, logg=2.0 very close to the parameters which crash the current implementation) on the right:
imageimage

The agreement between the methods is worse for the cool star, which is consistent with Korg's solver failing near there. Completely unexpectedly (to me), the new method actually produces closer agreement with the model atmosphere pretty much everywhere. I'd really like to know what the cause for disagreement with the atmosphere is, but my guess is charged molecules.

The seems like a slam dunk except that it's slow.

TODO

  • actually use new ne for continuum stuff, etc
  • make fast?
  • document changes in atmosphere code
  • add warning when electron number density diverges from model atmosphere
  • stress test to see where, if anywhere, Korg's chemical equilibrium can't converge

@ajwheeler ajwheeler mentioned this pull request Apr 28, 2023
18 tasks
@ajwheeler
Copy link
Owner Author

OK, so I spent some time speeding this up and it's actually a bit faster than the old implementation now for cool stars where chemical equilibrium is more complicated (more molecules).

new implementation: 70ms (sun), 148ms (cool giant)
old implementation: 70ms (sun) 227 ms (cool giant)

@codecov
Copy link

codecov bot commented May 10, 2023

Codecov Report

Patch coverage: 98.03% and project coverage change: +0.18 🎉

Comparison is base (c7caa79) 82.52% compared to head (9b0b920) 82.71%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #179      +/-   ##
==========================================
+ Coverage   82.52%   82.71%   +0.18%     
==========================================
  Files          22       22              
  Lines        1402     1423      +21     
==========================================
+ Hits         1157     1177      +20     
- Misses        245      246       +1     
Impacted Files Coverage Δ
src/statmech.jl 80.95% <97.50%> (+3.30%) ⬆️
src/synthesize.jl 94.64% <100.00%> (+0.04%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ajwheeler
Copy link
Owner Author

Github actions is currently down, but the tests pass on my computer. This is ready for review.

@ajwheeler ajwheeler marked this pull request as ready for review May 19, 2023 18:34
@ajwheeler ajwheeler merged commit 0494d82 into main May 19, 2023
@ajwheeler ajwheeler deleted the solve-for-ne branch May 19, 2023 18:34
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