Skip to content

Commit

Permalink
removed projections from spin-mag.-cons.
Browse files Browse the repository at this point in the history
  • Loading branch information
grayson-helmholz committed Aug 22, 2024
1 parent e54289e commit a045be5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/qrules/conservation_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,8 @@ def spin_conservation(


def spin_magnitude_conservation(
ingoing_spins: List[SpinEdgeInput],
outgoing_spins: List[SpinEdgeInput],
ingoing_spin_magnitudes: List[EdgeQN.spin_magnitude],
outgoing_spin_magnitudes: List[EdgeQN.spin_magnitude],
interaction_qns: SpinMagnitudeNodeInput,
) -> bool:
r"""Check for spin conservation.
Expand All @@ -710,20 +710,20 @@ def spin_magnitude_conservation(
# L and S can only be used if one side is a single state
# and the other side contains of two states (isobar)
# So do a full check if this is the case
if (len(ingoing_spins) == 1 and len(outgoing_spins) == 2) or (
len(ingoing_spins) == 2 and len(outgoing_spins) == 1
if (len(ingoing_spin_magnitudes) == 1 and len(outgoing_spin_magnitudes) == 2) or (
len(ingoing_spin_magnitudes) == 2 and len(outgoing_spin_magnitudes) == 1
):
return _check_magnitude(
[x.spin_magnitude for x in ingoing_spins],
[x.spin_magnitude for x in outgoing_spins],
[float(x) for x in ingoing_spin_magnitudes],
[float(x) for x in outgoing_spin_magnitudes],
interaction_qns,
)

# otherwise don't use S and L and just check magnitude
# are integral or non integral on both sides
return (
sum(float(x.spin_magnitude) for x in ingoing_spins).is_integer() # type: ignore[union-attr]
== sum(float(x.spin_magnitude) for x in outgoing_spins).is_integer() # type: ignore[union-attr]
sum(float(x) for x in ingoing_spin_magnitudes).is_integer() # type: ignore[union-attr]
== sum(float(x) for x in outgoing_spin_magnitudes).is_integer() # type: ignore[union-attr]
)


Expand Down
7 changes: 6 additions & 1 deletion tests/unit/conservation_rules/test_spin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
spin_magnitude_conservation,
)
from qrules.particle import Spin
from qrules.quantum_numbers import EdgeQuantumNumbers

_SpinRuleInputType = Tuple[List[SpinEdgeInput], List[SpinEdgeInput], SpinNodeInput]
_SpinRuleInputType = Tuple[
List[EdgeQuantumNumbers.spin_magnitude],
List[EdgeQuantumNumbers.spin_magnitude],
SpinNodeInput,
]


def __create_two_body_decay_spin_data(
Expand Down

0 comments on commit a045be5

Please sign in to comment.