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

Refactor isotope mass fraction handling and configuration #2974

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wkerzendorf
Copy link
Member

  • Remove raw_isotope_abundance from Composition class
  • Update mass fraction parsing to conditionally apply isotope decay
  • Modify default model_isotope_time_0 to -1 s to allow skipping decay
  • Update test fixtures to explicitly set model_isotope_time_0
  • Simplify mass fraction parsing functions by removing redundant returns

- Remove raw_isotope_abundance from Composition class
- Update mass fraction parsing to conditionally apply isotope decay
- Modify default model_isotope_time_0 to -1 s to allow skipping decay
- Update test fixtures to explicitly set model_isotope_time_0
- Simplify mass fraction parsing functions by removing redundant returns
@tardis-bot
Copy link
Contributor

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

2	W293  	[*] Blank line contains whitespace
2	F401  	[*] `radioactivedecay.converters` imported but unused
1	B020  	[ ] Loop control variable `isotope_dict` overrides iterable it iterates
1	RET505	[ ] Unnecessary `else` after `return` statement
1	PTH117	[ ] `os.path.isabs()` should be replaced by `Path.is_absolute()`
1	I001  	[*] Import block is un-sorted or un-formatted
1	E999  	[ ] SyntaxError: Expected an expression

Complete output(might be large):

tardis/energy_input/tests/test_gamma_ray_channel.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/energy_input/tests/test_gamma_ray_channel.py:8:30: F401 [*] `radioactivedecay.converters` imported but unused
tardis/energy_input/tests/test_gamma_ray_channel.py:13:5: F401 [*] `tardis.energy_input.energy_source.get_nuclear_lines_database` imported but unused
tardis/energy_input/tests/test_gamma_ray_channel.py:118:9: B020 Loop control variable `isotope_dict` overrides iterable it iterates
tardis/io/configuration/schemas/model_definitions.yml:2:13: E999 SyntaxError: Expected an expression
tardis/io/configuration/schemas/model_definitions.yml:164:1: W293 [*] Blank line contains whitespace
tardis/io/configuration/schemas/model_definitions.yml:210:1: W293 [*] Blank line contains whitespace
tardis/io/model/parse_mass_fraction_configuration.py:62:12: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
tardis/model/matter/composition.py:204:9: RET505 Unnecessary `else` after `return` statement
Found 9 errors.
[*] 5 fixable with the `--fix` option.

Copy link

codecov bot commented Feb 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.18%. Comparing base (13c9a31) to head (7c2e477).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2974      +/-   ##
==========================================
- Coverage   69.54%   69.18%   -0.36%     
==========================================
  Files         228      228              
  Lines       16429    16433       +4     
==========================================
- Hits        11425    11369      -56     
- Misses       5004     5064      +60     

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

@andrewfullard andrewfullard marked this pull request as draft February 17, 2025 15:42
@andrewfullard andrewfullard self-requested a review February 17, 2025 15:42
@tardis-bot
Copy link
Contributor

*beep* *bop*
Hi human,
I ran benchmarks as you asked comparing master (13c9a31) and the latest commit (7c2e477).
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 [13c9a314] <release-2025.02.16>   | After [7c2e4778]    | Ratio   | Benchmark (Parameter)                                                                                                               |
|----------|------------------------------------------|---------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------|
|          | 521±100ns                                | 581±90ns            | ~1.12   | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_compton_opacity_calculation                                      |
|          | 1.68±0.5μs                               | 1.51±0.2μs          | ~0.90   | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_line                    |
|          | 3.87±0.6μs                               | 3.41±0.6μs          | ~0.88   | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_within_shell                              |
|          | 581±100ns                                | 491±100ns           | ~0.85   | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_pair_creation_opacity_calculation                                |
|          | 3.18±0.6ms                               | 2.64±0.4ms          | ~0.83   | transport_montecarlo_single_packet_loop.BenchmarkTransportMontecarloSinglePacketLoop.time_single_packet_loop                        |
|          | 4.01±0.5ms                               | 3.06±0.07ms         | ~0.76   | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('scatter')                                     |
|          | 66.6±20μs                                | 42.7±20μs           | ~0.64   | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_scatter                                          |
|          | 64.7±0.4ms                               | 69.4±2ms            | 1.07    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe                  |
|          | 2.62±0.7μs                               | 2.74±0.5μs          | 1.05    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_bad_vpacket                                       |
|          | 7.07±2μs                                 | 7.39±2μs            | 1.05    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_volley                                    |
|          | 38.6±0.02s                               | 39.9±0.2s           | 1.04    | run_tardis.BenchmarkRunTardis.time_run_tardis                                                                                       |
|          | 40.9±20μs                                | 42.4±20μs           | 1.04    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_emission                                         |
|          | 3.98±0.02ms                              | 4.10±0.04ms         | 1.03    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('macroatom')                                   |
|          | 1.05±0m                                  | 1.06±0m             | 1.01    | run_tardis.BenchmarkRunTardis.time_run_tardis_rpacket_tracking                                                                      |
|          | 206±0.1ns                                | 207±0.2ns           | 1.01    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_intensity_black_body                                       |
|          | 581±200ns                                | 581±200ns           | 1.00    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_photoabsorption_opacity_calculation                              |
|          | 2.08±0m                                  | 2.09±0m             | 1.00    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_FormalIntegrator_functions                                 |
|          | 1.21±0μs                                 | 1.20±0μs            | 0.99    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_boundary                |
|          | 742±80ns                                 | 731±0.4ns           | 0.99    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_thomson_scatter                                       |
|          | 27.8±8μs                                 | 27.5±8μs            | 0.99    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list |
|          | 2.40±1μs                                 | 2.33±1μs            | 0.97    | transport_montecarlo_estimators_radfield_estimator_calcs.BenchmarkMontecarloMontecarloNumbaPacket.time_update_line_estimators       |
|          | 39.9±0.03μs                              | 38.7±0.04μs         | 0.97    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list                  |
|          | 1.76±0ms                                 | 1.68±0ms            | 0.95    | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop                             |
|          | 6.90±0.9μs                               | 6.39±0.7μs          | 0.93    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket                                           |

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

@@ -181,7 +181,7 @@ definitions:
description: filename
model_isotope_time_0:
type: quantity
default: 0 s
default: -1 s
Copy link
Contributor

Choose a reason for hiding this comment

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

Why -1? Doesn't that mean something different?

Copy link
Member Author

Choose a reason for hiding this comment

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

it mens we are using the exact same time as time_explosion. Can put in the description if that helps.

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.

4 participants