SNEWS2 / snewpy

A Python package for working with supernova neutrinos
https://snewpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
26 stars 19 forks source link

First pass at composite transformations. #203

Closed sybenzvi closed 5 days ago

sybenzvi commented 2 years ago

This PR is designed to address issue #183 by implementing a simple class to compose an arbitrary list of flavor transformations.

If instantiated as follows, c = CompositeTransformation(U1, U2, ..., Un) where U1, U2, etc. are different FlavorTransformation objects, the class will apply the transformations in the order supplied to the CompositeTransformation. I.e., U1 will be applied first, then U2, and so on to Un.

Unit tests need to be added to the branch before we proceed with the merger.

github-actions[bot] commented 2 years ago

Result of Benchmark Tests

Benchmark Min Max Mean
python/snewpy/test/test_snowglobes.py::test_simulation_chain_benchmark 4.18 4.29 4.24 +- 0.05
sybenzvi commented 2 years ago

Comment about the guts of CompositeTransformation: internally it performs matrix multiplication of the composed unitary transformations. The composite matrix is not supposed to be accessed by users, who should use the survival and transition probability functions prob_ee(t, E) etc. provided by the base class. For efficiency, the calculation of the transformation matrix is memoized so that it is not recalculated for all transition probabilities unless the input time and energy arguments change.

On this topic, the following checks should be completed:

JostMigenda commented 2 years ago

At first glance, this looks good to me; thanks! I would also suggest updating the FlavorTransformation.ipynb to add an example for this composite transformation.

jpkneller commented 1 year ago

The idea is a good one but the present implementation of the flavor transformations in SNEWPY means that there are only limited circumstances where you can string together flavor transformations. The neutrinos would have to decohere between the transformations being applied and the only flavor transformation we have in SNEWPY which occurs outside the supernova is neutrino decay.

jpkneller commented 1 year ago

I checked the math and it turns out chaining together SNEWPY's flavor transformations cannot be done even if the previously mentioned restriction that the neutrinos decohere between transformations is valid. Attached is a proof. proof.pdf

JostMigenda commented 1 year ago

Thanks for checking this and writing it up! If I understand correctly, there’s two different ways we could fix this:

  1. If we switch to six-flavour oscillations (see #99), we wouldn’t need the L and R matrices anymore
  2. If we stick with four-flavour oscillations, we could calculate the self.De1, self.De2 etc. in the __init__ function (as we already do for many of the existing transformations) and then use those in the calculation to compose flavour transformations.
jpkneller commented 1 year ago

Either option should work. The second is the easiest and I know what to do. I haven't looked at how much of the code would have to change if we went to 6 flavors though it's something we said we'd do.

sybenzvi commented 5 days ago

This PR is superseded by several other efforts to handle flavor transformations and is now obsolete. Closing without merging.