Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove need for spin projection in spin_magnitude_conservation rule #280

Closed
redeboer opened this issue Aug 9, 2024 · 1 comment · Fixed by #282
Closed

Remove need for spin projection in spin_magnitude_conservation rule #280

redeboer opened this issue Aug 9, 2024 · 1 comment · Fixed by #282
Assignees
Labels
⚙️ Enhancement Improvements and optimizations of existing features
Milestone

Comments

@redeboer
Copy link
Member

redeboer commented Aug 9, 2024

The spin_magnitude_conservation() rule requires SpinEdgeInput, which has a spin_projection attribute, even though the rule implementation does not need it. This is a problem for #158. That issue either needs to work with spin projections for now (which is what we eventually want to remove, see #219) or we need to remove the need for providing a spin projection altogether by solving this issue first.

def spin_magnitude_conservation(
ingoing_spins: List[SpinEdgeInput],
outgoing_spins: List[SpinEdgeInput],
interaction_qns: SpinMagnitudeNodeInput,
) -> bool:
r"""Check for spin conservation.
Implements
.. math::
|S_1 - S_2| \leq S \leq |S_1 + S_2|
and
.. math::
|L - S| \leq J \leq |L + S|
"""
# 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
):
return _check_magnitude(
[x.spin_magnitude for x in ingoing_spins],
[x.spin_magnitude for x in outgoing_spins],
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]
)

@redeboer redeboer added the ⚙️ Enhancement Improvements and optimizations of existing features label Aug 9, 2024
@redeboer redeboer added this to the 0.10.3 milestone Aug 9, 2024
@grayson-helmholz
Copy link
Contributor

grayson-helmholz commented Aug 26, 2024

Has been implemented in the remove_spin-projections_in_cons-rules-branch. Issue should be closeable after merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙️ Enhancement Improvements and optimizations of existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants