Skip to content

Conversation

@JostMigenda
Copy link
Member

Changes by @jpkneller to close #384. Should be merged after #351.

My review comments to follow in a bit …

jpkneller added 3 commits May 12, 2025 15:07
Renamed ThreeFlavorDecoherence to Equilibrate.
Added ThreeFlavorDecoherence class.
Added Equilibrate and ThreeFlavorDecoherence to autoclass lists
@JostMigenda
Copy link
Member Author

JostMigenda commented May 12, 2025

  • Unit tests and integration tests are currently failing due to these changes
  • With the third commit, we now have ThreeFlavorDecoherence (defined as TransformationChain(in_sn.ThreeFlavorDecoherence())) and Equilibrate in __init__.py. What (if anything) is the difference between them?
  • What about TwoFlavorDecoherence? Do we have the same situation there and would it make sense to split that up into a “black box” transformation and a separate in_sn transformation as well?

@Sheshuk
Copy link
Contributor

Sheshuk commented May 12, 2025

I like the idea of this splitting! But as a user I would find a class name Equilibrate misleading: it's a verb, while all other classes are nouns

@jpkneller
Copy link
Contributor

Unit tests and integration tests are currently failing due to these changes

I missed some consequences of the changes. It looks like the dictionaries in snowglobes.py are having problems.

With the third commit, we now have ThreeFlavorDecoherence (defined as TransformationChain(in_sn.ThreeFlavorDecoherence())) and Equilibrate in __init__.py. What (if anything) is the difference between them?

It's subtle. Equilibrate != ThreeFlavorDecoherence if in_vacuum != None in a TransformationChain object. Both are useful.

What about TwoFlavorDecoherence? Do we have the same situation there and would it make sense to split that up into a “black box” transformation and a separate in_sn transformation as well?

I don't think a 'black box' version of TwoFlavorDecoherence adds anything useful. It is almost the same as the CompleteExchange prescription.

@jpkneller
Copy link
Contributor

I like the idea of this splitting! But as a user I would find a class name Equilibrate misleading: it's a verb, while all other classes are nouns

Let's change it to Equilibration or FlavorEquilibration then.

@jpkneller
Copy link
Contributor

I like the idea of this splitting! But as a user I would find a class name Equilibrate misleading: it's a verb, while all other classes are nouns

Let's change it to Equilibration or FlavorEquilibration then.

I changed i to FlavorEquilibration

@jpkneller jpkneller marked this pull request as ready for review May 13, 2025 14:42
@Sheshuk Sheshuk added this to the v2.0 milestone May 26, 2025
Base automatically changed from Sheshuk/FlavorTransformations_with_FlavorMatrices to main June 18, 2025 10:55
@JostMigenda
Copy link
Member Author

Fixed a merge conflict with the main branch and reverted an accidental change that caused SyntaxErrors across all tests. Now the failing integration tests are due to the same remaining notebook issues that are also present on the main branch right now; but the failing unit test is specific to this PR.

@JostMigenda
Copy link
Member Author

With the third commit, we now have ThreeFlavorDecoherence (defined as TransformationChain(in_sn.ThreeFlavorDecoherence())) and Equilibrate in __init__.py. What (if anything) is the difference between them?

It's subtle. Equilibrate != ThreeFlavorDecoherence if in_vacuum != None in a TransformationChain object. Both are useful.

But the ThreeFlavorDecoherence defined at https://github.com/SNEWS2/snewpy/pull/385/files#diff-e680a3b29b6442c77439d1b901a0556c6b9d0893ffa8a04a84447b9759b9e1eeR74 does have the in_vacuum transformation set to None. So is there a difference between it and Equilibrate FlavorEquilibration?

(I understand they are different from the in_sn.ThreeFlavorDecoherence, which can be used as part of a TransformationChain alongside a nontrivial vacuum transformation.)

Comment on lines 85 to 89
def P_mf(self, t, E):
@FlavorMatrix.from_function(ThreeFlavor)
def P(f1, f2):
return (f1.is_neutrino == f2.is_neutrino)*1/3.
return P
Copy link
Member Author

Choose a reason for hiding this comment

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

This implementation seems to be just copied over from the flavor_transformation/__init__.py? Unfortunately, that doesn’t work. For one, the ThreeFlavor import from snewpy.flavor is missing in this file; but even if I add that, I get an error trying to use this:

import snewpy.flavor_transformation as ft
from snewpy.neutrino import MassHierarchy, MixingParameters

NMO = MixingParameters(MassHierarchy.NORMAL)
TFD = ft.ThreeFlavorDecoherence(NMO)  # <- TransformationChain that uses `in_sn.ThreeFlavorDecoherence`
TFD.P_ff(0,0)  # <- raises an AssertionError: Incompatible spaces <enum 'ThreeFlavor_MassBasis'>!=<enum 'ThreeFlavor'>

Copy link
Member Author

Choose a reason for hiding this comment

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

Full traceback:

>>> TFD.P_ff(0,0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    TFD.P_ff(0,0)
    ~~~~~~~~^^^^^
  File "/opt/miniconda3/envs/snewpy/lib/python3.13/site-packages/snewpy/flavor_transformation/TransformationChain.py", line 60, in P_ff
    return self.transforms.in_earth.P_fm(t,E) @ \
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           self.transforms.in_vacuum.P_mm(t,E) @ \
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
           self.transforms.in_sn.P_mf(t,E)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  File "/opt/miniconda3/envs/snewpy/lib/python3.13/site-packages/snewpy/flavor.py", line 197, in __matmul__
    assert self.flavor_in==other.flavor_out, f"Incompatible spaces {self.flavor_in}!={other.flavor_out}"
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Incompatible spaces <enum 'ThreeFlavor_MassBasis'>!=<enum 'ThreeFlavor'>

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I fixed this.

@jpkneller
Copy link
Contributor

jpkneller commented Oct 16, 2025

You're right, we don't need FlavorEquilibration.

jpkneller and others added 3 commits October 16, 2025 11:02
Fixed P_mf in ThreeFlavorDecoherence. 
Added FourFlavorDecoherence for fun
@JostMigenda
Copy link
Member Author

Thanks, I think that addresses all remaining issues. I just added a small fix for the corresponding unit test.

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.

Split ThreeFlavorDecoherence into “black box” and in_sn transformations

4 participants