Generic Diagram

Routines and class for all types of diagrams, inherited by others.

class adg.diag.Diagram(nx_graph)[source]

Bases: object

Describes a diagram with its related properties.

Parameters

nx_graph (NetworkX MultiDiGraph) – The graph of interest.

degrees

The ascendingly sorted degrees of the graph vertices.

Type

tuple

graph

The actual graph.

Type

NetworkX MultiDiGraph

io_degrees

The sorted version of unsort_io_degrees.

Type

tuple

max_degree

The maximal degree of a vertex in the graph.

Type

int

tags

The tag numbers associated to a diagram.

Type

list

unsort_degrees

The degrees of the graph vertices

Type

tuple

unsort_io_degrees

The list of in- and out-degrees for each vertex of the graph, stored in a (in, out) tuple.

Type

tuple

write_graph(latex_file, directory, write_time)[source]

Write the graph of the diagram to the LaTeX file.

Parameters
  • latex_file (file) – The LaTeX ouput file of the program.

  • directory (str) – Path to the result folder.

  • write_time (bool) – (Here to emulate polymorphism).

adg.diag.bimsrg_diagram_internals(graph, fmf_file, prop_type)[source]

Write to file the vertices and propagators of BIMSRG diagrams.

Parameters
  • graph (NetworkX MultiDiGraph) – The graph to be drawn.

  • fmf_file (file) – The FeymanMF file to be written to.

  • prop_type (str) – The FeymanMF type for drawing the propagators.

adg.diag.check_vertex_degree(matrices, three_body_use, nbody_max_observable, canonical_only, vertex_id)[source]

Check the degree of a specific vertex in a set of matrices.

Parameters
  • matrices (list) – Adjacency matrices.

  • three_body_use (bool) – True if one uses three-body forces.

  • nbody_max_observable (int) – Maximum body number for the observable.

  • canonical_only (bool) – True if one draws only canonical diagrams.

  • vertex_id (int) – The position of the studied vertex.

>>> test_matrices = [numpy.array([[0, 1, 2], [1, 0, 1], [0, 2, 0]]),         numpy.array([[2, 0, 2], [1, 2, 3], [1, 0, 0]]),         numpy.array([[0, 1, 3], [2, 0, 8], [2, 1, 0]])]
>>> check_vertex_degree(test_matrices, True, 3, False, 0)
>>> test_matrices 
[array([[0, 1, 2], [1, 0, 1], [0, 2, 0]]),
 array([[2, 0, 2], [1, 2, 3], [1, 0, 0]])]
>>> check_vertex_degree(test_matrices, False, 2, False, 0)
>>> test_matrices 
[array([[0, 1, 2], [1, 0, 1], [0, 2, 0]])]
adg.diag.create_checkable_diagram(pbmbpt_graph)[source]

Return a graph with anomalous props going both ways for topo check.

Parameters

pbmbpt_graph (NetworkX MultiDiGraph) – The graph to be copied.

Returns

Graph with double the anomalous props.

Return type

NetworkX MultiDiGraph

adg.diag.draw_diagram(directory, result_file, diagram_index, diag_type)[source]

Copy the diagram feynmanmp instructions in the result file.

Parameters
  • directory (str) – The path to the output folder.

  • result_file (file) – The LaTeX ouput file of the program.

  • diagram_index (str) – The number associated to the diagram.

  • diag_type (str) – The type of diagram used here.

adg.diag.extract_denom(start_graph, subgraph)[source]

Extract the appropriate denominator using the subgraph rule.

Parameters
  • start_graph (NetworkX MultiDiGraph) – The studied graph.

  • subgraph (NetworkX MultiDiGraph) – The subgraph used for this particular denominator factor.

Returns

The denominator factor for this subgraph.

Return type

str

adg.diag.feynmf_generator(graph, theory_type, diagram_name)[source]

Generate the feynmanmp instructions corresponding to the diagram.

Parameters
  • graph (NetworkX MultiDiGraph) – The graph of interest.

  • theory_type (str) – The name of the theory of interest.

  • diagram_name (str) – The name of the studied diagram.

adg.diag.label_vertices(graphs_list, theory_type, switch_flag)[source]

Account for different status of vertices in operator diagrams.

Parameters
  • graphs_list (list) – The Diagrams of interest.

  • theory_type (str) – The name of the theory of interest.

  • switch_flag (int) – When to switch A and B operators for BIMSRG.

adg.diag.no_trace(matrices)[source]

Select matrices with full 0 diagonal.

Parameters

matrices (list) – A list of adjacency matrices.

Returns

The adjacency matrices without non-zero diagonal elements.

Return type

list

>>> test_matrices = [[[0, 1, 2], [2, 0, 1], [5, 2, 0]],     [[2, 2, 2], [1, 2, 3], [0, 0, 0]],     [[0, 1, 3], [2, 0, 8], [2, 1, 0]]]
>>> no_trace(test_matrices)
[[[0, 1, 2], [2, 0, 1], [5, 2, 0]], [[0, 1, 3], [2, 0, 8], [2, 1, 0]]]
adg.diag.print_adj_matrices(directory, diagrams)[source]

Print a computer-readable file with the diagrams’ adjacency matrices.

Parameters
  • directory (str) – The path to the output directory.

  • diagrams (list) – All the diagrams.

adg.diag.prop_directions(vert_distance, nb_props)[source]

Return a list of possible propagators directions.

Parameters
  • vert_distance (int) – Distance between the two connected vertices.

  • nb_props (int) – Number of propagators to be drawn.

Returns

Propagators directions stored as strings.

Return type

list

adg.diag.propagator_style(prop_type)[source]

Return the FeynMF definition for the appropriate propagator type.

Parameters

prop_type (str) – The type of propagators used in the diagram.

Returns

The FeynMF definition for the propagator style used.

Return type

str

adg.diag.self_contractions(graph)[source]

Return the instructions for drawing the graph’s self-contractions.

Parameters

graph (NetworkX MultiDiGraph) – The graph being drawn.

Returns

FeynMF instructions for drawing the self-contractions.

Return type

str

adg.diag.to_skeleton(graph)[source]

Return the bare skeleton of a graph, i.e. only non-redundant links.

Parameters

graph (NetworkX MultiDiGraph) – The graph to be turned into a skeleton.

Returns

The skeleton of the initial graph.

Return type

NetworkX MultiDiGraph

adg.diag.topologically_distinct_diagrams(diagrams)[source]

Return a list of diagrams all topologically distinct.

Parameters

diagrams (list) – The Diagrams of interest.

Returns

Topologically unique diagrams.

Return type

list

adg.diag.update_permutations(comp_graph_perms, comp_graph_tag, mapping)[source]

Update permutations associated to the BMBPT diags for a shared TSD.

Parameters
  • comp_graph_perms (dict) – Permutations to be updated.

  • comp_graph_tag (int) – The tag associated to the TSD configuration.

  • mapping (dict) – permutations to go from previous ref TSD to new one.

adg.diag.vertex_positions(graph, order)[source]

Return the positions of the graph’s vertices.

Parameters
  • graph (NetworkX MultiDiGraph) – The graph of interest.

  • order (int) – The perturbative order of the graph.

Returns

The FeynMP instructions for positioning the vertices.

Return type

str