Ejemplo n.º 1
0
    def test_spin_ignore_z_component(self):
        spin_label = StateQuantumNumberNames.Spin
        angmom_label = InteractionQuantumNumberNames.L
        intspin_label = InteractionQuantumNumberNames.S
        spin_rule = SpinConservation(spin_label, False)
        cases = []

        for case in [([(0, 0, 1), (2, 1, 2), (2, 1, 1)], True)]:
            for spin_mag in case[0]:
                temp_case = (
                    [{
                        spin_label: Spin(1, 1)
                    }],
                    [
                        {
                            spin_label: Spin(spin_mag[0], 0)
                        },
                        {
                            spin_label: Spin(1, -1)
                        },
                    ],
                    {
                        angmom_label: Spin(spin_mag[1], 0),
                        intspin_label: Spin(spin_mag[2], -1),
                    },
                    case[1],
                )
                cases.append(temp_case)

        for case in cases:
            assert spin_rule.check(case[0], case[1], case[2]) is case[3]
Ejemplo n.º 2
0
 def check(self, ingoing_part_qns, outgoing_part_qns, interaction_qns):
     if len(ingoing_part_qns) == 1 and len(outgoing_part_qns) == 2:
         spin_label = StateQuantumNumberNames.Spin
         in_spins = [x[spin_label] for x in ingoing_part_qns]
         out_spins = [x[spin_label] for x in outgoing_part_qns]
         out_spins[1] = Spin(out_spins[1].magnitude(),
                             -out_spins[1].projection())
         helicity_diff = sum([x.projection() for x in out_spins])
         L = interaction_qns[InteractionQuantumNumberNames.L]
         S = interaction_qns[InteractionQuantumNumberNames.S]
         if (S.magnitude() < abs(helicity_diff)
                 or in_spins[0].magnitude() < abs(helicity_diff)):
             return False
         S = Spin(S.magnitude(), helicity_diff)
         if is_clebsch_gordan_coefficient_zero(out_spins[0], out_spins[1],
                                               S):
             return False
         in_spins[0] = Spin(in_spins[0].magnitude(), helicity_diff)
         return not is_clebsch_gordan_coefficient_zero(L, S, in_spins[0])
     return False
Ejemplo n.º 3
0
 def calculate_total_spins(self, part_list, interaction_qns):
     total_spins = set()
     if len(part_list) == 1:
         if self.use_projection:
             total_spins.add(part_list[0])
         else:
             total_spins.add(Spin(part_list[0].magnitude(), 0))
     else:
         # first couple all spins together
         spins_daughters_coupled = set()
         spin_list = deepcopy(part_list)
         while spin_list:
             if spins_daughters_coupled:
                 temp_coupled_spins = set()
                 for s in spins_daughters_coupled:
                     tempspin = spin_list.pop()
                     coupled_spins = self.spin_couplings(s, tempspin)
                     temp_coupled_spins.update(coupled_spins)
                 spins_daughters_coupled = temp_coupled_spins
             else:
                 spins_daughters_coupled.add(spin_list.pop())
         if InteractionQuantumNumberNames.L in interaction_qns:
             L = interaction_qns[InteractionQuantumNumberNames.L]
             S = interaction_qns[InteractionQuantumNumberNames.S]
             if self.use_projection:
                 if S in spins_daughters_coupled:
                     total_spins.update(self.spin_couplings(S, L))
             else:
                 if S.magnitude() in [
                         x.magnitude() for x in spins_daughters_coupled
                 ]:
                     total_spins.update(self.spin_couplings(S, L))
         else:
             if self.use_projection:
                 total_spins = spins_daughters_coupled
             else:
                 total_spins = [
                     Spin(x.magnitude(), 0.0)
                     for x in spins_daughters_coupled
                 ]
     return total_spins
