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

Ionization rates #2897

Merged
merged 20 commits into from
Jan 22, 2025
Merged

Conversation

andrewfullard
Copy link
Contributor

📝 Description

Type: 🚀 feature

Photo- and collisional ionization rates in the new setup.

📌 Resources

Examples, notebooks, and links to useful references.

🚦 Testing

How did you test these changes?

  • Testing pipeline
  • Other method (describe)
  • My changes can't be tested (explain why)

☑️ Checklist

  • I requested two reviewers for this pull request
  • I updated the documentation according to my changes
  • I built the documentation by applying the build_docs label

Note: If you are not allowed to perform any of these actions, ping (@) a contributor.

@tardis-bot
Copy link
Contributor

tardis-bot commented Dec 3, 2024

*beep* *bop*
Hi human,
I ran ruff on the latest commit (a969667).
Here are the outputs produced.
Results can also be downloaded as artifacts here.
Summarised output:

16	W291  	[*] Trailing whitespace
11	E999  	[ ] SyntaxError: Expected ',', found ':'
11	F401  	[ ] `tardis.plasma.equilibrium.rates.collision_strengths.UpsilonCMFGENSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
9	W293  	[*] Blank line contains whitespace
6	G004  	[ ] Logging statement uses f-string
5	E902  	[ ] No such file or directory (os error 2)
4	RET505	[ ] Unnecessary `else` after `return` statement
3	I001  	[*] Import block is un-sorted or un-formatted
2	PTH117	[ ] `os.path.isabs()` should be replaced by `Path.is_absolute()`
2	W292  	[*] No newline at end of file
2	W605  	[*] Invalid escape sequence: `\A`
1	ANN204	[ ] Missing return type annotation for special method `__getitem__`
1	RET506	[ ] Unnecessary `else` after `raise` statement
1	D202  	[*] No blank lines allowed after function docstring (found 1)
1	D406  	[*] Section name should end with a newline ("Returns")
1	D407  	[*] Missing dashed underline after section ("Returns")
1	F541  	[*] f-string without any placeholders

Complete output(might be large):

.github/workflows/benchmarks.yml:3:4: E999 SyntaxError: Expected an expression
.github/workflows/benchmarks.yml:20:5: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:86:49: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:116:81: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:117:54: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:204:1: W293 [*] Blank line contains whitespace
.github/workflows/benchmarks.yml:223:22: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:224:170: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:226:84: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:243:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:7:4: E999 SyntaxError: Expected an expression
.github/workflows/release.yml:94:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:97:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:104:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:107:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:110:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:115:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:119:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:144:23: W292 [*] No newline at end of file
.github/workflows/tests.yml:7:4: E999 SyntaxError: Expected an expression
.mailmap:1:38: E999 SyntaxError: Expected an expression
.mailmap:290:39: W292 [*] No newline at end of file
CHANGELOG.md:4:15: E999 SyntaxError: Expected ',', found ':'
CITATION.cff:3:1: E999 SyntaxError: Invalid annotated assignment target
README.rst:1:1: E999 SyntaxError: Expected a statement
docs/contributing/development/benchmarks.rst:1:1: E999 SyntaxError: Expected a statement
docs/contributing/development/running_tests.rst:1:1: E999 SyntaxError: Expected a statement
docs/contributing/development/running_tests.rst:37:42: W291 [*] Trailing whitespace
docs/contributing/development/running_tests.rst:60:112: W291 [*] Trailing whitespace
docs/contributing/development/running_tests.rst:61:124: W291 [*] Trailing whitespace
docs/contributing/development/running_tests.rst:65:92: W291 [*] Trailing whitespace
docs/contributing/development/running_tests.rst:66:107: W291 [*] Trailing whitespace
docs/contributing/development/running_tests.rst:76:62: W291 [*] Trailing whitespace
docs/io/output/how_to_rpacket_tracking.ipynb:cell 12:1:62: W291 [*] Trailing whitespace
docs/physics/setup/model.ipynb:cell 2:2:1: I001 [*] Import block is un-sorted or un-formatted
docs/physics/setup/model.ipynb:cell 25:19:12: F541 [*] f-string without any placeholders
docs/quickstart.ipynb:cell 12:1:39: W291 [*] Trailing whitespace
docs/quickstart.ipynb:cell 12:5:35: W291 [*] Trailing whitespace
docs/quickstart.ipynb:cell 16:10:26: W605 [*] Invalid escape sequence: `\A`
docs/quickstart.ipynb:cell 16:11:40: W605 [*] Invalid escape sequence: `\A`
docs/resources/credits.rst:1:1: E999 SyntaxError: Expected a statement
docs/workflows/v_inner_solver_workflow.ipynb:1:1: E902 No such file or directory (os error 2)
tardis/io/configuration/config_reader.py:53:29: G004 Logging statement uses f-string
tardis/io/configuration/config_reader.py:117:9: RET505 Unnecessary `else` after `return` statement
tardis/io/configuration/config_reader.py:141:13: RET505 Unnecessary `else` after `return` statement
tardis/io/configuration/config_reader.py:218:29: G004 Logging statement uses f-string
tardis/io/configuration/schemas/montecarlo_definitions.yml:1:13: E999 SyntaxError: Expected an expression
tardis/io/model/parse_geometry_configuration.py:50:12: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
tardis/io/model/parse_radiation_field_configuration.py:118:13: G004 Logging statement uses f-string
tardis/model/base.py:340:12: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
tardis/model/base.py:375:21: G004 Logging statement uses f-string
tardis/opacities/macro_atom/macroatom_state.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/opacities/opacity_state.py:210:9: ANN204 Missing return type annotation for special method `__getitem__`
tardis/opacities/opacity_state.py:216:9: D407 [*] Missing dashed underline after section ("Returns")
tardis/opacities/opacity_state.py:216:9: D406 [*] Section name should end with a newline ("Returns")
tardis/opacities/opacity_state.py:251:5: D202 [*] No blank lines allowed after function docstring (found 1)
tardis/opacities/tests/__init__.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/equilibrium/rates/__init__.py:2:5: F401 `tardis.plasma.equilibrium.rates.collision_strengths.UpsilonCMFGENSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/equilibrium/rates/__init__.py:3:5: F401 `tardis.plasma.equilibrium.rates.collision_strengths.UpsilonRegemorterSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/equilibrium/rates/__init__.py:6:5: F401 `tardis.plasma.equilibrium.rates.collisional_ionization_rates.CollisionalIonizationRateSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/equilibrium/rates/__init__.py:9:5: F401 `tardis.plasma.equilibrium.rates.collisional_ionization_strengths.CollisionalIonizationSeaton` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/equilibrium/rates/__init__.py:12:5: F401 `tardis.plasma.equilibrium.rates.collisional_rates.ThermalCollisionalRateSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/equilibrium/rates/__init__.py:15:5: F401 `tardis.plasma.equilibrium.rates.photoionization_rates.AnalyticPhotoionizationRateSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/equilibrium/rates/__init__.py:16:5: F401 `tardis.plasma.equilibrium.rates.photoionization_rates.EstimatedPhotoionizationRateSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/equilibrium/rates/__init__.py:19:5: F401 `tardis.plasma.equilibrium.rates.photoionization_strengths.AnalyticPhotoionizationCoeffSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/equilibrium/rates/__init__.py:20:5: F401 `tardis.plasma.equilibrium.rates.photoionization_strengths.EstimatedPhotoionizationCoeffSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/equilibrium/rates/__init__.py:21:5: F401 `tardis.plasma.equilibrium.rates.photoionization_strengths.SpontaneousRecombinationCoeffSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/equilibrium/rates/__init__.py:24:5: F401 `tardis.plasma.equilibrium.rates.radiative_rates.RadiativeRatesSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/radiation_field/validate_radiation_field.py:1:1: E902 No such file or directory (os error 2)
tardis/spectrum/formal_integral.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/spectrum/formal_integral.py:358:13: RET506 Unnecessary `else` after `raise` statement
tardis/spectrum/formal_integral.py:698:5: RET505 Unnecessary `else` after `return` statement
tardis/spectrum/formal_integral.py:734:5: RET505 Unnecessary `else` after `return` statement
tardis/workflows/simple_tardis_workflow.py:230:17: G004 Logging statement uses f-string
tardis/workflows/simple_tardis_workflow.py:449:17: G004 Logging statement uses f-string
tardis/workflows/util.py:1:1: E902 No such file or directory (os error 2)
tardis/workflows/v_inner_solver.py:1:1: E902 No such file or directory (os error 2)
Found 77 errors.
[*] 36 fixable with the `--fix` option.

Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 37.71930% with 71 lines in your changes missing coverage. Please review.

Project coverage is 69.17%. Comparing base (cc0b125) to head (a969667).
Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
...sma/equilibrium/rates/photoionization_strengths.py 38.59% 35 Missing ⚠️
.../plasma/equilibrium/rates/photoionization_rates.py 34.78% 15 Missing ⚠️
...ilibrium/rates/collisional_ionization_strengths.py 39.13% 14 Missing ⚠️
.../equilibrium/rates/collisional_ionization_rates.py 36.36% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2897      +/-   ##
==========================================
- Coverage   70.39%   69.17%   -1.22%     
==========================================
  Files         221      228       +7     
  Lines       16147    16427     +280     
==========================================
- Hits        11366    11363       -3     
- Misses       4781     5064     +283     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@andrewfullard andrewfullard marked this pull request as ready for review January 15, 2025 22:05
@tardis-bot
Copy link
Contributor

*beep* *bop*

Hi, human.

The docs workflow has succeeded ✔️

Click here to see your results.

@tardis-bot
Copy link
Contributor

*beep* *bop*
Hi human,
I ran benchmarks as you asked comparing master (cc0b125) and the latest commit (705c2ba).
Here are the logs produced by ASV.
Results can also be downloaded as artifacts here.

Significantly changed benchmarks:

All benchmarks:

Benchmarks that have stayed the same:

| Change   | Before [5e2d0bb3] <master>   | After [705c2baa]    | Ratio   | Benchmark (Parameter)                                                                                                               |
|----------|------------------------------|---------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------|
|          | 22.1±5μs                     | 30.0±8μs            | ~1.36   | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list |
|          | 551±200ns                    | 631±100ns           | ~1.15   | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_pair_creation_opacity_calculation                                |
|          | 41.5±30μs                    | 47.3±30μs           | ~1.14   | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_emission                                         |
|          | 3.09±0.3μs                   | 3.41±0.2μs          | ~1.10   | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_within_shell                              |
|          | 6.55±0.9μs                   | 5.64±1μs            | ~0.86   | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket                                           |
|          | 2.68±0ms                     | 2.88±0.03ms         | 1.07    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('scatter')                                     |
|          | 2.28±1μs                     | 2.45±2μs            | 1.07    | transport_montecarlo_estimators_radfield_estimator_calcs.BenchmarkMontecarloMontecarloNumbaPacket.time_update_line_estimators       |
|          | 39.0±0.1s                    | 40.6±0.01s          | 1.04    | run_tardis.BenchmarkRunTardis.time_run_tardis                                                                                       |
|          | 48.2±30μs                    | 50.3±60μs           | 1.04    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_scatter                                          |
|          | 3.98±0.05ms                  | 4.11±0.01ms         | 1.03    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('macroatom')                                   |
|          | 1.21±0μs                     | 1.22±0μs            | 1.01    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_boundary                |
|          | 1.06±0m                      | 1.05±0m             | 0.99    | run_tardis.BenchmarkRunTardis.time_run_tardis_rpacket_tracking                                                                      |
|          | 2.11±0.01m                   | 2.09±0m             | 0.99    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_FormalIntegrator_functions                                 |
|          | 206±0.4ns                    | 204±0.03ns          | 0.99    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_intensity_black_body                                       |
|          | 3.27±0.01μs                  | 3.25±0.5μs          | 0.99    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_bad_vpacket                                       |
|          | 7.36±2μs                     | 7.27±2μs            | 0.99    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_volley                                    |
|          | 40.5±0.03μs                  | 39.7±0.1μs          | 0.98    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list                  |
|          | 65.9±0.2ms                   | 64.6±0.3ms          | 0.98    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe                  |
|          | 762±1ns                      | 737±0.8ns           | 0.97    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_thomson_scatter                                       |
|          | 1.78±0.01ms                  | 1.72±0.01ms         | 0.97    | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop                             |
|          | 561±100ns                    | 531±200ns           | 0.95    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_compton_opacity_calculation                                      |
|          | 2.84±0.4ms                   | 2.69±0.5ms          | 0.95    | transport_montecarlo_single_packet_loop.BenchmarkTransportMontecarloSinglePacketLoop.time_single_packet_loop                        |
|          | 601±200ns                    | 561±100ns           | 0.93    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_photoabsorption_opacity_calculation                              |
|          | 1.69±0.6μs                   | 1.57±0.3μs          | 0.93    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_line                    |

If you want to see the graph of the results, you can check it here

@@ -0,0 +1,368 @@
{
Copy link
Contributor

@jvshields jvshields Jan 22, 2025

Choose a reason for hiding this comment

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

Line #21.    home = str(Path('~').expanduser())

I assume this notebook won't be be part of the final PR because of these paths? I do think it would be nice to include a notebook with very similar content to this just demonstrating how somebody would build their own level populations the way you do here.


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm planning to keep it around for now as a first-pass of this kind of documentation. I don't want it only on my local copy.

@@ -0,0 +1,368 @@
{
Copy link
Contributor

@jvshields jvshields Jan 22, 2025

Choose a reason for hiding this comment

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

Line #1.    spontaneous_recombination_rate_old = pd.read_csv("spontaneous_recomb.csv", index_col=[0, 1, 2])

Pretty sure I understand what this is coming from, but for the sake of reviewing this PR can you mention the differences between how it was being calculated before and now? Is it just the workflow prescription? At some point I was under the impression this is new calculations that we weren't doing before, so I'm not sure how we had recombination rates calculated with previous code.


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment on this. The previous data were recovered from a combination of the old plasma and the way Jack set up his continuum properties solver.

@jvshields
Copy link
Contributor

I like this PR a lot and don't have comments for the code. Well documented generally and does a good job linking back to the reference equations. I have some questions about the notebook but am happy to approve this when you need the approval.

@andrewfullard andrewfullard merged commit ae02584 into tardis-sn:master Jan 22, 2025
10 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants