示例#1
0
def test_treat_tsds():
    """Test for the treat_tsds routine."""
    # Setup for the test with one non-tree and two isomorphic trees
    diagrams = [
        np.array([[0, 1, 1, 0], [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 0]]),
        np.array([[0, 2, 2, 0], [0, 0, 0, 0], [0, 0, 0, 2], [0, 0, 0, 0]]),
        np.array([[0, 2, 2, 0], [0, 0, 0, 2], [0, 0, 0, 0], [0, 0, 0, 0]])
    ]
    graphs = [nx.from_numpy_matrix(diagram,
                                   create_using=nx.MultiDiGraph(),
                                   parallel_edges=True)
              for diagram in diagrams]
    adg.diag.label_vertices(graphs, "BMBPT", -1)
    diags = [adg.bmbpt.BmbptFeynmanDiagram(graph, ind)
             for ind, graph in enumerate(graphs)]
    for diag in diags:
        diag.attribute_qp_labels()
    tsds = [adg.tsd.TimeStructureDiagram(diag) for diag in diags]

    result_tsds, nb_trees = adg.tsd.treat_tsds(tsds)

    assert nb_trees == 1
    assert len(result_tsds) == 2
    assert result_tsds[0].is_tree
    assert not result_tsds[1].is_tree
    assert len(result_tsds[1].equivalent_trees) == 2
