예제 #1
0
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')
예제 #2
0
def test_canonical_clebsch_gordan_ls_couling(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 k, v in graph_node_setting_pairs.items():
        for e in v:
            e[0].node_props = node_props

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

    assert len(solutions) == solution_count
예제 #3
0
def generate_model_xml():
    from pycompwa.expertsystem.ui.system_control import (
        StateTransitionManager, InteractionTypes)

    from pycompwa.expertsystem.amplitude.helicitydecay import (
        HelicityDecayAmplitudeGeneratorXML)

    from pycompwa.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')
예제 #4
0
def test_script():
    logging.basicConfig(level=logging.INFO)
    # initialize the graph edges (intial 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')
예제 #5
0
from pycompwa.expertsystem.ui.system_control import (StateTransitionManager,
                                                     InteractionTypes)

from pycompwa.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')
예제 #6
0
def test_script_full():
    # initialize the graph edges (intial and final state)
    initial_state = [("Y", [-1, 1])]
    final_state = ["D0", "D0bar", "pi0", "pi0"]

    # 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,
     violated_rules) = tbd_manager.find_solutions(graph_node_setting_pairs)

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

    canonical_xml_generator = CanonicalDecayAmplitudeGeneratorXML()
    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.add_final_state_grouping([['D0', 'pi0'], ['D0bar', 'pi0']])
    tbd_manager.number_of_threads = 2

    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!")

    helicity_xml_generator = HelicityDecayAmplitudeGeneratorXML()
    helicity_xml_generator.generate(solutions)

    #print(helicity_xml_generator.fit_parameters,
    #      canonical_xml_generator.fit_parameters)
    assert (len(helicity_xml_generator.fit_parameters) == len(
        canonical_xml_generator.fit_parameters))
예제 #7
0
def test_script_full():
    # initialize the graph edges (intial and final state)
    initial_state = [("Y", [-1, 1])]
    final_state = ["D0", "D0bar", "pi0", "pi0"]

    # 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, violated_rules) = 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.add_final_state_grouping([['D0', 'pi0'], ['D0bar', 'pi0']])
    tbd_manager.number_of_threads = 2

    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!")

    helicity_xml_generator = HelicityAmplitudeGeneratorXML()
    helicity_xml_generator.generate(solutions)

    assert (len(helicity_xml_generator.get_fit_parameters()) ==
            len(canonical_xml_generator.get_fit_parameters()))
예제 #8
0
import logging

from pycompwa.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'])
예제 #9
0
""" sample script for the testing purposes using the decay
    e+e- -> D0 D0bar pi+ pi-
"""
import logging

from pycompwa.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'])
예제 #10
0
from pycompwa.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')