Exemplo n.º 1
0
def test_script():
    logging.basicConfig(level=logging.INFO)
    logging.getLogger().setLevel(logging.INFO)
    # initialize the graph edges (initial and final state)
    initial_state = [("D0", [0])]
    final_state = [("K_S0", [0]), ("K+", [0]), ("K-", [0])]

    tbd_manager = StateTransitionManager(initial_state, final_state,
                                         ["a0", "phi", "a2(1320)-"])
    tbd_manager.number_of_threads = 2

    graph_interaction_settings_groups = tbd_manager.prepare_graphs()
    (solutions, violated_rules
     ) = tbd_manager.find_solutions(graph_interaction_settings_groups)

    print("found " + str(len(solutions)) + " solutions!")
    assert len(solutions) == 5

    # print intermediate state particle names
    for g in solutions:
        print(g.edge_props[1]["@Name"])

    xml_generator = HelicityAmplitudeGeneratorXML()
    xml_generator.generate(solutions)
    xml_generator.write_to_file("D0ToKs0KpKm.xml")
Exemplo n.º 2
0
def test_external_edge_identical_particle_combinatorics(
        initial_state, final_state, final_state_groupings, result_graph_count):
    tbd_manager = StateTransitionManager(initial_state,
                                         final_state, [],
                                         formalism_type='helicity')

    tbd_manager.set_allowed_interaction_types([InteractionTypes.Strong])
    for x in final_state_groupings:
        tbd_manager.add_final_state_grouping(x)
    tbd_manager.number_of_threads = 1

    topology_graphs = tbd_manager.build_topologies()

    init_graphs = tbd_manager.create_seed_graphs(topology_graphs)
    match_external_edges(init_graphs)

    comb_graphs = []
    for x in init_graphs:
        comb_graphs.extend(
            perform_external_edge_identical_particle_combinatorics(x))
    assert len(comb_graphs) == result_graph_count

    ref_mapping_fs = create_edge_id_particle_mapping(comb_graphs[0],
                                                     get_final_state_edges)
    ref_mapping_is = create_edge_id_particle_mapping(comb_graphs[0],
                                                     get_initial_state_edges)

    for x in comb_graphs[1:]:
        assert ref_mapping_fs == create_edge_id_particle_mapping(
            x, get_final_state_edges)
        assert ref_mapping_is == create_edge_id_particle_mapping(
            x, get_initial_state_edges)
Exemplo n.º 3
0
def test_edge_swap(initial_state, final_state):
    tbd_manager = StateTransitionManager(initial_state,
                                         final_state, [],
                                         formalism_type='helicity')

    tbd_manager.set_allowed_interaction_types([InteractionTypes.Strong])
    tbd_manager.number_of_threads = 1

    topology_graphs = tbd_manager.build_topologies()
    init_graphs = tbd_manager.create_seed_graphs(topology_graphs)

    for x in init_graphs:
        ref_mapping = create_edge_id_particle_mapping(x, get_final_state_edges)
        edge_keys = list(ref_mapping.keys())
        edge1 = edge_keys[0]
        edge1_val = x.edges[edge1]
        edge1_props = x.edge_props[edge1]
        edge2 = edge_keys[1]
        edge2_val = x.edges[edge2]
        edge2_props = x.edge_props[edge2]
        x.swap_edges(edge1, edge2)
        assert x.edges[edge1] == edge2_val
        assert x.edges[edge2] == edge1_val
        assert x.edge_props[edge1] == edge2_props
        assert x.edge_props[edge2] == edge1_props
Exemplo n.º 4
0
def test_external_edge_initialization(initial_state, final_state,
                                      final_state_groupings,
                                      result_graph_count):
    tbd_manager = StateTransitionManager(initial_state,
                                         final_state, [],
                                         formalism_type='helicity')

    tbd_manager.set_allowed_interaction_types([InteractionTypes.Strong])
    for x in final_state_groupings:
        tbd_manager.add_final_state_grouping(x)
    tbd_manager.number_of_threads = 1

    topology_graphs = tbd_manager.build_topologies()

    init_graphs = tbd_manager.create_seed_graphs(topology_graphs)
    assert len(init_graphs) == result_graph_count
Exemplo n.º 5
0
def test_general_reaction(test_input, expected):
    # define all of the different decay scenarios
    print("processing case:" + str(test_input))

    tbd_manager = StateTransitionManager(
        test_input[0],
        test_input[1],
        formalism_type="canonical",
        topology_building="nbody",
        propagation_mode="full",
    )

    graph_interaction_settings = tbd_manager.prepare_graphs()
    (solutions,
     violated_rules) = tbd_manager.find_solutions(graph_interaction_settings)

    if len(solutions) > 0:
        print("is valid")
        assert len(expected) == 0
    else:
        print("not allowed! violates: " + str(violated_rules))
        assert set(violated_rules) == set(expected)
Exemplo n.º 6
0
def test_canonical_clebsch_gordan_ls_coupling(initial_state, final_state, L, S,
                                              solution_count):
    # because the amount of solutions is too big we change the default domains
    formalism_type = "canonical-helicity"
    int_settings = create_default_interaction_settings(formalism_type)

    remove_conservation_law(int_settings[InteractionTypes.Strong],
                            ParityConservationHelicity())

    tbd_manager = StateTransitionManager(
        initial_state,
        final_state,
        [],
        interaction_type_settings=int_settings,
        formalism_type=formalism_type,
    )

    tbd_manager.set_allowed_interaction_types([InteractionTypes.Strong])
    tbd_manager.number_of_threads = 2
    tbd_manager.filter_remove_qns = []

    l_label = InteractionQuantumNumberNames.L
    s_label = InteractionQuantumNumberNames.S
    qn_label = XMLLabelConstants.QuantumNumber

    spin_converter = SpinQNConverter()
    node_props = {
        0: {
            qn_label.name: [
                spin_converter.convert_to_dict(l_label, L),
                spin_converter.convert_to_dict(s_label, S),
            ]
        }
    }
    graph_node_setting_pairs = tbd_manager.prepare_graphs()
    for v in graph_node_setting_pairs.values():
        for e in v:
            e[0].node_props = node_props

    solutions = tbd_manager.find_solutions(graph_node_setting_pairs)[0]

    assert len(solutions) == solution_count
def test_script():
    logging.basicConfig(level=logging.INFO)
    # initialize the graph edges (initial and final state)
    initial_state = [("J/psi", [-1, 1])]
    final_state = [("gamma", [-1, 1]), ("pi0", [0]), ("pi0", [0])]

    tbd_manager = StateTransitionManager(
        initial_state, final_state, ["f0", "f2", "omega"]
    )
    tbd_manager.number_of_threads = 2
    tbd_manager.set_allowed_interaction_types(
        [InteractionTypes.Strong, InteractionTypes.EM]
    )
    graph_interaction_settings_groups = tbd_manager.prepare_graphs()

    (solutions, violated_rules) = tbd_manager.find_solutions(
        graph_interaction_settings_groups
    )

    print("found " + str(len(solutions)) + " solutions!")
    assert len(solutions) == 48

    ref_mapping_fs = create_edge_id_particle_mapping(
        solutions[0], get_final_state_edges
    )
    ref_mapping_is = create_edge_id_particle_mapping(
        solutions[0], get_initial_state_edges
    )
    for x in solutions[1:]:
        assert ref_mapping_fs == create_edge_id_particle_mapping(
            x, get_final_state_edges
        )
        assert ref_mapping_is == create_edge_id_particle_mapping(
            x, get_initial_state_edges
        )

    print("intermediate states:")
    intermediate_states = set()
    for g in solutions:
        int_edge_id = get_intermediate_state_edges(g)[0]
        intermediate_states.add(g.edge_props[int_edge_id]["@Name"])
    print(intermediate_states)

    xml_generator = HelicityAmplitudeGeneratorXML()
    xml_generator.generate(solutions)
    xml_generator.write_to_file("JPsiToGammaPi0Pi0.xml")
Exemplo n.º 8
0
def test_strong_reactions(test_input, expected):
    # general checks
    print("processing case:" + str(test_input))

    tbd_manager = StateTransitionManager(test_input[0], test_input[1], [], {},
                                         'canonical', 'nbody')

    tbd_manager.set_allowed_interaction_types([InteractionTypes.Strong])

    graph_interaction_settings = tbd_manager.prepare_graphs()
    (solutions,
     violated_rules) = tbd_manager.find_solutions(graph_interaction_settings)

    assert set(violated_rules) == set(expected)
Exemplo n.º 9
0
def test_strong_reactions(test_input, expected):
    # general checks
    print("processing case:" + str(test_input))

    tbd_manager = StateTransitionManager(
        test_input[0],
        test_input[1],
        formalism_type="canonical",
        topology_building="nbody",
        propagation_mode="full",
    )

    tbd_manager.set_allowed_interaction_types([InteractionTypes.Strong])

    graph_interaction_settings = tbd_manager.prepare_graphs()
    (solutions,
     violated_rules) = tbd_manager.find_solutions(graph_interaction_settings)

    assert set(violated_rules) == set(expected)
Exemplo n.º 10
0
def test_match_external_edges(initial_state, final_state):
    tbd_manager = StateTransitionManager(initial_state,
                                         final_state, [],
                                         formalism_type='helicity')

    tbd_manager.set_allowed_interaction_types([InteractionTypes.Strong])
    tbd_manager.number_of_threads = 1

    topology_graphs = tbd_manager.build_topologies()
    init_graphs = tbd_manager.create_seed_graphs(topology_graphs)

    match_external_edges(init_graphs)

    ref_mapping_fs = create_edge_id_particle_mapping(init_graphs[0],
                                                     get_final_state_edges)
    ref_mapping_is = create_edge_id_particle_mapping(init_graphs[0],
                                                     get_initial_state_edges)

    for x in init_graphs[1:]:
        assert ref_mapping_fs == create_edge_id_particle_mapping(
            x, get_final_state_edges)
        assert ref_mapping_is == create_edge_id_particle_mapping(
            x, get_initial_state_edges)
Exemplo n.º 11
0
def generate_model_xml():
    from expertsystem.ui.system_control import (StateTransitionManager,
                                                InteractionTypes)

    from expertsystem.amplitude.helicitydecay import (
        HelicityDecayAmplitudeGeneratorXML)

    from expertsystem.state.particle import get_xml_label, XMLLabelConstants
    # initialize the graph edges (initial and final state)
    initial_state = [("D1(2420)0", [-1, 1])]
    final_state = [("D0", [0]), ("pi-", [0]), ("pi+", [0])]

    tbd_manager = StateTransitionManager(initial_state, final_state, ['D*'])
    tbd_manager.number_of_threads = 1
    tbd_manager.set_allowed_interaction_types([InteractionTypes.Strong])
    graph_interaction_settings_groups = tbd_manager.prepare_graphs()

    (solutions, violated_rules
     ) = tbd_manager.find_solutions(graph_interaction_settings_groups)

    print("found " + str(len(solutions)) + " solutions!")

    print("intermediate states:")
    decinfo_label = get_xml_label(XMLLabelConstants.DecayInfo)
    for g in solutions:
        print(g.edge_props[1]['@Name'])
        for edge_props in g.edge_props.values():
            if decinfo_label in edge_props:
                del edge_props[decinfo_label]
                edge_props[decinfo_label] = {
                    get_xml_label(XMLLabelConstants.Type): "nonResonant"
                }

    xml_generator = HelicityDecayAmplitudeGeneratorXML()
    xml_generator.generate(solutions)
    xml_generator.write_to_file('model.xml')
Exemplo n.º 12
0
import logging

from expertsystem.ui.system_control import (StateTransitionManager,
                                            InteractionTypes)

logging.basicConfig(level=logging.INFO)

# initialize the graph edges (initial and final state)
initial_state = [("EpEm", [-1, 1])]
final_state = [("Chic1", [-1, 1]), ("pi+", [0]), ("pi-", [0])]

tbd_manager = StateTransitionManager(initial_state, final_state, [], {},
                                     'canonical')
tbd_manager.add_final_state_grouping([["Chic1", "pi+"]])
tbd_manager.set_allowed_interaction_types([InteractionTypes.EM])

graph_node_setting_pairs = tbd_manager.prepare_graphs()
(solutions,
 violated_rules) = tbd_manager.find_solutions(graph_node_setting_pairs)

print("found " + str(len(solutions)) + " solutions!")
if len(solutions) == 0:
    print("violated rules: " + str(violated_rules))

print("intermediate states:")
for g in solutions:
    print(g.edge_props[1]['@Name'])
Exemplo n.º 13
0
from expertsystem.ui.system_control import (
    StateTransitionManager,
    InteractionTypes,
)

from expertsystem.amplitude.helicitydecay import (
    HelicityDecayAmplitudeGeneratorXML, )

logging.basicConfig(level=logging.INFO)

# initialize the graph edges (initial and final state)
initial_state = [("J/psi", [1])]
final_state = [("pi0", [0]), ("pi+", [0]), ("pi-", [0])]

tbd_manager = StateTransitionManager(initial_state, final_state, ["rho"])
# tbd_manager.number_of_threads = 1
tbd_manager.add_final_state_grouping(["pi+", "pi-"])
tbd_manager.set_allowed_interaction_types([InteractionTypes.EM])
graph_interaction_settings_groups = tbd_manager.prepare_graphs()

(solutions, violated_rules
 ) = tbd_manager.find_solutions(graph_interaction_settings_groups)

print("found " + str(len(solutions)) + " solutions!")

print("intermediate states:")
for g in solutions:
    print(g.edge_props[1]["@Name"])

xml_generator = HelicityDecayAmplitudeGeneratorXML()
Exemplo n.º 14
0
""" sample script for the testing purposes using the decay
    e+e- -> D0 D0bar pi+ pi-
"""
import logging

from expertsystem.ui.system_control import StateTransitionManager

logging.basicConfig(level=logging.INFO)

# initialize the graph edges (intial and final state)
initial_state = [("EpEm", [-1, 1])]
final_state = [("D0", [0]), ("D0bar", [0]), ("pi+", [0]), ("pi-", [0])]

