Download this notebook here
.
Visualize decay topologies¶
The io.dot
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 list
of StateTransitionGraph
instances (see the Quickstart: Create an amplitude model).
First, we quickly create some dummy solutions. We’re not interested in the propagate process, so we decrease the logging
level as well
[1]:
import logging
logging.basicConfig(level=logging.ERROR)
[2]:
from expertsystem.amplitude.helicity_decay import HelicityAmplitudeGenerator
from expertsystem.ui import InteractionTypes, StateTransitionManager
stm = StateTransitionManager(
initial_state=[("J/psi(1S)", [-1, 1])],
final_state=["gamma", "pi0", "pi0"],
allowed_intermediate_particles=["f(0)(980)", "f(0)(1500)",],
)
stm.set_allowed_interaction_types([InteractionTypes.EM])
graph_interaction_settings_groups = stm.prepare_graphs()
solutions, _ = stm.find_solutions(graph_interaction_settings_groups)
Now, we use the convert_to_dot
function to create a str
of DOT language for the list of solutions (StateTransitionGraph
instances):
[3]:
from expertsystem import io
dot_source = io.dot.convert_to_dot(solutions)
This str
can then be visualized with a third-party library, for instance, with graphviz.Source
:
[4]:
import graphviz
graphviz.Source(dot_source)
[4]:
Note
graphviz
requires your system to have DOT installed, see Installation.
You can also serialize the DOT string to file with io.write
. The file extension for a DOT file is .gv
:
[5]:
io.write(instance=solutions, filename="decay_topologies.gv")