Ejemplo n.º 1
0
def test_xrayline(xrayline):
    assert xrayline.element.z == 118
    assert xrayline.transition == XrayTransition(2, 0, 1, 1, 0, 1)
    assert xrayline.iupac == "a"
    assert xrayline.siegbahn == "b"
    assert xrayline.energy_eV == pytest.approx(0.1, abs=1e-4)
    assert xrayline.probability == pytest.approx(0.2, abs=1e-4)
    assert xrayline.relative_weight == pytest.approx(0.3, abs=1e-4)
Ejemplo n.º 2
0
def test_xrayline_eq(xrayline):
    assert xrayline == XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "a",
                                "b", 0.1)
    assert xrayline == XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "z",
                                "b", 0.1)
    assert xrayline == XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "a",
                                "z", 0.1)
    assert xrayline == XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "a",
                                "b", 99.0)
    assert xrayline == XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "a",
                                "b", 0.1, 99.0)
    assert xrayline == XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "a",
                                "b", 0.1, 0.2, 99.0)
    assert xrayline == XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "a",
                                "b", 0.1, 0.2, 0.3)

    assert xrayline != XrayLine(117, XrayTransition(2, 0, 1, 1, 0, 1), "a",
                                "b", 0.1)
    assert xrayline != XrayLine(118, XrayTransition(3, 0, 1, 1, 0, 1), "a",
                                "b", 0.1)
Ejemplo n.º 3
0
def iter_transitions(max_n):
    for src_n, src_l, src_j_n, src_i in iter_subshells(max_n):

        for dst_n, dst_l, dst_j_n, dst_i in iter_subshells(MAX_N):
            # Cannot transition to itself
            if src_n == dst_n and src_l == dst_l and src_j_n == dst_j_n:
                continue

            # Transition must be from more to less energytic shell or
            # within the same shell
            if src_n < dst_n:
                continue

            # Coster-Kroning transition must be from more to less energetic subshells
            if src_n == dst_n and src_i <= dst_i:
                continue

            yield XrayTransition(src_n, src_l, src_j_n, dst_n, dst_l,
                                 dst_j_n), src_i, dst_i
Ejemplo n.º 4
0
    def __iter__(self):
        for n in range(1, MAX_N + 1):
            transition = XrayTransition(None, None, None, n, None,
                                        None)  # All transitions to this shell

            (
                ascii,
                utf16,
                html,
                latex,
            ) = AtomicShellNotationParser._create_entry_siegbahn(n)
            yield XrayTransitionNotation(base.UNATTRIBUTED, transition,
                                         base.SIEGBAHN, ascii, utf16, html,
                                         latex)

            ascii, utf16, html, latex = AtomicShellNotationParser._create_entry_iupac(
                n)
            yield XrayTransitionNotation(base.UNATTRIBUTED, transition,
                                         base.IUPAC, ascii, utf16, html, latex)
Ejemplo n.º 5
0
    def __iter__(self):
        families = set()
        for transition, _src_i, dst_i in iter_transitions(MAX_N):
            dst = transition.destination_subshell
            families.add((dst, dst_i))

        # Create family notations
        for atomic_subshell, i in families:
            if i == 0:  # Skip K, already a series
                continue

            n = atomic_subshell.n
            l = atomic_subshell.l
            j_n = atomic_subshell.j_n

            transition = XrayTransition(
                None, None, None, n, l,
                j_n)  # All transitions to this subshell

            (
                ascii,
                utf16,
                html,
                latex,
            ) = AtomicSubshellNotationParser._create_entry_siegbahn(
                n, l, j_n, i)
            yield XrayTransitionNotation(base.UNATTRIBUTED, transition,
                                         base.SIEGBAHN, ascii, utf16, html,
                                         latex)

            (
                ascii,
                utf16,
                html,
                latex,
            ) = AtomicSubshellNotationParser._create_entry_iupac(n, l, j_n, i)
            yield XrayTransitionNotation(base.UNATTRIBUTED, transition,
                                         base.IUPAC, ascii, utf16, html, latex)
