Esempio n. 1
0
    def __init__(self,
                 initial_state,
                 final_state,
                 allowed_intermediate_particles=[],
                 interaction_type_settings={},
                 formalism_type='helicity',
                 topology_building='isobar',
                 number_of_threads=4,
                 propagation_mode='fast'):
        self.number_of_threads = number_of_threads
        self.propagation_mode = propagation_mode
        self.initial_state = initial_state
        self.final_state = final_state
        self.interaction_type_settings = interaction_type_settings
        if not self.interaction_type_settings:
            self.interaction_type_settings = create_default_interaction_settings(
                formalism_type)
        self.interaction_determinators = [LeptonCheck(), GammaCheck()]
        self.allowed_intermediate_particles = allowed_intermediate_particles
        self.final_state_groupings = []
        self.allowed_interaction_types = [
            InteractionTypes.Strong, InteractionTypes.EM, InteractionTypes.Weak
        ]
        self.filter_remove_qns = []
        self.filter_ignore_qns = []
        if formalism_type == 'helicity':
            self.filter_remove_qns = [
                InteractionQuantumNumberNames.S,
                InteractionQuantumNumberNames.L
            ]
        if 'helicity' in formalism_type:
            self.filter_ignore_qns = [
                InteractionQuantumNumberNames.ParityPrefactor
            ]
        int_nodes = []
        if topology_building == 'isobar':
            if len(initial_state) == 1:
                int_nodes.append(InteractionNode("TwoBodyDecay", 1, 2))
        else:
            int_nodes.append(
                InteractionNode("NBodyScattering", len(initial_state),
                                len(final_state)))
            # turn of mass conservation, in case more than one initial state
            # particle is present
            if len(initial_state) > 1:
                self.interaction_type_settings = create_default_interaction_settings(
                    formalism_type, False)
        self.topology_builder = SimpleStateTransitionTopologyBuilder(int_nodes)

        # load default particles from database/file
        if len(particle_list) == 0:
            load_particle_list_from_xml(
                path.dirname(inspect.getfile(StateTransitionManager)) +
                '/../../particle_list.xml')
            # print(particle_list)
            logging.info("loaded " + str(len(particle_list)) +
                         " particles from xml file!")
Esempio n. 2
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
Esempio n. 3
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
Esempio n. 4
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))
Esempio n. 5
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()))