Ejemplo n.º 4
0
    def test_cparity_multiparticle_boson(self):
        cpar_rule = CParityConservation()
        cparity_label = StateQuantumNumberNames.Cparity
        spin_label = StateQuantumNumberNames.Spin
        pid_label = ParticlePropertyNames.Pid
        angmom_label = InteractionQuantumNumberNames.L
        intspin_label = InteractionQuantumNumberNames.S
        cases = []

        for ang_mom_case in [([0, 2, 4], True), ([1, 3], False)]:
            for ang_mom in ang_mom_case[0]:
                temp_case = ([{
                    cparity_label: 1
                }], [{
                    spin_label: Spin(0, 0),
                    pid_label: 100
                }, {
                    spin_label: Spin(0, 0),
                    pid_label: -100
                }], {
                    angmom_label: Spin(ang_mom, 0),
                    intspin_label: Spin(0, 0)
                }, ang_mom_case[1])

                cases.append(temp_case)
                cases.append(([{
                    cparity_label: -1
                }], temp_case[1], temp_case[2], not temp_case[3]))

        for ang_mom in [0, 1, 2, 3]:
            temp_case = ([{
                cparity_label: None
            }], [{
                spin_label: Spin(0, 0),
                pid_label: 100
            }, {
                spin_label: Spin(0, 0),
                pid_label: 100
            }], {
                angmom_label: Spin(ang_mom, 0),
                intspin_label: Spin(0, 0)
            }, True)

            cases.append(temp_case)
            cases.append(([{
                cparity_label: None
            }], temp_case[1], temp_case[2], True))

        for case in cases:
            assert cpar_rule.check(case[0], case[1], case[2]) is case[3]
Ejemplo n.º 5
0
    def spin_couplings(self, spin1, spin2):
        """
        implements the coupling of two spins
        |S1 - S2| <= S <= |S1 + S2| and M1 + M2 == M
        """
        j1 = spin1.magnitude()
        j2 = spin2.magnitude()
        if self.use_projection:
            m = spin1.projection() + spin2.projection()
            possible_spins = [
                Spin(x, m)
                for x in arange(abs(j1 - j2), j1 + j2 + 1, 1).tolist()
                if x >= abs(m)
            ]

            return [
                x for x in possible_spins
                if not is_clebsch_gordan_coefficient_zero(spin1, spin2, x)
            ]
        else:
            return [
                Spin(x, 0)
                for x in arange(abs(j1 - j2), j1 + j2 + 1, 1).tolist()
            ]
Ejemplo n.º 6
0
    def test_cparity_multiparticle_fermion(self):
        cpar_rule = CParityConservation()
        cparity_label = StateQuantumNumberNames.Cparity
        spin_label = StateQuantumNumberNames.Spin
        pid_label = ParticlePropertyNames.Pid
        angmom_label = InteractionQuantumNumberNames.L
        intspin_label = InteractionQuantumNumberNames.S
        cases = []

        all_spin_cases = list(product(range(0, 5), range(0, 5)))
        even_sum_cases = [x for x in all_spin_cases if (x[0] + x[1]) % 2 == 0]
        odd_sum_cases = [x for x in all_spin_cases if (x[0] + x[1]) % 2 != 0]
        for spin_case in [(even_sum_cases, True), (odd_sum_cases, False)]:
            for spin_ang_mom in spin_case[0]:
                temp_case = ([{
                    cparity_label: 1
                }], [{
                    spin_label: Spin(0.5, 0),
                    pid_label: 100
                }, {
                    spin_label: Spin(0.5, 0),
                    pid_label: -100
                }], {
                    angmom_label: Spin(spin_ang_mom[1], 0),
                    intspin_label: Spin(spin_ang_mom[0], 0)
                }, spin_case[1])

                cases.append(temp_case)
                cases.append(([{
                    cparity_label: -1
                }], temp_case[1], temp_case[2], not temp_case[3]))

        for ang_mom in [0, 1, 2, 3]:
            temp_case = ([{
                cparity_label: None
            }], [{
                spin_label: 0.0,
                pid_label: 100
            }, {
                spin_label: 0.0,
                pid_label: 100
            }], {
                angmom_label: Spin(0, 0),
                intspin_label: Spin(ang_mom, 0)
            }, True)

            cases.append(temp_case)
            cases.append(([{
                cparity_label: None
            }], temp_case[1], temp_case[2], True))

        for case in cases:
            assert cpar_rule.check(case[0], case[1], case[2]) is case[3]
