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 QRules from interface #281

Open
Tracked by #318
redeboer opened this issue Apr 27, 2022 · 1 comment
Open
Tracked by #318

Remove QRules from interface #281

redeboer opened this issue Apr 27, 2022 · 1 comment
Labels
Epic Collection of issues ⚠️ Interface Breaking changes to the API 🔨 Maintenance Maintenance and upkeep improvements
Milestone

Comments

@redeboer
Copy link
Member

redeboer commented Apr 27, 2022

It would be better if AmpForm modules can be built from an internal data structure, just like is happening in ComPWA/compwa.github.io#129 and ComPWA/compwa.github.io#133 (see in particular ComPWA/compwa.github.io#133 (comment)). That would make it easier to build up an amplitude model without having to generate all transitions with QRules. A problem with QRules is that its Transition class is too general for isobar decays, which makes the amplitude building code clunky.

So we need a data structure that:

  1. contains all information about an isobar decay that's required to formulate a complete amplitude model, including:
    • polarizations (helicities) of initial state and final states
    • resonances and their decay products (particularly the final state products to which they decay)
    • (?) spectator particles of those resonances
    • optional: LS-couplings
    • ...?
  2. is easy to navigate over while building up the amplitude expression
  3. is easy to construct for users
@redeboer redeboer added 🔨 Maintenance Maintenance and upkeep improvements ⚠️ Interface Breaking changes to the API labels Apr 27, 2022
@redeboer redeboer self-assigned this Apr 27, 2022
@redeboer
Copy link
Member Author

Some idea:

from typing import Generic

from attrs import frozen

State = TypeVar("State")
Interaction = TypeVar("Interaction")


@frozen
class IsobarNode(Generic[State, Interaction]):
    parent: State
    child1: State | IsobarNode
    child2: State | IsobarNode
    interaction: Interaction | None = field(default=None)

    @property
    def children(self) -> tuple[State, ...]:
        def flatten(
            obj: State | IsobarNode[State, Interaction]
        ) -> Sequence[State]:
            if isinstance(obj, IsobarNode):
                return obj.children
            return [obj]

        return (*flatten(self.child1), *flatten(self.child2))

where State and Interaction could be further specified with e.g.:

import sympy as sp

@frozen
class Particle:  # State
    name: str
    spin: sp.Rational
    # polarization: sp.Rational  # (?)
    parity: int


@frozen
class LSCoupling:  # Interaction
    L: int
    S: sp.Rational

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic Collection of issues ⚠️ Interface Breaking changes to the API 🔨 Maintenance Maintenance and upkeep improvements
Projects
Status: No status
Development

No branches or pull requests

1 participant