Ejemplo n.º 6
0
    def _parse_radiative_transition(self, rows):
        reaction_descriptor = self._extract_reaction_descriptor(rows)
        if reaction_descriptor != REACTION_DESCRIPTOR_TRANSITION:
            return

        reaction_modifier = self._extract_reaction_modifier(rows)
        if reaction_modifier != REACTION_MODIFIER_EXTRA:
            return

        outgoing_particle = self._extract_outgoing_particle(rows)
        if outgoing_particle != OUTGOING_PARTICLE_PHOTON:
            return

        reaction_property = self._extract_reaction_property(rows)
        if reaction_property != REACTION_PROPERTY_RADIATIVE_PROBABILITY:
            return

        element = self._extract_element(rows)

        destination_subshell = self._extract_destination_subshell(rows)

        for row in rows[2:]:
            source_subshell = self._extract_source_subshell([row])
            transition = XrayTransition(source_subshell, destination_subshell)

            value = float_(row[11:22])
            prop = XrayTransitionProbability(PERKINS1991, element, transition,
                                             value)
            logger.debug("Parsed: {0}".format(prop))
            yield prop

            value_eV = float_(row[22:33]) * 1e6
            prop = XrayTransitionEnergy(PERKINS1991, element, transition,
                                        value_eV)
            logger.debug("Parsed: {0}".format(prop))
            yield prop
Ejemplo n.º 7
0
def xrayline():
    return XrayLine(Element(118), XrayTransition(2, 0, 1, 1, 0, 1), "a", "b",
                    0.1, 0.2, 0.3)
Ejemplo n.º 8
0
def xraytransitionset():
    return XrayTransition(
        2, 1, None, 1, 0,
        1)  # L2 (2, 1, 0.5) and L3 (2, 1, 1.5) to K (1, 0, 0.5)
Ejemplo n.º 9
0
def test_xraytransition_hash(xraytransition):
    assert hash(xraytransition) == hash(XrayTransition((2, 0, 1), (1, 0, 1)))
    assert hash(xraytransition) == hash(
        XrayTransition(AtomicSubshell(2, 0, 1), AtomicSubshell(1, 0, 1)))
Ejemplo n.º 10
0
def test_xraytransition_eq(xraytransition):
    assert xraytransition == XrayTransition((2, 0, 1), (1, 0, 1))
Ejemplo n.º 11
0
def xraytransition(request):
    return XrayTransition(*request.param)
Ejemplo n.º 12
0
                                "b", 0.1, 99.0)
    assert xrayline == XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "a",
                                "b", 0.1, 0.2, 99.0)
    assert xrayline == XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "a",
                                "b", 0.1, 0.2, 0.3)

    assert xrayline != XrayLine(117, XrayTransition(2, 0, 1, 1, 0, 1), "a",
                                "b", 0.1)
    assert xrayline != XrayLine(118, XrayTransition(3, 0, 1, 1, 0, 1), "a",
                                "b", 0.1)


@pytest.mark.parametrize(
    "other",
    [
        XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "a", "b", 0.1),
        XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "z", "b", 0.1),
        XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "a", "z", 0.1),
        XrayLine(118, XrayTransition(2, 0, 1, 1, 0, 1), "a", "b", 0.2),
    ],
)
def test_xrayline_hash(xrayline, other):
    assert hash(xrayline) == hash(other)


def test_xrayline_repr(xrayline):
    assert repr(xrayline) == "XrayLine(a)"


def test_xrayline_frozen(xrayline):
    with pytest.raises(dataclasses.FrozenInstanceError):