Ejemplo n.º 7
0
from expertsystem.state.particle import (
    InteractionQuantumNumberNames,
    SpinQNConverter,
    Spin,
    XMLLabelConstants,
)
from expertsystem.state.conservationrules import ParityConservationHelicity


@pytest.mark.parametrize(
    "initial_state,final_state,L,S,solution_count",
    [
        (
            [("Y", [1])],
            [("D*(2007)0bar", [0]), ("D*(2007)0", [0])],
            Spin(1, 0),
            Spin(0, 0),
            1,
        ),
        (
            [("Y", [1])],
            [("D*(2007)0bar", [1]), ("D*(2007)0", [0])],
            Spin(1, 0),
            Spin(0, 0),
            0,
        ),
        (
            [("Y", [1])],
            [("D*(2007)0bar", [1]), ("D*(2007)0", [0])],
            Spin(1, 0),
            Spin(1, 0),
Ejemplo n.º 8
0
from expertsystem.amplitude.canonicaldecay import (
    CanonicalDecayAmplitudeGeneratorXML)
from expertsystem.ui.system_control import (StateTransitionManager,
                                            InteractionTypes, change_qn_domain,
                                            remove_conservation_law)
from expertsystem.ui.default_settings import (
    create_default_interaction_settings)
from expertsystem.state.particle import (InteractionQuantumNumberNames,
                                         create_spin_domain, SpinQNConverter,
                                         Spin, XMLLabelConstants)
from expertsystem.state.conservationrules import ParityConservationHelicity


@pytest.mark.parametrize("initial_state,final_state,L,S,solution_count", [
    ([("Y", [1])], [("D*(2007)0bar", [0]),
                    ("D*(2007)0", [0])], Spin(1, 0), Spin(0, 0), 1),
    ([("Y", [1])], [("D*(2007)0bar", [1]),
                    ("D*(2007)0", [0])], Spin(1, 0), Spin(0, 0), 0),
    ([("Y", [1])], [("D*(2007)0bar", [1]),
                    ("D*(2007)0", [0])], Spin(1, 0), Spin(1, 0), 1),
    ([("Y", [1])], [("D*(2007)0bar", [0]),
                    ("D*(2007)0", [0])], Spin(1, 0), Spin(1, 0), 0),
    ([("Y", [1])], [("D*(2007)0bar", [1]),
                    ("D*(2007)0", [0])], Spin(1, 0), Spin(2, 0), 1),
    ([("Y", [1])], [("D*(2007)0bar", [0]),
                    ("D*(2007)0", [0])], Spin(1, 0), Spin(2, 0), 1),
    ([("Y", [1])], [("D*(2007)0bar", [0]),
                    ("D*(2007)0", [1])], Spin(1, 0), Spin(0, 0), 0),
    ([("Y", [1])], [("D*(2007)0bar", [0]),
                    ("D*(2007)0", [1])], Spin(1, 0), Spin(1, 0), 1),
    ([("Y", [1])], [("D*(2007)0bar", [0]),
Ejemplo n.º 9
0
    def test_gparity_multiparticle_boson(self):
        gpar_rule = GParityConservation()
        gparity_label = StateQuantumNumberNames.Gparity
        spin_label = StateQuantumNumberNames.Spin
        pid_label = ParticlePropertyNames.Pid
        isospin_label = StateQuantumNumberNames.IsoSpin
        angmom_label = InteractionQuantumNumberNames.L
        cases = []

        for ang_mom_case in [([0, 2, 4], True), ([1, 3], False)]:
            for ang_mom in ang_mom_case[0]:
                temp_case = (
                    [{gparity_label: 1, isospin_label: Spin(0, 0)}],
                    [
                        {spin_label: Spin(0, 0), pid_label: 100},
                        {spin_label: Spin(0, 0), pid_label: -100},
                    ],
                    {angmom_label: Spin(ang_mom, 0)},
                    ang_mom_case[1],
                )

                cases.append(temp_case)
                cases.append(
                    (
                        [{gparity_label: -1, isospin_label: Spin(0, 0)}],
                        temp_case[1],
                        temp_case[2],
                        not temp_case[3],
                    )
                )

        for ang_mom_case in [([0, 2, 4], False), ([1, 3], True)]:
            for ang_mom in ang_mom_case[0]:
                temp_case = (
                    [{gparity_label: 1, isospin_label: Spin(1, 0)}],
                    [
                        {spin_label: Spin(0, 0), pid_label: 100},
                        {spin_label: Spin(0, 0), pid_label: -100},
                    ],
                    {angmom_label: Spin(ang_mom, 0)},
                    ang_mom_case[1],
                )

                cases.append(temp_case)
                cases.append(
                    (
                        [{gparity_label: -1, isospin_label: Spin(1, 0)}],
                        temp_case[1],
                        temp_case[2],
                        not temp_case[3],
                    )
                )

        for ang_mom in [0, 1, 2, 3]:
            temp_case = (
                [{gparity_label: 1}],
                [
                    {spin_label: Spin(0, 0), pid_label: 100},
                    {spin_label: Spin(0, 0), pid_label: 100},
                ],
                {angmom_label: Spin(ang_mom, 0)},
                True,
            )

            cases.append(temp_case)
            cases.append(
                ([{gparity_label: None}], temp_case[1], temp_case[2], True)
            )

        for case in cases:
            assert gpar_rule.check(case[0], case[1], case[2]) is case[3]
Ejemplo n.º 10
0
    def test_spin_all_defined(self):
        spin_label = StateQuantumNumberNames.Spin
        angmom_label = InteractionQuantumNumberNames.L
        intspin_label = InteractionQuantumNumberNames.S
        spin_rule = SpinConservation(spin_label)
        cases = []

        for case in [([0], True), ([1, 2, 3], False)]:
            for spin_mag in case[0]:
                temp_case = ([{
                    spin_label: Spin(0, 0)
                }], [{
                    spin_label: Spin(0, 0)
                }, {
                    spin_label: Spin(0, 0)
                }], {
                    angmom_label: Spin(spin_mag, 0),
                    intspin_label: Spin(0, 0)
                }, case[1])
                cases.append(temp_case)
        for case in [([0, 1, 2], True)]:
            for spin_mag in case[0]:
                temp_case = ([{
                    spin_label: Spin(spin_mag, 0)
                }], [{
                    spin_label: Spin(0, 0)
                }, {
                    spin_label: Spin(0, 0)
                }], {
                    angmom_label: Spin(spin_mag, 0),
                    intspin_label: Spin(0, 0)
                }, case[1])
                cases.append(temp_case)
        for case in [([0, 1, 2], True), ([3], False)]:
            for spin_mag in case[0]:
                temp_case = ([{
                    spin_label: Spin(spin_mag, 0)
                }], [{
                    spin_label: Spin(1, -1)
                }, {
                    spin_label: Spin(1, 1)
                }], {
                    angmom_label: Spin(0, 0),
                    intspin_label: Spin(spin_mag, 0)
                }, case[1])
                cases.append(temp_case)

        for case in [(Spin(1, -1), Spin(0, 0), Spin(1, -1), Spin(0, 0),
                      Spin(1, -1), True)]:
            temp_case = ([{
                spin_label: case[0]
            }], [{
                spin_label: case[1]
            }, {
                spin_label: case[2]
            }], {
                angmom_label: case[3],
                intspin_label: case[4]
            }, case[5])
            cases.append(temp_case)

        for case in cases:
            assert spin_rule.check(case[0], case[1], case[2]) is case[3]