Visualize decay topologies

Binder Colab

The io module allows you to convert a StateTransitionGraph to DOT language, which you can then visualize with third-party libraries such as Graphviz. This is particularly useful after running find_solutions, which produces a Result object with a list of StateTransitionGraph instances (see the Common workflow).

Setup

In this notebook, we’ll visualize the allowed transitions for the decay \(\psi' \to \gamma\eta\eta\) as an example.

[3]:
import expertsystem as es

result = es.reaction.generate(
    initial_state="psi(2S)",
    final_state=["gamma", "eta", "eta"],
    allowed_interaction_types="EM",
)

Convert to DOT and visualize

As noted in the usual workflow, the solutions contain all spin projection combinations (which is necessary for the amplitude module). It is possible to convert all these solutions to DOT language with io.convert_to_dot. To avoid visualizing all solutions, we just take a subset of the solutions:

[4]:
dot_source = es.io.convert_to_dot(result.solutions[::50][:3])  # just some selection

This str of DOT language for the list of StateTransitionGraph instances can then be visualized with a third-party library, for instance, with graphviz.Source:

[5]:
import graphviz

graphviz.Source(dot_source)
[5]:
../_images/usage_visualization_14_0.svg

You can also serialize the DOT string to file with io.write. The file extension for a DOT file is .gv:

[6]:
es.io.write(result.solutions, "decay_topologies_with_spin.gv")

Collapse graphs

Since this list of all possible spin projections (solutions) is rather long, it is often useful to make use of the get_particle_graphs or collapse_graphs methods to bundle comparable graphs. First, get_particle_graphs allows one collapse (ignore) the spin projections (we again show a selection only):

[7]:
graphs = result.get_particle_graphs()
dot_source = es.io.convert_to_dot(graphs[:3])
graphviz.Source(dot_source)
[7]:
../_images/usage_visualization_19_0.svg

If that list is still too much, there is collapse_graphs, which bundles all graphs with the same final state groupings:

[8]:
graphs = result.collapse_graphs()
dot_source = es.io.convert_to_dot(graphs)
graphviz.Source(dot_source)
[8]:
../_images/usage_visualization_21_0.svg