MBPT diagram¶
Routines and class for ManyBody 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 computerreadable format.
Type: str

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 computerreadable denominator of the graph.
Returns: The graph denominator tailored for automated frameworks. Return type: (str)

cd_numerator
()[source]¶ Return the computerreadable numerator.
Returns: The graph numerator tailored for automated frameworks. Return type: (str)

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)

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)

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)

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


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