Esempio n. 1
0
def __create_two_body_decay_spin_data(
    in_spin: Optional[Spin] = None,
    out_spin1: Optional[Spin] = None,
    out_spin2: Optional[Spin] = None,
    angular_momentum: Optional[Spin] = None,
    coupled_spin: Optional[Spin] = None,
) -> _SpinRuleInputType:
    spin_zero = Spin(0, 0)
    if in_spin is None:
        in_spin = spin_zero
    if out_spin1 is None:
        out_spin1 = spin_zero
    if out_spin2 is None:
        out_spin2 = spin_zero
    if angular_momentum is None:
        angular_momentum = spin_zero
    if coupled_spin is None:
        coupled_spin = spin_zero
    return (
        [
            SpinEdgeInput(
                EdgeQuantumNumbers.spin_magnitude(in_spin.magnitude),
                EdgeQuantumNumbers.spin_projection(in_spin.projection),
            )
        ],
        [
            SpinEdgeInput(
                EdgeQuantumNumbers.spin_magnitude(out_spin1.magnitude),
                EdgeQuantumNumbers.spin_projection(out_spin1.projection),
            ),
            SpinEdgeInput(
                EdgeQuantumNumbers.spin_magnitude(out_spin2.magnitude),
                EdgeQuantumNumbers.spin_projection(out_spin2.projection),
            ),
        ],
        SpinNodeInput(
            NodeQuantumNumbers.l_magnitude(angular_momentum.magnitude),
            NodeQuantumNumbers.l_projection(angular_momentum.projection),
            NodeQuantumNumbers.s_magnitude(coupled_spin.magnitude),
            NodeQuantumNumbers.s_projection(coupled_spin.projection),
        ),
    )
Esempio n. 2
0
    EdgeQuantumNumbers,
    NodeQuantumNumbers,
)

# Currently need to cast to the proper Edge/NodeQuantumNumber type, see
# https://github.com/ComPWA/expertsystem/issues/255