Ejemplo n.º 13
0
 "Lg5": base.Lg5,
 "Lg6": base.Lg6,
 "Lg8": base.Lg8,
 "Lg11": base.Lg11,
 "Ll": base.Ll,
 "Ls": base.Ls,
 "Lt": base.Lt,
 "Lv": base.Lv,
 "Lu": base.Lu,
 "Ma1": base.Ma1,
 "Ma2": base.Ma2,
 "Mb": base.Mb,
 "Mg": base.Mg,
 "Mz1": base.Mz1,
 "Mz2": base.Mz2,
 "N4-N6": XrayTransition(base.N6, base.N4),
 "N5-N6": XrayTransition(base.N6, base.N5),
 #'Kb2': 'Kb2I',
 #'Kb4': 'Kb4I',
 #'Kb5': 'Kb5I',
 # SKa,SKa',SKa'',SKa3,SKa3',SKa3'',SKa4,SKa5,SKa6,SKa7,SKa8,SKa9,SKb',SKb'',SKb+4,SKb+5,SKb7,SKb8,SKb9,SKbN,SKbX,SLa',SLa+IX,SLa+X,SLa+Y,SLa1+Z,SLa2',SLa3,SLa3+Z,SLa4,SLa5,SLa6,SLa7,SLa8,SLa9,SLaa,SLas,SLb'',SLb1+4,SLb14,SLb2+1,SLb2+2,SLb2+3,SLb2+4,SLb2+5,SLb2+7,SLb2+A,SLb2+B,SLb2+C,SLb5+1,SLb5+2,SLg1',SLg10,SLg2',SLg2'',SLg9,SMa+1,SMa+2,SMa+3,SMa+4,SMb1,SMb2,SMb3,SMg',Skb,Skb10,Skb6
 "L1M1": XrayTransition(base.L1, base.M1),
 "L1N1": XrayTransition(base.N1, base.L1),
 "L1N4": XrayTransition(base.N4, base.L1),
 "L1O1": XrayTransition(base.O1, base.L1),
 "L1O4": XrayTransition(base.O4, base.L1),
 "L2M2": XrayTransition(base.L2, base.M2),
 "L2M5": XrayTransition(base.M5, base.L2),
 "L2N2": XrayTransition(base.N2, base.L2),
 "L2N3": XrayTransition(base.N3, base.L2),
 "L2N5": XrayTransition(base.N5, base.L2),
Ejemplo n.º 14
0
P1 = AtomicSubshell(6, 0, 1)
P2 = AtomicSubshell(6, 1, 1)
P3 = AtomicSubshell(6, 1, 3)
P4 = AtomicSubshell(6, 2, 3)
P5 = AtomicSubshell(6, 2, 5)
P6 = AtomicSubshell(6, 3, 5)
P7 = AtomicSubshell(6, 3, 7)
P8 = AtomicSubshell(6, 4, 7)
P9 = AtomicSubshell(6, 4, 9)
P10 = AtomicSubshell(6, 5, 9)
P11 = AtomicSubshell(6, 5, 11)
Q1 = AtomicSubshell(7, 0, 1)
Q2 = AtomicSubshell(7, 1, 1)
Q3 = AtomicSubshell(7, 1, 3)

Ka1 = XrayTransition(L3, K)
Ka2 = XrayTransition(L2, K)
Ka = XrayTransition(2, 1, None, K)
Kb1 = XrayTransition(M3, K)
Kb2_1 = XrayTransition(N3, K)
Kb2_2 = XrayTransition(N2, K)
Kb2 = XrayTransition(4, 1, None, K)
Kb3 = XrayTransition(M2, K)
Kb1_3 = XrayTransition(3, 1, None, K)  # K-M2,3
Kb4_1 = XrayTransition(N5, K)
Kb4_2 = XrayTransition(N4, K)
Kb4 = XrayTransition(4, 2, None, K)
Kb5_1 = XrayTransition(M5, K)
Kb5_2 = XrayTransition(M4, K)
Kb5 = XrayTransition(3, 2, None, K)  # K-M4,5
KO2_3 = XrayTransition(5, 1, None, K)  # K-O2,3