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')
Exemple #2
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'])
Exemple #3
0
    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()
xml_generator.generate(solutions)
xml_generator.write_to_file("test.xml")
Exemple #4
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()
    )