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

Flexible packet initial radius #1592

Merged

Conversation

andrewfullard
Copy link
Contributor

@andrewfullard andrewfullard commented May 26, 2021

Description

The PacketCollection now includes the initial radius of packets. For the BlackBodySource this is just the inner radius of the ejecta.

Motivation and context

Preparation for creating packets without the inner radius set explicitly to the model inner radius e.g. for nebular phase

How has this been tested?

  • Testing pipeline.
  • Other.

Examples

Type of change

  • Bug fix.
  • New feature.
  • Breaking change.
  • None of the above.

Checklist

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
    • (optional) I have built the documentation on my fork following the instructions.
  • I have assigned and requested two reviewers for this pull request.

@codecov
Copy link

codecov bot commented May 26, 2021

Codecov Report

Merging #1592 (0c9deea) into master (351cc8f) will decrease coverage by 0.00%.
The diff coverage is n/a.

❗ Current head 0c9deea differs from pull request most recent head 6ce0c55. Consider uploading reports for the commit 6ce0c55 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1592      +/-   ##
==========================================
- Coverage   67.20%   67.20%   -0.01%     
==========================================
  Files          73       73              
  Lines        6147     6150       +3     
==========================================
+ Hits         4131     4133       +2     
- Misses       2016     2017       +1     
Impacted Files Coverage Δ
...dis/montecarlo/montecarlo_numba/numba_interface.py 49.62% <0.00%> (-0.38%) ⬇️
tardis/tardis/montecarlo/montecarlo_numba/base.py 29.62% <0.00%> (ø)
...rdis/montecarlo/montecarlo_numba/tests/conftest.py 91.11% <0.00%> (ø)
...dis/montecarlo/montecarlo_numba/tests/test_base.py 100.00% <0.00%> (ø)
tardis/tardis/montecarlo/base.py 88.64% <0.00%> (+0.06%) ⬆️
tardis/tardis/montecarlo/packet_source.py 97.29% <0.00%> (+0.07%) ⬆️

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 351cc8f...6ce0c55. Read the comment docs.

Copy link
Contributor

@chvogl chvogl left a comment

Choose a reason for hiding this comment

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

This looks good and sets the groundwork for treating different energy input modes in TARDIS.

@@ -166,7 +166,7 @@ def _initialize_geometry_arrays(self, model):
self.r_outer_cgs = model.r_outer.to("cm").value
self.v_inner_cgs = model.v_inner.to("cm/s").value

def _initialize_packets(self, T, no_of_packets, iteration):
def _initialize_packets(self, T, no_of_packets, iteration, radius):
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really related to this PR but maybe we should rename T (e.g. temperature).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. For the restructuring to come!

Copy link
Member

Choose a reason for hiding this comment

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

can we make this an issues

@@ -175,10 +175,11 @@ def _initialize_packets(self, T, no_of_packets, iteration):
seed = self.seed + iteration
rng = np.random.default_rng(seed=seed)
seeds = rng.choice(MAX_SEED_VAL, no_of_packets, replace=True)
nus, mus, energies = self.packet_source.create_packets(
T, no_of_packets, rng
radii, nus, mus, energies = self.packet_source.create_packets(
Copy link
Contributor

Choose a reason for hiding this comment

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

I am wondering if the radius/radii should be an attribute of the packet_source. In the case of the BlackBodySimpleSource, it would be set to r_inner by default. This way we might avoid passing this information through multiple layers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly, but we also expect the radius to be different for different packets in the nebular phase. So it needs to be an array of radii corresponding to the energy deposition radius.

Copy link
Member

Choose a reason for hiding this comment

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

I think there are all sorts of potential ways to configure this - but for now I think it's fine how it is.

Copy link
Member

@wkerzendorf wkerzendorf left a comment

Choose a reason for hiding this comment

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

Approved with minor changes 😉

@@ -166,7 +166,7 @@ def _initialize_geometry_arrays(self, model):
self.r_outer_cgs = model.r_outer.to("cm").value
self.v_inner_cgs = model.v_inner.to("cm/s").value

def _initialize_packets(self, T, no_of_packets, iteration):
def _initialize_packets(self, T, no_of_packets, iteration, radius):
Copy link
Member

Choose a reason for hiding this comment

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

can we make this an issues

@@ -175,10 +175,11 @@ def _initialize_packets(self, T, no_of_packets, iteration):
seed = self.seed + iteration
rng = np.random.default_rng(seed=seed)
seeds = rng.choice(MAX_SEED_VAL, no_of_packets, replace=True)
nus, mus, energies = self.packet_source.create_packets(
T, no_of_packets, rng
radii, nus, mus, energies = self.packet_source.create_packets(
Copy link
Member

Choose a reason for hiding this comment

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

I think there are all sorts of potential ways to configure this - but for now I think it's fine how it is.

tardis/montecarlo/packet_source.py Show resolved Hide resolved
@andrewfullard andrewfullard merged commit c25ea7e into tardis-sn:master Jun 1, 2021
@isaacgsmith isaacgsmith mentioned this pull request Jun 1, 2021
10 tasks
atharva-2001 pushed a commit to atharva-2001/tardis that referenced this pull request Oct 1, 2021
* Packet collections are initialized with a radius

* Docstring for create_packets
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