# BIMSRG Diagram¶

Routines and class for Bogoliubov IMSRG diagrams.

class `adg.bimsrg.``BimsrgDiagram`(nx_graph, tag_num)[source]

Describes a B-IMSRG Feynman diagram with its related properties.

`adjacency_mat`

The adjacency matrix of the diagram.

Type: Numpy array
`unique_id`

A unique number associated to the diagram.

Type: int
`expr`

The B-IMSRG expression associated to the diagram.

Type: str
`ext_io_degree`

The degree of the operator component the diagram corresponds to.

Type: tuple
`is_AB`

True if the diagram contributes to +AB, false if to -BA.

Type: bool
`adjacency_mat`
`attribute_expression`()[source]

Returns the LaTeX expression of the diagram.

The expression is extracted in a way that assumes the canonical representation of the vertices as well as a labeling of the external lines that would correspond to a canonical representation of the C operator vertex. As such, there is no sign factor associated to departing from the canonical representation of the diagram. This additionally prevents any line crossing from appearing.

Returns: The LaTeX expression for the diagram. (str)
`degrees`
`expr`
`ext_io_degree`
`graph`
`io_degrees`
`is_AB`
`max_degree`
`permutator`()[source]

Return the permutator associated to the diagram.

The labelling of the external lines correspond to the canonical representation of the C operator vertex.

Returns: The permutator associated to the diagram in LaTeX format. (str)
`sign`()[source]

Return the sign of the diagram.

As the diagrams are made with vertices in canonical representation and avoiding crossings, the only sign left is associated with the commutator.

Returns: The sign of the diagram. (str)
`symmetry_factor`()[source]

Returns the symmetry factor of the diagram in LaTeX format.

Returns: The LaTeX-formatted symmetry factor. (str)
`tags`
`unique_id`
`unsort_degrees`
`unsort_io_degrees`
`vertices_expression`()[source]

Return the expression associated to the vertices in LaTeX format.

The expressions are extracted in a way that assumes the canonical representation of the vertices as well as a labeling of the external lines that would correspond to a canonical representation of the C operator vertex. This prevents any crossing as well as additional sign tied to departing from the canonical representation.

Returns: The LaTeX-formatted expression for the vertices. (str)
`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, section_flags)[source]

Write section and subsections for BMBPT result file.

Parameters: result (file) – The LaTeX output file of the program. commands (dict) – The flags associated with run management. section_flags (dict) – UniqueIDs of diags starting each section.
`adg.bimsrg.``diagrams_generation`(orders)[source]

Generate diagrams for B-IMSRG.

Parameters: orders (tuple) – The B-IMSRG (N_A, N_B, N_C) order of the diagrams. NumPy arrays encoding the adjacency matrices of the graphs, and number of diagrams with the A vertex on top. (tuple)
`adg.bimsrg.``diagrams_subset`(deg_max_top, deg_max_bot, deg_max_ext)[source]

Generate diagrams for B-IMSRG.

Parameters: orders (tuple) – The max ranks (2*N_A, 2*N_B, 2*N_C) of the vertices. NumPy arrays encoding the adjacency matrices of the graphs. (list)
```>>> diagrams_subset(2, 2, 0) # doctest: +NORMALIZE_WHITESPACE
[array([[0, 0, 0, 0],
[0, 0, 2, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]])]
>>> len(diagrams_subset(2, 2, 2))
5
>>> len(diagrams_subset(4, 4, 4))
41
>>> len(diagrams_subset(0, 0, 0))
0
```
`adg.bimsrg.``order_diagrams`(diagrams, order)[source]

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

Parameters: diagrams (list) – The unordered BimsrgDiagrams. order (int) – The order of the B-IMSRG truncation. First element are the ordered BimsrgDiagrams. Second element is the number of diagrams for each type. Third element is flags for the output processing. (tuple)
`adg.bimsrg.``permutator`(set_1, set_2)[source]

Write the definition of the permutation operator given by the two sets.

Parameters: set_1 (list) – The list of the left-hand-side qp labels. set_2 (list) – The list of the right-hand-side qp labels. The LaTeX expression for the permutation operator. (str)
```>>> print(permutator([1, 2], )) # doctest: +NORMALIZE_WHITESPACE
P(k_{1}k_{2}/k_{3}) &= 1 - P_{k_{1} k_{3}} - P_{k_{2} k_{3}} \\
```
`adg.bimsrg.``two_partitions`(number)[source]

Return 2-partitions of the given integer.

Parameters: numbr (int) – The integer to partition. All the 2-partitions as tuples. (list)
```>>> two_partitions(3)
[(0, 3), (1, 2), (2, 1), (3, 0)]
```
```>>> two_partitions(0)
[(0, 0)]
```
```>>> two_partitions(-1)
[]
```
`adg.bimsrg.``write_header`(tex_file, commands, diags_nbs)[source]

Write overall header for BIMSRG result file.

Parameters: tex_file (file) – The ouput LaTeX file of the program. commands (Namespace) – Flags for the program run. diags_nbs (dict) – The number of diagrams per type.
`adg.bimsrg.``write_permutator_section`(tex_file, commands)[source]

Write the section defining permutation operators.

Parameters: tex_file (file) – The ouput LaTeX file of the program. commands (Namespace) – Flags for the program run.