예제 #1
0
    def test_numbers(self):

        assert Isotope(7, 14).numbers() == (7, 14)

        assert Isotope(6, 12, True).numbers() == (6, 12, True)

        assert Isotope(6, 12,
                       False).numbers(force_isomer=True) == (6, 12, False)
예제 #2
0
    def test_decay(self):
        assert Isotope(9, 26).decay().numbers() == (12, 26)

        assert Isotope(4, 8).decay().numbers() == (2, 4)

        assert Isotope(14, 26).decay().numbers() == (12, 26)

        assert Isotope(2, 4).decay().numbers() == (2, 4)

        # This asserts the code is not working physically but as intended
        assert Isotope(20, 36).decay().numbers() == (16, 36)
예제 #3
0
 def in_file(self, target: Union[str, "Isotope"]):
     target = Isotope.name(target)
     try:
         self.__getitem__(target)
         return True
     except Exception:
         return False
예제 #4
0
 def __getitem__(self, target: Union[str, "Isotope"]) -> KadonisReaction:
     target = Isotope.name(target)
     try:
         return self.df[
             (self.df["Z"] == target.charge_number)
             & (self.df["A"] == target.mass_number)].Reaction.iloc[0]
     except IndexError:
         raise Exception(str(target) + " Not found in file")
예제 #5
0
    def test_init(self):
        for n, r in zip(n_captures, n_capture_reactions):
            reaction = KadonisReaction(n, rr=[1.0] * 12, err=[0.0] * 12)

            assert str(reaction) == r

            assert (str(
                KadonisReaction(Isotope(7, 14), rr=[1.0] * 12,
                                err=[0.0] * 12)) == "n+N14 -> N15")
예제 #6
0
 def test_ppn_to_numbers(self):
     for iso, isomer, out in zip(self.isotopes, self.isomers,
                                 self.ppn_outputs):
         assert Isotope.ppn_name_factory(out).numbers(
             force_isomer=True) == (
                 iso[0],
                 iso[1],
                 isomer,
             )
예제 #7
0
    def get_n_gamma(self, target: Union[Isotope, str]) -> ReaclibReaction:
        """Gets reaction from target Isotope, matches __getitem__ method in the Kadonis class

        Parameters
        ----------
        target : [Isotope, str]

        Returns
        -------
        ReaclibReaction

        """
        target = Isotope.name(target)
        try:
            return self.df[(self.df.Chapter == 4)
                           & (self.df.E0 == "n")
                           & (self.df.E1
                              == str(target).lower())].Reaction.iloc[0]
        except IndexError:
            raise Exception(str(target) + " Not found in file")
예제 #8
0
파일: reaction.py 프로젝트: Samuel316/Rates
    def __init__(
        self,
        target: Union[str, Isotope],
        rr: List[real],
        err: List[real],
        temp: Tuple[real] = (5, 8, 10, 15, 20, 25, 30, 40, 50, 60, 80, 100),
        temp_units: str = "KeV",
        label: str = "Kadonis",
        colour: str = "C2",
    ):
        product = copy.deepcopy(Isotope.name(target))
        product.mass_number += 1
        super().__init__(["n", target], [product])

        self.rr = rr
        self.err = err
        self.temperature = temp
        self.temp_unit = temp_units
        self.label = label
        self.colour = colour
예제 #9
0
    def test_str(self):
        assert str(Isotope(7, 14)) == "N14"
        assert str(Isotope(4, 9)) == "Be9"

        assert str(Isotope(1, 0)) == "weak"
예제 #10
0
 def test_is_primordial(self):
     for s, j in Isotope.primordial:
         assert Isotope(s, j).is_primordial
예제 #11
0
 def test_is_stable(self):
     for s, j in Isotope.stable_isotopes:
         assert Isotope(s, j).is_stable
예제 #12
0
 def test_ppn_name_to_numbers(self):
     assert Isotope.ppn_name_to_numbers("NE 10") == (10, 10)
예제 #13
0
    def test_full_name(self):

        assert Isotope.name("Ne20").full_name == "Neon-20"
예제 #14
0
 def test_number_to_ppn_name_error(self):
     with pytest.raises(ValueError):
         Isotope.number_to_ppn_name(10, 10, 3)