@pytest.mark.parametrize(
    "rule_input, expected",
    [
        (
            (
                [
                    CParityEdgeInput(
                        spin_mag=EdgeQuantumNumbers.spin_magnitude(0.0),
                        pid=EdgeQuantumNumbers.pid(1),
                        c_parity=EdgeQuantumNumbers.c_parity(Parity(-1)),
                    )
                ],
                [
                    CParityEdgeInput(
                        spin_mag=EdgeQuantumNumbers.spin_magnitude(0.0),
                        pid=EdgeQuantumNumbers.pid(1),
                        c_parity=EdgeQuantumNumbers.c_parity(Parity(-1)),
                    ),
                    CParityEdgeInput(
                        spin_mag=EdgeQuantumNumbers.spin_magnitude(0.0),
                        pid=EdgeQuantumNumbers.pid(1),
                        c_parity=EdgeQuantumNumbers.c_parity(Parity(1)),
                    ),
from expertsystem.reaction.conservation_rules import (
    GellMannNishijimaInput,
    gellmann_nishijima,
)
from expertsystem.reaction.quantum_numbers import EdgeQuantumNumbers

# Currently need to cast to the proper Edge/NodeQuantumNumber type, see
# https://github.com/ComPWA/expertsystem/issues/255


@pytest.mark.parametrize(
    "particle, expected",
    [
        (
            GellMannNishijimaInput(
                charge=EdgeQuantumNumbers.charge(charge),
                isospin_proj=EdgeQuantumNumbers.isospin_projection(isospin_z),
                baryon_number=EdgeQuantumNumbers.baryon_number(1),
            ),
            charge == isospin_z + 0.5,
        )
        for charge, isospin_z in product(range(-1, 1), [-1, 0.5, 0, 0.5, 1])
    ]
    + [
        (
            GellMannNishijimaInput(
                charge=EdgeQuantumNumbers.charge(charge),
                isospin_proj=EdgeQuantumNumbers.isospin_projection(isospin_z),
                baryon_number=EdgeQuantumNumbers.baryon_number(1),
                strangeness=EdgeQuantumNumbers.strangeness(strangeness),
            ),
from expertsystem.particle import Parity
from expertsystem.reaction.conservation_rules import (
    IdenticalParticleSymmetryOutEdgeInput,
    identical_particle_symmetrization,
)
from expertsystem.reaction.quantum_numbers import EdgeQuantumNumbers

# Currently need to cast to the proper Edge/NodeQuantumNumber type, see
# https://github.com/ComPWA/expertsystem/issues/255


@pytest.mark.parametrize(
    "in_edges, out_edges, expected",
    [(
        [
            EdgeQuantumNumbers.parity(Parity(parity)),
        ],
        [
            IdenticalParticleSymmetryOutEdgeInput(
                spin_magnitude=EdgeQuantumNumbers.spin_magnitude(1.0),
                spin_projection=EdgeQuantumNumbers.spin_projection(0),
                pid=EdgeQuantumNumbers.pid(10),
            ),
            IdenticalParticleSymmetryOutEdgeInput(
                spin_magnitude=EdgeQuantumNumbers.spin_magnitude(1.0),
                spin_projection=EdgeQuantumNumbers.spin_projection(0),
                pid=EdgeQuantumNumbers.pid(10),
            ),
        ],
        parity == 1,
    ) for parity in [-1, 1]],
Esempio n. 5
0
from expertsystem.reaction.quantum_numbers import EdgeQuantumNumbers

# Currently need to cast to the proper Edge/NodeQuantumNumber type, see
# https://github.com/ComPWA/expertsystem/issues/255


@pytest.mark.parametrize(
    "rule_input, expected",
    [
        # we assume a two charged pion final state here
        # units are always in GeV
        (
            (
                [
                    MassEdgeInput(
                        mass=EdgeQuantumNumbers.mass(energy[0]),
                        width=EdgeQuantumNumbers.width(energy[1]),
                    )
                ],
                [
                    MassEdgeInput(EdgeQuantumNumbers.mass(0.139)),
                    MassEdgeInput(EdgeQuantumNumbers.mass(0.139)),
                ],
            ),
            expected,
        ) for energy, expected in zip(
            [
                (0.280, 0.0),
                (0.260, 0.010),
                (0.300, 0.05),
                (0.270, 0.0),
Esempio n. 6
0
    EdgeQuantumNumbers,
    NodeQuantumNumbers,
)

# Currently need to cast to the proper Edge/NodeQuantumNumber type, see
# https://github.com/ComPWA/expertsystem/issues/255


@pytest.mark.parametrize(
    "rule_input, expected",
    [
        (
            (
                [
                    GParityEdgeInput(
                        isospin=EdgeQuantumNumbers.isospin_magnitude(0),
                        spin_mag=EdgeQuantumNumbers.spin_magnitude(0),
                        pid=EdgeQuantumNumbers.pid(123),
                        g_parity=EdgeQuantumNumbers.g_parity(
                            Parity(g_parity_in[0])
                        ),
                    )
                ],
                [
                    GParityEdgeInput(
                        isospin=EdgeQuantumNumbers.isospin_magnitude(0),
                        spin_mag=EdgeQuantumNumbers.spin_magnitude(0),
                        pid=EdgeQuantumNumbers.pid(0),
                        g_parity=EdgeQuantumNumbers.g_parity(
                            Parity(g_parity_out[0][0])
                        ),
)
from expertsystem.reaction.quantum_numbers import (
    EdgeQuantumNumbers,
    NodeQuantumNumbers,
)

# Currently need to cast to the proper Edge/NodeQuantumNumber type, see
# https://github.com/ComPWA/expertsystem/issues/255


@pytest.mark.parametrize(
    "in_parities, out_parities, l_mag, expected",
    [
        (
            [
                EdgeQuantumNumbers.parity(Parity(parity_in)),
            ],
            [
                EdgeQuantumNumbers.parity(Parity(parity_out1)),
                EdgeQuantumNumbers.parity(Parity(1)),
            ],
            NodeQuantumNumbers.l_magnitude(l_mag),
            parity_in == parity_out1 * (-1)**(l_mag),  # pylint: disable=undefined-variable
        ) for parity_in, parity_out1, l_mag in product([-1, 1], [-1, 1],
                                                       range(0, 5))
    ],
)
def test_parity_conservation(in_parities, out_parities, l_mag, expected):
    assert parity_conservation(in_parities, out_parities, l_mag) is expected

from itertools import product

import pytest

from expertsystem.reaction.conservation_rules import helicity_conservation
from expertsystem.reaction.quantum_numbers import EdgeQuantumNumbers


@pytest.mark.parametrize(
    "in_edge_qns, out_edge_qns, expected",
    [(
        [
            EdgeQuantumNumbers.spin_magnitude(s_mag),
        ],
        [
            EdgeQuantumNumbers.spin_projection(lambda1),
            EdgeQuantumNumbers.spin_projection(lambda2),
        ],
        abs(lambda1 - lambda2) <= s_mag,
    ) for s_mag, lambda1, lambda2 in product(
        [0, 0.5, 1, 1.5, 2],
        [-2, -1.5, -1.0, -0.5, 0, 0.5, 1, 1.5, 2],
        [-1, 0, 1],
    )],
)
def test_helicity_conservation(in_edge_qns, out_edge_qns, expected):
    assert helicity_conservation(in_edge_qns, out_edge_qns) is expected