diff --git a/python/snewpy/models/ccsn.py b/python/snewpy/models/ccsn.py index 86ba9612..97c5eba8 100644 --- a/python/snewpy/models/ccsn.py +++ b/python/snewpy/models/ccsn.py @@ -814,8 +814,8 @@ class Mori_2023(_RegistryModel): _param_validator = lambda p: \ (p['axion_mass'] == 0 and p['axion_coupling'] == 0) or \ - (p['axion_mass'] == 100 and p['axion_coupling'] in (2,4,10,12,14,16,20)) or \ - (p['axion_mass'] == 200 and p['axion_coupling'] in (2,4,6,8,10,20)) + (p['axion_mass'].to_value('MeV') == 100 and p['axion_coupling'].to_value('1e-10/GeV') in (2,4,10,12,14,16,20)) or \ + (p['axion_mass'].to_value('MeV') == 200 and p['axion_coupling'].to_value('1e-10/GeV') in (2,4,6,8,10,20)) _param_abbrv = { 'axion_mass': '[0, 100, 200] MeV', @@ -831,18 +831,44 @@ def __new__(cls, axion_mass, axion_coupling): axion_coupling: int Axion-photon coupling, in units of 1e-10/GeV. Valid values are {axion_coupling}. """ + # Make sure axion coupling is converted to units 1e-10/GeV: + axion_coupling = np.round(axion_coupling.to('1e-10/GeV')) + # Load from Parameters cls.check_valid_params(cls, axion_mass=axion_mass, axion_coupling=axion_coupling) if axion_mass == 0: filename = 't-prof_std.dat' else: - filename = f't-prof_{axion_mass.to_value("MeV")}_{axion_coupling.to_value("1e-10/GeV")}.dat' - + filename = f't-prof_{axion_mass.to_value("MeV"):g}_{axion_coupling.to_value("1e-10/GeV"):g}.dat' + + # PNS mass table, from Mori+ 2023. + mpns = { (0, 0): 1.78, + (100, 2): 1.77, + (100, 4): 1.76, + (100, 10): 1.77, + (100, 12): 1.77, + (100, 14): 1.77, + (100, 16): 1.77, + (100, 20): 1.74, + (200, 2): 1.77, + (200, 4): 1.76, + (200, 6): 1.75, + (200, 8): 1.74, + (200, 10): 1.73, + (200, 20): 1.62 } + + am = int(axion_mass.to_value('MeV')) + ac = int(axion_coupling.to_value('1e-10/GeV')) + pns_mass = mpns[(am,ac)] + + # Set the metadata. metadata = { 'Axion mass': axion_mass, 'Axion coupling': axion_coupling, - 'Progenitor mass': 20*u.Msun } + 'Progenitor mass': 20*u.Msun, + 'PNS mass' : pns_mass*u.Msun + } return loaders.Mori_2023(filename, metadata) diff --git a/python/snewpy/models/loaders.py b/python/snewpy/models/loaders.py index 30541ea5..b448ae08 100644 --- a/python/snewpy/models/loaders.py +++ b/python/snewpy/models/loaders.py @@ -759,38 +759,14 @@ def __init__(self, filename, metadata={}): filename : str Absolute or relative path to file prefix. """ - # PNS mass table, from Mori+ 2023. - mpns = { (0, 0): 1.78, - (100, 2): 1.77, - (100, 4): 1.76, - (100, 10): 1.77, - (100, 12): 1.77, - (100, 14): 1.77, - (100, 16): 1.77, - (100, 20): 1.74, - (200, 2): 1.77, - (200, 4): 1.76, - (200, 6): 1.75, - (200, 8): 1.74, - (200, 10): 1.73, - (200, 20): 1.62 } - # Set up model metadata self.axion_mass = metadata['Axion mass'] self.axion_coupling = metadata['Axion coupling'] self.progenitor_mass = metadata['Progenitor mass'] + self.pns_mass = metadata['PNS mass'] self.metadata = metadata - filebase = os.path.splitext(os.path.basename(filename))[0] - if 'std' in filebase: - am, ac = 0, 0 - else: - am, ac = [int(_) for _ in filebase.split('_')[1:]] - - self.pns_mass = mpns[(am,ac)] * u.Msun - self.metadata['PNS mass'] = self.pns_mass - # Open the requested filename using the model downloader. datafile = _model_downloader.get_model_data(self.__class__.__name__, filename) diff --git a/python/snewpy/test/test_01_registry.py b/python/snewpy/test/test_01_registry.py index 176e3a06..191b711b 100644 --- a/python/snewpy/test/test_01_registry.py +++ b/python/snewpy/test/test_01_registry.py @@ -406,10 +406,15 @@ def test_Mori_2023(self): pns_mass = [1.78, 1.77, 1.76, 1.77, 1.77, 1.77, 1.77, 1.74, 1.77, 1.76, 1.75, 1.74, 1.73, 1.62] * u.Msun for ((am, ac), mpns) in zip(axion_mass_coupling, pns_mass): - model = Mori_2023(axion_mass=am, axion_coupling=ac) + model = Mori_2023(axion_mass=am*u.MeV, axion_coupling=ac*1e-10/u.GeV) + + axion_mass = float(am) * u.MeV + self.assertEqual(model.metadata['Axion mass'], axion_mass) + + axion_coupling = float(ac) * 1e-10/u.GeV + axion_coupling = np.round(axion_coupling.to('1e-10/GeV')) + self.assertEqual(model.metadata['Axion coupling'], axion_coupling) - self.assertEqual(model.metadata['Axion mass'], float(am)*u.MeV) - self.assertEqual(model.metadata['Axion coupling'], float(ac)*1e-10/u.GeV) self.assertEqual(model.metadata['Progenitor mass'], 20*u.Msun) self.assertEqual(model.metadata['PNS mass'], mpns)