-
Notifications
You must be signed in to change notification settings - Fork 17
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
Update neutrino.py #189
Update neutrino.py #189
Conversation
SNEWPY v 2.0 will require mass splittings
Adding mass squared differences as optional input into the three-flavo(u)r transformation classes (except 3-flavor decoherence)
The test failures are unrelated, should be fixed in #190. |
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.
As far as I understand, you want to have the possibility to override the mixing parameters for the FlavorTransformations
. Would it make sense to modify these values in the MixingParameters
class instance, and then pass this instance to the transformation, for example:
my_params = MixingParameters(MassHierarchy.NORMAL)
my_params.theta12 = 45 * u.deg
my_params.theta13 = 0 * u.deg
my_params.theta23 = 45 * u.deg
my_params.dm21_2 = 1.234e-5 * u.eV**2
my_params.dm32_2 = 5.678e-3 * u.eV**2
flavor_xform = AdiabaticMSW(my_params)
This would reduce the amount of repeating code and also the number of arguments in the constructor.
I suggest:
-
Make
MixingParameters
a dataclass (so it will be more clear for the user, that this is a container class, and all the parameters' types and units will be documented). For example: -
Make each
FlavorTransformation
class constructor to receive onlyMixingParameters
(or leave the constructors as is, if we want backward compatibility, but create construction classmethods? But the constructor change is more natural way)
You're right, that is probably a better solution. |
I removed the mass_squared_differences argument and now assign the default values based on the mh argument. |
pars = MixingParameters(mh) | ||
deltam21_2, deltam31_2, deltam32_2 = pars.get_mass_square_differences() |
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.
Now the problem is that pars
just gets generated each time, so it will hold only the default best fit values for the given mh
.
I suggest just directly pass MixingParameters instance here into flavor transformation constructor
This PR has been stale for some time. I suggest to:
so one can tweak the initial #create parameters
pars = MixingParameters(MassHierarchy.NORMAL)
#change mixing angle
pars.theta12 = 180<<u.deg
#pass parameters to new transformation
transform = AdiabaticMSW(pars) @jpkneller if you agree, I can implement this, and commit to this branch. |
I agree but does this break backwards compatibility? Are we starting version 2.0? If yes, I have other suggestions for changes. |
@Sheshuk: If we turn >>> from dataclasses import dataclass
>>> @dataclass
... class MixingParameters:
... theta12: float = 33.41
... theta13: float = 8.58
... theta23: float = 42.20
...
>>> f = MixingParameters()
>>> f
MixingParameters(theta12=33.41, theta13=8.58, theta23=42.2)
>>> g = MixingParameters()
>>> g.theta14 = 0.001 # additional attributes can be added …
>>> g # … but are not displayed …
MixingParameters(theta12=33.41, theta13=8.58, theta23=42.2)
>>> f == g # … and not used for comparisons(!)
True
>>> f.theta14
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'MixingParameters' object has no attribute 'theta14'
>>> g.theta14
0.001 I guess we could include all non-standard parameters that are used by at least one transformation in the dataclass, and then just set the ones that aren’t applicable to @jpkneller Yes, it would; e.g. sntools is using things like |
That's right, this might be problematic. Having @dataclass
class MixingParameters:
theta12: float = 33.41
theta13: float = 8.58
theta23: float = 42.20
@dataclass
class MixingParametersSterile(MixingParameters):
theta14:float = 0
par = MixingParametersSterile(theta12=45, theta14=30) however we don't have an easy and explicit way of extending existing parameters, which would be really nice: par = MixingParameters()
par1 =MixingParametersSterile(par, theta14) So I think your proposal to include additional parameters with zero default values is better. |
I think Andrey's solution for the cases where we have sterile neutrinos is a good one. |
Right now there are two additional changes I would like to make to the Flavor Transformations. The first is to replace the 8 prob_xy methods with one method (get_probabilities) that returns a 2D matrix of probabilities. The [x][y] element of the matrix is the probability that nu_y -> nu_x. The second change I would like to make is to add an additional argument altaz into the constructor for future Earth matter effect calculations. |
I've added issue #242 for this. Probably this can be a backward-compatible change - we can still keep the
Do you mean adding it to the |
That's okay with me.
Yes. Right now we can only do Earth matter effect calculations for 3 flavor neutrinos, not 4. The plan I have of how to implement Earth matter effects is that if the AltAz argument to the constructor of whichever FlavorTransformation class the user has picked is not None, we will store the coordinates of the supernova and then when the user calls the get_probabilities method and supplies a neutrino energy (or provides a list of them) we will call a routine in a separate module which I have written which does the Earth matter effect calculation and use its results in place of the three parameters which are called De1, De2 and De3. |
Can you take a look at the “composite flavour transformations” @sybenzvi worked on in #203 and check if that would work for you? The idea behind that PR was to make it easy to add Earth matter effect (or any other transformations, if it makes physical sense) on top of other |
I think this could be made to work. I want to check the math because SNEWPY doesn't distinguish between mu and tau neutrinos and calls them the x flavor, and the probabilities involving x have additional factors of 2 floating around. |
SNEWPY v 2.0 will require mass splittings