示例#2
0
def test_generate_anomalous_diags():
    """Test for the generate_anomalous_diags routine."""
    # Generate a simple BMBPT diagram
    diagram = np.array([[0, 2, 2], [0, 0, 0], [0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], "BMBPT", -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()

    two_body_diags = adg.pbmbpt.generate_anomalous_diags(diag, 2)
    assert len(two_body_diags) == 3

    three_body_diags = adg.pbmbpt.generate_anomalous_diags(diag, 3)
    assert len(three_body_diags) == 6

    diagram = np.array([[0, 2, 0], [0, 0, 2], [0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], "BMBPT", -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()

    two_body_diags = adg.pbmbpt.generate_anomalous_diags(diag, 2)
    assert len(two_body_diags) == 6

    three_body_diags = adg.pbmbpt.generate_anomalous_diags(diag, 3)
    assert len(three_body_diags) == 18
示例#3
0
def test_resummation_power():
    """Test for the resummation_power method."""
    # Test for a linear tree TSD
    diagram = np.array([[0, 2, 2], [0, 0, 2], [0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], 'BMBPT', -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()
    tsd = adg.tsd.TimeStructureDiagram(diag)

    assert tsd.resummation_power() == 1

    # Test for a non-linear tree TSD
    diagram = np.array([[0, 2, 2], [0, 0, 0], [0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], 'BMBPT', -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()
    tsd = adg.tsd.TimeStructureDiagram(diag)

    assert tsd.resummation_power() == 2
示例#4
0
def test___init__():
    """Test the creation of TSD objects."""
    # Test for a tree TSD
    diagram = np.array([[0, 2, 2], [0, 0, 2], [0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], 'BMBPT', -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()
    tsd = adg.tsd.TimeStructureDiagram(diag)

    assert tsd.is_tree
    assert tsd.resum == 1

    # Test for the simplest non-tree TSD
    diagram = np.array([[0, 2, 2, 0],
                        [0, 0, 0, 2],
                        [0, 0, 0, 2],
                        [0, 0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], 'BMBPT', -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()
    tsd = adg.tsd.TimeStructureDiagram(diag)

    assert not tsd.is_tree
    assert tsd.resum == 0
示例#5
0
def test_time_tree_denominator():
    """Test for the time_tree_denominator method."""
    diagram = np.array([[0, 2, 2], [0, 0, 0], [0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], "BMBPT", -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()
    tsd = adg.tsd.TimeStructureDiagram(diag)

    denom_ref = "\\epsilon^{}_{k_{1}k_{2}}\\ \\epsilon^{}_{k_{3}k_{4}}\\ "
    assert diag.time_tree_denominator(tsd.graph) == denom_ref
示例#6
0
def test_extract_numerator():
    """Test for the extract_numerator method."""
    diagram = np.array([[0, 2, 2], [0, 0, 0], [0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], "BMBPT", -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()

    numerator_ref = 'O^{40}_{k_{1}k_{2}k_{3}k_{4}} \\Omega^{02}_{k_{1}k_{2}}' \
        + ' \\Omega^{02}_{k_{3}k_{4}} '
    assert diag.extract_numerator() == numerator_ref
示例#7
0
def test_vertex_expression():
    """Test the vertex_expression method."""
    # Set up the test case
    diagram = np.array([[0, 2, 2], [0, 0, 2], [0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)

    # attribute_qp_labels is used and thus tested in the process
    diag.attribute_qp_labels()

    assert diag.vertex_expression(0) == '\\epsilon^{k_{1}k_{2}k_{3}k_{4}}_{}'
    assert diag.vertex_expression(1) == '\\epsilon^{k_{5}k_{6}}_{k_{1}k_{2}}'
    assert diag.vertex_expression(2) == '\\epsilon^{}_{k_{3}k_{4}k_{5}k_{6}}'
示例#8
0
def produce_expressions(diagrams, diagrams_time):
    """Produce and store the expressions associated to the BMBPT diagrams.

    Args:
        diagrams (list): The list of all BmbptFeynmanDiagrams.
        diagrams_time (list): Their associates TSDs.

    """
    for diag in diagrams:
        diag.attribute_qp_labels()
        for t_diag in diagrams_time:
            if diag.unique_id in t_diag.tags[1:]:
                diag.time_tag = t_diag.tags[0]
                diag.tsd_is_tree = t_diag.is_tree
                break
        diag.attribute_expressions(diagrams_time[diag.time_tag])
示例#9
0
def test_extract_integral():
    """Test for the extract_integral method."""
    diagram = np.array([[0, 2, 2], [0, 0, 0], [0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], "BMBPT", -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()

    # Vertex expressions are needed prior to integral extraction
    diag.vert_exp = [diag.vertex_expression(vertex) for vertex in diag.graph]

    integral_ref = '\\mathrm{d}\\tau_1\\mathrm{d}\\tau_2' \
        + 'e^{-\\tau_1 \\epsilon^{}_{k_{1}k_{2}}}' \
        + 'e^{-\\tau_2 \\epsilon^{}_{k_{3}k_{4}}}'
    assert diag.extract_integral() == integral_ref
示例#10
0
def test_treat_cycles():
    """Test for the treat_cycles method."""
    # Test the simplest non-tree tsd
    diagram = np.array([[0, 2, 2, 0],
                        [0, 0, 0, 2],
                        [0, 0, 0, 2],
                        [0, 0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], 'BMBPT', -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()
    tsd = adg.tsd.TimeStructureDiagram(diag)

    equivalent_trees = tsd.treat_cycles()

    assert len(equivalent_trees) == 2
    assert list(equivalent_trees[1].edges()) == [(0, 1), (1, 2), (2, 3)]
    assert list(equivalent_trees[0].edges()) == [(0, 2), (1, 3), (2, 1)]

    # Test for a case with a longer branch
    diagram = np.array([[0, 2, 2, 0, 0],
                        [0, 0, 0, 2, 0],
                        [0, 0, 0, 0, 2],
                        [0, 0, 0, 0, 2],
                        [0, 0, 0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], 'BMBPT', -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()
    tsd = adg.tsd.TimeStructureDiagram(diag)

    equivalent_trees = tsd.treat_cycles()

    assert len(equivalent_trees) == 3
示例#11
0
def test_attribute_expressions():
    """Test the attribute_expressions method."""
    # Test for a simple diagram associated to a tree TSD
    diagram = np.array([[0, 2, 2], [0, 0, 0], [0, 0, 0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], "BMBPT", -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()
    tsd = adg.tsd.TimeStructureDiagram(diag)

    # Normally attributed in produce_expressions
    diag.tsd_is_tree = True

    diag.attribute_expressions(tsd)

    feyn_ref = '\\lim\\limits_{\\tau \\to \\infty}\\frac{(-1)^2 }{2(2!)^2}' \
        + '\\sum_{k_i}O^{40}_{k_{1}k_{2}k_{3}k_{4}} \\Omega^{02}_{k_{1}k_{2}}'\
        + ' \\Omega^{02}_{k_{3}k_{4}} \\int_{0}^{\\tau}\\mathrm{d}\\tau_1' \
        + '\\mathrm{d}\\tau_2e^{-\\tau_1 \\epsilon^{}_{k_{1}k_{2}}}' \
        + 'e^{-\\tau_2 \\epsilon^{}_{k_{3}k_{4}}}\n'

    diag_ref = '\\frac{(-1)^2 }{2(2!)^2}\\sum_{k_i}' \
        + '\\frac{O^{40}_{k_{1}k_{2}k_{3}k_{4}} \\Omega^{02}_{k_{1}k_{2}} ' \
        + '\\Omega^{02}_{k_{3}k_{4}} }{\\epsilon^{}_{k_{1}k_{2}}\\ ' \
        + '\\epsilon^{}_{k_{3}k_{4}}\\ } \n'

    assert diag.feynman_exp == feyn_ref
    assert diag.diag_exp == diag_ref

    # Test for a diagram associated to a non-tree TSD
    diagram = np.array([[0, 2, 2, 0], [0, 0, 0, 2], [0, 0, 0, 2], [0, 0, 0,
                                                                   0]])
    graph = nx.from_numpy_matrix(diagram,
                                 create_using=nx.MultiDiGraph(),
                                 parallel_edges=True)
    adg.diag.label_vertices([graph], "BMBPT", -1)
    diag = adg.bmbpt.BmbptFeynmanDiagram(graph, 0)
    diag.attribute_qp_labels()
    tsd = adg.tsd.TimeStructureDiagram(diag)
    tsd.equivalent_trees = tsd.treat_cycles()

    diag.attribute_expressions(tsd)

    feyn_ref = '\\lim\\limits_{\\tau \\to \\infty}\\frac{(-1)^3 }{2(2!)^4}' \
        + '\\sum_{k_i}O^{40}_{k_{1}k_{2}k_{3}k_{4}} ' \
        + '\\Omega^{22}_{k_{5}k_{6}k_{1}k_{2}} ' \
        + '\\Omega^{22}_{k_{7}k_{8}k_{3}k_{4}} ' \
        + '\\Omega^{04}_{k_{7}k_{8}k_{5}k_{6}} \\int_{0}^{\\tau}' \
        + '\\mathrm{d}\\tau_1\\mathrm{d}\\tau_2\\mathrm{d}\\tau_3' \
        + '\\theta(\\tau_3-\\tau_1) \\theta(\\tau_3-\\tau_2) ' \
        + 'e^{-\\tau_1 \\epsilon^{k_{5}k_{6}}_{k_{1}k_{2}}}' \
        + 'e^{-\\tau_2 \\epsilon^{k_{7}k_{8}}_{k_{3}k_{4}}}' \
        + 'e^{-\\tau_3 \\epsilon^{}_{k_{5}k_{6}k_{7}k_{8}}}\n'

    diag_ref = '\\frac{(-1)^3 }{2(2!)^4}\\sum_{k_i}' \
        + 'O^{40}_{k_{1}k_{2}k_{3}k_{4}} \\Omega^{22}_{k_{5}k_{6}k_{1}k_{2}} '\
        + '\\Omega^{22}_{k_{7}k_{8}k_{3}k_{4}} ' \
        + '\\Omega^{04}_{k_{7}k_{8}k_{5}k_{6}} \\left[' \
        + '\\frac{1}{\\epsilon^{}_{k_{1}k_{2}k_{7}k_{8}}\\ ' \
        + '\\epsilon^{}_{k_{1}k_{2}k_{3}k_{4}}\\ ' \
        + '\\epsilon^{}_{k_{5}k_{6}k_{7}k_{8}}\\ } + ' \
        + '\\frac{1}{\\epsilon^{}_{k_{1}k_{2}k_{3}k_{4}}\\ ' \
        + '\\epsilon^{}_{k_{3}k_{4}k_{5}k_{6}}\\ ' \
        + '\\epsilon^{}_{k_{5}k_{6}k_{7}k_{8}}\\ } \\right]\n'

    assert diag.feynman_exp == feyn_ref
    assert diag.diag_exp == diag_ref