tbd_manager = StateTransitionManager(initial_state, final_state)

graph_node_setting_pairs = tbd_manager.prepare_graphs()
(solutions, violated_rules) = tbd_manager.find_solutions(graph_node_setting_pairs)

print("found " + str(len(solutions)) + " solutions!")

for g in solutions:
    #print(g.node_props[0])
    #print(g.node_props[1])
    print(g.edge_props[1]['@Name'])
Exemplo n.º 15
0
# initialize the graph edges (intial and final state)
initial_state = [("Y", [-1, 1])]
final_state = [("D0", [0]), ("D0bar", [0]), ("pi0", [0]), ("pi0", [0])]

# because the amount of solutions is too big we change the default domains
formalism_type = 'canonical-helicity'
int_settings = create_default_interaction_settings(formalism_type)
change_qn_domain(int_settings[InteractionTypes.Strong],
                 InteractionQuantumNumberNames.L,
                 create_spin_domain([0, 1], True))
change_qn_domain(int_settings[InteractionTypes.Strong],
                 InteractionQuantumNumberNames.S,
                 create_spin_domain([0, 1, 2], True))

tbd_manager = StateTransitionManager(initial_state,
                                     final_state, ['D*'],
                                     interaction_type_settings=int_settings,
                                     formalism_type=formalism_type)

tbd_manager.set_allowed_interaction_types([InteractionTypes.Strong])
tbd_manager.add_final_state_grouping([['D0', 'pi0'], ['D0bar', 'pi0']])
tbd_manager.number_of_threads = 2
tbd_manager.filter_remove_qns = []

graph_node_setting_pairs = tbd_manager.prepare_graphs()
# print(graph_node_setting_pairs)

(solutions,
 violated_rules) = tbd_manager.find_solutions(graph_node_setting_pairs)

print("found " + str(len(solutions)) + " solutions!")
Exemplo n.º 16
0
def test_script_simple():
    # initialize the graph edges (initial and final state)
    initial_state = [("Y", [-1, 1])]
    final_state = [("D*(2007)0", [-1, 0, 1]), ("D*(2007)0bar", [-1, 0, 1])]

    # because the amount of solutions is too big we change the default domains
    formalism_type = "canonical-helicity"
    int_settings = create_default_interaction_settings(formalism_type)
    change_qn_domain(
        int_settings[InteractionTypes.Strong],
        InteractionQuantumNumberNames.L,
        create_spin_domain([0, 1, 2, 3], True),
    )
    change_qn_domain(
        int_settings[InteractionTypes.Strong],
        InteractionQuantumNumberNames.S,
        create_spin_domain([0, 1, 2], True),
    )

    tbd_manager = StateTransitionManager(
        initial_state,
        final_state,
        ["D*"],
        interaction_type_settings=int_settings,
        formalism_type=formalism_type,
    )

    tbd_manager.set_allowed_interaction_types([InteractionTypes.Strong])
    # tbd_manager.add_final_state_grouping([['D0', 'pi0'], ['D0bar', 'pi0']])
    tbd_manager.number_of_threads = 2

    graph_node_setting_pairs = tbd_manager.prepare_graphs()

    solutions, _ = tbd_manager.find_solutions(graph_node_setting_pairs)

    print("found " + str(len(solutions)) + " solutions!")

    canonical_xml_generator = CanonicalAmplitudeGeneratorXML()
    canonical_xml_generator.generate(solutions)

    # because the amount of solutions is too big we change the default domains
    formalism_type = "helicity"
    int_settings = create_default_interaction_settings(formalism_type)
    change_qn_domain(
        int_settings[InteractionTypes.Strong],
        InteractionQuantumNumberNames.L,
        create_spin_domain([0, 1, 2, 3], True),
    )
    change_qn_domain(
        int_settings[InteractionTypes.Strong],
        InteractionQuantumNumberNames.S,
        create_spin_domain([0, 1, 2], True),
    )

    tbd_manager = StateTransitionManager(
        initial_state,
        final_state,
        ["D*"],
        interaction_type_settings=int_settings,
        formalism_type=formalism_type,
    )

    tbd_manager.set_allowed_interaction_types([InteractionTypes.Strong])
    tbd_manager.number_of_threads = 2

    graph_node_setting_pairs = tbd_manager.prepare_graphs()
    solutions, _ = tbd_manager.find_solutions(graph_node_setting_pairs)
    print("found " + str(len(solutions)) + " solutions!")

    helicity_xml_generator = HelicityAmplitudeGeneratorXML()
    helicity_xml_generator.generate(solutions)

    assert len(helicity_xml_generator.get_fit_parameters()) == len(
        canonical_xml_generator.get_fit_parameters()
    )