Custom topologies#

As illustrated in Generate transitions, the StateTransitionManager offers you a bit more flexibility than the façade function generate_transitions() used in the main Usage page. In this notebook, we go one step further, by specifying a custom Topology via StateTransitionManager.topologies.

Hide code cell content
import graphviz

import qrules
from qrules import InteractionType, StateTransitionManager
from qrules.topology import Edge, Topology

2-to-2 topology#

As a simple example, we start with a 2-to-2 scattering topology. We define it as follows:

topology = Topology(
    nodes=range(2),
    edges=enumerate(
        [
            Edge(None, 0),
            Edge(None, 0),
            Edge(1, None),
            Edge(1, None),
            Edge(0, 1),
        ],
        -2,
    ),
)
Hide code cell source
dot = qrules.io.asdot(
    topology,
    render_resonance_id=True,
    render_node=True,
    render_initial_state_id=True,
)
graphviz.Source(dot)
../_images/fdc022823ca93134298e693020bd2de8368d41d4b2dde99b44619e090cddbf6e.svg

First, we construct a StateTransitionManager for the transition \(K^-K^+ \to \pi^+\pi^-\). The constructed Topology can then be inserted via its topologies attribute:

stm = StateTransitionManager(
    initial_state=["K-", "K+"],
    final_state=["pi-", "pi+"],
    formalism="canonical",
)
stm.set_allowed_interaction_types([InteractionType.STRONG, InteractionType.EM])
stm.topologies = (topology,)  # tuple is immutable

For the rest, the process is just the same as in Generate transitions:

problem_sets = stm.create_problem_sets()
reaction_kk = stm.find_solutions(problem_sets)
Hide code cell source
dot = qrules.io.asdot(reaction_kk, collapse_graphs=True)
graphviz.Source(dot)
../_images/473cb8684c80bdc4879b591ceec8310d5b8c897fd0cb19138d1c350c8a17d028.svg

Warning

It is not yet possible to give the initial state a certain energy. So some collider process like \(e^-e^+\to\pi^+\pi\) does not result in a large number of resonances.

stm.initial_state = ["e-", "e+"]
problem_sets = stm.create_problem_sets()
reaction_ep = stm.find_solutions(problem_sets)
Hide code cell source
dot = qrules.io.asdot(reaction_ep, collapse_graphs=True)
graphviz.Source(dot)
../_images/8a08f40792ba04055e166cdb386abe6c8f93f5f0e61e3612a148e8439d000e7c.svg

What can do at most, is switch off MassConservation, either through the constructor of the StateTransitionManager, or by modifying ProblemSet.

stm = StateTransitionManager(
    initial_state=["e-", "e+"],
    final_state=["pi-", "pi+"],
    formalism="canonical",
    mass_conservation_factor=None,
)
stm.set_allowed_interaction_types([InteractionType.STRONG, InteractionType.EM])
stm.topologies = [topology]
problem_sets = stm.create_problem_sets()
reaction_ep_no_mass = stm.find_solutions(problem_sets)
Hide code cell source
dot = qrules.io.asdot(reaction_ep_no_mass, collapse_graphs=True)
graphviz.Source(dot)
../_images/6ca44d3d16d2f62c96fc75c304f6eae3b5cda67b377d0e932f2d929c621496cf.svg