MBPT diagram

Routines and class for Many-Body Perturbation Theory diagrams.

class adg.mbpt.MbptDiagram(mbpt_graph, tag_num)[source]

Bases: Diagram

Describes a MBPT diagram with its related properties.

Parameters
  • mbpt_graph (NetworkX MultiDiGraph) – The actual diagram.

  • tag_num (int) – The tag number associated to the graph.

adjacency_mat

The adjacency matrix of the graph.

Type

NumPy array

attribute_expression()[source]

Initialize the expression associated to the diagram.

attribute_ph_labels()[source]

Attribute the appropriate qp labels to the graph’s propagators.

calc_excitation()[source]

Return an integer coding for the excitation level of the diag.

Returns

The singles / doubles / etc. character of the graph.

Return type

int

cd_denominator()[source]

Return the computer-readable denominator of the graph.

Returns

The graph denominator tailored for automated frameworks.

Return type

str

cd_expr

The expression associated to the diagram in a computer-readable format.

Type

str

cd_numerator()[source]

Return the computer-readable numerator.

Returns

The graph numerator tailored for automated frameworks.

Return type

str

complex_conjugate

The tag number of the diagram’s complex conjugate. -1 if the graph has none.

Type

int

count_hole_lines()[source]

Return an integer for the number of hole lines in the graph.

Returns

The number of holes in the diagram.

Return type

int

degrees

The ascendingly sorted degrees of the graph vertices.

Type

tuple

excitation_level

The single, double, etc., excitation character.

Type

int

expr

The MBPT expression associated to the diagram.

Type

str

extract_denominator()[source]

Return the denominator for a MBPT graph.

Returns

The denominator of the diagram.

Return type

str

extract_numerator()[source]

Return the numerator associated to a MBPT graph.

Returns

The numerator of the diagram.

Return type

str

graph

The actual graph.

Type

NetworkX MultiDiGraph

incidence

The incidence matrix of the graph.

Type

NumPy array

io_degrees

The sorted version of unsort_io_degrees.

Type

tuple

is_complex_conjug_of(test_diagram)[source]

Return True if self and test_diagram are complex conjugate.

Parameters

test_diagram (MbptDiagram) – A diagram to compare with.

Returns

The complex conjugate status of the pair of diagrams.

Return type

bool

loops_number()[source]

Return the number of loops in the diagram as an integer.

Returns

The number of loops in the graph.

Return type

int

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)

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).

write_section(result, commands, flags)[source]

Write sections for MBPT result file.

Parameters
  • result (file) – The LaTeX output file to be written in.

  • commands (dict) – The flags associated with run management.

  • flags (dict) – The identifier of each section-starting graph.

adg.mbpt.attribute_conjugate(diagrams)[source]

Attribute to each diagram its complex conjugate.

The diagrams involved in conjugate pairs receive the tag associated to their partner in the complex_conjugate attribute.

Parameters

diagrams (list) – The topologically unique MbptDiagrams.

adg.mbpt.diagrams_generation(order)[source]

Generate the diagrams for the MBPT case.

Parameters

order (int) – The perturbative order of interest.

Returns

A list of NumPy arrays with the diagrams adjacency matrices.

Return type

list

>>> diagrams_generation(2) 
[array([[0, 2], [2, 0]])]
>>> diagrams_generation(3) 
[array([[0, 2, 0], [0, 0, 2], [2, 0, 0]]),
 array([[0, 1, 1], [1, 0, 1], [1, 1, 0]]),
 array([[0, 0, 2], [2, 0, 0], [0, 2, 0]])]
>>> diagrams_generation(1)
[]
adg.mbpt.extract_cd_denom(start_graph, subgraph)[source]

Extract the computer-readable denominator using the subgraph rule.

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

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

Returns

The denominator factor associated to this subgraph.

Return type

str

adg.mbpt.order_diagrams(diagrams)[source]

Order the MBPT diagrams and return the number of diags for each type.

Parameters

diagrams (list) – The unordered MbptDiagrams.

Returns

First element are the ordered MbptDiagrams. Second element is the number of diagrams for each excitation level type.

Return type

tuple

adg.mbpt.print_cd_output(directory, diagrams)[source]

Print a computer-readable file for automated frameworks.

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

  • diagrams (list) – All the MbptDiagrams.

adg.mbpt.write_diag_exp(latex_file, mbpt_diag)[source]

Write the expression associated to a diagram in the LaTeX file.

Parameters
  • latex_file (file) – The LaTeX output file to be written in.

  • mbpt_diag (MbptDiagram) – The diagram which expression is being written.

adg.mbpt.write_header(tex_file, diags_nbs)[source]

Write tha appropriate header for the LaTeX file for MBPT diagrams.

Parameters
  • tex_file (file) – The LaTeX ouput file to be written in.

  • diags_nbs (dict) – A dict with the number of diagrams per excitation level type.