-
Notifications
You must be signed in to change notification settings - Fork 22
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
Sheshuk/flavor transformations with flavor matrices #351
base: release_v2.0
Are you sure you want to change the base?
Sheshuk/flavor transformations with flavor matrices #351
Conversation
…FlavorDecoherence
Comment from @Sheshuk (2024-08-13): some classes are implementing all flavor transformations. Others are handling transformations only in certain environments, e.g., in Earth or in vacuum. As a result, the matrix outputs are not consistent or equivalent across all classes (e.g., flavor-to-flavor, flavor-to-mass, mass-to-mass, etc.). This needs to be checked carefully in the code to ensure that mixing operations between the classes is not allowed if physically the transformations should not be mixed. All classes inherit from |
Finally I think this is ready for review. What I did
Next steps (to be done in separate PRs):
|
One more thing: I had to swap the formulas for NMO and IMO for NeutrinoDecay in the tests: 09735b5 I'm not sure this is correct. we need a cross-check |
Thanks a lot for this work @Sheshuk! Sorry it’s taking me a while to review this; I’m still looking through the code but wanted to get at least some high level comments to you now:
This class structure looks really good to me. Just two comments:
This is really nice for readability!
At first glance, that makes sense to me; but happy to revisit it later.
That makes sense; I’ll largely skip that during my review. And a first comment on the code: snewpy/python/snewpy/flavor_transformation/transforms.py Lines 116 to 119 in d8664a6
The TransformationChain instances are currently saving the transforms in two different places; can we simplify that?
|
* If SNOSHEWS/BEMEWS import fails: only catch ModuleNotFoundError, which we re-throw later * Ensure MassHierarchy is imported from snewpy.neutrino consistently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Individual comments are at the appropriate line in the code.
Regarding the code arrangement in flavor_transformation/
:
In addition to the in_*
submodules (which makes sense), there are three fairly generic submodules (__init__.py
, base.py
and transforms.py
) and it’s not obvious to me what code goes where. My intuition would probably be to drop transforms.py
by putting NoTransformation
/CompleteExchange
/ThreeFlavorDecoherence
into __init__.py
(alongside the backwards-compatible transformation chains) and moving FlavorTransformation
and TransformationChain
into base.py
?
Finally, I added a commit cleaning up unused imports.
@JostMigenda thanks a lot for your review!
Yes, it is correct. I also don't like it being asymmetric, so if you have any idea of making it more clear for the user, please tell.
I agree, But probably we should do the renaming in a separate PR, it will be rather straightforward.
Sure. I can make
That makes sense, thank you, I'll do that! The only classes standing out here are |
Co-authored-by: Jost Migenda <[email protected]>
Co-authored-by: Jost Migenda <[email protected]>
On second thought, this makes a circular import: |
* move transformation presets to __init__.py * move FlavorTransformation base class to base.py
Better reflects the contents of the file.
Hm … good point; I can see it being very confusing if
Yep, let’s do that! I’ve created #366 to keep track of it.
It would certainly eliminate any risk of bugs where we change e.g. >>> from collections import namedtuple
>>> Transformations = namedtuple('Transformations', 'in_sn, in_vacuum, in_earth')
>>> transforms = Transformations('AdiabaticMSW', 'NoVacuumTransformation', 'NoEarthMatter')
>>> for t in transforms:
... print(t)
...
AdiabaticMSW
NoVacuumTransformation
NoEarthMatter
>>> transforms.in_vacuum
'NoVacuumTransformation' In particular, the current design doesn’t make it clear that iterating over
I guess they are more of a mix-in than a base class; but I’m fine with that.
Oh, good point! After thinking about it for a while, I think the main issue is the
The first of these should probably be |
…_suggested_restructuring Suggested restructuring of `snewpy.flavor_transformations` submodules
Good idea, that's perfect use case for that. I also like I'll do it now. |
I'm glad you caught this. I checked the formulas, they are now correct. I must have mixed up NMO and IMO. |
To be merged after #350
In this PR I do the following:
FlavorMatrix
class everywhere inget_probabilities
Three/FourFlavorTransformation.Pmf_HighDensityLimit
methods toThree/FourFlavorMixingParameters.Pmf_HighDensityLimit
- I think they belong next there, next toVacuumMixingMatrix
EarthMatter
transform (based on BEMEWS)MSWEffect
transform (based on SNOSHEWS)