MBPT diagram

Routines and class for Many-Body Perturbation Theory diagrams.

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

Bases: adg.diag.Diagram

Describes a MBPT diagram with its related properties.

incidence

The incidence matrix of the graph.

Type:NumPy array
excitation_level

The single, double, etc., excitation character.

Type:int
complex_conjugate

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

Type:int
expr

The MBPT expression associated to the diagram.

Type:str
cd_expr

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

Type:str
adjacency_mat

The adjacency matrix of the graph.

Type:NumPy array
adjacency_mat
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
cd_numerator()[source]

Return the computer-readable numerator.

Returns:The graph numerator tailored for automated frameworks.
Return type:(str)
complex_conjugate
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
excitation_level
expr
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
incidence
io_degrees
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
tags
unsort_degrees
unsort_io_degrees
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) # doctest: +NORMALIZE_WHITESPACE
[array([[0, 2], [2, 0]])]
>>> diagrams_generation(3) # doctest: +NORMALIZE_WHITESPACE
[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.