예제 #15
0
 def test_decay_isotope(self):
     assert Isotope.decay_isotope(10, 10) == (5, 10, False)
예제 #16
0
 def test_class_re_input_to_name(self):
     assert str(Isotope.name(Isotope(7, 14))) == "N14"
예제 #17
0
 def test_name(self):
     for n, n_out in zip(self.names, self.names_out):
         isotope = Isotope.name(n)
         assert str(isotope) == n_out
예제 #18
0
 def test_init_to_ppn(self):
     for iso, isomer, out in zip(self.isotopes, self.isomers,
                                 self.ppn_outputs):
         assert Isotope(iso[0], iso[1], isomer).ppn_name == out
예제 #19
0
 def test_init(self):
     with pytest.raises(ValueError):
         assert Isotope(119, 350)
     with pytest.raises(ValueError):
         assert Isotope(118, 351)
예제 #20
0
    def read_file(file_path: Union[str, Path]) -> pd.DataFrame:
        """

        Parameters
        ----------
        file_path :

        Returns
        -------

        """
        file_path = Path(file_path)

        df = pd.read_csv(
            file_path,
            index_col=False,
            sep="\t",
            header=0,
            dtype={
                "Z": np.uint8,
                "A": np.uint8,
                "Isomer": str,
                "Sym": str
            },
            na_values="-",
        )

        try:
            df.drop([" ; reaction rate including SEF in cm3/mole/s"],
                    axis=1,
                    inplace=True)
            version = 1.0
        except KeyError:
            df.rename(
                {"100(keV); reaction rate including SEF in cm3/mole/s": "100"},
                axis=1,
                inplace=True,
            )
            version = 0.3
            print("Warning Loading Kadonis in 0.3 format")
        except:
            raise Exception

        if version == 1.0:
            df["Reaction"] = df.apply(
                lambda df: KadonisReaction(
                    target=Isotope(df.Z, df.A),
                    label="Kadonis 1.0",
                    rr=[
                        df["RR(5keV)"],
                        df["RR(8keV)"],
                        df["RR(10keV)"],
                        df["RR(15keV)"],
                        df["RR(20keV)"],
                        df["RR(25keV)"],
                        df["RR(30keV)"],
                        df["RR(40keV)"],
                        df["RR(50keV)"],
                        df["RR(60keV)"],
                        df["RR(80keV)"],
                        df["RR(100keV)"],
                    ],
                    err=[
                        df["Err(5keV)"],
                        df["Err(8keV)"],
                        df["Err(10keV)"],
                        df["Err(15keV)"],
                        df["Err(20keV)"],
                        df["Err(25keV)"],
                        df["Err(30keV)"],
                        df["Err(40keV)"],
                        df["Err(50keV)"],
                        df["Err(60keV)"],
                        df["Err(80keV)"],
                        df["Err(100keV)"],
                    ],
                ),
                axis=1,
            )

        elif version == 0.3:
            df["Reaction"] = df.apply(
                lambda df: KadonisReaction(
                    target=Isotope(df.Z, df.A),
                    label="Kadonis 0.3",
                    rr=[
                        df["5"],
                        df["8"],
                        df["10"],
                        df["15"],
                        df["20"],
                        df["25"],
                        df["30"],
                        df["40"],
                        df["50"],
                        df["60"],
                        df["80"],
                        df["100"],
                    ],
                    err=[0.0] * 12,
                ),
                axis=1,
            )

        pickle_path = "{0}.temp".format(str(file_path.parent / file_path.stem))
        df.to_pickle(pickle_path)
        return df
예제 #21
0
    def test_eq(self):
        assert Isotope.name("Ne20") == "Ne20" and "ne20" and "20Ne"

        assert Isotope.name("O12") != "NE20"
예제 #22
0
파일: reaction.py 프로젝트: Samuel316/Rates
 def __init__(self, targets: iso_list_type,
              products: iso_list_type) -> None:
     self.targets = [Isotope.name(t) for t in targets]
     self.products = [Isotope.name(t) for t in products]
예제 #23
0
    def test_number_to_ppn_name(self):
        assert Isotope.number_to_ppn_name(10, 10, 1) == "NE 10"

        assert Isotope.number_to_ppn_name(10, 10, 2) == "NE*10"