function innerTauNum(type, innerLoopNum, interactionTauNum)
-
-internal imaginary-time degrees of freedom for a given diagram type and internal loop number.
-For the vertex functions (self-energy, polarization, vertex3, and vertex4), innerTauNum is equivalent to tauNum.
-For the Green function, tauNum = innerTauNum + external tauNum
function innerTauNum(type::DiagramType, innerLoopNum, interactionTauNum)
-
-internal imaginary-time degrees of freedom for a given diagram type and internal loop number.
-For the vertex functions (self-energy, polarization, vertex3, and vertex4), innerTauNum is equivalent to tauNum.
-For the Green function, tauNum = innerTauNum + external tauNum
function diagdictGV(type::Symbol, MaxOrder::Int, has_counterterm::Bool=false;
- MinOrder::Int=1, spinPolarPara::Float64=0.0)
-
-Generates a FeynmanGraph Dict: the Feynman diagrams with static interactions in a given `type`, and
-spin-polarizaition parameter `spinPolarPara`, to given minmimum/maximum orders `MinOrder/MaxOrder`, with switchable couterterms.
-Generates a `LabelProduct`: `labelProd` for these FeynmanGraphs.
Arguments:
type (Symbol): The type of the Feynman diagrams, including :spinPolar, :chargePolar, :sigma_old, :green, or :freeEnergy.
Maxorder (Int): The maximum actual order of the diagrams.
has_counterterm (Bool): false for G0W0, true for GW with self-energy and interaction counterterms (defaults to false).
MinOrder (Int, optional): The minmimum actual order of the diagrams (defaults to 1).
spinPolarPara (Float64, optional): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).
Returns
A tuple (dict_graphs, fermi_labelProd, bose_labelProd, leafMap) where
dict_graphs is a Dict{Tuple{Int,Int,Int},Tuple{Vector{FeynmanGraph},Vector{Vector{Int}}}} object representing the diagrams. The key is (order, Gorder, Vorder). The element is a Tuple (graphVector, extT_labels).
labelProd is a LabelProduct object containing the labels for the leaves of graphs,
function diagdictGV(type::Symbol, gkeys::Vector{Tuple{Int,Int,Int}}; spinPolarPara::Float64=0.0)
-
-Generates a FeynmanGraph Dict: the Feynman diagrams with static interactions in the given `type` and
-spin-polarizaition parameter `spinPolarPara`, with given couterterm-orders (from `gkeys`).
-Generates a `LabelProduct`: `labelProd` for these FeynmanGraphs.
Arguments:
type (Symbol): The type of the Feynman diagrams, including :spinPolar, :chargePolar, :sigma_old, :green, or :freeEnergy.
gkeys (Vector{Tuple{Int,Int,Int}}): The (order, Gorder, Vorder) of the diagrams. Gorder is the order of self-energy counterterms, and Vorder is the order of interaction counterterms.
spinPolarPara (Float64, optional): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).
Returns
A tuple (dict_graphs, fermi_labelProd, bose_labelProd, leafMap) where
dict_graphs is a Dict{Tuple{Int,Int,Int},Tuple{Vector{FeynmanGraph},Vector{Vector{Int}}}} object representing the diagrams. The key is (order, Gorder, Vorder). The element is a Tuple (graphVector, extT_labels).
labelProd is a LabelProduct object containing the labels for the leaves of graphs,
function diagsGV(type::Symbol, order::Int, GOrder::Int=0, VerOrder::Int=0;
+ labelProd::Union{Nothing,LabelProduct}=nothing, spinPolarPara::Float64=0.0,
+ tau_labels::Union{Nothing,Vector{Int}}=nothing, filter::Vector{Filter}=[NoHartree])
Generates a `Vector{FeynmanGraph}`: the given-`type` diagrams with static interactions of a given order, where the actual order of diagrams equals to `order + VerOrder + 2 * GOrder`.
Generates a `LabelProduct`: `labelProd` with inputs `tau_labels` and all the possible momenta-loop basis.
-Generates external tau labels Vector{Vector{Int}}. The i-th labels (Vector{Int}) corresponds to the i-th `FeynmanGraph` in `Vector{FeynmanGraph}`.
Arguments:
type (Symbol): The type of the diagrams, including :spinPolar, :chargePolar, :sigma, :green, or :freeEnergy.
order (Int): The order of the diagrams without counterterms.
GOrder (Int, optional): The order of self-energy counterterms (defaults to 0).
VerOrder (Int, optional): The order of interaction counterterms (defaults to 0).
labelProd (Union{Nothing,LabelProduct}=nothing, optional): The initial cartesian QuantumOperator.label product (defaults to nothing).
spinPolarPara (Float64, optional): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).
tau_labels(Union{Nothing, Vector{Int}}, optional): The labels for the discrete time of each vertex. (defaults to nothing).
Returns
A tuple (diagrams, fermi_labelProd, bose_labelProd, extT_labels) where
diagrams is a Vector{FeynmanGraph} object representing the diagrams,
labelProd is a LabelProduct object containing the labels for the leaves of graphs,
extT_labels is a Vector{Vector{Int}} object containing the external tau labels for each FeynmanGraph in diagrams.
function leafstates(leaf_maps::Vector{Dict{Int,G}}, labelProd::LabelProduct) where {T,G<:FeynmanGraph}
+Generates external tau labels Vector{Vector{Int}}. The i-th labels (Vector{Int}) corresponds to the i-th `FeynmanGraph` in `Vector{FeynmanGraph}`.
Arguments:
type (Symbol): The type of the diagrams, including :spinPolar, :chargePolar, :sigma, :green, or :freeEnergy.
order (Int): The order of the diagrams without counterterms.
GOrder (Int, optional): The order of self-energy counterterms (defaults to 0).
VerOrder (Int, optional): The order of interaction counterterms (defaults to 0).
labelProd (Union{Nothing,LabelProduct}=nothing, optional): The initial cartesian QuantumOperator.label product (defaults to nothing).
spinPolarPara (Float64, optional): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).
tau_labels(Union{Nothing, Vector{Int}}, optional): The labels for the discrete time of each vertex. (defaults to nothing).
Returns
A tuple (diagrams, fermi_labelProd, bose_labelProd, extT_labels) where
diagrams is a Vector{FeynmanGraph} object representing the diagrams,
labelProd is a LabelProduct object containing the labels for the leaves of graphs,
extT_labels is a Vector{Union{Tuple,Vector{Int}}} object containing the external tau labels for each FeynmanGraph in diagrams.
function diagsGV_ver4(order::Int; spinPolarPara::Float64=0.0, filter::Vector{Filter}=[NoHartree], channels=[PHr, PHEr, PPr, Alli])
-Extracts leaf information from the leaf mapping from the leaf value's index to the leaf node for all graph partitions
-and their associated LabelProduct data (`labelProd`).
-The information includes their initial value, type, in/out time, and loop momenta.
Arguments:
leaf_maps: A vector of the dictionary mapping the leaf value's index to the FeynmanGraph of this leaf. Each dict corresponds to a graph partition, such as (order, Gorder, Vorder).
labelProd: A LabelProduct used to label the leaves of graphs.
Returns
A tuple of vectors containing information about the leaves of graphs, including their initial values, types, input and output time indexes, and loop-momenta indexes.
function read_diagrams(filename::AbstractString; loopPool::Union{LoopPool,Nothing}=nothing,
+Generates a `Vector{Graph}`: the 4-point vertex diagrams with static interactions of a given order.
Arguments:
order (Int): The order of the diagrams without counterterms.
spinPolarPara (Float64, optional): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).
channels (optional): The channels for the diagrams, defaults to [PHr, PHEr, PPr, Alli].
filter (optional): Filter criteria for the diagrams, defaults to [NoHartree].
function read_diagrams(filename::AbstractString; loopPool::Union{LoopPool,Nothing}=nothing,
dim::Int=3, tau_labels::Union{Nothing,Vector{Int}}=nothing, GTypes=[0, 1], VTypes=[0, 1, 2],
keywords::Vector{String}=["Polarization", "DiagNum", "Order", "GNum", "Ver4Num", "LoopNum", "ExtLoopIndex",
"DummyLoopIndex", "TauNum", "ExtTauIndex", "DummyTauIndex"])
Reads a GV_diagrams file and returns FeynmanGraph of diagrams in this file
-and the corresponding `LabelProduct` objects, which are used to keep track of QuantumOperator.label.
Arguments:
filename (AbstractString): The path to the file containing the diagrams.
loopPool (Union{LoopPool,Nothing}): An optional LoopPool object. If not provided, a new one will be created.
spinPolarPara (Float64): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).
dim (Int): The dimension of the system, used to initialize the LoopPool object. Default is 3.
tau_labels (Union{Nothing,Vector{Int}}): The labels for the Tau objects in the diagrams. If not provided, they will be set to the integers from 1 to tauNum.
GTypes (Vector{Int}): The labels for the fermionic G objects in the diagrams. Default is [0, 1].
VTypes (Vector{Int}): The labels for the bosonic V objects in the diagrams. Default is [0, 1, 2].
keywords (Vector{String}): A set of keywords used to extract information from the file. Default is ["Polarization", "DiagNum", "Order", "GNum", "Ver4Num", "LoopNum", "ExtLoopIndex", "DummyLoopIndex", "TauNum", "ExtTauIndex", "DummyTauIndex"].
Returns
A tuple (diagrams, fermi_labelProd, bose_labelProd) where
diagrams is a FeynmanGraph object representing the diagrams,
fermi_labelProd is a LabelProduct object containing the labels for the fermionic G objects in the diagrams,
bose_labelProd is a LabelProduct object containing the labels for the bosonic W objects in the diagrams.
This document was generated with Documenter.jl version 0.27.10 on Thursday 30 November 2023. Using Julia version 1.9.4.
+and the corresponding `LabelProduct` objects, which are used to keep track of QuantumOperator.label.
Arguments:
filename (AbstractString): The path to the file containing the diagrams.
loopPool (Union{LoopPool,Nothing}): An optional LoopPool object. If not provided, a new one will be created.
spinPolarPara (Float64): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).
dim (Int): The dimension of the system, used to initialize the LoopPool object. Default is 3.
tau_labels (Union{Nothing,Vector{Int}}): The labels for the Tau objects in the diagrams. If not provided, they will be set to the integers from 1 to tauNum.
GTypes (Vector{Int}): The labels for the fermionic G objects in the diagrams. Default is [0, 1].
VTypes (Vector{Int}): The labels for the bosonic V objects in the diagrams. Default is [0, 1, 2].
keywords (Vector{String}): A set of keywords used to extract information from the file. Default is ["Polarization", "DiagNum", "Order", "GNum", "Ver4Num", "LoopNum", "ExtLoopIndex", "DummyLoopIndex", "TauNum", "ExtTauIndex", "DummyTauIndex"].
Returns
A tuple (diagrams, fermi_labelProd, bose_labelProd) where
diagrams is a FeynmanGraph object representing the diagrams,
fermi_labelProd is a LabelProduct object containing the labels for the fermionic G objects in the diagrams,
bose_labelProd is a LabelProduct object containing the labels for the bosonic W objects in the diagrams.
function compile(graphs::AbstractVector{<:AbstractGraph}; root::AbstractVector{Int}=[id(g) for g in graphs])
Compile a list of graphs into a julia static function. The function takes two arguments: root and leaf. root is a vector of the root node ids of the graphs, and leaf is a vector of the leaf node ids of the graphs. This function calls tojuliastr and generate a defined function using RuntimeGeneratedFunctions. Comparing to eval(Meta.parse(tojuliastr(...))), this function does not leak out the function name into global scope.
function compile_C(graphs::AbstractVector{<:AbstractGraph}, filename::String;
+ datatype::DataType=_dtype.weight, root::AbstractVector{Int}=[id(g) for g in graphs], func_name="eval_graph")
+
+Compiles a set of graphs into C language code and append the generated code to a specified file.
Arguments
datatype::DataType: This type is used for variables types in the generated C code.
graphs::AbstractVector{<:AbstractGraph}: An array of graph objects. These graphs are processed to generate Julia code.
filename::String: The name of the file to which the generated code will be appended. The file is created if it does not exist.
root::AbstractVector{Int} (keyword): An array of integers representing root nodes for each graph in graphs. By default, it is an array of IDs obtained by calling id(g) for each graph g in graphs.
func_name::String (keyword): The base name for the function(s) to be generated. Defaults to "eval_graph".
Returns
A dictionary (leafmap) that maps the index of the leaf weight's table leafVal to the leaf graph.
function compile_Julia(graphs::AbstractVector{<:AbstractGraph}, filename::String;
+ root::AbstractVector{Int}=[id(g) for g in graphs], func_name="eval_graph!")
+
+Compiles a set of graphs into Julia code and append the generated code to a specified file.
Arguments
graphs::AbstractVector{<:AbstractGraph}: An array of graph objects. These graphs are processed to generate Julia code.
filename::String: The name of the file to which the generated code will be appended. The file is created if it does not exist.
root::AbstractVector{Int} (keyword): An array of integers representing root nodes for each graph in graphs. By default, it is an array of IDs obtained by calling id(g) for each graph g in graphs.
func_name::String (keyword): The base name for the function(s) to be generated. Defaults to "eval_graph!".
Returns
A dictionary (leafmap) that maps the index of the leaf weight's table leafVal to the leaf graph.
function to_dot_str(graphs::AbstractVector{<:AbstractGraph}, name::String="")
+
+Compile a list of graphs into a string for dot language.
+
+# Arguments:
+- `graphs` vector of computational graphs
+- `title` The name of the compiled function (defaults to nothing)
function to_julia_str(graphs::AbstractVector{<:AbstractGraph}, leafMap::Dict{Int,Int}; root::AbstractVector{Int}=[id(g) for g in graphs],
+ name::String="eval_graph!")
Compile a list of Feynman graphs into a string for a julia static function. The complied function takes two arguments: root and leafVal. root is a vector of the root node ids of the graphs, and leafVal is a vector of the leaf nodes' weights of the graphs.
Arguments:
graphs (AbstractVector{G}): The vector object representing the Feynman graphs,
root (AbstractVector{Int}, optional): The vector of the root node ids of the graphs (defaults to [id(g) for g in graphs]).
name (String,optional): The name of the complied function (defaults to "eval_graph!").
Returns:
A String representing the compiled Julia function.
leafMap (Dict{Int,G}): A dictionary that maps the index of the leaf weight's table leafVal to the leaf graph.
function to_pystatic(operator::Type, subgraphs::AbstractVector{<:AbstractGraph}, subgraph_factors::AbstractVector)
+
+Returns the static representation of a computational graph node `g` with operator `operator`, subgraphs `subgraphs`, and subgraph factors `subgraph_factors` in python.
function to_python_str(graphs::AbstractVector{<:AbstractGraph})
+
+Compile a list of graphs into a string for a python static function and output a python script which support the mindspore and jax framework.
Arguments:
graphs vector of computational graphs
framework the type of the python frameworks, including :jax and mindspore.
mutable struct FeynmanGraph{F<:Number,W}
-Computational graph representation of a (collection of) Feynman diagram(s). All Feynman diagrams should share the same set of external and internal vertices.
Members:
id::Int the unique hash id to identify the diagram
name::Symbol name of the diagram
orders::Vector{Int} orders associated with the Feynman graph, e.g., loop/derivative orders
properties::FeynmanProperties diagrammatic properties, e.g., the operator vertices and topology
subgraphs::Vector{FeynmanGraph{F,W}} vector of sub-diagrams
subgraph_factors::Vector{F} scalar multiplicative factors associated with each subdiagram
factor::F a number representing the total scalar multiplicative factor for the diagram.
weight::W weight of the diagram
Example:
julia> g1 = FeynmanGraph([]; vertices=[𝑓⁺(1),𝑓⁻(2)], external_indices=[1,2], external_legs=[true,true])
+Computational graph representation of a (collection of) Feynman diagram(s). All Feynman diagrams should share the same set of external and internal vertices.
Members:
id::Int the unique hash id to identify the diagram
name::Symbol name of the diagram
orders::Vector{Int} orders associated with the Feynman graph, e.g., loop/derivative orders
properties::FeynmanProperties diagrammatic properties, e.g., the operator vertices and topology
subgraphs::Vector{FeynmanGraph{F,W}} vector of sub-diagrams
subgraph_factors::Vector{F} scalar multiplicative factors associated with each subdiagram
mutable struct Graph{F<:Number,W}
-A representation of a computational graph, e.g., an expression tree, with type stable node data.
Members:
id::Int the unique hash id to identify the diagram
name::Symbol name of the diagram
orders::Vector{Int} orders associated with the graph, e.g., derivative orders
subgraphs::Vector{Graph{F,W}} vector of sub-diagrams
subgraph_factors::Vector{F} scalar multiplicative factors associated with each subgraph. Note that the subgraph factors may be manipulated algebraically. To associate a fixed multiplicative factor with this graph which carries some semantic meaning, use the factor argument instead.
operator::DataType node operation. Addition and multiplication are natively supported via operators Sum and Prod, respectively. Should be a concrete subtype of AbstractOperator.
factor::F a number representing the total scalar multiplicative factor for the diagram.
weight::W the weight of this node
Example:
julia> g1 = Graph([])
+A representation of a computational graph, e.g., an expression tree, with type stable node data.
Members:
id::Int the unique hash id to identify the diagram
name::Symbol name of the diagram
orders::Vector{Int} orders associated with the graph, e.g., derivative orders
subgraphs::Vector{Graph{F,W}} vector of sub-diagrams
subgraph_factors::Vector{F} scalar multiplicative factors associated with each subgraph. Note that the subgraph factors may be manipulated algebraically. To associate a fixed multiplicative factor with this graph which carries some semantic meaning, use the factor argument instead.
operator::DataType node operation. Addition and multiplication are natively supported via operators Sum and Prod, respectively. Should be a concrete subtype of AbstractOperator.
weight::W the weight of this node
properties::Any extra information of Green's functions.
function Base.:+(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}
Returns a graph `g1 + g2` representing the addition of two Feynman diagrams `g2` with `g1`.
-Diagrams `g1` and `g2` must have the same diagram type, orders, and external vertices.
function Base.:+(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}
Returns a graph `g1 + g2` representing the addition of `g2` with `g1`.
-Graphs `g1` and `g2` must have the same orders.
function Base.:-(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}
Returns a graph `g1 - g2` representing the subtraction of `g2` from `g1`.
-Diagrams `g1` and `g2` must have the same diagram type, orders, and external vertices.
function Base.:-(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}
Returns a graph `g1 - g2` representing the subtraction of `g2` from `g1`.
-Graphs `g1` and `g2` must have the same orders.
function Base.convert(::Type{G}, g::FeynmanGraph{F,W}) where {F,W,G<:Graph}
Converts a FeynmanGraph `g` into a Graph, discarding its Feynman properties.
After conversion, graph `g` is no longer guaranteed to be a valid (group of) Feynman diagram(s).
# Arguments:
-- `g` computational graph
function build_derivative_graph(graphs::AbstractVector{G}, orders::NTuple{N,Int};
+Write a text representation of an AbstractGraph `graph` to the output stream `io`.
function build_derivative_graph(graphs::AbstractVector{G}, orders::NTuple{N,Int};
nodes_id=nothing) where {G<:Graph,N}
-Constructs a derivative graph using forward automatic differentiation with given graphs and derivative orders.
Arguments:
graphs: A vector of graphs.
orders::NTuple{N,Int}: A tuple indicating the orders of differentiation. N represents the number of independent variables to be differentiated.
nodes_id: Optional node IDs to indicate saving their derivative graph.
Returns:
A dictionary containing the dual derivative graphs for all indicated nodes.
If isnothing(nodes_id), indicated nodes include all leaf and root nodes. Otherwise, indicated nodes include all root nodes and other nodes from nodes_id.
function burn_from_targetleaves!(graphs::AbstractVector{G}, targetleaves_id::AbstractVector{Int}; verbose=0) where {G <: AbstractGraph}
+Constructs a derivative graph using forward automatic differentiation with given graphs and derivative orders.
Arguments:
graphs: A vector of graphs.
orders::NTuple{N,Int}: A tuple indicating the orders of differentiation. N represents the number of independent variables to be differentiated.
nodes_id: Optional node IDs to indicate saving their derivative graph.
Returns:
A dictionary containing the dual derivative graphs for all indicated nodes.
If isnothing(nodes_id), indicated nodes include all leaf and root nodes. Otherwise, indicated nodes include all root nodes and other nodes from nodes_id.
function burn_from_targetleaves!(graphs::AbstractVector{G}, targetleaves_id::AbstractVector{Int}; verbose=0) where {G <: AbstractGraph}
-Removes all nodes connected to the target leaves in-place via "Prod" operators.
Arguments:
graphs: A vector of graphs.
targetleaves_id::AbstractVector{Int}: Vector of target leafs' id.
verbose: Level of verbosity (default: 0).
Returns:
The id of a constant graph with a zero factor if any graph in graphs was completely burnt; otherwise, nothing.
function diagram_type(g::FeynmanGraph)
+Returns the total number of operations in the totally expanded version (without any parentheses in the mathematical expression) of the graph.
Arguments:
g::Graph: graph for which to find the total number of operations in its expanded version.
function disconnect_subgraphs!(g::G) where {G<:AbstractGraph}
Empty the subgraphs and subgraph_factors of graph `g`. Any child nodes of g
+not referenced elsewhere in the full computational graph are effectively deleted.
function external_indices(g::FeynmanGraph)
-Returns a list of Boolean indices external_legs (::Vector{Bool}) indicating which external vertices of FeynmanGraph `g` have real legs (true: real leg, false: fake leg).
function external_legs(g::FeynmanGraph)
+
+Returns a list of Boolean indices external_legs (::Vector{Bool}) indicating which external vertices of FeynmanGraph `g` have real legs (true: real leg, false: fake leg).
function external_vertex(ops::OperatorProduct;
name="", factor=one(_dtype.factor), weight=zero(_dtype.weight), operator=Sum())
-Create a ExternalVertex-type FeynmanGraph from given OperatorProduct `ops`, including several quantum operators for an purely external vertex.
function feynman_diagram(subgraphs::Vector{FeynmanGraph{F,W}}, topology::Vector{Vector{Int}}, perm_noleg::Union{Vector{Int},Nothing}=nothing;
+Create a ExternalVertex-type FeynmanGraph from given OperatorProduct `ops`, including several quantum operators for an purely external vertex.
function feynman_diagram(subgraphs::Vector{FeynmanGraph{F,W}}, topology::Vector{Vector{Int}}, perm_noleg::Union{Vector{Int},Nothing}=nothing;
factor=one(_dtype.factor), weight=zero(_dtype.weight), name="", diagtype::DiagramType=GenericDiag()) where {F,W}
Create a FeynmanGraph representing feynman diagram from all subgraphs and topology (connections between vertices),
@@ -90,23 +95,29 @@
3:f⁺(7)f⁻(8)ϕ(9)=0.0
4:f⁺(1)|f⁻(5)⋅-1.0=0.0
5:ϕ(3)|ϕ(9)=0.0
- 6:f⁺(4)|f⁻(8)⋅-1.0=0.0
function flatten_all_chains!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0)
-Flattens all nodes representing trivial unary chains in-place in given graphs.
Arguments:
graphs: A collection of graphs to be processed.
verbose: Level of verbosity (default: 0).
Returns:
The mutated collection graphs with all chains in each graph flattened.
function flatten_chains!(g::AbstractGraph)
Recursively flattens chains of subgraphs within the given graph `g` by merging certain trivial unary subgraphs
into their parent graphs in the in-place form.
Acts only on subgraphs of `g` with the following structure: 𝓞 --- 𝓞' --- ⋯ --- 𝓞'' ⋯ (!),
-where the stop-case (!) represents a leaf, a non-trivial unary operator 𝓞'''(g) != g, or a non-unary operation.
function flatten_chains(g::AbstractGraph)
+where the stop-case (!) represents a leaf, a non-trivial unary operator 𝓞'''(g) != g, or a non-unary operation.
function flatten_chains(g::AbstractGraph)
Recursively flattens chains of subgraphs within a given graph `g` by merging certain trivial unary subgraphs into their parent graphs,
-This function returns a new graph with flatten chains, dervied from the input graph `g` remaining unchanged.
function forwardAD(diag::Graph{F,W}, ID::Int) where {F,W}
+This function returns a new graph with flatten chains, derived from the input graph `g` remaining unchanged.
flatten_prod!(graph::G; map::Dict{Int,G}=Dict{Int,G}()) where {G<:AbstractGraph}
+
+Recursively merge multi-product sub-branches within the given graph `g by merging product subgraphs
+into their parent product graphs in the in-place form.
Arguments:
g::AbstractGraph: graph to be modified
map::Dict{Int,G}=Dict{Int,G}(): A dictionary that maps the id of an original node with its corresponding new node after transformation.
In recursive transform, nodes can be visited several times by different parents. This map keeps track of those visited, and reuse those transformed sub-branches instead of recreating them.
flatten_sum!(graph::G; map::Dict{Int,G}=Dict{Int,G}()) where {G<:AbstractGraph}
-Given a graph G and an id of graph g, calculate the derivative d G / d g by forward propagation algorithm.
function forwardAD_root!(graphs::AbstractVector{G}, idx::Int=1,
+Recursively merge multi-product sub-branches within the given graph `g by merging sum subgraphs
+into their parent sum graphs in the in-place form.
Arguments:
g::AbstractGraph: graph to be modified
map::Dict{Int,G}=Dict{Int,G}(): A dictionary that maps the id of an original node with its corresponding new node after transformation.
In recursive transform, nodes can be visited several times by different parents. This map keeps track of those visited, and reuse those transformed sub-branches instead of recreating them.
function forwardAD(diag::Graph{F,W}, ID::Int) where {F,W}
+
+Given a graph G and an id of graph g, calculate the derivative d G / d g by forward propagation algorithm.
function forwardAD_root!(graphs::AbstractVector{G}, idx::Int=1,
dual::Dict{Tuple{Int,NTuple{N,Bool}},G}=Dict{Tuple{Int,Tuple{Bool}},G}()) where {G<:Graph,N}
-Computes the forward automatic differentiation (AD) of the given graphs beginning from the roots.
Arguments:
graphs: A vector of graphs.
idx: Index for differentiation (default: 1).
dual: A dictionary that holds the result of differentiation.
Returns:
The dual dictionary populated with all differentiated graphs, including the intermediate AD.
function has_zero_subfactors(g)
+
+Returns whether the graph g has only zero-valued subgraph factor(s).
+Note that this function does not recurse through subgraphs of g, so that one may have, e.g.,
+`isfactorless(g) == true` but `isfactorless(eldest(g)) == false`.
+By convention, returns `false` if g is a leaf.
function interaction(ops::OperatorProduct; name="", reorder::Union{Function,Nothing}=nothing,
factor=one(_dtype.factor), weight=zero(_dtype.weight), operator=Sum())
Create a Interaction-type FeynmanGraph from given OperatorProduct `ops`, including several quantum operators for a vertex.
-One can call a reorder function for the operators ordering.
function isequiv(a::AbstractGraph, b::AbstractGraph, args...)
-Returns whether the graph g is factorless, i.e., has unity factor and, if applicable,
-subgraph factor(s). Note that this function does not recurse through subgraphs of g, so
-that one may have, e.g., `isfactorless(g) == true` but `isfactorless(eldest(g)) == false`.
function linear_combination(graphs::Vector{FeynmanGraph{F,W}}, constants::AbstractVector=ones(F, length(graphs))) where {F,W}
+Returns whether the graph g is a leaf (terminating tree node).
function linear_combination(graphs::Vector{FeynmanGraph{F,W}}, constants::AbstractVector=ones(F, length(graphs))) where {F,W}
Given a vector 𝐠 of graphs each with the same type and external/internal vertices and
an equally-sized vector 𝐜 of constants, returns a new graph representing the linear combination (𝐜 ⋅ 𝐠).
The function identifies unique graphs from the input `graphs` and sums their associated `constants`.
-All input Graphs must have the same diagram type, orders, and external vertices.
Arguments:
graphs vector of input FeymanGraphs
constants vector of scalar multiples (defaults to ones(F, length(graphs))).
Returns:
A new FeynmanGraph{F,W} object representing the linear combination of the unique input graphs weighted by the constants,
where duplicate graphs in the input graphs are combined by summing their associated constants.
Example:
Given graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1+c3)*g1 + c2*g2`.
function linear_combination(graphs::Vector{Graph{F,W}}, constants::AbstractVector=ones(F, length(graphs))) where {F,W}
+All input Graphs must have the same diagram type, orders, and external vertices.
Arguments:
graphs vector of input FeymanGraphs
constants vector of scalar multiples (defaults to ones(F, length(graphs))).
Returns:
A new FeynmanGraph{F,W} object representing the linear combination of the unique input graphs weighted by the constants,
where duplicate graphs in the input graphs are combined by summing their associated constants.
Example:
Given graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1+c3)*g1 + c2*g2`.
function linear_combination(graphs::Vector{Graph{F,W}}, constants::AbstractVector=ones(F, length(graphs))) where {F,W}
Given a vector 𝐠 of graphs and an equally-sized vector 𝐜 of constants, returns a new
graph representing the linear combination (𝐜 ⋅ 𝐠).
The function identifies unique graphs from the input `graphs` and sums their associated `constants`.
-All input graphs must have the same orders.
Arguments:
graphs vector of computational graphs
constants vector of scalar multiples (defaults to ones(F, length(graphs))).
Returns:
A new Graph{F,W} object representing the linear combination of the unique input graphs weighted by the constants,
where duplicate graphs in the input graphs are combined by summing their associated constants.
Example:
Given graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1+c3)*g1 + c2*g2`.
function linear_combination(g1::FeynmanGraph{F,W}, g2::FeynmanGraph{F,W}, c1, c2) where {F,W}
Returns a graph representing the linear combination `c1*g1 + c2*g2`. If `g1 == g2`, it will return a graph representing `(c1+c2)*g1`
-Feynman Graphs `g1` and `g2` must have the same diagram type, orders, and external vertices.
function linear_combination(g1::Graph{F,W}, g2::Graph{F,W}, c1, c2) where {F,W}
+Feynman Graphs `g1` and `g2` must have the same diagram type, orders, and external vertices.
function linear_combination(g1::Graph{F,W}, g2::Graph{F,W}, c1, c2) where {F,W}
Returns a graph representing the linear combination `c1*g1 + c2*g2`.
If `g1 == g2`, it will return a graph representing `(c1+c2)*g1`.
-Graphs `g1` and `g2` must have the same orders.
function merge_all_linear_combinations!(g::AbstractGraph; verbose=0)
-Merges all nodes representing a linear combination of a non-unique list of subgraphs in-place within a single graph.
function merge_all_linear_combinations!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0)
+Merges all nodes representing a linear combination of a non-unique list of subgraphs in-place in the given graph `g`.
function merge_all_linear_combinations!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0)
-Merges all nodes representing a linear combination of a non-unique list of subgraphs in-place in given graphs.
function merge_all_multi_products!(g::Graph; verbose=0)
+Merges all nodes representing a linear combination of a non-unique list of subgraphs in-place in the given graphs.
function merge_all_multi_products!(g::Graph; verbose=0)
-Merges all nodes representing a multi product of a non-unique list of subgraphs in-place within a single graph.
function merge_all_multi_products!(graphs::Union{Tuple,AbstractVector{<:Graph}}; verbose=0)
+Merges all nodes representing a multi product of a non-unique list of subgraphs in-place in the given graph `g`.
function merge_all_multi_products!(graphs::Union{Tuple,AbstractVector{<:Graph}}; verbose=0)
-Merges all nodes representing a multi product of a non-unique list of subgraphs in-place in given graphs.
function merge_linear_combination(g::AbstractGraph)
+Merges all nodes representing a multi product of a non-unique list of subgraphs in-place in the given graphs.
function merge_linear_combination!(g::AbstractGraph)
Modifies a computational graph `g` by factorizing multiplicative prefactors, e.g.,
3*g1 + 5*g2 + 7*g1 + 9*g2 ↦ 10*g1 + 14*g2 = linear_combination(g1, g2, 10, 14).
Returns a linear combination of unique subgraphs and their total prefactors.
-Does nothing if the graph `g` does not represent a Sum operation.
function merge_linear_combination(g::AbstractGraph)
Returns a copy of computational graph `g` with multiplicative prefactors factorized,
e.g., 3*g1 + 5*g2 + 7*g1 + 9*g2 ↦ 10*g1 + 14*g2 = linear_combination(g1, g2, 10, 14).
Returns a linear combination of unique subgraphs and their total prefactors.
-Does nothing if the graph `g` does not represent a Sum operation.
function merge_multi_product!(g::Graph{F,W}) where {F,W}
Merge multiple products within a computational graph `g` if they share the same operator (`Prod`).
If `g.operator == Prod`, this function will merge `N` identical subgraphs into a single subgraph with a power operator `Power(N)`.
-The function ensures each unique subgraph is counted and merged appropriately, preserving any distinct subgraph_factors associated with them.
Arguments:
g::Graph: graph to be modified
Returns
A merged computational graph with potentially fewer subgraphs if there were repeating subgraphs with the Prod operator. If the input graph's operator isn't Prod, the function returns the input graph unchanged.
function merge_multi_product(g::Graph{F,W}) where {F,W}
+The function ensures each unique subgraph is counted and merged appropriately, preserving any distinct subgraph_factors associated with them.
Arguments:
g::Graph: graph to be modified
Returns
A merged computational graph with potentially fewer subgraphs if there were repeating subgraphs with the Prod operator. If the input graph's operator isn't Prod, the function returns the input graph unchanged.
function merge_multi_product(g::Graph{F,W}) where {F,W}
Returns a copy of computational graph `g` with multiple products merged if they share the same operator (`Prod`).
If `g.operator == Prod`, this function will merge `N` identical subgraphs into a single subgraph with a power operator `Power(N)`.
-The function ensures each unique subgraph is counted and merged appropriately, preserving any distinct subgraph_factors associated with them.
Arguments:
g::Graph: graph to be modified
Returns
A merged computational graph with potentially fewer subgraphs if there were repeating subgraphs with the Prod operator. If the input graph's operator isn't Prod, the function returns the input graph unchanged.
multi_product(graphs::Vector{Graph{F,W}}, constants::AbstractVector=ones(F, length(graphs))) where {F,W,C}
+The function ensures each unique subgraph is counted and merged appropriately, preserving any distinct subgraph_factors associated with them.
Arguments:
g::Graph: graph to be modified
Returns
A merged computational graph with potentially fewer subgraphs if there were repeating subgraphs with the Prod operator. If the input graph's operator isn't Prod, the function returns the input graph unchanged.
multi_product(graphs::Vector{Graph{F,W}}, constants::AbstractVector=ones(F, length(graphs))) where {F,W,C}
Construct a product graph from multiple input graphs, where each graph can be weighted by a constant.
For graphs that are repeated more than once, it adds a power operator to the subgraph to represent the repetition.
-Moreover, it optimizes any trivial unary operators in the resulting product graph.
Arguments:
graphs::Vector{Graph{F,W}}: A vector of input graphs to be multiplied.
constants::AbstractVector: A vector of scalar multiples. If not provided, it defaults to a vector of ones of the same length as graphs.
Returns:
A new product graph with the unique subgraphs (or powered versions thereof) and the associated constants as subgraph factors.
Example:
Given graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1*c3)*(g1)^2 * c2*g2`.
function multi_product(g1::Graph{F,W}, g2::Graph{F,W}, c1=F(1), c2=F(1)) where {F,W,C}
+Moreover, it optimizes any trivial unary operators in the resulting product graph.
Arguments:
graphs::Vector{Graph{F,W}}: A vector of input graphs to be multiplied.
constants::AbstractVector: A vector of scalar multiples. If not provided, it defaults to a vector of ones of the same length as graphs.
Returns:
A new product graph with the unique subgraphs (or powered versions thereof) and the associated constants as subgraph factors.
Example:
Given graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1*c3)*(g1)^2 * c2*g2`.
function multi_product(g1::Graph{F,W}, g2::Graph{F,W}, c1=F(1), c2=F(1)) where {F,W,C}
Returns a graph representing the multi product `c1*g1 * c2*g2`.
-If `g1 == g2`, it will return a graph representing `c1*c2 * (g1)^2` with `Power(2)` operator.
function optimize!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0, normalize=nothing)
+Returns whether the graph g has only one child (subgraph).
open_parenthesis!(graph::G; map::Dict{Int,G}=Dict{Int,G}()) where {G<:AbstractGraph}
-In-place optimization of given `graphs`. Removes duplicated leaves, merges chains, and merges linear combinations.
Arguments:
graphs: A tuple or vector of graphs.
verbose: Level of verbosity (default: 0).
normalize: Optional function to normalize the graphs (default: nothing).
function optimize(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0, normalize=nothing)
+Recursively open parenthesis of subgraphs within the given graph `g`with in place form. The graph eventually becomes
+a single Sum root node with multiple subgraphs that represents multi-product of nodes (not flattened).
Arguments:
g::AbstractGraph: graph to be modified
map::Dict{Int,G}=Dict{Int,G}(): A dictionary that maps the id of an original node with its corresponding new node after transformation.
In recursive transform, nodes can be visited several times by different parents. This map keeps track of those visited, and reuse those transformed sub-branches instead of recreating them. parents
function optimize!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; level=0, verbose=0, normalize=nothing)
-Optimizes a copy of given `graphs`. Removes duplicated leaves, merges chains, and merges linear combinations.
Arguments:
graphs: A tuple or vector of graphs.
verbose: Level of verbosity (default: 0).
normalize: Optional function to normalize the graphs (default: nothing).
function orders(g::AbstractGraph)
+In-place optimization of given `graphs`. Removes duplicated leaves, flattens chains,
+merges linear combinations, and removes zero-valued subgraphs. When `level > 0`, also removes duplicated intermediate nodes.
Arguments:
graphs: A tuple or vector of graphs.
level: Optimization level (default: 0). A value greater than 0 triggers more extensive but slower optimization processes, such as removing duplicated intermediate nodes.
verbose: Level of verbosity (default: 0).
normalize: Optional function to normalize the graphs (default: nothing).
Returns
Returns the optimized graphs. If the input graphs is empty, it returns nothing.
function optimize(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; level=0, verbose=0, normalize=nothing)
-Returns the derivative orders (::Vector{Int}) of computational graph `g`.
function plot_tree(graph::AbstractGraph; verbose = 0, maxdepth = 6)
+Optimizes a copy of given `graphs`. Removes duplicated nodes (when `level > 0`) or leaves, flattens chains,
+merges linear combinations, and removing zero-valued subgraphs.
Arguments:
graphs: A tuple or vector of graphs.
level: Optimization level (default: 0). A value greater than 0 triggers more extensive but slower optimization processes, such as removing duplicated nodes.
verbose: Level of verbosity (default: 0).
normalize: Optional function to normalize the graphs (default: nothing).
function propagator(ops::Union{OperatorProduct,Vector{QuantumOperator}};
name="", factor=one(_dtype.factor), weight=zero(_dtype.weight), operator=Sum())
-Create a Propagator-type FeynmanGraph from given OperatorProduct or Vector{QuantumOperator} `ops`, including two quantum operators.
function relabel!(g::FeynmanGraph, map::Dict{Int,Int})
+Create a Propagator-type FeynmanGraph from given OperatorProduct or Vector{QuantumOperator} `ops`, including two quantum operators.
function relabel!(g::FeynmanGraph, map::Dict{Int,Int})
Relabels the quantum operators in `g` and its subgraphs according to `map`.
-For example, `map = {1=>2, 3=>2}`` will find all quantum operators with labels 1 and 3, and then map them to 2.
function relabel(g::FeynmanGraph, map::Dict{Int,Int})
+For example, `map = {1=>2, 3=>2}`` will find all quantum operators with labels 1 and 3, and then map them to 2.
function relabel(g::FeynmanGraph, map::Dict{Int,Int})
Returns a copy of `g` with quantum operators in `g` and its subgraphs relabeled according to `map`.
-For example, `map = {1=>2, 3=>2}` will find all quantum operators with labels 1 and 3, and then map them to 2.
function remove_duplicated_leaves!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0, normalize=nothing, kwargs...)
+For example, `map = {1=>2, 3=>2}` will find all quantum operators with labels 1 and 3, and then map them to 2.
function remove_all_zero_valued_subgraphs!(g::AbstractGraph; verbose=0)
+
+Recursively removes all zero-valued subgraph(s) in-place in the given graph `g`.
function remove_all_zero_valued_subgraphs!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0)
+
+Recursively removes all zero-valued subgraph(s) in-place in the given graphs.
function remove_duplicated_leaves!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0, normalize=nothing, kwargs...)
+
+Removes duplicated leaf nodes in-place from a collection of graphs. It also provides optional normalization for these leaves.
Arguments:
graphs: A collection of graphs to be processed.
verbose: Level of verbosity (default: 0).
normalize: Optional function to normalize the graphs (default: nothing).
function remove_zero_valued_subgraphs!(g::AbstractGraph)
+
+Removes zero-valued (zero subgraph_factor) subgraph(s) of a computational graph `g`. If all subgraphs are zero-valued, the first one (`eldest(g)`) will be retained.
function remove_zero_valued_subgraphs(g::AbstractGraph)
-Removes duplicated leaf nodes in-place from a collection of graphs. It also provides optional normalization for these leaves.
Arguments:
graphs: A collection of graphs to be processed.
verbose: Level of verbosity (default: 0).
normalize: Optional function to normalize the graphs (default: nothing).
function replace_subgraph!(g::AbstractGraph, w::AbstractGraph, m::AbstractGraph)
+Returns a copy of graph `g` with zero-valued (zero subgraph_factor) subgraph(s) removed.
+If all subgraphs are zero-valued, the first one (`eldest(g)`) will be retained.
function replace_subgraph!(g::AbstractGraph, w::AbstractGraph, m::AbstractGraph)
Modifies `g` by replacing the subgraph `w` with a new graph `m`.
-For Feynman diagrams, subgraphs `w` and `m` should have the same diagram type, orders, and external indices.
function replace_subgraph(g::AbstractGraph, w::AbstractGraph, m::AbstractGraph)
+For Feynman diagrams, subgraphs `w` and `m` should have the same diagram type, orders, and external indices.
function replace_subgraph(g::AbstractGraph, w::AbstractGraph, m::AbstractGraph)
Creates a modified copy of `g` by replacing the subgraph `w` with a new graph `m`.
-For Feynman diagrams, subgraphs `w` and `m` should have the same diagram type, orders, and external indices.
function setsubgraphfactors!(g::AbstractGraph, subgraph_factors::AbstractVector, indices::AbstractVector{Int})
Update the specified subgraph factors of graph `g` at indices `indices` to `subgraph_factors`.
-By default, calls `set_subgraph_factor!(g, subgraph_factors[i], i)` for each `i` in `indices`.
function set_subgraphs!(g::AbstractGraph, subgraphs::AbstractVector{<:AbstractGraph}, indices::AbstractVector{Int})
Update the specified subgraphs of graph `g` at indices `indices` to `subgraphs`.
-By default, calls `set_subgraph!(g, subgraphs[i], i)` for each `i` in `indices`.
function standardize_labels!(g::FeynmanGraph)
+For Feynman diagrams, subgraphs `w` and `m` should have the same diagram type, orders, and external indices.
function setsubgraphfactors!(g::AbstractGraph, subgraph_factors::AbstractVector, indices::AbstractVector{Int})
Update the specified subgraph factors of graph `g` at indices `indices` to `subgraph_factors`.
+By default, calls `set_subgraph_factor!(g, subgraph_factors[i], i)` for each `i` in `indices`.
function set_subgraphs!(g::AbstractGraph, subgraphs::AbstractVector{<:AbstractGraph}, indices::AbstractVector{Int})
Update the specified subgraphs of graph `g` at indices `indices` to `subgraphs`.
+By default, calls `set_subgraph!(g, subgraphs[i], i)` for each `i` in `indices`.
function standardize_labels!(g::FeynmanGraph)
Finds all labels involved in `g` and its subgraphs and
modifies `g` by relabeling in standardized order, e.g.,
-(1, 4, 5, 7, ...) ↦ (1, 2, 3, 4, ....)
function standardize_labels!(g::FeynmanGraph)
Finds all labels involved in `g` and its subgraphs and returns
a copy of `g` relabeled in a standardized order, e.g.,
-(1, 4, 5, 7, ...) ↦ (1, 2, 3, 4, ....)
function vertex(g::FeynmanGraph, i=1)
Returns the `i`th vertex (::OperatorProduct) of FeynmanGraph `g`.
-Defaults to the first vertex if an index `i` is not supplied.
function derivative(diags::Union{Diagram,Tuple,AbstractVector}, ::Type{ID}, order::Int) where {ID<:PropagatorId}
-
-Automatic differentiation derivative on the diagrams
function derivative(diags::Union{Tuple,AbstractVector}, ::Type{ID}; index::Int=index(ID)) where {W,ID<:PropagatorId}
-function derivative(diags::Vector{Diagram{W}}, ::Type{ID}; index::Int=index(ID)) where {W,ID<:PropagatorId}
-
-Automatic differentiation derivative on the diagrams
Arguments
diags : diagrams to take derivative
ID : DiagramId to apply the differentiation
index : index of the id.order array element to increase the order
removeDuplicatedLeaves!(diags::AbstractVector; verbose = 0)
-
-remove duplicated nodes such as: ---> ver4 ---> InteractionId. Leaf will not be touched!
function removeHartreeFock!(diag::Diagram{W}) where {W}
-function removeHartreeFock!(diags::Union{Tuple,AbstractVector})
-
-Remove the Hartree-Fock insertions that without any derivatives on the propagator and the interaction.
Arguments
diags : diagrams to remove the Fock insertion
Remarks
The operations removeHartreeFock! and taking derivatives doesn't commute with each other!
If the input diagram is a Hartree-Fock diagram, then the overall weight will become zero!
struct LoopPool{T}
-
-Pool of loop basis. Each loop basis corresponds to a loop variable.
-A loop variable is a linear combination of N independent loops. The combination coefficients is what we call a loop basis.
-For example, if a loop is a momentum K, then
-
-varibale_i = K_1*basis[1, i] + K_2*basis[2, i] + K_3*basis[3, i] + ...
Members
name::Symbol : name of the pool
dim::Int : dimension of a loop variable (for example, the dimension of a momentum-frequency loop variable is (d+1) where d is the spatial dimension)
N::Int : number of independent loops (dimension of loop basis)
basis::Matrix{T} : Matrix of (N x Nb) that stores the loop basis, where Nb is the number of loop basis (or number of loop variables).
current::Matrix{T} : Matrix of (dim x Nb) that stores the loop variables, where Nb is the number of loop basis (or number of loop variables).
mutable struct Node{PARA,F}
-
-Node Object, which is the building block of the diagram tree. Each node is a collection of CACHED proapgator objects and other child CACHED node objects
Members
para::PARA : user-defined parameters, which will be used to evaluate the factor and the weight of the node (e.g., if the node represents a vertex function, then the parameter may be the momentum basis of the external legs)
operation::Int : #1: multiply, 2: add, ...
factor::F : additional factor of the node
components::Vector{Vector{Int}} : Index to the cached propagators stored in certain pools. Each Vector{Int} is for one kind of propagator.
childNodes::Vector{Int} : Indices to the cached nodes stored in certain pool. They are the child of the current node in the diagram tree.
parent::Int : Index to the cached nodes which is the parent of the current node.
function addnode!(diag::ExpressionTree{V,PARA,F,W}, operator, name, children::Union{Tuple, AbstractVector}, factor = 1.0; para = nothing) where {V,PARA,F,W}
-
-Add a node into the expression tree.
children : Indices to the cached nodes stored in certain pool. They are the child of the current node in the diagram tree. It should be in the format of Vector{Int}.
factor = 1.0 : Factor of the node
para = nothing : Additional paramenter required to evaluate the node. Set to nothing by default.
function addPropagator!(diag::ExpressionTree, name, factor = 1.0; site = [], loop = nothing, para = nothing, order::Int = 0)
-
-Add a propagator into the diagram tree.
Arguments
diag : diagrammatic experssion tree.
order::Int = 0 : Order of the propagator.
name = :none : name of the propagator.
factor = 1 : Factor of the propagator.
site = [] : site basis (e.g, time and space coordinate) of the propagator.
loop = nothing : loop basis (e.g, momentum and frequency) of the propagator.
para = nothing : Additional paramenter required to evaluate the propagator.
struct LoopPool{T}
Pool of loop basis. Each loop basis corresponds to a loop variable.
A loop variable is a linear combination of N independent loops. The combination coefficients is what we call a loop basis.
For example, if a loop is a momentum K, then
-varibale_i = K_1*basis[1, i] + K_2*basis[2, i] + K_3*basis[3, i] + ...
Members
name::Symbol : name of the pool
dim::Int : dimension of a loop variable (for example, the dimension of a momentum-frequency loop variable is (d+1) where d is the spatial dimension)
basis::Matrix{T} : Matrix of (N x Nb) that stores the loop basis, where Nb is the number of loop basis (or number of loop variables).
loops::Matrix{T} : Matrix of (dim x Nb) that stores the loop variables, where Nb is the number of loop basis (or number of loop variables).
abstract type PropagatorId <: DiagramId end
-julia> d = ver4.diagram[1] # take the first diagram
-5978:↑↑Dyn#[0, 0, 0, 0],t(1, 1, 1, 1)=0.0=⨁ (5026, 5071, 5137, 5146, 5175, 5220, 5312, 5321, 5350, 5396, 5463, 5473, 5503, 5549, 5642, 5652, 5682, 5793, 5831, 5968)
+The abstract type of all bare propagators
function extract_var_dependence(map::Dict{Int,DiagTree.DiagramId}, ::Type{ID}, numvars::Int)
+Convert a tuple of the indexes of each label to a single linear index of the LabelProduct.
Argument:
'obj': The LabelProduct object
'index...': N indexes of the label factor, where N is the number of label factor
function leafstates(leaf_maps::Vector{Dict{Int,G}}, maxloopNum::Int)
-Given a map between graph id and DiagramId, extract the variable dependence of all graphs.
Arguments:
map::Dict{Int,DiagTree.DiagramId}: A dictionary mapping graph ids to DiagramIds. DiagramId stores the diagram information of the corresponding graph.
ID: The particular type of ID that has the given variable dependence.
numvars: The number of variables which the diagram depends on.
@generated function index_to_linear(obj::LabelProduct{LT,N}, I...) where {LT,N}
+Extracts leaf information from the leaf mapping from the leaf value's index to the leaf node for all graph partitions.
+The information includes their initial value, type, orders, in/out time, and loop momentum index.
+The loop basis is also obtained for all the graphs.
Arguments:
leaf_maps: A vector of the dictionary mapping the leaf value's index to the Graph of this leaf. Each dict corresponds to a graph partition, such as (order, Gorder, Vorder).
maxloopNum: The maximum loop-momentum number.
Returns
A tuple of vectors containing information about the leaves of graphs, including their initial values, types, orders, input and output time indexes, and loop-momenta indexes.
Loop-momentum basis (::Vector{Vector{Float64}}) for all the graphs.
function leafstates(leaf_maps::Vector{Dict{Int,G}}, labelProd::LabelProduct) where {G<:Union{Graph,FeynmanGraph}}
-Convert a tuple of the indexes of each label to a single linear index of the LabelProduct.
Argument:
'obj': The LabelProduct object
'index...': N indexes of the label factor, where N is the number of label factor
This document was generated with Documenter.jl version 0.27.10 on Thursday 30 November 2023. Using Julia version 1.9.4.
+Extracts leaf information from the leaf mapping from the leaf value's index to the leaf node for all graph partitions
+and their associated LabelProduct data (`labelProd`).
+The information includes their initial value, type, orders, in/out time, and loop momenta.
Arguments:
leaf_maps: A vector of the dictionary mapping the leaf value's index to the FeynmanGraph/Graph of this leaf. Each dict corresponds to a graph partition, such as (order, Gorder, Vorder).
labelProd: A LabelProduct used to label the leaves of graphs.
Returns
A tuple of vectors containing information about the leaves of graphs, including their initial values, types, orders, input and output time indexes, and loop-momenta indexes.
struct OperatorProduct <: AbstractVector{QuantumOperator}
struct of a quantum-operator product. It is a subtype of `AbstractVector` and
-inherits a large set of Vector behaviors including iteration and indexing.
Members:
operators::Vector{QuantumOperator} vector of quantum operators
function correlator_order(operator::OperatorProduct)
function correlator_order(operator::OperatorProduct)
Convert a OperatorProduct to correlator-ordered form.
-Returns the associated statistical sign and permutation.
function normal_order(operator::OperatorProduct)
Computes the permutation required to convert a OperatorProduct to normal-ordered form.
-Returns the associated statistical sign and permutation.
The parity of a permutation P is +1 if the number of 2-cycles (swaps) in an n-cycle decomposition with n ≤ 2 is even, and -1 if the number of 2-cycles is odd.
The parity of a permutation P is +1 if the number of 2-cycles (swaps) in an n-cycle decomposition with n ≤ 2 is even, and -1 if the number of 2-cycles is odd.
function ep_coupling(para::DiagPara{W};
- extK=[DiagTree.getK(para.totalLoopNum, 1), DiagTree.getK(para.totalLoopNum, 2), DiagTree.getK(para.totalLoopNum, 3)],
+The channels of the left and right sub-vertex4 of a bubble diagram in the parquet equation
#Members
phi : channels of left sub-vertex for the particle-hole and particle-hole-exchange bubbles
ppi : channels of left sub-vertex for the particle-particle bubble
function ep_coupling(para::DiagPara;
+ extK=[getK(para.totalLoopNum, 1), getK(para.totalLoopNum, 2), getK(para.totalLoopNum, 3)],
channels::AbstractVector=[PHr, PHEr, PPr, Alli],
subdiagram=false,
name=:none, resetuid=false,
blocks::ParquetBlocks=ParquetBlocks()
-) where {W}
Generate electron-phonon 4-vertex diagrams using Parquet Algorithm. The right incoming Tau will be set to the last Tau for all diagrams | | Γ3 –––-| | |
Arguments
para : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx
extK : basis of external loops as a vector [left in, left out, right in, right out].
channels : vector of channels in the left Γ3 diagrams.
subdiagram : a sub-vertex or not
name : name of the vertex
resetuid : restart uid count from 1
blocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.
Output
A DataFrame with fields :response, :extT, :diagram, :hash.
Output
A DataFrame with fields :response, :type, :extT, :diagram, :hash
function sigma(para, extK = DiagTree.getK(para.totalLoopNum, 1), subdiagram = false; name = :Σ, resetuid = false, blocks::ParquetBlocks=ParquetBlocks())
Build sigma diagram. When sigma is created as a subdiagram, then no Fock diagram is generated if para.filter contains NoFock, and no sigma diagram is generated if para.filter contains Girreducible
Arguments
para : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx
extK : basis of external loop.
subdiagram : a sub-vertex or not
name : name of the diagram
resetuid : restart uid count from 1
blocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.
Output
A DataFrame with fields :type, :extT, :diagram, :hash
All sigma share the same incoming Tau index, but not the outgoing one
Generate 3-vertex diagrams using Parquet Algorithm. With imaginary-time variables, all vertex3 generated has the same bosonic Tidx $extT[1]=para.firstTauIdx$ and the incoming fermionic Tidx $extT[2]=para.firstTauIdx+1$.
#Arguments
para : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx
extK : basis of external loops as a vector [bosonic leg (out), fermionic in, fermionic out], extK[1] = extK[2] - extK[3].
subdiagram : a sub-vertex or not
name : name of the vertex
chan : vector of channels of the current 4-vertex.
resetuid : restart uid count from 1
blocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.
Output
A DataFrame with fields :response, :extT, :diagram, :hash.
Generate electron-phonon 4-vertex diagrams using Parquet Algorithm. The right incoming Tau will be set to the last Tau for all diagrams | | Γ3 –––-| | |
Arguments
para : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx
extK : basis of external loops as a vector [left in, left out, right in, right out].
channels : vector of channels in the left Γ3 diagrams.
subdiagram : a sub-vertex or not
name : name of the vertex
resetuid : restart uid count from 1
blocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.
Output
A DataFrame with fields :response, :extT, :diagram, :hash.
Output
A DataFrame with fields :response, :type, :extT, :diagram, :hash
get_ver4I()
+
+Retrieves the global dictionary `vertex4I_diags` that contains graph initialized by `initialize_vertex4I_diags`.
+This function is a getter that provides access to the stored graph data of the 3- and 4-point fully-irreducible (Alli) vertex functions.
initialize_vertex4I_diags(; filter=[NoHartree], spinPolarPara::Float64=0.0)
+
+Initialize the vertex4I_diags dictionary with the diagrams of the 3- and 4-point fully-irreducible (Alli) vertex functions.
Parameters
filter (optional) : a list of filter conditions to select the diagrams. Default is [NoHartree].
spinPolarPara (optional) : the spin-polarization parameter. Default is 0.0.
function innerTauNum(type::DiagramType, innerLoopNum, interactionTauNum)
+
+internal imaginary-time degrees of freedom for a given diagram type and internal loop number.
+For the vertex functions (self-energy, polarization, vertex3, and vertex4), innerTauNum is equivalent to tauNum.
+For the Green function, tauNum = innerTauNum + external tauNum
function mergeby(df::DataFrame, fields=Vector{Symbol}();
+ operator=Sum(), name::Symbol=:none,
+ getid::Function=g -> GenericId(g[1, :diagram].properties.para, Tuple(g[1, fields]))
+)
+
+Aggregates and merges rows in a DataFrame based on specified fields and an aggregation operator.
+It is designed to work with data frames containing diagram representations or similar structured data,
+allowing for flexible aggregation based on custom identifiers and properties.
Parameters
df: A DataFrame to be processed. It must contain a column named :diagram which holds Graph.
fields: A vector of Symbols specifying the columns based on which the aggregation groups are formed.
operator: The aggregation operator to be applied. This operator is used to aggregate data across rows within each group formed by the specified fields. The default is Sum().
name: An optional Symbol representing the name of a new column to store the aggregated results. The default is :none.
getid: A function that generates a unique identifier for each group based on the specified fields and the properties of the :diagram column. The default function is g -> GenericId(g[1, :diagram].properties.para, Tuple(g[1, fields])).
function sigma(para::DiagPara, extK=getK(para.totalLoopNum, 1), subdiagram=false;
+ name=:Σ, resetuid=false, blocks::ParquetBlocks=ParquetBlocks())
Build sigma diagram. When sigma is created as a subdiagram, then no Fock diagram is generated if para.filter contains NoFock, and no sigma diagram is generated if para.filter contains Girreducible
Arguments
para : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx
extK : basis of external loop.
subdiagram : a sub-vertex or not
name : name of the diagram
resetuid : restart uid count from 1
blocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.
Output
A DataFrame with fields :type, :extT, :diagram, :hash
All sigma share the same incoming Tau index, but not the outgoing one
update_extKT(diags::Vector{Graph}, para::DiagPara, legK::Vector{Vector{Float64}}) -> Vector{Graph}
+
+Returns a new vector of graphs with updated external momenta (`extK`) and external times (`extT`),
+based on the provided graphs, parameters, and external legs' momenta.
Arguments
diags::Vector{Graph}: A vector of Graph objects.
para::DiagPara: parameters reconstructed in the graphs. Its firstTauIdx will update the extT of graphs.
legK::Vector{Vector{Float64}}: basis of the external momenta for the legs of the diagram as [left in, left out, right in, right out].
extraLoopIdx: the index of the extra loop in the external momenta basis in legK. Defaults to nothing, which means no extra loop is included.
Returns
Vector{Graph}: A new vector of Graph objects with updated extK, extT, and para (if existing) properties for each node.
update_extKT!(diags::Vector{Graph}, para::DiagPara, legK::Vector{Vector{Float64}})
+
+Update the external momenta (`extK`) and external times (`extT`) of all the nodes in a vector of graphs in-place.
Arguments
diags::Vector{Graph}: A vector of Graph objects.
para::DiagPara: parameters reconstructed in the graphs. Its firstTauIdx will update the extT of graphs.
legK::Vector{Vector{Float64}}: basis of the external momenta for the legs of the diagram as [left in, left out, right in, right out].
extraLoopIdx: the index of the extra loop in the external momenta basis in legK. Defaults to nothing, which means no extra loop is included.
Generate 3-vertex diagrams using Parquet Algorithm. With imaginary-time variables, all vertex3 generated has the same bosonic Tidx $extT[1]=para.firstTauIdx$ and the incoming fermionic Tidx $extT[2]=para.firstTauIdx+1$.
#Arguments
para : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx
extK : basis of external loops as a vector [bosonic leg (out), fermionic in, fermionic out], extK[1] = extK[2] - extK[3].
subdiagram : a sub-vertex or not
name : name of the vertex
channels : vector of channels of the current 4-vertex.
resetuid : restart uid count from 1
blocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.
Output
A DataFrame with fields :response, :extT, :diagram, :hash.
julia> using FeynmanDiagram julia> para = DiagPara(type = Ver4Diag, innerLoopNum = 1, hasTau = true);ERROR: UndefVarError: `Ver4Diag` not defined julia> Parquet.vertex4(para)ERROR: UndefVarError: `para` not defined julia> para = DiagPara(type = Ver3Diag, innerLoopNum = 1, hasTau = true);ERROR: UndefVarError: `Ver3Diag` not defined julia> Parquet.vertex3(para)ERROR: UndefVarError: `para` not defined julia> para = DiagPara(type = SigmaDiag, innerLoopNum = 1, hasTau = true);ERROR: UndefVarError: `SigmaDiag` not defined julia> Parquet.sigma(para)ERROR: UndefVarError: `para` not defined julia> para = DiagPara(type = PolarDiag, innerLoopNum = 1, hasTau = true);ERROR: UndefVarError: `PolarDiag` not defined julia> Parquet.polarization(para)ERROR: UndefVarError: `para` not defined
Settings
This document was generated with Documenter.jl version 0.27.10 on Friday 16 February 2024. Using Julia version 1.10.1.
diff --git a/dev/lib/taylorseries/index.html b/dev/lib/taylorseries/index.html
new file mode 100644
index 00000000..893ca85a
--- /dev/null
+++ b/dev/lib/taylorseries/index.html
@@ -0,0 +1,46 @@
+
+Taylor expansions in independent variables (support AbstractGraph) · FeynmanDiagram.jl
ParamsTaylor
+
+DataType holding the current parameters for `TaylorSeries`.
+This part of code is adopted from TaylorSeries.jl (https://github.com/JuliaDiff/TaylorSeries.jl)
Fields:
orders :: Int Orders (degree) of the polynomials
num_vars :: Int Number of variables
variable_names :: Vector{String} Names of the variables
variable_symbols :: Vector{Symbol} Symbols of the variables
function TaylorSeries(::Type{T}, nv::Int) where {T}
+
+Create a taylor series equal to variable with index nv. For example, if global variables are "x y", in put nv=2 generate series t=y.
Arguments:
::Type{T} DataType of coefficients in taylor series.
function Base.:+(g1::TaylorSeries{T}, c::S) where {T,S<:Number}
+
+Returns a taylor series `g1 + c` representing the addition of constant `c` with `g1`.
function Base.:+(c::S, g1::TaylorSeries{T}) where {S<:Number,T}
+
+Returns a taylor series `g1 + c` representing the addition of constant `c` with `g1`.
function Base.:-(g1::TaylorSeries{T,V}, g2::TaylorSeries{T,V}) where {T,V}
+
+Returns a taylor series `g1 - g2` representing the difference of `g2` with `g1`.
Return a TaylorSeries{T} vector with each entry representing an independent variable. names defines the output for each variable (separated by a space). The default type T is Float64, and the default for orders is the one defined globally.
If numvars is not specified, it is inferred from names. If only one variable name is defined and numvars>1, it uses this name with subscripts for the different variables.
julia> set_variables(Int, "x y z", orders=[4,4,4])
+3-element Array{TaylorSeries.Taylor{Int},1}:
+ 1 x + 𝒪(x⁵y⁵z⁵)
+ 1 y + 𝒪(x⁵y⁵z⁵)
+ 1 z + 𝒪(x⁵y⁵z⁵)
function taylor_binomial(o1::Vector{Int}, o2::Vector{Int})
+
+Return the taylor binomial prefactor when product two high-order derivatives with order o1 and o2.
+
+# Arguments:
+- `o1` Order of first derivative
+- `o2` Order of second derivative
function taylor_factorial(o::Vector{Int})
+
+Return the taylor factorial prefactor with order o.
+
+# Arguments:
+- `o` Order of the taylor coefficient
For illustrative simplicity, let us consider the renormalization of the chemical potential and Yukawa effective mass in the uniform electron gas (UEG). Following the Negele & Orland conventions, the non-interacting Green's function $g$ is given by
where $G$ is the bold Green's function, $\omega_n = 2\pi (n+1)/\beta$ is a fermionic Matsubara frequency, and $\mu$ is the exact chemical potential derived from the interacting density $n$. The 1PI self-energy $\Sigma$ is then defined through the following Dyson equation:
\[ G^{-1} = g^{-1} + \Sigma \implies G = g - g\Sigma g + g\Sigma g \Sigma g - ...\;.\]
Following the variational diagrammatic Monte-Carlo (VDMC) approach, we rewrite the bare Green's function $g$ in terms of a renormalized propagator $g_R$, writing
where, motivated by Luttinger's theorem, the renormalized chemical potential $\mu_R = \mu - \delta\mu \equiv \epsilon_F = k^2_F / 2 m$ is chosen so as to preserve the non-interacting Fermi surface, whereas $\lambda$ is taken as a fixed, non-zero constant.
Similarly, the Coulomb interaction is re-written as
For illustrative simplicity, let us consider the renormalization of the chemical potential and Yukawa effective mass in the uniform electron gas (UEG). Following the Negele & Orland conventions, the non-interacting Green's function $g$ is given by
where $G$ is the bold Green's function, $\omega_n = 2\pi (n+1)/\beta$ is a fermionic Matsubara frequency, and $\mu$ is the exact chemical potential derived from the interacting density $n$. The 1PI self-energy $\Sigma$ is then defined through the following Dyson equation:
\[ G^{-1} = g^{-1} + \Sigma \implies G = g - g\Sigma g + g\Sigma g \Sigma g - ...\;.\]
Following the variational diagrammatic Monte-Carlo (VDMC) approach, we rewrite the bare Green's function $g$ in terms of a renormalized propagator $g_R$, writing
where, motivated by Luttinger's theorem, the renormalized chemical potential $\mu_R = \mu - \delta\mu \equiv \epsilon_F = k^2_F / 2 m$ is chosen so as to preserve the non-interacting Fermi surface, whereas $\lambda$ is taken as a fixed, non-zero constant.
Similarly, the Coulomb interaction is re-written as
In the NEFT codebase, the counterterms are generated by directly differentiating diagrams in the perturbative series for a given observable, which allows for a flexible and generic reformulation of the VDMC algorithm. This is made possible by representing all diagrams by differentiable expression trees. In contrast, in the original VDMC approach one first Taylor expands all propagators $g[g_R]$ and $V[V_\lambda]$ entering a given observable by hand and collects terms in orders of $\xi$ manually prior to integration.
The $\mathcal{O}(\xi^N)$ counterterms in RPT with $n$ and $m$ chemical potential / interaction derivatives are given by
where $D$ is the sum of all Feynman diagrams at the appropriate loop order $N - n - m$. The renormalization is performed in post-processing by multiplying with the Taylor series for $(\delta\mu)^n (\delta\lambda)^m$ in $\xi$ and collecting terms $\propto \xi^N$. The chemical potential shift $\delta \mu_n$ is derived from a separate MC simulation of $\Sigma^{\lambda_R}_F(k_F, ik_0)$.
To demonstrate that the two approaches outlined above are equivalent, it is sufficient to consider separately the cases of $V$ and $g$ raised to an arbitrary power in the Matsubara representation; we will omit the coordinates for brevity.
First, consider the chemical potential counterterms. Let $\delta\mu \equiv \mu_0 - \mu_R$. Taylor expanding $g[g_R]$ about $\delta\mu = 0$, we have
Since the order of differentiation w.r.t. $\mu$ and $\lambda$ does not matter, it follows that a general diagram $\mathcal{D}[g, V] \sim g^n V^m$ may be represented either by pre-expanding $g[g_\mu]$ and $V[V_\lambda]$ and collecting terms, or by directly evaluating terms in the Taylor series for $\mathcal{D}[g_\mu, V_\lambda]$; this codebase uses the latter approach.
An example of the interaction counterterm evaluation for a diagram with $n_\lambda = 3$ and $m$ interaction lines. Since the Julia implementation evaluates the interaction counterterms of a given diagram as $\frac{(-\lambda)^n}{n!}\partial^n_\lambda V^m_\lambda$, we pick up an extra factor of $l!$ on each $l$th-order derivative in the chain rule.
As a concrete example, we have evaluated the individual diagrams and associated counterterms entering the RPT series for the total density $n[g_\mu, V_\lambda]$ in units of the non-interacting density $n_0$. The diagrams/counterterms are denoted by partitions $\mathcal{P} \equiv (n_{\text{loop}}, n_\mu, n_\lambda)$ indicating the total loop order and number of $\mu$ and $\lambda$ derivatives.
For this benchmark, we take $r_s = 1$, $\beta = 40 \epsilon_F$, and $\lambda = 0.6$. All partitions contributing up to 4th order are included, as well as some selected partitions at 5th and 6th order.
$(n_{\text{loop}}, n_\lambda, n_\mu)$
$n / n_0$
(1, 0, 1)
0.40814(16)
(1, 0, 2)
0.02778(21)
(1, 0, 3)
-0.00096(60)
(2, 0, 0)
0.28853(12)
(2, 1, 0)
0.07225(3)
(2, 2, 0)
0.02965(2)
(2, 0, 1)
0.09774(30)
(2, 1, 1)
0.01594(10)
(2, 0, 2)
0.00240(130)
(3, 0, 0)
0.10027(37)
(3, 1, 0)
0.04251(21)
(3, 0, 1)
0.02600(150)
(4, 0, 0)
0.00320(130)
(2, 1, 2)
-0.00111(18)
(2, 0, 3)
-0.00430(150)
(3, 2, 0)
0.02241(8)
(3, 3, 0)
0.01429(7)
Settings
This document was generated with Documenter.jl version 0.27.10 on Thursday 30 November 2023. Using Julia version 1.9.4.
+\end{aligned}\]
Since the order of differentiation w.r.t. $\mu$ and $\lambda$ does not matter, it follows that a general diagram $\mathcal{D}[g, V] \sim g^n V^m$ may be represented either by pre-expanding $g[g_\mu]$ and $V[V_\lambda]$ and collecting terms, or by directly evaluating terms in the Taylor series for $\mathcal{D}[g_\mu, V_\lambda]$; this codebase uses the latter approach.
An example of the interaction counterterm evaluation for a diagram with $n_\lambda = 3$ and $m$ interaction lines. Since the Julia implementation evaluates the interaction counterterms of a given diagram as $\frac{(-\lambda)^n}{n!}\partial^n_\lambda V^m_\lambda$, we pick up an extra factor of $l!$ on each $l$th-order derivative in the chain rule.
As a concrete example, we have evaluated the individual diagrams and associated counterterms entering the RPT series for the total density $n[g_\mu, V_\lambda]$ in units of the non-interacting density $n_0$. The diagrams/counterterms are denoted by partitions $\mathcal{P} \equiv (n_{\text{loop}}, n_\mu, n_\lambda)$ indicating the total loop order and number of $\mu$ and $\lambda$ derivatives.
For this benchmark, we take $r_s = 1$, $\beta = 40 \epsilon_F$, and $\lambda = 0.6$. All partitions contributing up to 4th order are included, as well as some selected partitions at 5th and 6th order.
$(n_{\text{loop}}, n_\lambda, n_\mu)$
$n / n_0$
(1, 0, 1)
0.40814(16)
(1, 0, 2)
0.02778(21)
(1, 0, 3)
-0.00096(60)
(2, 0, 0)
0.28853(12)
(2, 1, 0)
0.07225(3)
(2, 2, 0)
0.02965(2)
(2, 0, 1)
0.09774(30)
(2, 1, 1)
0.01594(10)
(2, 0, 2)
0.00240(130)
(3, 0, 0)
0.10027(37)
(3, 1, 0)
0.04251(21)
(3, 0, 1)
0.02600(150)
(4, 0, 0)
0.00320(130)
(2, 1, 2)
-0.00111(18)
(2, 0, 3)
-0.00430(150)
(3, 2, 0)
0.02241(8)
(3, 3, 0)
0.01429(7)
Settings
This document was generated with Documenter.jl version 0.27.10 on Friday 16 February 2024. Using Julia version 1.10.1.
where the indices $x, y$ could be different from diagrams to diagrams, and $\Gamma_3$ is the inproper three-vertex function. Eliminate the additional sign, one derives,
We define the polarization $P$ as the one-interaction irreducible (or proper) vertex function,
\[\chi^{-1} = P^{-1} + V,\]
Settings
This document was generated with Documenter.jl version 0.27.10 on Friday 16 February 2024. Using Julia version 1.10.1.
diff --git a/dev/manual/hubbard_atom/index.html b/dev/manual/hubbard_atom/index.html
index 5755cff4..db4b665e 100644
--- a/dev/manual/hubbard_atom/index.html
+++ b/dev/manual/hubbard_atom/index.html
@@ -1,2 +1,2 @@
-Hubbard Atom as a Test Case · FeynmanDiagram.jl
One may use the Hubbard atom model to benchmark the Feynman diagrams generated by FeynmanDiagram.jl. In this note, we derive the vertex functions and their power expansion in interaction. The test is implemented in the test folder.
One may use the Hubbard atom model to benchmark the Feynman diagrams generated by FeynmanDiagram.jl. In this note, we derive the vertex functions and their power expansion in interaction. The test is implemented in the test folder.
In general, the interaction (or scattering amplitude) between two spin-$1/2$ particles only has two independent spin components. Here we briefly review some of the common conventions of the spin components in literature, and show how to map between different conventions.
We assume a particle from the left collides with a particle from the right. Due to the interaction between the two particles, one of them scatters to the left, and the other to the right.
We will use the index $\alpha,\beta,\gamma,\delta$ to label the left incoming, the left outgoing, the right incoming and the right outgoing particles. We assume four legs associate with four momentum-frequency vectors $k_1, k_2, k_3, k_4$.
There are two possible scatterings: a direct scattering where the two particles don't permutate after the collision, and an exchange scattering where the two particles permutate. Therefore, the total scattering amplitude has two contributions,
where the exchange contribution is different from the direct counterpart up to an exchange of two outgoing legs and an overall particle statistic sign $\xi =\pm 1$,
A interaction is split into a term that is independent of the spin (e.g., Coulomb interaction between electrons) and a term with spin dependence (e.g., ferromagnetic/antiferromagnetic interaction). This convention is commonly used in textbooks of Fermi liquid theory.
To derive the above equations, we use the identity $\vec{\sigma}_{\alpha\beta}\cdot \vec{\sigma}_{\gamma\delta}=2 \delta_{\alpha \delta} \delta_{\beta \gamma}-\delta_{\alpha \beta} \delta_{\gamma \delta}$, which gives the following equations,
An alternative parameterization of the interaction matrix is by specifiying the spin components $v_{\uparrow\uparrow} \equiv v_{\uparrow\uparrow\uparrow\uparrow}$ and $v_{\uparrow\downarrow} \equiv v_{\uparrow\uparrow\downarrow\downarrow}$. They can be derived from $v_s$ and $v_a$ by the simple relation,
In general, the interaction (or scattering amplitude) between two spin-$1/2$ particles only has two independent spin components. Here we briefly review some of the common conventions of the spin components in literature, and show how to map between different conventions.
We assume a particle from the left collides with a particle from the right. Due to the interaction between the two particles, one of them scatters to the left, and the other to the right.
We will use the index $\alpha,\beta,\gamma,\delta$ to label the left incoming, the left outgoing, the right incoming and the right outgoing particles. We assume four legs associate with four momentum-frequency vectors $k_1, k_2, k_3, k_4$.
There are two possible scatterings: a direct scattering where the two particles don't permutate after the collision, and an exchange scattering where the two particles permutate. Therefore, the total scattering amplitude has two contributions,
where the exchange contribution is different from the direct counterpart up to an exchange of two outgoing legs and an overall particle statistic sign $\xi =\pm 1$,
A interaction is split into a term that is independent of the spin (e.g., Coulomb interaction between electrons) and a term with spin dependence (e.g., ferromagnetic/antiferromagnetic interaction). This convention is commonly used in textbooks of Fermi liquid theory.
To derive the above equations, we use the identity $\vec{\sigma}_{\alpha\beta}\cdot \vec{\sigma}_{\gamma\delta}=2 \delta_{\alpha \delta} \delta_{\beta \gamma}-\delta_{\alpha \beta} \delta_{\gamma \delta}$, which gives the following equations,
An alternative parameterization of the interaction matrix is by specifiying the spin components $v_{\uparrow\uparrow} \equiv v_{\uparrow\uparrow\uparrow\uparrow}$ and $v_{\uparrow\downarrow} \equiv v_{\uparrow\uparrow\downarrow\downarrow}$. They can be derived from $v_s$ and $v_a$ by the simple relation,
This document was generated with Documenter.jl version 0.27.10 on Thursday 30 November 2023. Using Julia version 1.9.4.
+Search · FeynmanDiagram.jl
Loading search...
Settings
This document was generated with Documenter.jl version 0.27.10 on Friday 16 February 2024. Using Julia version 1.10.1.
diff --git a/dev/search_index.js b/dev/search_index.js
index f979a580..96dad124 100644
--- a/dev/search_index.js
+++ b/dev/search_index.js
@@ -1,3 +1,3 @@
var documenterSearchIndex = {"docs":
-[{"location":"lib/GV/#GV-expansion-to-a-computational-graph","page":"GV expansion to a computational graph","title":"GV expansion to a computational graph","text":"","category":"section"},{"location":"lib/GV/#API","page":"GV expansion to a computational graph","title":"API","text":"","category":"section"},{"location":"lib/GV/","page":"GV expansion to a computational graph","title":"GV expansion to a computational graph","text":"Modules = [FeynmanDiagram.GV]","category":"page"},{"location":"lib/GV/#FeynmanDiagram.GV.diagdictGV","page":"GV expansion to a computational graph","title":"FeynmanDiagram.GV.diagdictGV","text":"function diagdictGV(type::Symbol, MaxOrder::Int, has_counterterm::Bool=false;\n MinOrder::Int=1, spinPolarPara::Float64=0.0)\n\nGenerates a FeynmanGraph Dict: the Feynman diagrams with static interactions in a given `type`, and \nspin-polarizaition parameter `spinPolarPara`, to given minmimum/maximum orders `MinOrder/MaxOrder`, with switchable couterterms. \nGenerates a `LabelProduct`: `labelProd` for these FeynmanGraphs.\n\nArguments:\n\ntype (Symbol): The type of the Feynman diagrams, including :spinPolar, :chargePolar, :sigma_old, :green, or :freeEnergy.\nMaxorder (Int): The maximum actual order of the diagrams.\nhas_counterterm (Bool): false for G0W0, true for GW with self-energy and interaction counterterms (defaults to false).\nMinOrder (Int, optional): The minmimum actual order of the diagrams (defaults to 1).\nspinPolarPara (Float64, optional): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).\n\nReturns\n\nA tuple (dict_graphs, fermi_labelProd, bose_labelProd, leafMap) where \n\ndict_graphs is a Dict{Tuple{Int,Int,Int},Tuple{Vector{FeynmanGraph},Vector{Vector{Int}}}} object representing the diagrams. The key is (order, Gorder, Vorder). The element is a Tuple (graphVector, extT_labels).\nlabelProd is a LabelProduct object containing the labels for the leaves of graphs, \n\n\n\n\n\n","category":"function"},{"location":"lib/GV/#FeynmanDiagram.GV.diagdictGV-Tuple{Symbol, Vector{Tuple{Int64, Int64, Int64}}}","page":"GV expansion to a computational graph","title":"FeynmanDiagram.GV.diagdictGV","text":"function diagdictGV(type::Symbol, gkeys::Vector{Tuple{Int,Int,Int}}; spinPolarPara::Float64=0.0)\n\nGenerates a FeynmanGraph Dict: the Feynman diagrams with static interactions in the given `type` and \nspin-polarizaition parameter `spinPolarPara`, with given couterterm-orders (from `gkeys`). \nGenerates a `LabelProduct`: `labelProd` for these FeynmanGraphs.\n\nArguments:\n\ntype (Symbol): The type of the Feynman diagrams, including :spinPolar, :chargePolar, :sigma_old, :green, or :freeEnergy.\ngkeys (Vector{Tuple{Int,Int,Int}}): The (order, Gorder, Vorder) of the diagrams. Gorder is the order of self-energy counterterms, and Vorder is the order of interaction counterterms. \nspinPolarPara (Float64, optional): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).\n\nReturns\n\nA tuple (dict_graphs, fermi_labelProd, bose_labelProd, leafMap) where \n\ndict_graphs is a Dict{Tuple{Int,Int,Int},Tuple{Vector{FeynmanGraph},Vector{Vector{Int}}}} object representing the diagrams. The key is (order, Gorder, Vorder). The element is a Tuple (graphVector, extT_labels).\nlabelProd is a LabelProduct object containing the labels for the leaves of graphs, \n\n\n\n\n\n","category":"method"},{"location":"lib/GV/#FeynmanDiagram.GV.eachorder_diag","page":"GV expansion to a computational graph","title":"FeynmanDiagram.GV.eachorder_diag","text":"function eachorder_diag(type::Symbol, order::Int, VerOrder::Int=0, GOrder::Int=0; loopPool::Union{LoopPool,Nothing}=nothing,\n tau_labels::Union{Nothing,Vector{Int}}=nothing, GTypes::Union{Nothing,Vector{Int}}=nothing, VTypes::Union{Nothing,Vector{Int}}=nothing)\n\nGenerates a `Vector{FeynmanGraph}`: the given-`type` diagrams with static interactions of a given order, where the actual order of diagrams equals to `order + VerOrder + 2 * GOrder`.\nGenerates a `LabelProduct`: `labelProd` with inputs `tau_labels` and all the possible momenta-loop basis. \nGenerates external tau labels Vector{Vector{Int}}. The i-th labels (Vector{Int}) corresponds to the i-th `FeynmanGraph` in `Vector{FeynmanGraph}`.\n\nArguments:\n\ntype (Symbol): The type of the diagrams, including :spinPolar, :chargePolar, :sigma, :green, or :freeEnergy.\norder (Int): The order of the diagrams without counterterms.\nGOrder (Int, optional): The order of self-energy counterterms (defaults to 0).\nVerOrder (Int, optional): The order of interaction counterterms (defaults to 0).\nlabelProd (Union{Nothing,LabelProduct}=nothing, optional): The initial cartesian QuantumOperator.label product (defaults to nothing).\nspinPolarPara (Float64, optional): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).\ntau_labels(Union{Nothing, Vector{Int}}, optional): The labels for the discrete time of each vertex. (defaults to nothing).\n\nReturns\n\nA tuple (diagrams, fermi_labelProd, bose_labelProd, extT_labels) where \n\ndiagrams is a Vector{FeynmanGraph} object representing the diagrams, \nlabelProd is a LabelProduct object containing the labels for the leaves of graphs, \nextT_labels is a Vector{Vector{Int}} object containing the external tau labels for each FeynmanGraph in diagrams.\n\n\n\n\n\n","category":"function"},{"location":"lib/GV/#FeynmanDiagram.GV.leafstates-Union{Tuple{G}, Tuple{Array{Dict{Int64, G}, 1}, LabelProduct}} where G<:FeynmanGraph","page":"GV expansion to a computational graph","title":"FeynmanDiagram.GV.leafstates","text":"function leafstates(leaf_maps::Vector{Dict{Int,G}}, labelProd::LabelProduct) where {T,G<:FeynmanGraph}\n\nExtracts leaf information from the leaf mapping from the leaf value's index to the leaf node for all graph partitions\nand their associated LabelProduct data (`labelProd`). \nThe information includes their initial value, type, in/out time, and loop momenta.\n\nArguments:\n\nleaf_maps: A vector of the dictionary mapping the leaf value's index to the FeynmanGraph of this leaf. Each dict corresponds to a graph partition, such as (order, Gorder, Vorder).\nlabelProd: A LabelProduct used to label the leaves of graphs.\n\nReturns\n\nA tuple of vectors containing information about the leaves of graphs, including their initial values, types, input and output time indexes, and loop-momenta indexes.\n\n\n\n\n\n","category":"method"},{"location":"lib/GV/#FeynmanDiagram.GV.read_diagrams-Tuple{AbstractString}","page":"GV expansion to a computational graph","title":"FeynmanDiagram.GV.read_diagrams","text":"function read_diagrams(filename::AbstractString; loopPool::Union{LoopPool,Nothing}=nothing,\n dim::Int=3, tau_labels::Union{Nothing,Vector{Int}}=nothing, GTypes=[0, 1], VTypes=[0, 1, 2],\n keywords::Vector{String}=[\"Polarization\", \"DiagNum\", \"Order\", \"GNum\", \"Ver4Num\", \"LoopNum\", \"ExtLoopIndex\",\n \"DummyLoopIndex\", \"TauNum\", \"ExtTauIndex\", \"DummyTauIndex\"])\n\nReads a GV_diagrams file and returns FeynmanGraph of diagrams in this file \nand the corresponding `LabelProduct` objects, which are used to keep track of QuantumOperator.label.\n\nArguments:\n\nfilename (AbstractString): The path to the file containing the diagrams.\nloopPool (Union{LoopPool,Nothing}): An optional LoopPool object. If not provided, a new one will be created.\nspinPolarPara (Float64): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).\ndim (Int): The dimension of the system, used to initialize the LoopPool object. Default is 3.\ntau_labels (Union{Nothing,Vector{Int}}): The labels for the Tau objects in the diagrams. If not provided, they will be set to the integers from 1 to tauNum.\nGTypes (Vector{Int}): The labels for the fermionic G objects in the diagrams. Default is [0, 1].\nVTypes (Vector{Int}): The labels for the bosonic V objects in the diagrams. Default is [0, 1, 2].\nkeywords (Vector{String}): A set of keywords used to extract information from the file. Default is [\"Polarization\", \"DiagNum\", \"Order\", \"GNum\", \"Ver4Num\", \"LoopNum\", \"ExtLoopIndex\", \"DummyLoopIndex\", \"TauNum\", \"ExtTauIndex\", \"DummyTauIndex\"].\n\nReturns\n\nA tuple (diagrams, fermi_labelProd, bose_labelProd) where \n\ndiagrams is a FeynmanGraph object representing the diagrams, \nfermi_labelProd is a LabelProduct object containing the labels for the fermionic G objects in the diagrams, \nbose_labelProd is a LabelProduct object containing the labels for the bosonic W objects in the diagrams.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#Quantum-operator-and-its-product","page":"Quantum operator and its product","title":"Quantum operator and its product","text":"","category":"section"},{"location":"lib/operator/#API","page":"Quantum operator and its product","title":"API","text":"","category":"section"},{"location":"lib/operator/","page":"Quantum operator and its product","title":"Quantum operator and its product","text":"Modules = [FeynmanDiagram.QuantumOperators]","category":"page"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.OperatorProduct","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.OperatorProduct","text":"struct OperatorProduct <: AbstractVector{QuantumOperator}\n\nstruct of a quantum-operator product. It is a subtype of `AbstractVector` and\ninherits a large set of Vector behaviors including iteration and indexing.\n\nMembers:\n\noperators::Vector{QuantumOperator} vector of quantum operators\n\n\n\n\n\n","category":"type"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.QuantumOperator","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.QuantumOperator","text":"struct QuantumOperator\n\nstruct of a quantum operator.\n\nMembers:\n\noperator::Datatype: type of quantum operator, supports :f⁺, :f⁻, :f, :b⁺, :b⁻, :ϕ\nlabel::Int: label of the operator indices. It could represent spacetime, spin, momentum, flavor, etc.\nis_ghost::Bool: whether the operator is a ghost operator or not.\n\n\n\n\n\n","category":"type"},{"location":"lib/operator/#Base.:*-Tuple{QuantumOperator, QuantumOperator}","page":"Quantum operator and its product","title":"Base.:*","text":"Base.:*(o1::Union{QuantumOperator, OperatorProduct}, o2::Union{QuantumOperator, OperatorProduct})\n\n`o1 * o2` returns the quantum operator product of `o1` and `o2`\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#Base.adjoint-Tuple{OperatorProduct}","page":"Quantum operator and its product","title":"Base.adjoint","text":"Base.adjoint(o::OperatorProduct)\n\nReturn the conjuated composite operator of `o`.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#Base.adjoint-Tuple{QuantumOperator}","page":"Quantum operator and its product","title":"Base.adjoint","text":"Base.adjoint(operator::QuantumOperator)\n\nReturn the conjuated quantum operator of `operator`.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.correlator_order-Tuple{OperatorProduct}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.correlator_order","text":"function correlator_order(operator::OperatorProduct)\nfunction correlator_order(operator::OperatorProduct)\n\nConvert a OperatorProduct to correlator-ordered form. \nReturns the associated statistical sign and permutation.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.fermionic_annihilation-Tuple{Any}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.fermionic_annihilation","text":"Create a OperatorProduct with one quantum operator from given label `i`.\nIt supports the following abbreviated function form:\n\n''' const 𝑓⁻ = fermionicannihilation const 𝑓⁺ = fermioniccreation const 𝑓 = majorana const 𝑏⁻ = bosonicannihilation const 𝑏⁺ = bosoniccreation const 𝜙 = real_classic '''\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.isannihilation-Tuple{QuantumOperator}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.isannihilation","text":"function isannihilation(operator::QuantumOperator)\n\nCheck if `operator` is an annihilation operator.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.iscreation-Tuple{QuantumOperator}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.iscreation","text":"function iscreation(operator::QuantumOperator)\n\nCheck if `operator` is a creation operator.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.isfermionic-Tuple{OperatorProduct}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.isfermionic","text":"function isfermionic(o::OperatorProduct)\n\nCheck if `o` is a fermionic composite operator.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.isfermionic-Tuple{QuantumOperator}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.isfermionic","text":"function isfermionic(operator::QuantumOperator)\n\nCheck if `operator` is a fermionic operator.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.normal_order-Tuple{OperatorProduct}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.normal_order","text":"function normal_order(operator::OperatorProduct)\n\nComputes the permutation required to convert a OperatorProduct to normal-ordered form. \nReturns the associated statistical sign and permutation.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.parity-Tuple{AbstractVector{Int64}}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.parity","text":"The parity of a permutation P is +1 if the number of 2-cycles (swaps) in an n-cycle decomposition with n ≤ 2 is even, and -1 if the number of 2-cycles is odd.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.parity_old-Tuple{Any}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.parity_old","text":"calculate the parity of a given permutation of the array [1, 2, 3, ...]\n\n\n\n\n\n","category":"method"},{"location":"lib/exprtree/#Diagrams-as-an-Expression-Tree","page":"Diagrams as an Expression Tree","title":"Diagrams as an Expression Tree","text":"","category":"section"},{"location":"lib/exprtree/#API","page":"Diagrams as an Expression Tree","title":"API","text":"","category":"section"},{"location":"lib/exprtree/","page":"Diagrams as an Expression Tree","title":"Diagrams as an Expression Tree","text":"Modules = [FeynmanDiagram.ExprTree]","category":"page"},{"location":"lib/exprtree/#FeynmanDiagram.ExprTree.LoopPool","page":"Diagrams as an Expression Tree","title":"FeynmanDiagram.ExprTree.LoopPool","text":"struct LoopPool{T}\n\nPool of loop basis. Each loop basis corresponds to a loop variable.\nA loop variable is a linear combination of N independent loops. The combination coefficients is what we call a loop basis.\nFor example, if a loop is a momentum K, then\n\nvaribale_i = K_1*basis[1, i] + K_2*basis[2, i] + K_3*basis[3, i] + ...\n\nMembers\n\nname::Symbol : name of the pool\ndim::Int : dimension of a loop variable (for example, the dimension of a momentum-frequency loop variable is (d+1) where d is the spatial dimension)\nN::Int : number of independent loops (dimension of loop basis)\nbasis::Matrix{T} : Matrix of (N x Nb) that stores the loop basis, where Nb is the number of loop basis (or number of loop variables).\ncurrent::Matrix{T} : Matrix of (dim x Nb) that stores the loop variables, where Nb is the number of loop basis (or number of loop variables).\n\n\n\n\n\n","category":"type"},{"location":"lib/exprtree/#FeynmanDiagram.ExprTree.Node","page":"Diagrams as an Expression Tree","title":"FeynmanDiagram.ExprTree.Node","text":"mutable struct Node{PARA,F}\n\nNode Object, which is the building block of the diagram tree. Each node is a collection of CACHED proapgator objects and other child CACHED node objects\n\nMembers\n\npara::PARA : user-defined parameters, which will be used to evaluate the factor and the weight of the node (e.g., if the node represents a vertex function, then the parameter may be the momentum basis of the external legs)\noperation::Int : #1: multiply, 2: add, ...\nfactor::F : additional factor of the node\ncomponents::Vector{Vector{Int}} : Index to the cached propagators stored in certain pools. Each Vector{Int} is for one kind of propagator.\nchildNodes::Vector{Int} : Indices to the cached nodes stored in certain pool. They are the child of the current node in the diagram tree.\nparent::Int : Index to the cached nodes which is the parent of the current node.\n\n\n\n\n\n","category":"type"},{"location":"lib/exprtree/#FeynmanDiagram.ExprTree.addnode!-Union{Tuple{W}, Tuple{F}, Tuple{PARA}, Tuple{V}, Tuple{ExpressionTree{V, PARA, F, W}, Any, Any, Union{Tuple, AbstractVector}}, Tuple{ExpressionTree{V, PARA, F, W}, Any, Any, Union{Tuple, AbstractVector}, Any}} where {V, PARA, F, W}","page":"Diagrams as an Expression Tree","title":"FeynmanDiagram.ExprTree.addnode!","text":"function addnode!(diag::ExpressionTree{V,PARA,F,W}, operator, name, children::Union{Tuple, AbstractVector}, factor = 1.0; para = nothing) where {V,PARA,F,W}\n\nAdd a node into the expression tree.\n\nArguments\n\ndiag::ExpressionTree : diagrammatic experssion tree.\noperator::Int : #1: multiply, 2: add, ...\nname : name of the node\nchildren : Indices to the cached nodes stored in certain pool. They are the child of the current node in the diagram tree. It should be in the format of Vector{Int}.\nfactor = 1.0 : Factor of the node\npara = nothing : Additional paramenter required to evaluate the node. Set to nothing by default.\n\n\n\n\n\n","category":"method"},{"location":"lib/exprtree/#FeynmanDiagram.ExprTree.addpropagator!-Union{Tuple{W}, Tuple{F}, Tuple{PARA}, Tuple{V}, Tuple{ExpressionTree{V, PARA, F, W}, Any}, Tuple{ExpressionTree{V, PARA, F, W}, Any, Any}} where {V, PARA, F, W}","page":"Diagrams as an Expression Tree","title":"FeynmanDiagram.ExprTree.addpropagator!","text":"function addPropagator!(diag::ExpressionTree, name, factor = 1.0; site = [], loop = nothing, para = nothing, order::Int = 0)\n\nAdd a propagator into the diagram tree.\n\nArguments\n\ndiag : diagrammatic experssion tree.\norder::Int = 0 : Order of the propagator.\nname = :none : name of the propagator.\nfactor = 1 : Factor of the propagator.\nsite = [] : site basis (e.g, time and space coordinate) of the propagator.\nloop = nothing : loop basis (e.g, momentum and frequency) of the propagator.\npara = nothing : Additional paramenter required to evaluate the propagator.\n\n\n\n\n\n","category":"method"},{"location":"lib/exprtree/#FeynmanDiagram.ExprTree.getNode-Tuple{Any, Int64}","page":"Diagrams as an Expression Tree","title":"FeynmanDiagram.ExprTree.getNode","text":"function getNode(diag::Diagrams, nidx::Int)\n\nget Node in the diag with the index nidx.\n\n\n\n\n\n","category":"method"},{"location":"lib/exprtree/#FeynmanDiagram.ExprTree.getNodeWeight-Tuple{Any, Int64}","page":"Diagrams as an Expression Tree","title":"FeynmanDiagram.ExprTree.getNodeWeight","text":"function getNodeWeight(tree, nidx::Int)\n\nget Node weight in the diagram experssion tree with the index nidx.\n\n\n\n\n\n","category":"method"},{"location":"lib/exprtree/#FeynmanDiagram.ExprTree.showTree-Tuple{ExpressionTree, Int64}","page":"Diagrams as an Expression Tree","title":"FeynmanDiagram.ExprTree.showTree","text":"showTree(diag::Diagrams, _root = diag.root[end]; verbose = 0, depth = 999)\n\nVisualize the diagram tree using ete3 python package\n\n#Arguments\n\ndiag: the Diagrams struct to visualize\n_root: the index of the root node to visualize\nverbose=0: the amount of information to show\ndepth=999: deepest level of the diagram tree to show\n\n\n\n\n\n","category":"method"},{"location":"lib/diagtree/#Diagrams-as-an-AbstractTree","page":"Diagrams as an AbstractTree","title":"Diagrams as an AbstractTree","text":"","category":"section"},{"location":"lib/diagtree/#API","page":"Diagrams as an AbstractTree","title":"API","text":"","category":"section"},{"location":"lib/diagtree/","page":"Diagrams as an AbstractTree","title":"Diagrams as an AbstractTree","text":"Modules = [FeynmanDiagram.DiagTree]","category":"page"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.BareGreenNId","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.BareGreenNId","text":"time-ordered N-point Bare Green's function\n\n\n\n\n\n","category":"type"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.BareHoppingId","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.BareHoppingId","text":"hopping function c⁺c⁻\n\n\n\n\n\n","category":"type"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.ConnectedGreenNId","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.ConnectedGreenNId","text":"time-ordered N-point Composite Green's function\n\n\n\n\n\n","category":"type"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.Diagram","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.Diagram","text":"mutable struct Diagram{W}\n\nstruct of a diagram. A diagram of a sum or produce of various subdiagrams.\n\nMembers\n\nhash::Int : the unique hash number to identify the diagram\nname::Symbol : name of the diagram\nid::DiagramId : diagram id \noperator::Operator : operation, support Sum() and Prod()\nfactor::W : additional factor of the diagram\nsubdiagram::Vector{Diagram{W}} : vector of sub-diagrams\nweight::W : weight of the diagram\n\n\n\n\n\n","category":"type"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.DiagramId","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.DiagramId","text":"abstract type DiagramId end\n\nThe abstract type of all diagrams/subdiagrams/bare propagators\n\n\n\n\n\n","category":"type"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.GreenNId","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.GreenNId","text":"time-ordered N-point Composite Green's function\n\n\n\n\n\n","category":"type"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.PropagatorId","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.PropagatorId","text":"abstract type PropagatorId <: DiagramId end\n\nThe abstract type of all bare propagators\n\n\n\n\n\n","category":"type"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.derivative-Union{Tuple{ID}, Tuple{Union{Tuple, AbstractVector}, Type{ID}, Int64}} where ID<:PropagatorId","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.derivative","text":"function derivative(diags::Union{Diagram,Tuple,AbstractVector}, ::Type{ID}, order::Int) where {ID<:PropagatorId}\n\nAutomatic differentiation derivative on the diagrams\n\nArguments\n\ndiags : diagrams to take derivative\nID : DiagramId to apply the differentiation\norder::Int : derivative order\n\n\n\n\n\n","category":"method"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.derivative-Union{Tuple{ID}, Tuple{Union{Tuple, AbstractVector}, Type{ID}}} where ID<:PropagatorId","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.derivative","text":"function derivative(diags::Union{Tuple,AbstractVector}, ::Type{ID}; index::Int=index(ID)) where {W,ID<:PropagatorId}\nfunction derivative(diags::Vector{Diagram{W}}, ::Type{ID}; index::Int=index(ID)) where {W,ID<:PropagatorId}\n\nAutomatic differentiation derivative on the diagrams\n\nArguments\n\ndiags : diagrams to take derivative\nID : DiagramId to apply the differentiation\nindex : index of the id.order array element to increase the order\n\n\n\n\n\n","category":"method"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.plot_tree-Tuple{Diagram}","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.plot_tree","text":"function plot_tree(diag::Diagram; verbose = 0, maxdepth = 6)\n\nVisualize the diagram tree using ete3 python package\n\n#Arguments\n\ndiag : the Diagram struct to visualize\nverbose=0 : the amount of information to show\nmaxdepth=6 : deepest level of the diagram tree to show\n\n\n\n\n\n","category":"method"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.removeDuplicatedLeaves!-Union{Tuple{Array{Diagram{W}, 1}}, Tuple{W}} where W","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.removeDuplicatedLeaves!","text":"removeDuplicatedLeaves!(diags::AbstractVector; verbose = 0)\n\nremove duplicated nodes such as: ---> ver4 ---> InteractionId. Leaf will not be touched!\n\n\n\n\n\n","category":"method"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.removeHartreeFock!-Union{Tuple{Diagram{W}}, Tuple{W}} where W","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.removeHartreeFock!","text":"function removeHartreeFock!(diag::Diagram{W}) where {W}\nfunction removeHartreeFock!(diags::Union{Tuple,AbstractVector})\n\nRemove the Hartree-Fock insertions that without any derivatives on the propagator and the interaction.\n\nArguments\n\ndiags : diagrams to remove the Fock insertion\n\nRemarks\n\nThe operations removeHartreeFock! and taking derivatives doesn't commute with each other! \nIf the input diagram is a Hartree-Fock diagram, then the overall weight will become zero! \nThe return value is always nothing\n\n\n\n\n\n","category":"method"},{"location":"lib/diagtree/#FeynmanDiagram.DiagTree.removeOneChildParent!-Union{Tuple{Array{Diagram{W}, 1}}, Tuple{W}} where W","page":"Diagrams as an AbstractTree","title":"FeynmanDiagram.DiagTree.removeOneChildParent!","text":"removeOneChildParent!(diags::AbstractVector; verbose = 0)\n\nremove duplicated nodes such as: ---> ver4 ---> InteractionId. Leaf will not be touched!\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#Front-end-translates-a-source-code-into-a-computational-graph","page":"Front-end translates a source code into a computational graph","title":"Front-end translates a source code into a computational graph","text":"","category":"section"},{"location":"lib/frontend/#API","page":"Front-end translates a source code into a computational graph","title":"API","text":"","category":"section"},{"location":"lib/frontend/","page":"Front-end translates a source code into a computational graph","title":"Front-end translates a source code into a computational graph","text":"Modules = [FeynmanDiagram.FrontEnds]","category":"page"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.LabelProduct","page":"Front-end translates a source code into a computational graph","title":"FeynmanDiagram.FrontEnds.LabelProduct","text":"The cartesian QuantumOperator.label product:\n\n#Parameters:\n\n'LT': Type of labels\n'N' : Number of labels' type\n\n#Members:\n\n'labels' : The list of labels in the LabelProduct\n'dims' : A tuple of the length of the label factors\n\n\n\n\n\n","category":"type"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.LoopPool","page":"Front-end translates a source code into a computational graph","title":"FeynmanDiagram.FrontEnds.LoopPool","text":"struct LoopPool{T}\n\nPool of loop basis. Each loop basis corresponds to a loop variable.\nA loop variable is a linear combination of N independent loops. The combination coefficients is what we call a loop basis.\nFor example, if a loop is a momentum K, then\n\nvaribale_i = K_1*basis[1, i] + K_2*basis[2, i] + K_3*basis[3, i] + ...\n\nMembers\n\nname::Symbol : name of the pool\ndim::Int : dimension of a loop variable (for example, the dimension of a momentum-frequency loop variable is (d+1) where d is the spatial dimension)\nbasis::Matrix{T} : Matrix of (N x Nb) that stores the loop basis, where Nb is the number of loop basis (or number of loop variables).\nloops::Matrix{T} : Matrix of (dim x Nb) that stores the loop variables, where Nb is the number of loop basis (or number of loop variables).\n\n\n\n\n\n","category":"type"},{"location":"lib/frontend/#Base.length-Tuple{LabelProduct}","page":"Front-end translates a source code into a computational graph","title":"Base.length","text":"function Base.length(obj::LabelProduct)\n\nReturn the number of grids of the LabelProduct.\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#Base.show-Tuple{IO, LabelProduct}","page":"Front-end translates a source code into a computational graph","title":"Base.show","text":"function Base.show(io::IO, obj::LabelProduct)\n\nPrint the LabelProduct.\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#Base.size-Tuple{LabelProduct, Int64}","page":"Front-end translates a source code into a computational graph","title":"Base.size","text":"function Base.size(obj::LabelProduct, I::Int)\n\nReturn the length of the specifict Ith label factor of the LabelProduct.\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#Base.size-Tuple{LabelProduct}","page":"Front-end translates a source code into a computational graph","title":"Base.size","text":"function Base.size(obj::LabelProduct, I::Int)\n\nReturn the length of the specifict Ith label factor of the LabelProduct.\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.Graph!-Union{Tuple{Diagram{W}}, Tuple{W}} where W","page":"Front-end translates a source code into a computational graph","title":"FeynmanDiagram.FrontEnds.Graph!","text":"function Graph!(d::DiagTree.Diagram{W}; map=Dict{Int,DiagTree.DiagramId}()) where {W}\n\nConverts a DiagTree d into a Graph, storing the diagram information (which is a DiagramId object) in a Graph.id to DiagramId dictionary ``map\".\n\nArguments:\n\nd: DiagTree.Diagram object.\nmap: map between the Graph.id and DiagramId. It will be updated with the new nodes and leaves contained in the DiagTree.Diagram d.\n\nExample:\n\njulia> para = DiagParaF64(type = Ver4Diag, innerLoopNum=2);\n\njulia> ver4=Parquet.build(para)\n2×5 DataFrame\n Row │ diagram extT hash response type \n │ Diagram… Tuple… Int64 Response Analytic… \n─────┼─────────────────────────────────────────────────────────────────────────────\n 1 │ 5978:↑↑Dyn#[0, 0, 0, 0],t(1, 1, … (1, 1, 1, 1) 5978 UpUp Dynamic\n 2 │ 5979:↑↓Dyn#[0, 0, 0, 0],t(1, 1, … (1, 1, 1, 1) 5979 UpDown Dynamic\n\njulia> d = ver4.diagram[1] # take the first diagram\n5978:↑↑Dyn#[0, 0, 0, 0],t(1, 1, 1, 1)=0.0=⨁ (5026, 5071, 5137, 5146, 5175, 5220, 5312, 5321, 5350, 5396, 5463, 5473, 5503, 5549, 5642, 5652, 5682, 5793, 5831, 5968)\n\njulia> root = FrontEnds.Graph!(d)\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.extract_var_dependence-Union{Tuple{ID}, Tuple{Dict{Int64, DiagramId}, Type{ID}}} where ID<:PropagatorId","page":"Front-end translates a source code into a computational graph","title":"FeynmanDiagram.FrontEnds.extract_var_dependence","text":"function extract_var_dependence(map::Dict{Int,DiagTree.DiagramId}, ::Type{ID}, numvars::Int)\n\nGiven a map between graph id and DiagramId, extract the variable dependence of all graphs.\n\nArguments:\n\nmap::Dict{Int,DiagTree.DiagramId}: A dictionary mapping graph ids to DiagramIds. DiagramId stores the diagram information of the corresponding graph. \nID: The particular type of ID that has the given variable dependence. \nnumvars: The number of variables which the diagram depends on.\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.index_to_linear-Union{Tuple{N}, Tuple{LT}, Tuple{LabelProduct{LT, N}, Vararg{Any}}} where {LT, N}","page":"Front-end translates a source code into a computational graph","title":"FeynmanDiagram.FrontEnds.index_to_linear","text":"@generated function index_to_linear(obj::LabelProduct{LT,N}, I...) where {LT,N}\n\nConvert a tuple of the indexes of each label to a single linear index of the LabelProduct.\n\nArgument:\n\n'obj': The LabelProduct object\n'index...': N indexes of the label factor, where N is the number of label factor\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.linear_to_index-Union{Tuple{N}, Tuple{LT}, Tuple{LabelProduct{LT, N}, Int64}} where {LT, N}","page":"Front-end translates a source code into a computational graph","title":"FeynmanDiagram.FrontEnds.linear_to_index","text":"function linear_to_index(obj::LabelProduct, I::Int)\n\nConvert the single linear index of the LabelProduct to a tuple of indexes of each label. \n\nArgument:\n\n'obj': The LabelProduct object\n'I': The linear index of the LabelProduct \n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#Parquet-Algorithm-to-Build-Diagrams","page":"Parquet Algorithm to Build Diagrams","title":"Parquet Algorithm to Build Diagrams","text":"","category":"section"},{"location":"lib/parquet/#API","page":"Parquet Algorithm to Build Diagrams","title":"API","text":"","category":"section"},{"location":"lib/parquet/","page":"Parquet Algorithm to Build Diagrams","title":"Parquet Algorithm to Build Diagrams","text":"Modules = [FeynmanDiagram.Parquet]","category":"page"},{"location":"lib/parquet/#FeynmanDiagram.Parquet.ParquetBlocks","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.Parquet.ParquetBlocks","text":"struct ParquetBlocks\n\nThe channels of the left and right sub-vertex4 of a bubble diagram in the parquet equation\n\n#Members\n\nphi : channels of left sub-vertex for the particle-hole and particle-hole-exchange bubbles\nppi : channels of left sub-vertex for the particle-particle bubble\nΓ4 : channels of right sub-vertex of all channels\n\n\n\n\n\n","category":"type"},{"location":"lib/parquet/#FeynmanDiagram.Parquet.ep_coupling-Union{Tuple{DiagPara{W}}, Tuple{W}} where W","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.Parquet.ep_coupling","text":"function ep_coupling(para::DiagPara{W};\n extK=[DiagTree.getK(para.totalLoopNum, 1), DiagTree.getK(para.totalLoopNum, 2), DiagTree.getK(para.totalLoopNum, 3)],\n channels::AbstractVector=[PHr, PHEr, PPr, Alli],\n subdiagram=false,\n name=:none, resetuid=false,\n blocks::ParquetBlocks=ParquetBlocks()\n) where {W}\n\nGenerate electron-phonon 4-vertex diagrams using Parquet Algorithm. The right incoming Tau will be set to the last Tau for all diagrams | | Γ3 –––-| | |\n\nArguments\n\npara : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx\nextK : basis of external loops as a vector [left in, left out, right in, right out]. \nchannels : vector of channels in the left Γ3 diagrams. \nsubdiagram : a sub-vertex or not\nname : name of the vertex\nresetuid : restart uid count from 1\nblocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.\n\nOutput\n\nA DataFrame with fields :response, :extT, :diagram, :hash. \n\nOutput\n\nA DataFrame with fields :response, :type, :extT, :diagram, :hash\n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#FeynmanDiagram.Parquet.green-Union{Tuple{DiagPara{W}}, Tuple{W}, Tuple{DiagPara{W}, Any}, Tuple{DiagPara{W}, Any, Any}, Tuple{DiagPara{W}, Any, Any, Any}} where W","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.Parquet.green","text":"green(para::DiagPara, extK = DiagTree.getK(para.totalLoopNum, 1), extT = para.hasTau ? (1, 2) : (0, 0), subdiagram = false;\n name = :G, resetuid = false, blocks::ParquetBlocks=ParquetBlocks())\n\nBuild composite Green's function. By definition, para.firstTauIdx is the first Tau index of the left most self-energy subdiagram.\n\nArguments\n\npara : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx\nextK : basis of external loop. \nextT: [Tau index of the left leg, Tau index of the right leg]\nsubdiagram : a sub-vertex or not\nname : name of the diagram\nresetuid : restart uid count from 1\nblocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.\n\nOutput\n\nA Diagram object or nothing if the Green's function is illegal. \n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#FeynmanDiagram.Parquet.polarization-Union{Tuple{DiagPara{W}}, Tuple{W}, Tuple{DiagPara{W}, Any}, Tuple{DiagPara{W}, Any, Any}} where W","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.Parquet.polarization","text":"function polarization(para, extK = DiagTree.getK(para.totalLoopNum, 1), subdiagram = false; name = :Π, resetuid = false, blocks::ParquetBlocks=ParquetBlocks())\n\nGenerate polarization diagrams using Parquet Algorithm.\n\nArguments\n\npara : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx\nextK : basis of external loop. \nsubdiagram : a sub-vertex or not\nname : name of the vertex\nresetuid : restart uid count from 1\nblocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.\n\nOutput\n\nA DataFrame with fields :response, :diagram, :hash. \nAll polarization share the same external Tau index. With imaginary-time variables, they are extT = (para.firstTauIdx, para.firstTauIdx+1)\n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#FeynmanDiagram.Parquet.sigma-Union{Tuple{DiagPara{W}}, Tuple{W}, Tuple{DiagPara{W}, Any}, Tuple{DiagPara{W}, Any, Any}} where W","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.Parquet.sigma","text":"function sigma(para, extK = DiagTree.getK(para.totalLoopNum, 1), subdiagram = false; name = :Σ, resetuid = false, blocks::ParquetBlocks=ParquetBlocks())\n\nBuild sigma diagram. When sigma is created as a subdiagram, then no Fock diagram is generated if para.filter contains NoFock, and no sigma diagram is generated if para.filter contains Girreducible\n\nArguments\n\npara : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx\nextK : basis of external loop. \nsubdiagram : a sub-vertex or not\nname : name of the diagram\nresetuid : restart uid count from 1\nblocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.\n\nOutput\n\nA DataFrame with fields :type, :extT, :diagram, :hash\nAll sigma share the same incoming Tau index, but not the outgoing one\n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#FeynmanDiagram.Parquet.vertex3-Union{Tuple{DiagPara{WW}}, Tuple{WW}, Tuple{DiagPara{WW}, Any}, Tuple{DiagPara{WW}, Any, Any}} where WW","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.Parquet.vertex3","text":"function vertex3(para, extK = [DiagTree.getK(para.totalLoopNum, 1), DiagTree.getK(para.totalLoopNum, 2)],\n subdiagram = false; name = :Γ3, chan = [PHr, PHEr, PPr, Alli], resetuid = false, \n blocks::ParquetBlocks=ParquetBlocks()\n )\n\nGenerate 3-vertex diagrams using Parquet Algorithm. With imaginary-time variables, all vertex3 generated has the same bosonic Tidx extT1=parafirstTauIdx and the incoming fermionic Tidx extT2=parafirstTauIdx+1.\n\n#Arguments\n\npara : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx\nextK : basis of external loops as a vector [bosonic leg (out), fermionic in, fermionic out], extK[1] = extK[2] - extK[3]. \nsubdiagram : a sub-vertex or not\nname : name of the vertex\nchan : vector of channels of the current 4-vertex. \nresetuid : restart uid count from 1\nblocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.\n\nOutput\n\nA DataFrame with fields :response, :extT, :diagram, :hash. \n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#FeynmanDiagram.Parquet.vertex4-Union{Tuple{DiagPara{W}}, Tuple{W}, Tuple{DiagPara{W}, Any}, Tuple{DiagPara{W}, Any, AbstractVector}, Tuple{DiagPara{W}, Any, AbstractVector, Any}} where W","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.Parquet.vertex4","text":"vertex4(para::DiagPara,\n extK = [DiagTree.getK(para.totalLoopNum, 1), DiagTree.getK(para.totalLoopNum, 2), DiagTree.getK(para.totalLoopNum, 3)],\n chan::AbstractVector = [PHr, PHEr, PPr, Alli],\n subdiagram = false;\n level = 1, name = :none, resetuid = false,\n blocks::ParquetBlocks=ParquetBlocks(),\n blockstoplevel::ParquetBlocks=blocks\n )\n\nGenerate 4-vertex diagrams using Parquet Algorithm\n\nArguments\n\npara : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx\nextK : basis of external loops as a vector [left in, left out, right in, right out]. \nchan : vector of channels of the current 4-vertex. \nsubdiagram : a sub-vertex or not\nname : name of the vertex\nlevel : level in the diagram tree\nresetuid : restart uid count from 1\nblocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.\nblockstoplevel : building blocks of the Parquet equation at the toplevel. See the struct ParquetBlocks for more details.\n\nOutput\n\nA DataFrame with fields :response, :type, :extT, :diagram, :hash\n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#Usage","page":"Parquet Algorithm to Build Diagrams","title":"Usage","text":"","category":"section"},{"location":"lib/parquet/","page":"Parquet Algorithm to Build Diagrams","title":"Parquet Algorithm to Build Diagrams","text":"using FeynmanDiagram\npara = DiagPara(type = Ver4Diag, innerLoopNum = 1, hasTau = true);\nParquet.vertex4(para)\n\npara = DiagPara(type = Ver3Diag, innerLoopNum = 1, hasTau = true);\nParquet.vertex3(para)\n\npara = DiagPara(type = SigmaDiag, innerLoopNum = 1, hasTau = true);\nParquet.sigma(para)\n\npara = DiagPara(type = PolarDiag, innerLoopNum = 1, hasTau = true);\nParquet.polarization(para)","category":"page"},{"location":"lib/computgraph/#Computational-graph-for-general-feynman-diagrams","page":"Computational graph for general feynman diagrams","title":"Computational graph for general feynman diagrams","text":"","category":"section"},{"location":"lib/computgraph/#API","page":"Computational graph for general feynman diagrams","title":"API","text":"","category":"section"},{"location":"lib/computgraph/","page":"Computational graph for general feynman diagrams","title":"Computational graph for general feynman diagrams","text":"Modules = [FeynmanDiagram.ComputationalGraphs]","category":"page"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.FeynmanGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.FeynmanGraph","text":"mutable struct FeynmanGraph{F<:Number,W}\n\nComputational graph representation of a (collection of) Feynman diagram(s). All Feynman diagrams should share the same set of external and internal vertices.\n\nMembers:\n\nid::Int the unique hash id to identify the diagram\nname::Symbol name of the diagram\norders::Vector{Int} orders associated with the Feynman graph, e.g., loop/derivative orders\nproperties::FeynmanProperties diagrammatic properties, e.g., the operator vertices and topology\nsubgraphs::Vector{FeynmanGraph{F,W}} vector of sub-diagrams \nsubgraph_factors::Vector{F} scalar multiplicative factors associated with each subdiagram\noperator::DataType node operation (Sum, Prod, etc.)\nfactor::F a number representing the total scalar multiplicative factor for the diagram.\nweight::W weight of the diagram\n\nExample:\n\njulia> g1 = FeynmanGraph([]; vertices=[𝑓⁺(1),𝑓⁻(2)], external_indices=[1,2], external_legs=[true,true])\n1:f⁺(1)|f⁻(2)=0.0\n\njulia> g2 = FeynmanGraph([]; vertices=[𝑓⁺(3),𝑓⁻(4)], external_indices=[1,2], external_legs=[true,true])\n2:f⁺(3)|f⁻(4)=0.0\n\njulia> g = FeynmanGraph([g1,g2]; vertices=[𝑓⁺(1),𝑓⁻(2),𝑓⁺(3),𝑓⁻(4)], operator=ComputationalGraphs.Prod(), external_indices=[1,2,3,4], external_legs=[true,true,true,true])\n3:f⁺(1)|f⁻(2)|f⁺(3)|f⁻(4)=0.0=Ⓧ (1,2)\n\n\n\n\n\n","category":"type"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.Graph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.Graph","text":"mutable struct Graph{F<:Number,W}\n\nA representation of a computational graph, e.g., an expression tree, with type stable node data.\n\nMembers:\n\nid::Int the unique hash id to identify the diagram\nname::Symbol name of the diagram\norders::Vector{Int} orders associated with the graph, e.g., derivative orders\nsubgraphs::Vector{Graph{F,W}} vector of sub-diagrams \nsubgraph_factors::Vector{F} scalar multiplicative factors associated with each subgraph. Note that the subgraph factors may be manipulated algebraically. To associate a fixed multiplicative factor with this graph which carries some semantic meaning, use the factor argument instead.\noperator::DataType node operation. Addition and multiplication are natively supported via operators Sum and Prod, respectively. Should be a concrete subtype of AbstractOperator.\nfactor::F a number representing the total scalar multiplicative factor for the diagram.\nweight::W the weight of this node\n\nExample:\n\njulia> g1 = Graph([])\n1=0.0\n\njulia> g2 = Graph([]; factor=2)\n2⋅2.0=0.0\n\njulia> g = Graph([g1, g2]; operator=ComputationalGraphs.Sum())\n3=0.0=⨁ (1,2)\n\n\n\n\n\n","category":"type"},{"location":"lib/computgraph/#Base.:*-Union{Tuple{W}, Tuple{F}, Tuple{Any, FeynmanGraph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:*","text":"function Base.:*(c1, g2::Graph{F,W}) where {F,W}\n\nReturns a graph representing the scalar multiplication `c1*g2`.\n\nArguments:\n\nc1 scalar multiple\ng2 Feynman graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:*-Union{Tuple{W}, Tuple{F}, Tuple{Any, Graph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:*","text":"function Base.:*(c1, g2::Graph{F,W}) where {F,W}\n\nReturns a graph representing the scalar multiplication `c1*g2`.\n\nArguments:\n\nc1 scalar multiple\ng2 computational graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:*-Union{Tuple{W}, Tuple{F}, Tuple{FeynmanGraph{F, W}, Any}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:*","text":"function Base.:*(g1::Graph{F,W}, c2) where {F,W}\n\nReturns a graph representing the scalar multiplication `g1*c2`.\n\nArguments:\n\ng1 Feynman graph\nc2 scalar multiple\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:*-Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Any}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:*","text":"function Base.:*(g1::Graph{F,W}, c2) where {F,W}\n\nReturns a graph representing the scalar multiplication `g1*c2`.\n\nArguments:\n\ng1 computational graph\nc2 scalar multiple\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:*-Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Graph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:*","text":"function Base.:*(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}\n\nReturns a graph `g1 * g2` representing the graph product between `g1` and `g2`.\n\nArguments:\n\ng1 first computational graph\ng2 second computational graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:+-Union{Tuple{W}, Tuple{F}, Tuple{FeynmanGraph{F, W}, FeynmanGraph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:+","text":"function Base.:+(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}\n\nReturns a graph `g1 + g2` representing the addition of two Feynman diagrams `g2` with `g1`.\nDiagrams `g1` and `g2` must have the same diagram type, orders, and external vertices.\n\nArguments:\n\ng1 first Feynman graph\ng2 second Feynman graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:+-Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Graph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:+","text":"function Base.:+(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}\n\nReturns a graph `g1 + g2` representing the addition of `g2` with `g1`.\nGraphs `g1` and `g2` must have the same orders.\n\nArguments:\n\ng1 first computational graph\ng2 second computational graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:--Union{Tuple{W}, Tuple{F}, Tuple{FeynmanGraph{F, W}, FeynmanGraph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:-","text":"function Base.:-(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}\n\nReturns a graph `g1 - g2` representing the subtraction of `g2` from `g1`.\nDiagrams `g1` and `g2` must have the same diagram type, orders, and external vertices.\n\nArguments:\n\ng1 first Feynman graph\ng2 second Feynman graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:--Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Graph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:-","text":"function Base.:-(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}\n\nReturns a graph `g1 - g2` representing the subtraction of `g2` from `g1`.\nGraphs `g1` and `g2` must have the same orders.\n\nArguments:\n\ng1 first computational graph\ng2 second computational graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.convert-Union{Tuple{G}, Tuple{W}, Tuple{F}, Tuple{Type{G}, FeynmanGraph{F, W}}} where {F, W, G<:Graph}","page":"Computational graph for general feynman diagrams","title":"Base.convert","text":"function Base.convert(::Type{G}, g::FeynmanGraph{F,W}) where {F,W,G<:Graph}\n\nConverts a FeynmanGraph `g` into a Graph, discarding its Feynman properties.\nAfter conversion, graph `g` is no longer guaranteed to be a valid (group of) Feynman diagram(s).\n\n# Arguments:\n- `g` computational graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.show-Tuple{IO, AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"Base.show","text":"show(io::IO, graph::AbstractGraph; kwargs...)\n\nWrite a text representation of an AbstractGraph `graph` to the output stream `io`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.alleq-Tuple{Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.alleq","text":"Checks that all elements of an iterable x are equal.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.build_derivative_graph-Union{Tuple{N}, Tuple{G}, Tuple{AbstractVector{G}, Tuple{Vararg{Int64, N}}}} where {G<:Graph, N}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.build_derivative_graph","text":"function build_derivative_graph(graphs::AbstractVector{G}, orders::NTuple{N,Int};\n nodes_id=nothing) where {G<:Graph,N}\n\nConstructs a derivative graph using forward automatic differentiation with given graphs and derivative orders.\n\nArguments:\n\ngraphs: A vector of graphs.\norders::NTuple{N,Int}: A tuple indicating the orders of differentiation. N represents the number of independent variables to be differentiated.\nnodes_id: Optional node IDs to indicate saving their derivative graph.\n\nReturns:\n\nA dictionary containing the dual derivative graphs for all indicated nodes. \n\nIf isnothing(nodes_id), indicated nodes include all leaf and root nodes. Otherwise, indicated nodes include all root nodes and other nodes from nodes_id.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.burn_from_targetleaves!-Union{Tuple{G}, Tuple{AbstractVector{G}, AbstractVector{Int64}}} where G<:AbstractGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.burn_from_targetleaves!","text":"function burn_from_targetleaves!(graphs::AbstractVector{G}, targetleaves_id::AbstractVector{Int}; verbose=0) where {G <: AbstractGraph}\n\nRemoves all nodes connected to the target leaves in-place via \"Prod\" operators.\n\nArguments:\n\ngraphs: A vector of graphs.\ntargetleaves_id::AbstractVector{Int}: Vector of target leafs' id.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nThe id of a constant graph with a zero factor if any graph in graphs was completely burnt; otherwise, nothing.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.collect_labels-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.collect_labels","text":"function collect_labels(g::FeynmanGraph)\n\nReturns the list of sorted unique labels in graph `g`.\n\nArguments:\n\ng::FeynmanGraph: graph to find labels for\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.constant_graph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.constant_graph","text":"function constant_graph(factor=one(_dtype.factor))\n\nReturns a graph that represents a constant equal to f, where f is the factor with default value 1.\n\nArguments:\n\nf: constant factor\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.count_operation-Tuple{G} where G<:AbstractGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.count_operation","text":"function count_operation(g::Graph)\n\nReturns the total number of additions and multiplications in the graph.\n\nArguments:\n\ng::Graph: graph for which to find the total number of operations.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.diagram_type-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.diagram_type","text":"function diagram_type(g::FeynmanGraph)\n\nReturns the diagram type (::DiagramType) of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.drop_topology-Tuple{FeynmanProperties}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.drop_topology","text":"function drop_topology(p::FeynmanProperties)\n\nReturns a copy of the given FeynmanProperties `p` modified to have no topology.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.eldest-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.eldest","text":"function eldest(g::AbstractGraph)\n\nReturns the first child (subgraph) of a graph g.\n\nArguments:\n\ng::AbstractGraph: graph for which to find the first child\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.external_indices-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.external_indices","text":"function external_indices(g::FeynmanGraph)\n\nReturns a list of indices (::Vector{Int}}) to the external vertices of the FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.external_labels-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.external_labels","text":"function external_labels(g::FeynmanGraph)\n\nReturns the labels of all physical external vertices of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.external_legs-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.external_legs","text":"function external_legs(g::FeynmanGraph)\n\nReturns a list of Boolean indices external_legs (::Vector{Bool}) indicating which external vertices of FeynmanGraph `g` have real legs (true: real leg, false: fake leg).\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.external_operators-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.external_operators","text":"function external_operators(g::FeynmanGraph)\n\nReturns all physical external operators (::OperatorProduct}) of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.external_vertex-Tuple{OperatorProduct}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.external_vertex","text":"function external_vertex(ops::OperatorProduct;\n name=\"\", factor=one(_dtype.factor), weight=zero(_dtype.weight), operator=Sum())\nCreate a ExternalVertex-type FeynmanGraph from given OperatorProduct `ops`, including several quantum operators for an purely external vertex.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.factor-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.factor","text":"function factor(g::AbstractGraph)\n\nReturns the fixed scalar-multiplicative factor of the computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.feynman_diagram-Union{Tuple{W}, Tuple{F}, Tuple{Array{FeynmanGraph{F, W}, 1}, Vector{Vector{Int64}}}, Tuple{Array{FeynmanGraph{F, W}, 1}, Vector{Vector{Int64}}, Union{Nothing, Vector{Int64}}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.feynman_diagram","text":"function feynman_diagram(subgraphs::Vector{FeynmanGraph{F,W}}, topology::Vector{Vector{Int}}, perm_noleg::Union{Vector{Int},Nothing}=nothing;\n factor=one(_dtype.factor), weight=zero(_dtype.weight), name=\"\", diagtype::DiagramType=GenericDiag()) where {F,W}\n\nCreate a FeynmanGraph representing feynman diagram from all subgraphs and topology (connections between vertices),\nwhere each ExternalVertex is given in `vertices`, \nwhile internal vertices are constructed with external legs of graphs in `vertices`, or simply OperatorProduct in `vertices`.\n\nArguments:\n\nsubgraphs::Vector{FeynmanGraph{F,W}} all subgraphs of the diagram. All external operators of subgraphs constitute all operators of the new diagram.\ntopology::Vector{Vector{Int}} topology of the diagram. Each Vector{Int} stores operators' index connected with each other (as a propagator). \nperm_noleg::Union{Vector{Int},Nothing}=nothing permutation of all the nonleg external operators. By default, setting nothing means to use the default order from subgraphs.\nfactor::F overall scalar multiplicative factor for this diagram (e.g., permutation sign)\nweight weight of the diagram\nname name of the diagram\ndiagtype type of the diagram\n\nExample:\n\njulia> V = [𝑓⁺(1)𝑓⁻(2)𝜙(3), 𝑓⁺(4)𝑓⁻(5)𝜙(6), 𝑓⁺(7)𝑓⁻(8)𝜙(9)];\njulia> g = feynman_diagram(interaction.(V), [[1, 5], [3, 9], [4, 8]], [3, 1, 2])\n7:f⁺(1)f⁻(2)ϕ(3)|f⁺(4)f⁻(5)ϕ(6)|f⁺(7)f⁻(8)ϕ(9)=0.0=Ⓧ (1,2,3,4,5,6)\n\njulia> g.subgraphs\n6-element Vector{FeynmanGraph{Float64, Float64}}:\n 1:f⁺(1)f⁻(2)ϕ(3)=0.0\n 2:f⁺(4)f⁻(5)ϕ(6)=0.0\n 3:f⁺(7)f⁻(8)ϕ(9)=0.0\n 4:f⁺(1)|f⁻(5)⋅-1.0=0.0\n 5:ϕ(3)|ϕ(9)=0.0\n 6:f⁺(4)|f⁻(8)⋅-1.0=0.0\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.flatten_all_chains!-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.flatten_all_chains!","text":"function flatten_all_chains!(g::AbstractGraph; verbose=0)\n\nF Flattens all nodes representing trivial unary chains in-place in the given graph g. \n\nArguments:\n\ngraphs: The graph to be processed.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nThe mutated graph g with all chains flattened.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.flatten_all_chains!-Tuple{Union{Tuple, AbstractVector{<:AbstractGraph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.flatten_all_chains!","text":"function flatten_all_chains!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0)\n\nFlattens all nodes representing trivial unary chains in-place in given graphs.\n\nArguments:\n\ngraphs: A collection of graphs to be processed.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nThe mutated collection graphs with all chains in each graph flattened.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.flatten_chains!-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.flatten_chains!","text":"function flatten_chains!(g::AbstractGraph)\n\nRecursively flattens chains of subgraphs within the given graph `g` by merging certain trivial unary subgraphs \ninto their parent graphs in the in-place form.\n\nActs only on subgraphs of `g` with the following structure: 𝓞 --- 𝓞' --- ⋯ --- 𝓞'' ⋯ (!),\nwhere the stop-case (!) represents a leaf, a non-trivial unary operator 𝓞'''(g) != g, or a non-unary operation.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.flatten_chains-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.flatten_chains","text":"function flatten_chains(g::AbstractGraph) \n\nRecursively flattens chains of subgraphs within a given graph `g` by merging certain trivial unary subgraphs into their parent graphs,\nThis function returns a new graph with flatten chains, dervied from the input graph `g` remaining unchanged.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.forwardAD-Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Int64}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.forwardAD","text":"function forwardAD(diag::Graph{F,W}, ID::Int) where {F,W}\n\nGiven a graph G and an id of graph g, calculate the derivative d G / d g by forward propagation algorithm.\n\nArguments:\n\ndiag::Graph{F,W}: Graph G to be differentiated\nID::Int: ID of the graph g \n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.forwardAD_root!-Union{Tuple{AbstractVector{G}}, Tuple{N}, Tuple{G}, Tuple{AbstractVector{G}, Int64}, Tuple{AbstractVector{G}, Int64, Dict{Tuple{Int64, Tuple{Vararg{Bool, N}}}, G}}} where {G<:Graph, N}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.forwardAD_root!","text":"function forwardAD_root!(graphs::AbstractVector{G}, idx::Int=1,\n dual::Dict{Tuple{Int,NTuple{N,Bool}},G}=Dict{Tuple{Int,Tuple{Bool}},G}()) where {G<:Graph,N}\n\nComputes the forward automatic differentiation (AD) of the given graphs beginning from the roots.\n\nArguments:\n\ngraphs: A vector of graphs.\nidx: Index for differentiation (default: 1).\ndual: A dictionary that holds the result of differentiation.\n\nReturns:\n\nThe dual dictionary populated with all differentiated graphs, including the intermediate AD.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.group-Union{Tuple{G}, Tuple{AbstractVector{G}, Vector{Int64}}} where G<:FeynmanGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.group","text":"function group(gv::AbstractVector{G}, indices::Vector{Int}) where {G<:FeynmanGraph}\n\nGroup the graphs in gv by the external operators at the indices indices. Return a dictionary of Vector{OperatorProduct} to GraphVector.\n\nExample\n\njulia> p1 = propagator(𝑓⁺(1)𝑓⁻(2));\n\njulia> p2 = propagator(𝑓⁺(1)𝑓⁻(3));\n\njulia> p3 = propagator(𝑓⁺(2)𝑓⁻(3));\n\njulia> gv = [p1, p2, p3];\n\njulia> ComputationalGraphs.group(gv, [1, 2])\nDict{Vector{OperatorProduct}, Vector{FeynmanGraph{Float64, Float64}}} with 3 entries:\n [f⁻(2), f⁺(1)] => [1:f⁺(1)|f⁻(2)⋅-1.0=0.0]\n [f⁻(3), f⁺(1)] => [2:f⁺(1)|f⁻(3)⋅-1.0=0.0]\n [f⁻(3), f⁺(2)] => [3:f⁺(2)|f⁻(3)⋅-1.0=0.0]\n\njulia> ComputationalGraphs.group(gv, [1, ])\nDict{Vector{OperatorProduct}, Vector{FeynmanGraph{Float64, Float64}}} with 2 entries:\n [f⁻(3)] => [2:f⁺(1)|f⁻(3)⋅-1.0=0.0, 3:f⁺(2)|f⁻(3)⋅-1.0=0.0]\n [f⁻(2)] => [1:f⁺(1)|f⁻(2)⋅-1.0=0.0]\n\njulia> ComputationalGraphs.group(gv, [2, ])\nDict{Vector{OperatorProduct}, Vector{FeynmanGraph{Float64, Float64}}} with 2 entries:\n [f⁺(2)] => [3:f⁺(2)|f⁻(3)⋅-1.0=0.0]\n [f⁺(1)] => [1:f⁺(1)|f⁻(2)⋅-1.0=0.0, 2:f⁺(1)|f⁻(3)⋅-1.0=0.0]\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.haschildren-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.haschildren","text":"function haschildren(g::AbstractGraph)\n\nReturns whether the graph has any children (subgraphs).\n\nArguments:\n\ng::AbstractGraph: graph to be analyzed\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.id-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.id","text":"function id(g::AbstractGraph)\n\nReturns the unique hash id of computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.interaction-Tuple{OperatorProduct}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.interaction","text":"function interaction(ops::OperatorProduct; name=\"\", reorder::Union{Function,Nothing}=nothing,\n factor=one(_dtype.factor), weight=zero(_dtype.weight), operator=Sum())\nCreate a Interaction-type FeynmanGraph from given OperatorProduct `ops`, including several quantum operators for a vertex.\nOne can call a reorder function for the operators ordering.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.is_external-Tuple{FeynmanGraph, Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.is_external","text":"function isexternaloperators(g::FeynmanGraph, i) \n\nCheck if `i` in the external indices of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.is_internal-Tuple{FeynmanGraph, Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.is_internal","text":"function is_internal(g::FeynmanGraph, i) \n\nCheck if `i` in the internal indices of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.isapprox_one-Tuple{Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.isapprox_one","text":"function isapprox_one(x)\n\nReturns true if x ≈ one(x).\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.isassociative-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.isassociative","text":"function isassociative(g::AbstractGraph)\n\nReturns true if the graph operation of node `g` is associative.\nOtherwise, returns false.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.isbranch-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.isbranch","text":"function isbranch(g::AbstractGraph)\n\nReturns whether the graph g is a branch-type (depth-1 and one-child) graph.\n\nArguments:\n\ng::AbstractGraph: graph to be analyzed\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.ischain-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.ischain","text":"function ischain(g::AbstractGraph)\n\nReturns whether the graph g is a chain-type graph (i.e., a unary string).\n\nArguments:\n\ng::AbstractGraph: graph to be analyzed\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.isequiv-Tuple{AbstractGraph, AbstractGraph, Vararg{Any}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.isequiv","text":"function isequiv(a::AbstractGraph, b::AbstractGraph, args...)\n\nDetermine whether graph `a` is equivalent to graph `b` without considering fields in `args`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.isfactorless-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.isfactorless","text":"function isfactorless(g)\n\nReturns whether the graph g is factorless, i.e., has unity factor and, if applicable,\nsubgraph factor(s). Note that this function does not recurse through subgraphs of g, so \nthat one may have, e.g., `isfactorless(g) == true` but `isfactorless(eldest(g)) == false`.\n\nArguments:\n\ng::AbstractGraph: graph to be analyzed\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.isleaf-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.isleaf","text":"function isleaf(g::AbstractGraph)\n\nReturns whether the graph g is a leaf (terminating tree node).\n\nArguments:\n\ng::AbstractGraph: graph to be analyzed\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.linear_combination-Union{Tuple{Array{FeynmanGraph{F, W}, 1}}, Tuple{W}, Tuple{F}, Tuple{Array{FeynmanGraph{F, W}, 1}, AbstractVector}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.linear_combination","text":"function linear_combination(graphs::Vector{FeynmanGraph{F,W}}, constants::AbstractVector=ones(F, length(graphs))) where {F,W}\n\nGiven a vector 𝐠 of graphs each with the same type and external/internal vertices and \nan equally-sized vector 𝐜 of constants, returns a new graph representing the linear combination (𝐜 ⋅ 𝐠). \nThe function identifies unique graphs from the input `graphs` and sums their associated `constants`.\nAll input Graphs must have the same diagram type, orders, and external vertices.\n\nArguments:\n\ngraphs vector of input FeymanGraphs\nconstants vector of scalar multiples (defaults to ones(F, length(graphs))).\n\nReturns:\n\nA new FeynmanGraph{F,W} object representing the linear combination of the unique input graphs weighted by the constants, \n\nwhere duplicate graphs in the input graphs are combined by summing their associated constants. \n\nExample:\n\nGiven graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1+c3)*g1 + c2*g2`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.linear_combination-Union{Tuple{Array{Graph{F, W}, 1}}, Tuple{W}, Tuple{F}, Tuple{Array{Graph{F, W}, 1}, AbstractVector}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.linear_combination","text":"function linear_combination(graphs::Vector{Graph{F,W}}, constants::AbstractVector=ones(F, length(graphs))) where {F,W}\n\nGiven a vector 𝐠 of graphs and an equally-sized vector 𝐜 of constants, returns a new\ngraph representing the linear combination (𝐜 ⋅ 𝐠). \nThe function identifies unique graphs from the input `graphs` and sums their associated `constants`.\nAll input graphs must have the same orders.\n\nArguments:\n\ngraphs vector of computational graphs\nconstants vector of scalar multiples (defaults to ones(F, length(graphs))).\n\nReturns:\n\nA new Graph{F,W} object representing the linear combination of the unique input graphs weighted by the constants, \n\nwhere duplicate graphs in the input graphs are combined by summing their associated constants. \n\nExample:\n\nGiven graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1+c3)*g1 + c2*g2`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.linear_combination-Union{Tuple{W}, Tuple{F}, Tuple{FeynmanGraph{F, W}, FeynmanGraph{F, W}}, Tuple{FeynmanGraph{F, W}, FeynmanGraph{F, W}, Any}, Tuple{FeynmanGraph{F, W}, FeynmanGraph{F, W}, Any, Any}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.linear_combination","text":"function linear_combination(g1::FeynmanGraph{F,W}, g2::FeynmanGraph{F,W}, c1, c2) where {F,W}\n\nReturns a graph representing the linear combination `c1*g1 + c2*g2`. If `g1 == g2`, it will return a graph representing `(c1+c2)*g1`\nFeynman Graphs `g1` and `g2` must have the same diagram type, orders, and external vertices.\n\nArguments:\n\ng1 first Feynman graph\ng2 second Feynman graph\nc1: first scalar multiple (defaults to 1).\nc2: second scalar multiple (defaults to 1).\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.linear_combination-Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Graph{F, W}}, Tuple{Graph{F, W}, Graph{F, W}, Any}, Tuple{Graph{F, W}, Graph{F, W}, Any, Any}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.linear_combination","text":"function linear_combination(g1::Graph{F,W}, g2::Graph{F,W}, c1, c2) where {F,W}\n\nReturns a graph representing the linear combination `c1*g1 + c2*g2`.\nIf `g1 == g2`, it will return a graph representing `(c1+c2)*g1`.\nGraphs `g1` and `g2` must have the same orders.\n\nArguments:\n\ng1 first computational graph\ng2 second computational graph\nc1 first scalar multiple\nc2 second scalar multiple\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_all_linear_combinations!-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_all_linear_combinations!","text":"function merge_all_linear_combinations!(g::AbstractGraph; verbose=0)\n\nMerges all nodes representing a linear combination of a non-unique list of subgraphs in-place within a single graph.\n\nArguments:\n\ng: An AbstractGraph.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nOptimized graph.\n\n\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_all_linear_combinations!-Tuple{Union{Tuple, AbstractVector{<:AbstractGraph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_all_linear_combinations!","text":"function merge_all_linear_combinations!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0)\n\nMerges all nodes representing a linear combination of a non-unique list of subgraphs in-place in given graphs.\n\nArguments:\n\ngraphs: A collection of graphs to be processed.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nOptimized graphs.\n\n\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_all_multi_products!-Tuple{Graph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_all_multi_products!","text":"function merge_all_multi_products!(g::Graph; verbose=0)\n\nMerges all nodes representing a multi product of a non-unique list of subgraphs in-place within a single graph.\n\nArguments:\n\ng::Graph: A Graph.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nOptimized graph.\n\n\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_all_multi_products!-Tuple{Union{Tuple, AbstractVector{<:Graph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_all_multi_products!","text":"function merge_all_multi_products!(graphs::Union{Tuple,AbstractVector{<:Graph}}; verbose=0)\n\nMerges all nodes representing a multi product of a non-unique list of subgraphs in-place in given graphs.\n\nArguments:\n\ngraphs: A collection of graphs to be processed.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nOptimized graphs.\n\n\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_linear_combination!-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_linear_combination!","text":"function merge_linear_combination(g::AbstractGraph)\n\nModifies a computational graph `g` by factorizing multiplicative prefactors, e.g.,\n3*g1 + 5*g2 + 7*g1 + 9*g2 ↦ 10*g1 + 14*g2 = linear_combination(g1, g2, 10, 14).\nReturns a linear combination of unique subgraphs and their total prefactors. \nDoes nothing if the graph `g` does not represent a Sum operation.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_linear_combination-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_linear_combination","text":"function merge_linear_combination(g::AbstractGraph)\n\nReturns a copy of computational graph `g` with multiplicative prefactors factorized,\ne.g., 3*g1 + 5*g2 + 7*g1 + 9*g2 ↦ 10*g1 + 14*g2 = linear_combination(g1, g2, 10, 14).\nReturns a linear combination of unique subgraphs and their total prefactors. \nDoes nothing if the graph `g` does not represent a Sum operation.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_multi_product!-Union{Tuple{Graph{F, W}}, Tuple{W}, Tuple{F}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_multi_product!","text":"function merge_multi_product!(g::Graph{F,W}) where {F,W}\n\nMerge multiple products within a computational graph `g` if they share the same operator (`Prod`).\nIf `g.operator == Prod`, this function will merge `N` identical subgraphs into a single subgraph with a power operator `Power(N)`. \nThe function ensures each unique subgraph is counted and merged appropriately, preserving any distinct subgraph_factors associated with them.\n\nArguments:\n\ng::Graph: graph to be modified\n\nReturns\n\nA merged computational graph with potentially fewer subgraphs if there were repeating subgraphs with the Prod operator. If the input graph's operator isn't Prod, the function returns the input graph unchanged.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_multi_product-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_multi_product","text":"function merge_multi_product(g::Graph{F,W}) where {F,W}\n\nReturns a copy of computational graph `g` with multiple products merged if they share the same operator (`Prod`).\nIf `g.operator == Prod`, this function will merge `N` identical subgraphs into a single subgraph with a power operator `Power(N)`. \nThe function ensures each unique subgraph is counted and merged appropriately, preserving any distinct subgraph_factors associated with them.\n\nArguments:\n\ng::Graph: graph to be modified\n\nReturns\n\nA merged computational graph with potentially fewer subgraphs if there were repeating subgraphs with the Prod operator. If the input graph's operator isn't Prod, the function returns the input graph unchanged.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.multi_product-Union{Tuple{Array{Graph{F, W}, 1}}, Tuple{W}, Tuple{F}, Tuple{Array{Graph{F, W}, 1}, AbstractVector}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.multi_product","text":"multi_product(graphs::Vector{Graph{F,W}}, constants::AbstractVector=ones(F, length(graphs))) where {F,W,C}\n\nConstruct a product graph from multiple input graphs, where each graph can be weighted by a constant. \nFor graphs that are repeated more than once, it adds a power operator to the subgraph to represent the repetition.\nMoreover, it optimizes any trivial unary operators in the resulting product graph.\n\nArguments:\n\ngraphs::Vector{Graph{F,W}}: A vector of input graphs to be multiplied.\nconstants::AbstractVector: A vector of scalar multiples. If not provided, it defaults to a vector of ones of the same length as graphs.\n\nReturns:\n\nA new product graph with the unique subgraphs (or powered versions thereof) and the associated constants as subgraph factors.\n\nExample:\n\nGiven graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1*c3)*(g1)^2 * c2*g2`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.multi_product-Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Graph{F, W}}, Tuple{Graph{F, W}, Graph{F, W}, Any}, Tuple{Graph{F, W}, Graph{F, W}, Any, Any}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.multi_product","text":"function multi_product(g1::Graph{F,W}, g2::Graph{F,W}, c1=F(1), c2=F(1)) where {F,W,C}\n\nReturns a graph representing the multi product `c1*g1 * c2*g2`.\nIf `g1 == g2`, it will return a graph representing `c1*c2 * (g1)^2` with `Power(2)` operator.\n\nArguments:\n\ng1: first computational graph\ng2: second computational graph\nc1: first scalar multiple (defaults to 1).\nc2: second scalar multiple (defaults to 1).\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.name-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.name","text":"function name(g::AbstractGraph)\n\nReturns the name of computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.onechild-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.onechild","text":"function onechild(g::AbstractGraph)\n\nReturns whether the graph g has only one child (subgraph).\n\nArguments:\n\ng::AbstractGraph: graph to be analyzed\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.operator-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.operator","text":"function operator(g::AbstractGraph)\n\nReturns the operation associated with computational graph node `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.optimize!-Tuple{Union{Tuple, AbstractVector{<:AbstractGraph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.optimize!","text":"function optimize!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0, normalize=nothing)\n\nIn-place optimization of given `graphs`. Removes duplicated leaves, merges chains, and merges linear combinations.\n\nArguments:\n\ngraphs: A tuple or vector of graphs.\nverbose: Level of verbosity (default: 0).\nnormalize: Optional function to normalize the graphs (default: nothing).\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.optimize-Tuple{Union{Tuple, AbstractVector{<:AbstractGraph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.optimize","text":"function optimize(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0, normalize=nothing)\n\nOptimizes a copy of given `graphs`. Removes duplicated leaves, merges chains, and merges linear combinations.\n\nArguments:\n\ngraphs: A tuple or vector of graphs.\nverbose: Level of verbosity (default: 0).\nnormalize: Optional function to normalize the graphs (default: nothing).\n\nReturns:\n\nA tuple/vector of optimized graphs.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.orders-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.orders","text":"function orders(g::AbstractGraph)\n\nReturns the derivative orders (::Vector{Int}) of computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.plot_tree-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.plot_tree","text":"function plot_tree(graph::AbstractGraph; verbose = 0, maxdepth = 6)\n\nVisualize the computational graph as a tree using ete3 python package\n\n#Arguments\n\ngraph::AbstractGraph : the computational graph struct to visualize\nverbose=0 : the amount of information to show\nmaxdepth=6 : deepest level of the computational graph to show\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.propagator-Tuple{Union{OperatorProduct, Vector{QuantumOperator}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.propagator","text":"function propagator(ops::Union{OperatorProduct,Vector{QuantumOperator}};\n name=\"\", factor=one(_dtype.factor), weight=zero(_dtype.weight), operator=Sum())\n\nCreate a Propagator-type FeynmanGraph from given OperatorProduct or Vector{QuantumOperator} `ops`, including two quantum operators.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.relabel!-Tuple{FeynmanGraph, Dict{Int64, Int64}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.relabel!","text":"function relabel!(g::FeynmanGraph, map::Dict{Int,Int})\n\nRelabels the quantum operators in `g` and its subgraphs according to `map`.\nFor example, `map = {1=>2, 3=>2}`` will find all quantum operators with labels 1 and 3, and then map them to 2.\n\nArguments:\n\ng::FeynmanGraph: graph to be modified\nmap: mapping from old labels to the new ones\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.relabel-Tuple{FeynmanGraph, Dict{Int64, Int64}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.relabel","text":"function relabel(g::FeynmanGraph, map::Dict{Int,Int})\n\nReturns a copy of `g` with quantum operators in `g` and its subgraphs relabeled according to `map`.\nFor example, `map = {1=>2, 3=>2}` will find all quantum operators with labels 1 and 3, and then map them to 2.\n\nArguments:\n\ng::FeynmanGraph: graph to be modified\nmap: mapping from old labels to the new ones\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.remove_duplicated_leaves!-Tuple{Union{Tuple, AbstractVector{<:AbstractGraph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.remove_duplicated_leaves!","text":"function remove_duplicated_leaves!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0, normalize=nothing, kwargs...)\n\nRemoves duplicated leaf nodes in-place from a collection of graphs. It also provides optional normalization for these leaves.\n\nArguments:\n\ngraphs: A collection of graphs to be processed.\nverbose: Level of verbosity (default: 0).\nnormalize: Optional function to normalize the graphs (default: nothing).\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.replace_subgraph!-Tuple{AbstractGraph, AbstractGraph, AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.replace_subgraph!","text":"function replace_subgraph!(g::AbstractGraph, w::AbstractGraph, m::AbstractGraph)\n\nModifies `g` by replacing the subgraph `w` with a new graph `m`.\nFor Feynman diagrams, subgraphs `w` and `m` should have the same diagram type, orders, and external indices.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\nw::AbstractGraph: subgraph to replace\nm::AbstractGraph: new subgraph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.replace_subgraph-Tuple{AbstractGraph, AbstractGraph, AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.replace_subgraph","text":"function replace_subgraph(g::AbstractGraph, w::AbstractGraph, m::AbstractGraph)\n\nCreates a modified copy of `g` by replacing the subgraph `w` with a new graph `m`.\nFor Feynman diagrams, subgraphs `w` and `m` should have the same diagram type, orders, and external indices.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\nw::AbstractGraph: subgraph to replace\nm::AbstractGraph: new subgraph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_factor!-Tuple{AbstractGraph, Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_factor!","text":"function set_factor!(g::AbstractGraph, factor)\n\nUpdate the factor of graph `g` to `factor`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_id!-Tuple{AbstractGraph, Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_id!","text":"function set_id!(g::AbstractGraph, id)\n\nUpdate the id of graph `g` to `id`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_name!-Tuple{AbstractGraph, AbstractString}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_name!","text":"function set_name!(g::AbstractGraph, name::AbstractString)\n\nUpdate the name of graph `g` to `name`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_operator!-Tuple{AbstractGraph, AbstractOperator}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_operator!","text":"function set_operator!(g::AbstractGraph, operator::AbstractOperator)\n\nUpdate the operator of graph `g` to `typeof(operator)`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_operator!-Tuple{AbstractGraph, Type{<:AbstractOperator}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_operator!","text":"function set_operator!(g::AbstractGraph, operator::Type{<:AbstractOperator})\n\nUpdate the operator of graph `g` to `operator`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_orders!-Tuple{AbstractGraph, AbstractVector}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_orders!","text":"function set_orders!(g::AbstractGraph, orders::AbstractVector)\n\nUpdate the orders of graph `g` to `orders`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_subgraph!","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_subgraph!","text":"function set_subgraph!(g::AbstractGraph, subgraph::AbstractGraph, i=1)\n\nUpdate the `i`th subgraph of graph `g` to `subgraph`.\nDefaults to the first subgraph factor if an index `i` is not supplied.\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_subgraph_factor!","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_subgraph_factor!","text":"function setsubgraphfactor!(g::AbstractGraph, subgraph_factor, i=1)\n\nUpdate the `i`th subgraph factor of graph `g` to `subgraph_factor`.\nDefaults to the first subgraph factor if an index `i` is not supplied.\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_subgraph_factors!-Tuple{AbstractGraph, AbstractVector, AbstractVector{Int64}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_subgraph_factors!","text":"function setsubgraphfactors!(g::AbstractGraph, subgraph_factors::AbstractVector, indices::AbstractVector{Int})\n\nUpdate the specified subgraph factors of graph `g` at indices `indices` to `subgraph_factors`.\nBy default, calls `set_subgraph_factor!(g, subgraph_factors[i], i)` for each `i` in `indices`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_subgraph_factors!-Tuple{AbstractGraph, AbstractVector}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_subgraph_factors!","text":"function setsubgraphfactors!(g::AbstractGraph, subgraph_factors::AbstractVector)\n\nUpdate the subgraph factors of graph `g` to `subgraphs`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_subgraphs!-Tuple{AbstractGraph, AbstractVector{<:AbstractGraph}, AbstractVector{Int64}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_subgraphs!","text":"function set_subgraphs!(g::AbstractGraph, subgraphs::AbstractVector{<:AbstractGraph}, indices::AbstractVector{Int})\n\nUpdate the specified subgraphs of graph `g` at indices `indices` to `subgraphs`.\nBy default, calls `set_subgraph!(g, subgraphs[i], i)` for each `i` in `indices`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_subgraphs!-Tuple{AbstractGraph, AbstractVector{<:AbstractGraph}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_subgraphs!","text":"function set_subgraphs!(g::AbstractGraph, subgraphs::AbstractVector{<:AbstractGraph})\n\nUpdate the full list of subgraphs of graph `g` to `subgraphs`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_weight!-Tuple{AbstractGraph, Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_weight!","text":"function set_weight!(g::AbstractGraph, weight)\n\nUpdate the weight of graph `g` to `weight`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.standardize_labels!-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.standardize_labels!","text":"function standardize_labels!(g::FeynmanGraph)\n\nFinds all labels involved in `g` and its subgraphs and \nmodifies `g` by relabeling in standardized order, e.g.,\n(1, 4, 5, 7, ...) ↦ (1, 2, 3, 4, ....)\n\nArguments:\n\ng::FeynmanGraph: graph to be relabeled\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.standardize_labels-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.standardize_labels","text":"function standardize_labels!(g::FeynmanGraph)\n\nFinds all labels involved in `g` and its subgraphs and returns \na copy of `g` relabeled in a standardized order, e.g.,\n(1, 4, 5, 7, ...) ↦ (1, 2, 3, 4, ....)\n\nArguments:\n\ng::FeynmanGraph: graph to be relabeled\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.subgraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.subgraph","text":"function subgraph(g::AbstractGraph, i=1)\n\nReturns a copy of the `i`th subgraph of computational graph `g`.\nDefaults to the first subgraph if an index `i` is not supplied.\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.subgraph_factor","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.subgraph_factor","text":"function subgraph_factor(g::AbstractGraph, i=1)\n\nReturns a copy of the `i`th subgraph factor of computational graph `g`.\nDefaults to the first subgraph factor if an index `i` is not supplied.\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.subgraph_factors-Tuple{AbstractGraph, AbstractVector{Int64}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.subgraph_factors","text":"function subgraph_factors(g::AbstractGraph, indices::AbstractVector{Int})\n\nReturns the subgraph factors of computational graph `g` at indices `indices`.\nBy default, calls `subgraph_factor(g, i)` for each `i` in `indices`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.subgraph_factors-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.subgraph_factors","text":"function subgraph_factors(g::AbstractGraph)\n\nReturns the subgraph factors of computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.subgraphs-Tuple{AbstractGraph, AbstractVector{Int64}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.subgraphs","text":"function subgraphs(g::AbstractGraph, indices::AbstractVector{Int})\n\nReturns the subgraphs of computational graph `g` at indices `indices`.\nBy default, calls `subgraph(g, i)` for each `i` in `indices`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.subgraphs-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.subgraphs","text":"function subgraphs(g::AbstractGraph)\n\nReturns the subgraphs of computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.topology-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.topology","text":"function topology(g::FeynmanGraph)\n\nReturns the topology (::Vector{Vector{Int}}) of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.unary_istrivial-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.unary_istrivial","text":"function unary_istrivial(g::AbstractGraph)\n\nReturns true if the unary form of the graph operation of node `g` is trivial.\nOtherwise, returns false.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.unique_leaves-Tuple{AbstractVector{<:AbstractGraph}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.unique_leaves","text":"function unique_leaves(graphs::AbstractVector{<:AbstractGraph})\n\nIdentifies and retrieves unique leaf nodes from a set of graphs.\n\nArguments:\n\ngraphs: A collection of graphs to be processed.\n\nReturns:\n\nA mapping dictionary from the id of each leaf to the unique leaf node.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.vertex","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.vertex","text":"function vertex(g::FeynmanGraph, i=1)\n\nReturns the `i`th vertex (::OperatorProduct) of FeynmanGraph `g`.\nDefaults to the first vertex if an index `i` is not supplied.\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.vertices-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.vertices","text":"function vertices(g::FeynmanGraph)\n\nReturns all vertices (::Vector{OperatorProduct}) of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.weight-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.weight","text":"function weight(g::AbstractGraph)\n\nReturns the weight of the computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"manual/interaction/#Interaction/Scattering-Amplitude-Convention","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"","category":"section"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"In general, the interaction (or scattering amplitude) between two spin-12 particles only has two independent spin components. Here we briefly review some of the common conventions of the spin components in literature, and show how to map between different conventions.","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"We assume a particle from the left collides with a particle from the right. Due to the interaction between the two particles, one of them scatters to the left, and the other to the right. ","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"We will use the index alphabetagammadelta to label the left incoming, the left outgoing, the right incoming and the right outgoing particles. We assume four legs associate with four momentum-frequency vectors k_1 k_2 k_3 k_4.","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"There are two possible scatterings: a direct scattering where the two particles don't permutate after the collision, and an exchange scattering where the two particles permutate. Therefore, the total scattering amplitude has two contributions,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v_alphabetagammadelta(1234) = v^d_alphabetagammadelta(1234)+v^e_alphabetagammadelta(1234)","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"where the exchange contribution is different from the direct counterpart up to an exchange of two outgoing legs and an overall particle statistic sign xi =pm 1,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^e_alphabetagammadelta(1234) = xi v^d_alphadeltagammabeta(1432)","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"where we have abbreviated the momentum-frequency vectors as indices.","category":"page"},{"location":"manual/interaction/#.-Spin-symmetric-and-asymmetric-convention:","page":"Interaction/Scattering-Amplitude Convention","title":"1. Spin symmetric and asymmetric convention:","text":"","category":"section"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"A interaction is split into a term that is independent of the spin (e.g., Coulomb interaction between electrons) and a term with spin dependence (e.g., ferromagnetic/antiferromagnetic interaction). This convention is commonly used in textbooks of Fermi liquid theory.","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^d_alphabetagammadelta(1234) equiv v^s_1234delta_alphabetadelta_gammadelta + v^a_1234 vecsigma_alphabetacdot vecsigma_gammadelta","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"where the superscript d means the scattering is direct.","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"If two particles permute after the collision, then one needs to exchange beta leftrightarrow gamma and other internal variables,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^e_alphabetagammadelta(1234) = xi v^s_1432delta_alphadeltadelta_gammabeta + xi v^a_1432 vecsigma_alphadeltacdot vecsigma_gammabeta","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^e_alphabetagammadelta(1234) = xifracv^s_1432+3v^a_14322delta_alphabetadelta_gammadelta + xi fracv^s_1432-v^a_14322 vecsigma_alphabetacdot vecsigma_gammadelta","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"To derive the above equations, we use the identity vecsigma_alphabetacdot vecsigma_gammadelta=2 delta_alpha delta delta_beta gamma-delta_alpha beta delta_gamma delta, which gives the following equations,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"delta_alphadeltadelta_gammabeta=frac12delta_alphabetadelta_gammadelta+frac12vecsigma_alphabetacdot vecsigma_gammadelta","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"and,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"vecsigma_alphadeltacdot vecsigma_gammabeta=frac32delta_alphabetadelta_gammadelta-frac12vecsigma_alphabetacdot vecsigma_gammadelta","category":"page"},{"location":"manual/interaction/#.-Spin-\\uparrow\\uparrow-and-\\uparrow\\downarrow-convention:","page":"Interaction/Scattering-Amplitude Convention","title":"2. Spin uparrowuparrow and uparrowdownarrow convention:","text":"","category":"section"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"An alternative parameterization of the interaction matrix is by specifiying the spin components v_uparrowuparrow equiv v_uparrowuparrowuparrowuparrow and v_uparrowdownarrow equiv v_uparrowuparrowdownarrowdownarrow. They can be derived from v_s and v_a by the simple relation,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^d_uparrowuparrow(1234) = v^s_1234+v^a_1234","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^d_uparrowdownarrow(1234) = v^s_1234-v^a_1234","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"If two particles permute after the collision, the exchange interaction v^e,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^e_uparrowuparrow(1234) = xifracv^s_1432+3v^a_14322+xifracv^s_1432-v^s_14322 = xi v^s_1432+ xi v^a_1432","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^e_uparrowdownarrow(1234) = xifracv^s_1432+3v^a_14322-xifracv^s_1432-v^s_14322 = 2 xi v^a_1432","category":"page"},{"location":"manual/feynman_rule/#Feynman-Rules","page":"Feynman Rules","title":"Feynman Rules","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"In general, we follow the convention in the textbook \"Quantum Many-particle Systems\" by J. Negele and H. Orland, Page 95,","category":"page"},{"location":"manual/feynman_rule/#Fourier-Transform","page":"Feynman Rules","title":"Fourier Transform","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"G(tau) = frac1beta sum_n G(iomega_n) texte^-iomega_n tau","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"G(iomega_n) = int_0^beta G(tau) texte^iomega_n tau dtau","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where the Matsubara-frequency omega_n=2pi nbeta for boson and omega_n = 2pi (n+1)beta for fermion.","category":"page"},{"location":"manual/feynman_rule/#Action-and-Partition-Sum","page":"Feynman Rules","title":"Action and Partition Sum","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The partition sum associates with a generic action,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"Z = int mathcalDbarpsimathcalDpsi expleft(-Sright)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where the action takes a generic form,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"S = barpsi_1left(fracpartialpartial tau +epsilon_k right)psi_1 + V_1234barpsi_1barpsi_2psi_3psi_4","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where barpsi and psi are Grassman fields.","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"In the Matsubara-frequency domain, the action is,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"S = barpsi_1left(-iomega_n +epsilon_k right)psi_1 + V_1234barpsi_1barpsi_2psi_3psi_4","category":"page"},{"location":"manual/feynman_rule/#Bare-Propagator","page":"Feynman Rules","title":"Bare Propagator","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"Imaginary time","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"g(tau k) = leftmathcalT psi(k tau) barpsi(k 0) right_0= frace^-epsilon_k tau1+e^-epsilon_k betatheta(tau)+xi frace^-epsilon_k (beta+tau)1+e^-epsilon_k betatheta(-tau)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where xi is +1 for boson and -1 for fermion.","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"Matusbara frequency","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"g(iomega_n k) = -frac1iomega_n-epsilon_k","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"Then the action takes a simple form,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"S = barpsi_1g_12^-1psi_2 + V_1234barpsi_1barpsi_2psi_3psi_4","category":"page"},{"location":"manual/feynman_rule/#Dressed-Propagator-and-Self-energy","page":"Feynman Rules","title":"Dressed Propagator and Self-energy","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The dressed propagator is given by,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"G(tau k) = leftmathcalT psi(k tau) barpsi(k 0) right","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"and we define the self-energy Sigma as the one-particle irreducible vertex function,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"G^-1 = g^-1 + Sigma","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"so that","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"G = g - gSigma g + gSigma g Sigma g - ","category":"page"},{"location":"manual/feynman_rule/#Perturbative-Expansion-of-the-Green's-Function","page":"Feynman Rules","title":"Perturbative Expansion of the Green's Function","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"(Image: Sign rule for the Wick contractions.)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"(Image: Diagrammatic expansion of the Green's function.)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The sign of a Green's function diagram is given by (-1)^n_v xi^n_F, where","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"n_v is the number of interactions.\nn_F is the number of the fermionic loops.","category":"page"},{"location":"manual/feynman_rule/#Feynman-Rules-for-the-Self-energy","page":"Feynman Rules","title":"Feynman Rules for the Self-energy","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"From the Green's function diagrams, one can derive the negative self-energy diagram,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"(Image: Diagrammatic expansion of the self-energy.)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"beginaligned\n-Sigma = (-1) xi V_34 g_44+(-1) V_34 g_34 \n+(-1)^2 xi V_34 V_56 g_46 g_64 g_43+(-1)^2 V_34 V_56 g_35 g_54 g_42+cdots\nendaligned","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The sign of a negative self-energy -Sigma diagram is given by (-1)^n_v xi^n_F, where","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"n_v is the number of interactions.\nn_F is the number of the fermionic loops.","category":"page"},{"location":"manual/feynman_rule/#Feynman-Rules-for-the-3-point-Vertex-Function","page":"Feynman Rules","title":"Feynman Rules for the 3-point Vertex Function","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The self-energy is related to the 3-point vertex function through an equation,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"-left(Sigma_3 x -Sigma^Hartree_3 xright) = G_3y cdot left(-V_3 4right) cdot Gamma^3_4yx","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where the indices x y could be different from diagrams to diagrams, and Gamma_3 is the inproper three-vertex function. Eliminate the additional sign, one derives,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"Sigma_3 x -Sigma^Hartree_3 x = G_3y cdot V_3 4 cdot Gamma^3_4yx","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"(Image: Diagrammatic expansion of the 3-point vertex function.)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The diagram weights are given by,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"beginaligned\nGamma^(3)= 1 + (-1) xi V_56 g_46 g_64 + (-1) V_56 g_54 g_46\n+(-1)^2 xi^2 V_56 V_78 g_46 g_64 g_58 g_85+(-1)^2xi V_56 V_78 g_74 g_46+cdots\nendaligned","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The sign of Gamma^(3) diagram is given by (-1)^n_v xi^n_F.","category":"page"},{"location":"manual/feynman_rule/#Feynman-Rules-for-the-4-point-Vertex-Function","page":"Feynman Rules","title":"Feynman Rules for the 4-point Vertex Function","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The 4-point vertex function is related to the 3-point vertex function through an equation,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"Gamma^(3)_4yx = xi cdot G_4s cdot G_t 4 cdot Gamma^(4)_s t y x","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where the indices x y s t could be different from diagrams to diagrams.","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"(Image: Diagrammatic expansion of the 4-point vertex function.)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The diagram weights are given by,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"beginaligned\nGamma^(4)= (-1) V_56^textdirect + (-1)xi V_56^exchange\n+(-1)^2 xi V_56 V_78 g_58 g_85+(-1)^2 V_56 V_78+cdots\nendaligned","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where we used the identity xi^2 = 1.","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The sign of Gamma^(4) diagram is given by (-1)^n_v xi^n_F multiplied with a sign from the permutation of the external legs.","category":"page"},{"location":"manual/feynman_rule/#Feynman-Rules-for-the-Susceptibility","page":"Feynman Rules","title":"Feynman Rules for the Susceptibility","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The susceptibility can be derived from Gamma^(4).","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"chi_12 equiv leftmathcalT n_1 n_2right_textconnected = xi G_12 G_2 1 + xi G_1s G_t 1 Gamma^(4)_s t y x G_2y G_x 2","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"(Image: Diagrammatic expansion of the susceptibility.)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"We define the polarization P as the one-interaction irreducible (or proper) vertex function,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"chi^-1 = P^-1 + V","category":"page"},{"location":"manual/hubbard_atom/#Hubbard-Atom-as-a-Test-Case","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"","category":"section"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"One may use the Hubbard atom model to benchmark the Feynman diagrams generated by FeynmanDiagram.jl. In this note, we derive the vertex functions and their power expansion in interaction. The test is implemented in the test folder.","category":"page"},{"location":"manual/hubbard_atom/#Hamiltonian","page":"Hubbard Atom as a Test Case","title":"1 Hamiltonian","text":"","category":"section"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"hatH=U n_uparrow n_downarrow-mu (n_uparrow+n_downarrow)","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"where U is the on-site interaction, mu is the chemical potential.","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"The eigenstates are,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"left 0 right\n: E_0=0.\nleft uparrow right\nand left downarrow right : E_1=-mu.\nleft uparrow downarrow right\n: E_2=U-2mu.","category":"page"},{"location":"manual/hubbard_atom/#Partition-sum","page":"Hubbard Atom as a Test Case","title":"2 Partition sum","text":"","category":"section"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"Z=1+2e^mubeta+e^-beta(U-2mu)","category":"page"},{"location":"manual/hubbard_atom/#Two-point-Green's-function","page":"Hubbard Atom as a Test Case","title":"3 Two-point Green's function","text":"","category":"section"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"For the imaginary-time tau0,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"G(tau)=lefttextT c_uparrow(tau) c^+_uparrow(0) right=frac1Zsum_n left nrighte^-(beta-tau)Hc_uparrow e^-tau H c^+_uparrow left n right","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"Only the states left 0 right and left downarrow right contribute,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"G(tau)=frace^mu tau+e^mu betae^-(U-mu)tauZ","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"For example, at half filling mu=U2, there is one particle and,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"G(tau)=frace^-Utau2+e^-U(beta-tau)22(1+e^-Ubeta2)","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"Transform to the Matsubara frequency,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"G(iomega_n) = int_0^beta G(tau)e^iomega_ntau dtau","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"G(iomega_n)=-frac1Zleft(frac1+e^mu betaiomega_n+mu+e^mubetafrac1+e^-(U-mu)betaiomega_n-(U-mu)right)","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"By setting U=0, one can show that the above dressed Green's function reduce to the bare one,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"g(iomega_n) = -frac1iomega_n+mu","category":"page"},{"location":"manual/hubbard_atom/#Self-energy","page":"Hubbard Atom as a Test Case","title":"4 Self-energy","text":"","category":"section"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"The self-energy is defined as G^-1(iomega_n)=g^-1(iomega_n)-Sigma(iomega_n), so that","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"Sigma(iomega_n) = fracU e^beta mu (mu +i w) left(e^beta mu +e^beta Uright)e^beta U (-mu +U-i w)+e^beta (mu +U) (-2 mu +U-2 i w)-e^2 beta mu (mu +i w)","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"For benchmark purpose, here we also provide the power expansion of the self-energy at the low-energy limit omega_0 = pi beta with mu=0,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"Sigma(iomega_0) = -fracU2+frac(pi +2 i) beta U^28 pi -fracleft(pi ^2-4right) beta ^2 U^332 pi ^2-fracleft(24 i-12 pi +6 i pi ^2+pi ^3right) beta ^3 U^4384 pi ^3+fracleft(-48-48 i pi -24 pi ^2+12 i pi ^3+5 pi ^4right) beta ^4 U^51536 pi ^4+Oleft(U^6right)","category":"page"},{"location":"","page":"Home","title":"Home","text":"CurrentModule = FeynmanDiagram","category":"page"},{"location":"#FeynmanDiagram","page":"Home","title":"FeynmanDiagram","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Documentation for FeynmanDiagram.","category":"page"},{"location":"","page":"Home","title":"Home","text":"","category":"page"},{"location":"","page":"Home","title":"Home","text":"Modules = [FeynmanDiagram]","category":"page"},{"location":"#FeynmanDiagram.innerTauNum-NTuple{4, Any}","page":"Home","title":"FeynmanDiagram.innerTauNum","text":"function innerTauNum(type, innerLoopNum, interactionTauNum)\n\ninternal imaginary-time degrees of freedom for a given diagram type and internal loop number.\nFor the vertex functions (self-energy, polarization, vertex3, and vertex4), innerTauNum is equivalent to tauNum.\nFor the Green function, tauNum = innerTauNum + external tauNum\n\n\n\n\n\n","category":"method"},{"location":"#FeynmanDiagram.innerTauNum-Tuple{FeynmanDiagram.DiagramType, Any, Any}","page":"Home","title":"FeynmanDiagram.innerTauNum","text":"function innerTauNum(type::DiagramType, innerLoopNum, interactionTauNum)\n\ninternal imaginary-time degrees of freedom for a given diagram type and internal loop number.\nFor the vertex functions (self-energy, polarization, vertex3, and vertex4), innerTauNum is equivalent to tauNum.\nFor the Green function, tauNum = innerTauNum + external tauNum\n\n\n\n\n\n","category":"method"},{"location":"#Parameters.reconstruct-Union{Tuple{W}, Tuple{Type{DiagPara{W}}, DiagPara{W}, Any}} where W","page":"Home","title":"Parameters.reconstruct","text":"Parameters.reconstruct(p::DiagPara; kws...)\n\nType-stable version of the Parameters.reconstruct\n\n\n\n\n\n","category":"method"},{"location":"#Parameters.reconstruct-Union{Tuple{W}, Tuple{Type{DiagramPara{W}}, DiagramPara{W}, Any}} where W","page":"Home","title":"Parameters.reconstruct","text":"Parameters.reconstruct(p::DiagramPara; kws...)\n\nType-stable version of the Parameters.reconstruct\n\n\n\n\n\n","category":"method"},{"location":"#Library-Outline","page":"Home","title":"Library Outline","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Pages = [\n \"lib/operator.md\",\n \"lib/computgraph.md\",\n \"lib/frontend.md\",\n \"lib/GV.md\",\n \"lib/parquet.md\",\n \"lib/diagtree.md\",\n \"lib/exprtree.md\",\n]\nDepth = 2","category":"page"},{"location":"manual/counterterms/#Evaluation-of-counterterms","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"","category":"section"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"For illustrative simplicity, let us consider the renormalization of the chemical potential and Yukawa effective mass in the uniform electron gas (UEG). Following the Negele & Orland conventions, the non-interacting Green's function g is given by","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" g(mathbfk iomega_n) = -frac1iomega_n-epsilon_mathbfk + mu","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"where G is the bold Green's function, omega_n = 2pi (n+1)beta is a fermionic Matsubara frequency, and mu is the exact chemical potential derived from the interacting density n. The 1PI self-energy Sigma is then defined through the following Dyson equation:","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" G^-1 = g^-1 + Sigma implies G = g - gSigma g + gSigma g Sigma g - ","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"Following the variational diagrammatic Monte-Carlo (VDMC) approach, we rewrite the bare Green's function g in terms of a renormalized propagator g_R, writing","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" g(mathbfk iomega_n) = -frac1iomega_n-epsilon_mathbfk + mu_R + deltamu","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"where, motivated by Luttinger's theorem, the renormalized chemical potential mu_R = mu - deltamu equiv epsilon_F = k^2_F 2 m is chosen so as to preserve the non-interacting Fermi surface, whereas lambda is taken as a fixed, non-zero constant.","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"Similarly, the Coulomb interaction is re-written as","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" V(q) = frace^2epsilon_0 q^2 = frace^2epsilon_0 frac1q^2 + lambda + deltalambda","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"We then work perturbatively in terms of the following renormalized Green's function and interaction,","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"beginaligned\n g_R(k iomega_n) equiv -frac1iomega_n-epsilon_k + mu_R = g(k iomega_n) Big_deltamu = 02ex\n V_lambda(q) equiv frace^2epsilon_0 frac1q^2 + lambda = V(q) Big_deltalambda = 0\nendaligned","category":"page"},{"location":"manual/counterterms/#New-approach-to-counterterm-evaluation","page":"Evaluation of counterterms","title":"New approach to counterterm evaluation","text":"","category":"section"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"In the NEFT codebase, the counterterms are generated by directly differentiating diagrams in the perturbative series for a given observable, which allows for a flexible and generic reformulation of the VDMC algorithm. This is made possible by representing all diagrams by differentiable expression trees. In contrast, in the original VDMC approach one first Taylor expands all propagators gg_R and VV_lambda entering a given observable by hand and collects terms in orders of xi manually prior to integration.","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"The mathcalO(xi^N) counterterms in RPT with n and m chemical potential / interaction derivatives are given by","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" (deltamu)^n (deltalambda)^m times frac1n mpartial^n_mu partial^m_lambda D_N - n - m","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"where D is the sum of all Feynman diagrams at the appropriate loop order N - n - m. The renormalization is performed in post-processing by multiplying with the Taylor series for (deltamu)^n (deltalambda)^m in xi and collecting terms propto xi^N. The chemical potential shift delta mu_n is derived from a separate MC simulation of Sigma^lambda_R_F(k_F ik_0).","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"To demonstrate that the two approaches outlined above are equivalent, it is sufficient to consider separately the cases of V and g raised to an arbitrary power in the Matsubara representation; we will omit the coordinates for brevity.","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"First, consider the chemical potential counterterms. Let deltamu equiv mu_0 - mu_R. Taylor expanding gg_R about deltamu = 0, we have","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" g = fracg_R1 - g_Rdeltamu = g_Rsum^infty_n=0 (g_Rdeltamu)^n = sum^infty_n=0 frac(deltamu)^nn partial^n_mu g_R","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"since","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" g^n+1_R = frac1n partial^n_mu g_R","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"Then,","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"beginaligned\n g^m = left(sum^infty_n=0 frac(deltamu)^nn partial^n_mu g_Rright)^m = g^m_Rleft(1 - g_Rdeltamuright)^-m = g^m_R sum^infty_n=0 binomm+n-1n (g_Rdeltamu)^n\n = sum^infty_n=0 (deltamu)^n frac(m+n-1)n (m-1) g^m+n_R = sum^infty_n=0 frac(deltamu)^nn (m-1) partial^m+n-1_mu g_R = sum^infty_n=0 frac(deltamu)^nn partial^n_mu g^m_R\nendaligned","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"where in the last step, we replaced","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"beginaligned\n frac1(m-1) partial^m-1_mu g_R = g^m_R\nendaligned","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"Thus, the series for g^m may be represented either by expanding each gg_R by hand and collecting terms, or by a direct Taylor expansion of g^m about deltamu = 0.","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"It remains to show that these two strategies are also equivalent for the expansion of V^m. Let deltalambda equiv lambda_0 - lambda_R = -lambda_R and Taylor expand VV_lambda about deltalambda = 0—we obtain","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"\n V = fracV_ lambda1 - fraclambdaq^2 + lambda = V_lambda sum_n=0^infty left(fraclambdaq^2 + lambdaright)^n = V_lambda sum_n=0^infty left(V_lambda deltalambdaright)^n = sum^infty_n=0 frac(-lambda)^nn partial^n_lambda V_lambda\n","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" V = fracV_ lambda1 - delta_lambda = V_lambda sum_n=0^infty delta^n_lambda = sum^infty_n=0 frac(deltalambda)^nn partial^n_lambda V_lambda","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"where","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" delta_lambda equiv fraclambdaq^2 + lambda","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"since","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"beginaligned\n frac(deltalambda)^nn partial^n_lambda V_lambda = 8pifrac(-lambda)^nn partial^n_lambda left(frac1q^2 + lambdaright) = frac8pilambda^n(q^2 + lambda)^n+1 = V_lambda delta^n_lambda\nendaligned","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"We also have that","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"beginaligned\n frac(deltalambda)^nn partial^n_lambda V^m_lambda = left(fraclambda8piright)^n fracm^(n)n V^m+n_lambda = binomm + n - 1n V^m_lambda delta^n_lambda\nendaligned","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"where m^(n) = prod_i=0^n-1 (m + i) is a rising factorial and","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" binomm + n - 1n = frac(m + n - 1)n (m-1) = fracm^(n)n","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"Thus,","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"beginaligned\n V^m = left(sum^infty_n=0 frac(deltalambda)^nn partial^n_lambda V_lambdaright)^m = V^m_lambda left(1 - delta_lambdaright)^-m = sum^infty_n=0 binomm+n-1n V^m_lambda delta^n_lambda = sum^infty_n=0 frac(deltalambda)^nn partial^n_lambda V^m_lambda\nendaligned","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"Since the order of differentiation w.r.t. mu and lambda does not matter, it follows that a general diagram mathcalDg V sim g^n V^m may be represented either by pre-expanding gg_mu and VV_lambda and collecting terms, or by directly evaluating terms in the Taylor series for mathcalDg_mu V_lambda; this codebase uses the latter approach.","category":"page"},{"location":"manual/counterterms/#Evaluation-of-interaction-counterterms","page":"Evaluation of counterterms","title":"Evaluation of interaction counterterms","text":"","category":"section"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"An example of the interaction counterterm evaluation for a diagram with n_lambda = 3 and m interaction lines. Since the Julia implementation evaluates the interaction counterterms of a given diagram as frac(-lambda)^nnpartial^n_lambda V^m_lambda, we pick up an extra factor of l on each lth-order derivative in the chain rule.","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"(Image: An example of the representation of interaction counterterm diagrams via differentiation.)","category":"page"},{"location":"manual/counterterms/#Benchmark-of-counterterms-in-the-UEG","page":"Evaluation of counterterms","title":"Benchmark of counterterms in the UEG","text":"","category":"section"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"As a concrete example, we have evaluated the individual diagrams and associated counterterms entering the RPT series for the total density ng_mu V_lambda in units of the non-interacting density n_0. The diagrams/counterterms are denoted by partitions mathcalP equiv (n_textloop n_mu n_lambda) indicating the total loop order and number of mu and lambda derivatives.","category":"page"},{"location":"manual/counterterms/#D-UEG","page":"Evaluation of counterterms","title":"3D UEG","text":"","category":"section"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"For this benchmark, we take r_s = 1, beta = 40 epsilon_F, and lambda = 06. All partitions contributing up to 4th order are included, as well as some selected partitions at 5th and 6th order.","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"(n_textloop n_lambda n_mu) n n_0\n(1, 0, 1) 0.40814(16)\n(1, 0, 2) 0.02778(21)\n(1, 0, 3) -0.00096(60)\n(2, 0, 0) 0.28853(12)\n(2, 1, 0) 0.07225(3)\n(2, 2, 0) 0.02965(2)\n(2, 0, 1) 0.09774(30)\n(2, 1, 1) 0.01594(10)\n(2, 0, 2) 0.00240(130)\n(3, 0, 0) 0.10027(37)\n(3, 1, 0) 0.04251(21)\n(3, 0, 1) 0.02600(150)\n(4, 0, 0) 0.00320(130)\n(2, 1, 2) -0.00111(18)\n(2, 0, 3) -0.00430(150)\n(3, 2, 0) 0.02241(8)\n(3, 3, 0) 0.01429(7)","category":"page"}]
+[{"location":"manual/counterterms/#Evaluation-of-counterterms","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"","category":"section"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"For illustrative simplicity, let us consider the renormalization of the chemical potential and Yukawa effective mass in the uniform electron gas (UEG). Following the Negele & Orland conventions, the non-interacting Green's function g is given by","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" g(mathbfk iomega_n) = -frac1iomega_n-epsilon_mathbfk + mu","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"where G is the bold Green's function, omega_n = 2pi (n+1)beta is a fermionic Matsubara frequency, and mu is the exact chemical potential derived from the interacting density n. The 1PI self-energy Sigma is then defined through the following Dyson equation:","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" G^-1 = g^-1 + Sigma implies G = g - gSigma g + gSigma g Sigma g - ","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"Following the variational diagrammatic Monte-Carlo (VDMC) approach, we rewrite the bare Green's function g in terms of a renormalized propagator g_R, writing","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" g(mathbfk iomega_n) = -frac1iomega_n-epsilon_mathbfk + mu_R + deltamu","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"where, motivated by Luttinger's theorem, the renormalized chemical potential mu_R = mu - deltamu equiv epsilon_F = k^2_F 2 m is chosen so as to preserve the non-interacting Fermi surface, whereas lambda is taken as a fixed, non-zero constant.","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"Similarly, the Coulomb interaction is re-written as","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" V(q) = frace^2epsilon_0 q^2 = frace^2epsilon_0 frac1q^2 + lambda + deltalambda","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"We then work perturbatively in terms of the following renormalized Green's function and interaction,","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"beginaligned\n g_R(k iomega_n) equiv -frac1iomega_n-epsilon_k + mu_R = g(k iomega_n) Big_deltamu = 02ex\n V_lambda(q) equiv frace^2epsilon_0 frac1q^2 + lambda = V(q) Big_deltalambda = 0\nendaligned","category":"page"},{"location":"manual/counterterms/#New-approach-to-counterterm-evaluation","page":"Evaluation of counterterms","title":"New approach to counterterm evaluation","text":"","category":"section"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"In the NEFT codebase, the counterterms are generated by directly differentiating diagrams in the perturbative series for a given observable, which allows for a flexible and generic reformulation of the VDMC algorithm. This is made possible by representing all diagrams by differentiable expression trees. In contrast, in the original VDMC approach one first Taylor expands all propagators gg_R and VV_lambda entering a given observable by hand and collects terms in orders of xi manually prior to integration.","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"The mathcalO(xi^N) counterterms in RPT with n and m chemical potential / interaction derivatives are given by","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" (deltamu)^n (deltalambda)^m times frac1n mpartial^n_mu partial^m_lambda D_N - n - m","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"where D is the sum of all Feynman diagrams at the appropriate loop order N - n - m. The renormalization is performed in post-processing by multiplying with the Taylor series for (deltamu)^n (deltalambda)^m in xi and collecting terms propto xi^N. The chemical potential shift delta mu_n is derived from a separate MC simulation of Sigma^lambda_R_F(k_F ik_0).","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"To demonstrate that the two approaches outlined above are equivalent, it is sufficient to consider separately the cases of V and g raised to an arbitrary power in the Matsubara representation; we will omit the coordinates for brevity.","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"First, consider the chemical potential counterterms. Let deltamu equiv mu_0 - mu_R. Taylor expanding gg_R about deltamu = 0, we have","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" g = fracg_R1 - g_Rdeltamu = g_Rsum^infty_n=0 (g_Rdeltamu)^n = sum^infty_n=0 frac(deltamu)^nn partial^n_mu g_R","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"since","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" g^n+1_R = frac1n partial^n_mu g_R","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"Then,","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"beginaligned\n g^m = left(sum^infty_n=0 frac(deltamu)^nn partial^n_mu g_Rright)^m = g^m_Rleft(1 - g_Rdeltamuright)^-m = g^m_R sum^infty_n=0 binomm+n-1n (g_Rdeltamu)^n\n = sum^infty_n=0 (deltamu)^n frac(m+n-1)n (m-1) g^m+n_R = sum^infty_n=0 frac(deltamu)^nn (m-1) partial^m+n-1_mu g_R = sum^infty_n=0 frac(deltamu)^nn partial^n_mu g^m_R\nendaligned","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"where in the last step, we replaced","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"beginaligned\n frac1(m-1) partial^m-1_mu g_R = g^m_R\nendaligned","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"Thus, the series for g^m may be represented either by expanding each gg_R by hand and collecting terms, or by a direct Taylor expansion of g^m about deltamu = 0.","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"It remains to show that these two strategies are also equivalent for the expansion of V^m. Let deltalambda equiv lambda_0 - lambda_R = -lambda_R and Taylor expand VV_lambda about deltalambda = 0—we obtain","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"\n V = fracV_ lambda1 - fraclambdaq^2 + lambda = V_lambda sum_n=0^infty left(fraclambdaq^2 + lambdaright)^n = V_lambda sum_n=0^infty left(V_lambda deltalambdaright)^n = sum^infty_n=0 frac(-lambda)^nn partial^n_lambda V_lambda\n","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" V = fracV_ lambda1 - delta_lambda = V_lambda sum_n=0^infty delta^n_lambda = sum^infty_n=0 frac(deltalambda)^nn partial^n_lambda V_lambda","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"where","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" delta_lambda equiv fraclambdaq^2 + lambda","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"since","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"beginaligned\n frac(deltalambda)^nn partial^n_lambda V_lambda = 8pifrac(-lambda)^nn partial^n_lambda left(frac1q^2 + lambdaright) = frac8pilambda^n(q^2 + lambda)^n+1 = V_lambda delta^n_lambda\nendaligned","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"We also have that","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"beginaligned\n frac(deltalambda)^nn partial^n_lambda V^m_lambda = left(fraclambda8piright)^n fracm^(n)n V^m+n_lambda = binomm + n - 1n V^m_lambda delta^n_lambda\nendaligned","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"where m^(n) = prod_i=0^n-1 (m + i) is a rising factorial and","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":" binomm + n - 1n = frac(m + n - 1)n (m-1) = fracm^(n)n","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"Thus,","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"beginaligned\n V^m = left(sum^infty_n=0 frac(deltalambda)^nn partial^n_lambda V_lambdaright)^m = V^m_lambda left(1 - delta_lambdaright)^-m = sum^infty_n=0 binomm+n-1n V^m_lambda delta^n_lambda = sum^infty_n=0 frac(deltalambda)^nn partial^n_lambda V^m_lambda\nendaligned","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"Since the order of differentiation w.r.t. mu and lambda does not matter, it follows that a general diagram mathcalDg V sim g^n V^m may be represented either by pre-expanding gg_mu and VV_lambda and collecting terms, or by directly evaluating terms in the Taylor series for mathcalDg_mu V_lambda; this codebase uses the latter approach.","category":"page"},{"location":"manual/counterterms/#Evaluation-of-interaction-counterterms","page":"Evaluation of counterterms","title":"Evaluation of interaction counterterms","text":"","category":"section"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"An example of the interaction counterterm evaluation for a diagram with n_lambda = 3 and m interaction lines. Since the Julia implementation evaluates the interaction counterterms of a given diagram as frac(-lambda)^nnpartial^n_lambda V^m_lambda, we pick up an extra factor of l on each lth-order derivative in the chain rule.","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"(Image: An example of the representation of interaction counterterm diagrams via differentiation.)","category":"page"},{"location":"manual/counterterms/#Benchmark-of-counterterms-in-the-UEG","page":"Evaluation of counterterms","title":"Benchmark of counterterms in the UEG","text":"","category":"section"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"As a concrete example, we have evaluated the individual diagrams and associated counterterms entering the RPT series for the total density ng_mu V_lambda in units of the non-interacting density n_0. The diagrams/counterterms are denoted by partitions mathcalP equiv (n_textloop n_mu n_lambda) indicating the total loop order and number of mu and lambda derivatives.","category":"page"},{"location":"manual/counterterms/#D-UEG","page":"Evaluation of counterterms","title":"3D UEG","text":"","category":"section"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"For this benchmark, we take r_s = 1, beta = 40 epsilon_F, and lambda = 06. All partitions contributing up to 4th order are included, as well as some selected partitions at 5th and 6th order.","category":"page"},{"location":"manual/counterterms/","page":"Evaluation of counterterms","title":"Evaluation of counterterms","text":"(n_textloop n_lambda n_mu) n n_0\n(1, 0, 1) 0.40814(16)\n(1, 0, 2) 0.02778(21)\n(1, 0, 3) -0.00096(60)\n(2, 0, 0) 0.28853(12)\n(2, 1, 0) 0.07225(3)\n(2, 2, 0) 0.02965(2)\n(2, 0, 1) 0.09774(30)\n(2, 1, 1) 0.01594(10)\n(2, 0, 2) 0.00240(130)\n(3, 0, 0) 0.10027(37)\n(3, 1, 0) 0.04251(21)\n(3, 0, 1) 0.02600(150)\n(4, 0, 0) 0.00320(130)\n(2, 1, 2) -0.00111(18)\n(2, 0, 3) -0.00430(150)\n(3, 2, 0) 0.02241(8)\n(3, 3, 0) 0.01429(7)","category":"page"},{"location":"lib/operator/#Quantum-operator-and-its-product","page":"Quantum operator and its product","title":"Quantum operator and its product","text":"","category":"section"},{"location":"lib/operator/#API","page":"Quantum operator and its product","title":"API","text":"","category":"section"},{"location":"lib/operator/","page":"Quantum operator and its product","title":"Quantum operator and its product","text":"Modules = [FeynmanDiagram.QuantumOperators]","category":"page"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.OperatorProduct","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.OperatorProduct","text":"struct OperatorProduct <: AbstractVector{QuantumOperator}\n\nstruct of a quantum-operator product. It is a subtype of `AbstractVector` and\ninherits a large set of Vector behaviors including iteration and indexing.\n\nMembers:\n\noperators::Vector{QuantumOperator} vector of quantum operators\n\n\n\n\n\n","category":"type"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.QuantumOperator","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.QuantumOperator","text":"struct QuantumOperator\n\nstruct of a quantum operator.\n\nMembers:\n\noperator::Datatype: type of quantum operator, supports :f⁺, :f⁻, :f, :b⁺, :b⁻, :ϕ\nlabel::Int: label of the operator indices. It could represent spacetime, spin, momentum, flavor, etc.\nis_ghost::Bool: whether the operator is a ghost operator or not.\n\n\n\n\n\n","category":"type"},{"location":"lib/operator/#Base.:*-Tuple{QuantumOperator, QuantumOperator}","page":"Quantum operator and its product","title":"Base.:*","text":"Base.:*(o1::Union{QuantumOperator, OperatorProduct}, o2::Union{QuantumOperator, OperatorProduct})\n\n`o1 * o2` returns the quantum operator product of `o1` and `o2`\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#Base.adjoint-Tuple{OperatorProduct}","page":"Quantum operator and its product","title":"Base.adjoint","text":"Base.adjoint(o::OperatorProduct)\n\nReturn the conjuated composite operator of `o`.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#Base.adjoint-Tuple{QuantumOperator}","page":"Quantum operator and its product","title":"Base.adjoint","text":"Base.adjoint(operator::QuantumOperator)\n\nReturn the conjuated quantum operator of `operator`.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.correlator_order-Tuple{OperatorProduct}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.correlator_order","text":"function correlator_order(operator::OperatorProduct)\nfunction correlator_order(operator::OperatorProduct)\n\nConvert a OperatorProduct to correlator-ordered form. \nReturns the associated statistical sign and permutation.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.fermionic_annihilation-Tuple{Any}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.fermionic_annihilation","text":"Create a OperatorProduct with one quantum operator from given label `i`.\nIt supports the following abbreviated function form:\n\n''' const 𝑓⁻ = fermionicannihilation const 𝑓⁺ = fermioniccreation const 𝑓 = majorana const 𝑏⁻ = bosonicannihilation const 𝑏⁺ = bosoniccreation const 𝜙 = real_classic '''\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.isannihilation-Tuple{QuantumOperator}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.isannihilation","text":"function isannihilation(operator::QuantumOperator)\n\nCheck if `operator` is an annihilation operator.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.iscreation-Tuple{QuantumOperator}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.iscreation","text":"function iscreation(operator::QuantumOperator)\n\nCheck if `operator` is a creation operator.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.isfermionic-Tuple{OperatorProduct}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.isfermionic","text":"function isfermionic(o::OperatorProduct)\n\nCheck if `o` is a fermionic composite operator.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.isfermionic-Tuple{QuantumOperator}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.isfermionic","text":"function isfermionic(operator::QuantumOperator)\n\nCheck if `operator` is a fermionic operator.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.normal_order-Tuple{OperatorProduct}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.normal_order","text":"function normal_order(operator::OperatorProduct)\n\nComputes the permutation required to convert a OperatorProduct to normal-ordered form. \nReturns the associated statistical sign and permutation.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.parity-Tuple{AbstractVector{Int64}}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.parity","text":"The parity of a permutation P is +1 if the number of 2-cycles (swaps) in an n-cycle decomposition with n ≤ 2 is even, and -1 if the number of 2-cycles is odd.\n\n\n\n\n\n","category":"method"},{"location":"lib/operator/#FeynmanDiagram.QuantumOperators.parity_old-Tuple{Any}","page":"Quantum operator and its product","title":"FeynmanDiagram.QuantumOperators.parity_old","text":"calculate the parity of a given permutation of the array [1, 2, 3, ...]\n\n\n\n\n\n","category":"method"},{"location":"lib/backend/#Compilers-compile-computational-graphs-to-optimized-source-code-for-diverse-platforms","page":"Compilers compile computational graphs to optimized source code for diverse platforms","title":"Compilers compile computational graphs to optimized source code for diverse platforms","text":"","category":"section"},{"location":"lib/backend/#API","page":"Compilers compile computational graphs to optimized source code for diverse platforms","title":"API","text":"","category":"section"},{"location":"lib/backend/","page":"Compilers compile computational graphs to optimized source code for diverse platforms","title":"Compilers compile computational graphs to optimized source code for diverse platforms","text":"Modules = [FeynmanDiagram.Compilers]","category":"page"},{"location":"lib/backend/#FeynmanDiagram.Compilers.compile-Tuple{AbstractVector{<:AbstractGraph}}","page":"Compilers compile computational graphs to optimized source code for diverse platforms","title":"FeynmanDiagram.Compilers.compile","text":"function compile(graphs::AbstractVector{<:AbstractGraph}; root::AbstractVector{Int}=[id(g) for g in graphs])\n\nCompile a list of graphs into a julia static function. The function takes two arguments: root and leaf. root is a vector of the root node ids of the graphs, and leaf is a vector of the leaf node ids of the graphs. This function calls tojuliastr and generate a defined function using RuntimeGeneratedFunctions. Comparing to eval(Meta.parse(tojuliastr(...))), this function does not leak out the function name into global scope.\n\nExample:\n\nfactor = 1.5\nV1 = [𝑓⁺(1)𝑓⁻(2), 𝑓⁺(3)𝑓⁻(4)]\nsubgraphs = [external_vertex(V1[1]), external_vertex(V1[2])]\ng = FeynmanGraph(subgraphs; factor=factor)\n# println(g)\neval_graph! = Compilers.compile([g,])\nroot = [0.0,]\nleaf = [1.0, 2.0]\n\n@assert eval_graph!(root, leaf) ≈ (leaf[1] + leaf[2]) * factor\n\n\n\n\n\n","category":"method"},{"location":"lib/backend/#FeynmanDiagram.Compilers.compile_C-Tuple{AbstractVector{<:AbstractGraph}, String}","page":"Compilers compile computational graphs to optimized source code for diverse platforms","title":"FeynmanDiagram.Compilers.compile_C","text":"function compile_C(graphs::AbstractVector{<:AbstractGraph}, filename::String; \n datatype::DataType=_dtype.weight, root::AbstractVector{Int}=[id(g) for g in graphs], func_name=\"eval_graph\")\n\nCompiles a set of graphs into C language code and append the generated code to a specified file.\n\nArguments\n\ndatatype::DataType: This type is used for variables types in the generated C code.\ngraphs::AbstractVector{<:AbstractGraph}: An array of graph objects. These graphs are processed to generate Julia code.\nfilename::String: The name of the file to which the generated code will be appended. The file is created if it does not exist.\nroot::AbstractVector{Int} (keyword): An array of integers representing root nodes for each graph in graphs. By default, it is an array of IDs obtained by calling id(g) for each graph g in graphs.\nfunc_name::String (keyword): The base name for the function(s) to be generated. Defaults to \"eval_graph\".\n\nReturns\n\nA dictionary (leafmap) that maps the index of the leaf weight's table leafVal to the leaf graph.\n\n\n\n\n\n","category":"method"},{"location":"lib/backend/#FeynmanDiagram.Compilers.compile_Julia-Tuple{AbstractVector{<:AbstractGraph}, String}","page":"Compilers compile computational graphs to optimized source code for diverse platforms","title":"FeynmanDiagram.Compilers.compile_Julia","text":"function compile_Julia(graphs::AbstractVector{<:AbstractGraph}, filename::String; \n root::AbstractVector{Int}=[id(g) for g in graphs], func_name=\"eval_graph!\")\n\nCompiles a set of graphs into Julia code and append the generated code to a specified file.\n\nArguments\n\ngraphs::AbstractVector{<:AbstractGraph}: An array of graph objects. These graphs are processed to generate Julia code.\nfilename::String: The name of the file to which the generated code will be appended. The file is created if it does not exist.\nroot::AbstractVector{Int} (keyword): An array of integers representing root nodes for each graph in graphs. By default, it is an array of IDs obtained by calling id(g) for each graph g in graphs.\nfunc_name::String (keyword): The base name for the function(s) to be generated. Defaults to \"eval_graph!\".\n\nReturns\n\nA dictionary (leafmap) that maps the index of the leaf weight's table leafVal to the leaf graph.\n\n\n\n\n\n","category":"method"},{"location":"lib/backend/#FeynmanDiagram.Compilers.to_dot_str","page":"Compilers compile computational graphs to optimized source code for diverse platforms","title":"FeynmanDiagram.Compilers.to_dot_str","text":"function to_dot_str(graphs::AbstractVector{<:AbstractGraph}, name::String=\"\")\n\nCompile a list of graphs into a string for dot language.\n\n# Arguments:\n- `graphs` vector of computational graphs\n- `title` The name of the compiled function (defaults to nothing)\n\n\n\n\n\n","category":"function"},{"location":"lib/backend/#FeynmanDiagram.Compilers.to_julia_str-Tuple{AbstractVector{<:AbstractGraph}}","page":"Compilers compile computational graphs to optimized source code for diverse platforms","title":"FeynmanDiagram.Compilers.to_julia_str","text":"function to_julia_str(graphs::AbstractVector{<:AbstractGraph}, leafMap::Dict{Int,Int}; root::AbstractVector{Int}=[id(g) for g in graphs],\n name::String=\"eval_graph!\")\n\nCompile a list of Feynman graphs into a string for a julia static function. The complied function takes two arguments: root and leafVal. root is a vector of the root node ids of the graphs, and leafVal is a vector of the leaf nodes' weights of the graphs. \n\nArguments:\n\ngraphs (AbstractVector{G}): The vector object representing the Feynman graphs,\nroot (AbstractVector{Int}, optional): The vector of the root node ids of the graphs (defaults to [id(g) for g in graphs]).\nname (String,optional): The name of the complied function (defaults to \"eval_graph!\"). \n\nReturns:\n\nA String representing the compiled Julia function.\nleafMap (Dict{Int,G}): A dictionary that maps the index of the leaf weight's table leafVal to the leaf graph.\n\n\n\n\n\n","category":"method"},{"location":"lib/backend/#FeynmanDiagram.Compilers.to_pystatic-Tuple{Type, AbstractVector{<:AbstractGraph}, AbstractVector}","page":"Compilers compile computational graphs to optimized source code for diverse platforms","title":"FeynmanDiagram.Compilers.to_pystatic","text":"function to_pystatic(operator::Type, subgraphs::AbstractVector{<:AbstractGraph}, subgraph_factors::AbstractVector)\n\nReturns the static representation of a computational graph node `g` with operator `operator`, subgraphs `subgraphs`, and subgraph factors `subgraph_factors` in python.\n\n\n\n\n\n","category":"method"},{"location":"lib/backend/#FeynmanDiagram.Compilers.to_python_str","page":"Compilers compile computational graphs to optimized source code for diverse platforms","title":"FeynmanDiagram.Compilers.to_python_str","text":"function to_python_str(graphs::AbstractVector{<:AbstractGraph})\n\nCompile a list of graphs into a string for a python static function and output a python script which support the mindspore and jax framework.\n\nArguments:\n\ngraphs vector of computational graphs\nframework the type of the python frameworks, including :jax and mindspore.\n\n\n\n\n\n","category":"function"},{"location":"lib/backend/#FeynmanDiagram.Compilers.to_static-Tuple{Type, AbstractVector{<:AbstractGraph}, AbstractVector}","page":"Compilers compile computational graphs to optimized source code for diverse platforms","title":"FeynmanDiagram.Compilers.to_static","text":"function to_static(operator::Type, subgraphs::AbstractVector{<:AbstractGraph}, subgraph_factors::AbstractVector)\n\nReturns the static representation of a computational graph node g with operator operator, subgraphs subgraphs, and subgraph factors subgraph_factors.\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#Front-end-generates-Feynman-diagrams-and-translates-then-into-a-computational-graph","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"Front-end generates Feynman diagrams and translates then into a computational graph","text":"","category":"section"},{"location":"lib/frontend/#API","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"API","text":"","category":"section"},{"location":"lib/frontend/","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"Front-end generates Feynman diagrams and translates then into a computational graph","text":"Modules = [FeynmanDiagram.FrontEnds]","category":"page"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.BareGreenNId","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.BareGreenNId","text":"time-ordered N-point Bare Green's function\n\n\n\n\n\n","category":"type"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.BareHoppingId","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.BareHoppingId","text":"hopping function c⁺c⁻\n\n\n\n\n\n","category":"type"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.ConnectedGreenNId","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.ConnectedGreenNId","text":"time-ordered N-point Composite Green's function\n\n\n\n\n\n","category":"type"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.DiagramId","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.DiagramId","text":"abstract type DiagramId end\n\nThe abstract type of all diagrams/subdiagrams/bare propagators\n\n\n\n\n\n","category":"type"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.GreenNId","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.GreenNId","text":"time-ordered N-point Composite Green's function\n\n\n\n\n\n","category":"type"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.LabelProduct","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.LabelProduct","text":"The cartesian QuantumOperator.label product:\n\n#Parameters:\n\n'LT': Type of labels\n'N' : Number of labels' type\n\n#Members:\n\n'labels' : The list of labels in the LabelProduct\n'dims' : A tuple of the length of the label factors\n\n\n\n\n\n","category":"type"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.LoopPool","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.LoopPool","text":"struct LoopPool{T}\n\nPool of loop basis. Each loop basis corresponds to a loop variable.\nA loop variable is a linear combination of N independent loops. The combination coefficients is what we call a loop basis.\nFor example, if a loop is a momentum K, then\n\nvaribale_i = K_1*basis[1, i] + K_2*basis[2, i] + K_3*basis[3, i] + ...\n\nMembers\n\nname::Symbol : name of the pool\ndim::Int : dimension of a loop variable (for example, the dimension of a momentum-frequency loop variable is (d+1) where d is the spatial dimension)\nbasis::Matrix{T} : Matrix of (N x Nb) that stores the loop basis, where Nb is the number of loop basis (or number of loop variables).\nloops::Matrix{T} : Matrix of (dim x Nb) that stores the loop variables, where Nb is the number of loop basis (or number of loop variables).\n\n\n\n\n\n","category":"type"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.PropagatorId","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.PropagatorId","text":"abstract type PropagatorId <: DiagramId end\n\nThe abstract type of all bare propagators\n\n\n\n\n\n","category":"type"},{"location":"lib/frontend/#Base.length-Tuple{LabelProduct}","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"Base.length","text":"function Base.length(obj::LabelProduct)\n\nReturn the number of grids of the LabelProduct.\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#Base.show-Tuple{IO, LabelProduct}","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"Base.show","text":"function Base.show(io::IO, obj::LabelProduct)\n\nPrint the LabelProduct.\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#Base.size-Tuple{LabelProduct, Int64}","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"Base.size","text":"function Base.size(obj::LabelProduct, I::Int)\n\nReturn the length of the specifict Ith label factor of the LabelProduct.\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#Base.size-Tuple{LabelProduct}","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"Base.size","text":"function Base.size(obj::LabelProduct, I::Int)\n\nReturn the length of the specifict Ith label factor of the LabelProduct.\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.index_to_linear-Union{Tuple{N}, Tuple{LT}, Tuple{LabelProduct{LT, N}, Vararg{Any}}} where {LT, N}","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.index_to_linear","text":"@generated function index_to_linear(obj::LabelProduct{LT,N}, I...) where {LT,N}\n\nConvert a tuple of the indexes of each label to a single linear index of the LabelProduct.\n\nArgument:\n\n'obj': The LabelProduct object\n'index...': N indexes of the label factor, where N is the number of label factor\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.leafstates-Union{Tuple{G}, Tuple{Array{Dict{Int64, G}, 1}, Int64}} where G<:Graph","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.leafstates","text":"function leafstates(leaf_maps::Vector{Dict{Int,G}}, maxloopNum::Int)\n\nExtracts leaf information from the leaf mapping from the leaf value's index to the leaf node for all graph partitions. \nThe information includes their initial value, type, orders, in/out time, and loop momentum index.\nThe loop basis is also obtained for all the graphs.\n\nArguments:\n\nleaf_maps: A vector of the dictionary mapping the leaf value's index to the Graph of this leaf. Each dict corresponds to a graph partition, such as (order, Gorder, Vorder).\nmaxloopNum: The maximum loop-momentum number.\n\nReturns\n\nA tuple of vectors containing information about the leaves of graphs, including their initial values, types, orders, input and output time indexes, and loop-momenta indexes.\nLoop-momentum basis (::Vector{Vector{Float64}}) for all the graphs.\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.leafstates-Union{Tuple{G}, Tuple{Array{Dict{Int64, G}, 1}, LabelProduct}} where G<:Union{FeynmanGraph, Graph}","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.leafstates","text":"function leafstates(leaf_maps::Vector{Dict{Int,G}}, labelProd::LabelProduct) where {G<:Union{Graph,FeynmanGraph}}\n\nExtracts leaf information from the leaf mapping from the leaf value's index to the leaf node for all graph partitions\nand their associated LabelProduct data (`labelProd`). \nThe information includes their initial value, type, orders, in/out time, and loop momenta.\n\nArguments:\n\nleaf_maps: A vector of the dictionary mapping the leaf value's index to the FeynmanGraph/Graph of this leaf. Each dict corresponds to a graph partition, such as (order, Gorder, Vorder).\nlabelProd: A LabelProduct used to label the leaves of graphs.\n\nReturns\n\nA tuple of vectors containing information about the leaves of graphs, including their initial values, types, orders, input and output time indexes, and loop-momenta indexes.\n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.linear_to_index-Union{Tuple{N}, Tuple{LT}, Tuple{LabelProduct{LT, N}, Int64}} where {LT, N}","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.linear_to_index","text":"function linear_to_index(obj::LabelProduct, I::Int)\n\nConvert the single linear index of the LabelProduct to a tuple of indexes of each label. \n\nArgument:\n\n'obj': The LabelProduct object\n'I': The linear index of the LabelProduct \n\n\n\n\n\n","category":"method"},{"location":"lib/frontend/#FeynmanDiagram.FrontEnds.reconstruct-Tuple{FeynmanDiagram.FrontEnds.DiagramId, Vararg{Pair{Symbol}}}","page":"Front-end generates Feynman diagrams and translates then into a computational graph","title":"FeynmanDiagram.FrontEnds.reconstruct","text":"reconstruct(instance::DiagramId, updates::Pair{Symbol}...)\n\nCreate a new instance of the same type as instance, with specified fields updated to new values.\n\nUsage\n\nnewinstance = reconstruct(oldinstance, :field1 => newvalue1, :field2 => newvalue2)\n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#Parquet-Algorithm-to-Build-Diagrams","page":"Parquet Algorithm to Build Diagrams","title":"Parquet Algorithm to Build Diagrams","text":"","category":"section"},{"location":"lib/parquet/#API","page":"Parquet Algorithm to Build Diagrams","title":"API","text":"","category":"section"},{"location":"lib/parquet/","page":"Parquet Algorithm to Build Diagrams","title":"Parquet Algorithm to Build Diagrams","text":"Modules = [FeynmanDiagram.Parquet]","category":"page"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.ParquetBlocks","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.ParquetBlocks","text":"struct ParquetBlocks\n\nThe channels of the left and right sub-vertex4 of a bubble diagram in the parquet equation\n\n#Members\n\nphi : channels of left sub-vertex for the particle-hole and particle-hole-exchange bubbles\nppi : channels of left sub-vertex for the particle-particle bubble\nΓ4 : channels of right sub-vertex of all channels\n\n\n\n\n\n","category":"type"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.ep_coupling-Tuple{FeynmanDiagram.FrontEnds.Parquet.DiagPara}","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.ep_coupling","text":"function ep_coupling(para::DiagPara;\n extK=[getK(para.totalLoopNum, 1), getK(para.totalLoopNum, 2), getK(para.totalLoopNum, 3)],\n channels::AbstractVector=[PHr, PHEr, PPr, Alli],\n subdiagram=false,\n name=:none, resetuid=false,\n blocks::ParquetBlocks=ParquetBlocks()\n)\n\nGenerate electron-phonon 4-vertex diagrams using Parquet Algorithm. The right incoming Tau will be set to the last Tau for all diagrams | | Γ3 –––-| | |\n\nArguments\n\npara : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx\nextK : basis of external loops as a vector [left in, left out, right in, right out]. \nchannels : vector of channels in the left Γ3 diagrams. \nsubdiagram : a sub-vertex or not\nname : name of the vertex\nresetuid : restart uid count from 1\nblocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.\n\nOutput\n\nA DataFrame with fields :response, :extT, :diagram, :hash. \n\nOutput\n\nA DataFrame with fields :response, :type, :extT, :diagram, :hash\n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.get_ver4I-Tuple{}","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.get_ver4I","text":"get_ver4I()\n\nRetrieves the global dictionary `vertex4I_diags` that contains graph initialized by `initialize_vertex4I_diags`. \nThis function is a getter that provides access to the stored graph data of the 3- and 4-point fully-irreducible (Alli) vertex functions.\n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.green","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.green","text":"green(para::DiagPara, extK = getK(para.totalLoopNum, 1), extT = para.hasTau ? (1, 2) : (0, 0), subdiagram = false;\n name = :G, resetuid = false, blocks::ParquetBlocks=ParquetBlocks())\n\nBuild composite Green's function. By definition, para.firstTauIdx is the first Tau index of the left most self-energy subdiagram.\n\nArguments\n\npara : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx\nextK : basis of external loop. \nextT: [Tau index of the left leg, Tau index of the right leg]\nsubdiagram : a sub-vertex or not\nname : name of the diagram\nresetuid : restart uid count from 1\nblocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.\n\nOutput\n\nA Graph object or nothing if the Green's function is illegal. \n\n\n\n\n\n","category":"function"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.initialize_vertex4I_diags-Tuple{}","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.initialize_vertex4I_diags","text":"initialize_vertex4I_diags(; filter=[NoHartree], spinPolarPara::Float64=0.0)\n\nInitialize the vertex4I_diags dictionary with the diagrams of the 3- and 4-point fully-irreducible (Alli) vertex functions.\n\nParameters\n\nfilter (optional) : a list of filter conditions to select the diagrams. Default is [NoHartree].\nspinPolarPara (optional) : the spin-polarization parameter. Default is 0.0.\n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.innerTauNum-Tuple{FeynmanDiagram.FrontEnds.Parquet.DiagramType, Any, Any}","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.innerTauNum","text":"function innerTauNum(type::DiagramType, innerLoopNum, interactionTauNum)\n\ninternal imaginary-time degrees of freedom for a given diagram type and internal loop number.\nFor the vertex functions (self-energy, polarization, vertex3, and vertex4), innerTauNum is equivalent to tauNum.\nFor the Green function, tauNum = innerTauNum + external tauNum\n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.mergeby","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.mergeby","text":"function mergeby(df::DataFrame, fields=Vector{Symbol}();\n operator=Sum(), name::Symbol=:none,\n getid::Function=g -> GenericId(g[1, :diagram].properties.para, Tuple(g[1, fields]))\n)\n\nAggregates and merges rows in a DataFrame based on specified fields and an aggregation operator.\nIt is designed to work with data frames containing diagram representations or similar structured data, \nallowing for flexible aggregation based on custom identifiers and properties.\n\nParameters\n\ndf: A DataFrame to be processed. It must contain a column named :diagram which holds Graph.\nfields: A vector of Symbols specifying the columns based on which the aggregation groups are formed.\noperator: The aggregation operator to be applied. This operator is used to aggregate data across rows within each group formed by the specified fields. The default is Sum().\nname: An optional Symbol representing the name of a new column to store the aggregated results. The default is :none.\ngetid: A function that generates a unique identifier for each group based on the specified fields and the properties of the :diagram column. The default function is g -> GenericId(g[1, :diagram].properties.para, Tuple(g[1, fields])).\n\n\n\n\n\n","category":"function"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.polarization","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.polarization","text":"function polarization(para::DiagPara, extK=getK(para.totalLoopNum, 1), subdiagram=false; name=:Π, resetuid=false, blocks::ParquetBlocks=ParquetBlocks())\n\nGenerate polarization diagrams using Parquet Algorithm.\n\nArguments\n\npara : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx\nextK : basis of external loop. \nsubdiagram : a sub-vertex or not\nname : name of the vertex\nresetuid : restart uid count from 1\nblocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.\n\nOutput\n\nA DataFrame with fields :response, :diagram, :hash. \nAll polarization share the same external Tau index. With imaginary-time variables, they are extT = (para.firstTauIdx, para.firstTauIdx+1)\n\n\n\n\n\n","category":"function"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.sigma","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.sigma","text":"function sigma(para::DiagPara, extK=getK(para.totalLoopNum, 1), subdiagram=false;\n name=:Σ, resetuid=false, blocks::ParquetBlocks=ParquetBlocks())\n\nBuild sigma diagram. When sigma is created as a subdiagram, then no Fock diagram is generated if para.filter contains NoFock, and no sigma diagram is generated if para.filter contains Girreducible\n\nArguments\n\npara : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx\nextK : basis of external loop. \nsubdiagram : a sub-vertex or not\nname : name of the diagram\nresetuid : restart uid count from 1\nblocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.\n\nOutput\n\nA DataFrame with fields :type, :extT, :diagram, :hash\nAll sigma share the same incoming Tau index, but not the outgoing one\n\n\n\n\n\n","category":"function"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.update_extKT","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.update_extKT","text":"update_extKT(diags::Vector{Graph}, para::DiagPara, legK::Vector{Vector{Float64}}) -> Vector{Graph}\n\nReturns a new vector of graphs with updated external momenta (`extK`) and external times (`extT`), \nbased on the provided graphs, parameters, and external legs' momenta.\n\nArguments\n\ndiags::Vector{Graph}: A vector of Graph objects.\npara::DiagPara: parameters reconstructed in the graphs. Its firstTauIdx will update the extT of graphs.\nlegK::Vector{Vector{Float64}}: basis of the external momenta for the legs of the diagram as [left in, left out, right in, right out]. \nextraLoopIdx: the index of the extra loop in the external momenta basis in legK. Defaults to nothing, which means no extra loop is included. \n\nReturns\n\nVector{Graph}: A new vector of Graph objects with updated extK, extT, and para (if existing) properties for each node.\n\n\n\n\n\n","category":"function"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.update_extKT!","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.update_extKT!","text":"update_extKT!(diags::Vector{Graph}, para::DiagPara, legK::Vector{Vector{Float64}})\n\nUpdate the external momenta (`extK`) and external times (`extT`) of all the nodes in a vector of graphs in-place.\n\nArguments\n\ndiags::Vector{Graph}: A vector of Graph objects.\npara::DiagPara: parameters reconstructed in the graphs. Its firstTauIdx will update the extT of graphs.\nlegK::Vector{Vector{Float64}}: basis of the external momenta for the legs of the diagram as [left in, left out, right in, right out].\nextraLoopIdx: the index of the extra loop in the external momenta basis in legK. Defaults to nothing, which means no extra loop is included. \n\n\n\n\n\n","category":"function"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.vertex3","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.vertex3","text":"function vertex3(para::DiagPara, _extK=[getK(para.totalLoopNum, 1), getK(para.totalLoopNum, 2)], subdiagram=false;\n name=:Γ3, channels=[PHr, PHEr, PPr, Alli], resetuid=false, blocks::ParquetBlocks=ParquetBlocks())\n\nGenerate 3-vertex diagrams using Parquet Algorithm. With imaginary-time variables, all vertex3 generated has the same bosonic Tidx extT1=parafirstTauIdx and the incoming fermionic Tidx extT2=parafirstTauIdx+1.\n\n#Arguments\n\npara : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx\nextK : basis of external loops as a vector [bosonic leg (out), fermionic in, fermionic out], extK[1] = extK[2] - extK[3]. \nsubdiagram : a sub-vertex or not\nname : name of the vertex\nchannels : vector of channels of the current 4-vertex. \nresetuid : restart uid count from 1\nblocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.\n\nOutput\n\nA DataFrame with fields :response, :extT, :diagram, :hash. \n\n\n\n\n\n","category":"function"},{"location":"lib/parquet/#FeynmanDiagram.FrontEnds.Parquet.vertex4","page":"Parquet Algorithm to Build Diagrams","title":"FeynmanDiagram.FrontEnds.Parquet.vertex4","text":"vertex4(para::DiagPara,\n extK = [getK(para.totalLoopNum, 1), getK(para.totalLoopNum, 2), getK(para.totalLoopNum, 3)],\n subdiagram = false;\n channels::AbstractVector = [PHr, PHEr, PPr, Alli],\n level = 1, name = :none, resetuid = false,\n blocks::ParquetBlocks=ParquetBlocks(),\n blockstoplevel::ParquetBlocks=blocks\n )\n\nGenerate 4-vertex diagrams using Parquet Algorithm\n\nArguments\n\npara : parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdx\nextK : basis of external loops as a vector [left in, left out, right in, right out]. \nsubdiagram : a sub-vertex or not\nchannels : vector of channels of the current 4-vertex. \nname : name of the vertex\nlevel : level in the diagram tree\nresetuid : restart uid count from 1\nblocks : building blocks of the Parquet equation. See the struct ParquetBlocks for more details.\nblockstoplevel : building blocks of the Parquet equation at the toplevel. See the struct ParquetBlocks for more details.\n\nOutput\n\nA DataFrame with fields :response, :type, :extT, :diagram, :hash\n\n\n\n\n\n","category":"function"},{"location":"lib/parquet/#Parameters.reconstruct-Tuple{Type{FeynmanDiagram.FrontEnds.Parquet.DiagPara}, FeynmanDiagram.FrontEnds.Parquet.DiagPara, Any}","page":"Parquet Algorithm to Build Diagrams","title":"Parameters.reconstruct","text":"Parameters.reconstruct(p::DiagPara; kws...)\n\nType-stable version of the Parameters.reconstruct\n\n\n\n\n\n","category":"method"},{"location":"lib/parquet/#Usage","page":"Parquet Algorithm to Build Diagrams","title":"Usage","text":"","category":"section"},{"location":"lib/parquet/","page":"Parquet Algorithm to Build Diagrams","title":"Parquet Algorithm to Build Diagrams","text":"using FeynmanDiagram\npara = DiagPara(type = Ver4Diag, innerLoopNum = 1, hasTau = true);\nParquet.vertex4(para)\n\npara = DiagPara(type = Ver3Diag, innerLoopNum = 1, hasTau = true);\nParquet.vertex3(para)\n\npara = DiagPara(type = SigmaDiag, innerLoopNum = 1, hasTau = true);\nParquet.sigma(para)\n\npara = DiagPara(type = PolarDiag, innerLoopNum = 1, hasTau = true);\nParquet.polarization(para)","category":"page"},{"location":"lib/computgraph/#Computational-graph-for-general-feynman-diagrams","page":"Computational graph for general feynman diagrams","title":"Computational graph for general feynman diagrams","text":"","category":"section"},{"location":"lib/computgraph/#API","page":"Computational graph for general feynman diagrams","title":"API","text":"","category":"section"},{"location":"lib/computgraph/","page":"Computational graph for general feynman diagrams","title":"Computational graph for general feynman diagrams","text":"Modules = [FeynmanDiagram.ComputationalGraphs]","category":"page"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.FeynmanGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.FeynmanGraph","text":"mutable struct FeynmanGraph{F<:Number,W}\n\nComputational graph representation of a (collection of) Feynman diagram(s). All Feynman diagrams should share the same set of external and internal vertices.\n\nMembers:\n\nid::Int the unique hash id to identify the diagram\nname::Symbol name of the diagram\norders::Vector{Int} orders associated with the Feynman graph, e.g., loop/derivative orders\nproperties::FeynmanProperties diagrammatic properties, e.g., the operator vertices and topology\nsubgraphs::Vector{FeynmanGraph{F,W}} vector of sub-diagrams \nsubgraph_factors::Vector{F} scalar multiplicative factors associated with each subdiagram\noperator::DataType node operation (Sum, Prod, etc.)\nweight::W weight of the diagram\n\nExample:\n\njulia> g1 = FeynmanGraph([]; vertices=[𝑓⁺(1),𝑓⁻(2)], external_indices=[1,2], external_legs=[true,true])\n1:f⁺(1)|f⁻(2)=0.0\n\njulia> g2 = FeynmanGraph([]; vertices=[𝑓⁺(3),𝑓⁻(4)], external_indices=[1,2], external_legs=[true,true])\n2:f⁺(3)|f⁻(4)=0.0\n\njulia> g = FeynmanGraph([g1,g2]; vertices=[𝑓⁺(1),𝑓⁻(2),𝑓⁺(3),𝑓⁻(4)], operator=ComputationalGraphs.Prod(), external_indices=[1,2,3,4], external_legs=[true,true,true,true])\n3:f⁺(1)|f⁻(2)|f⁺(3)|f⁻(4)=0.0=Ⓧ (1,2)\n\n\n\n\n\n","category":"type"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.Graph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.Graph","text":"mutable struct Graph{F<:Number,W}\n\nA representation of a computational graph, e.g., an expression tree, with type stable node data.\n\nMembers:\n\nid::Int the unique hash id to identify the diagram\nname::Symbol name of the diagram\norders::Vector{Int} orders associated with the graph, e.g., derivative orders\nsubgraphs::Vector{Graph{F,W}} vector of sub-diagrams \nsubgraph_factors::Vector{F} scalar multiplicative factors associated with each subgraph. Note that the subgraph factors may be manipulated algebraically. To associate a fixed multiplicative factor with this graph which carries some semantic meaning, use the factor argument instead.\noperator::DataType node operation. Addition and multiplication are natively supported via operators Sum and Prod, respectively. Should be a concrete subtype of AbstractOperator.\nweight::W the weight of this node\nproperties::Any extra information of Green's functions.\n\nExample:\n\njulia> g1 = Graph([])\n1=0.0\n\njulia> g2 = Graph([]; factor=2)\n2⋅2.0=0.0\n\njulia> g = Graph([g1, g2]; operator=ComputationalGraphs.Sum())\n3=0.0=⨁ (1,2)\n\n\n\n\n\n","category":"type"},{"location":"lib/computgraph/#Base.:*-Union{Tuple{W}, Tuple{F}, Tuple{Any, FeynmanGraph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:*","text":"function Base.:*(c1, g2::Graph{F,W}) where {F,W}\n\nReturns a graph representing the scalar multiplication `c1*g2`.\n\nArguments:\n\nc1 scalar multiple\ng2 Feynman graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:*-Union{Tuple{W}, Tuple{F}, Tuple{Any, Graph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:*","text":"function Base.:*(c1, g2::Graph{F,W}) where {F,W}\n\nReturns a graph representing the scalar multiplication `c1*g2`.\n\nArguments:\n\nc1 scalar multiple\ng2 computational graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:*-Union{Tuple{W}, Tuple{F}, Tuple{FeynmanGraph{F, W}, Any}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:*","text":"function Base.:*(g1::Graph{F,W}, c2) where {F,W}\n\nReturns a graph representing the scalar multiplication `g1*c2`.\n\nArguments:\n\ng1 Feynman graph\nc2 scalar multiple\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:*-Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Any}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:*","text":"function Base.:*(g1::Graph{F,W}, c2) where {F,W}\n\nReturns a graph representing the scalar multiplication `g1*c2`.\n\nArguments:\n\ng1 computational graph\nc2 scalar multiple\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:*-Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Graph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:*","text":"function Base.:*(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}\n\nReturns a graph `g1 * g2` representing the graph product between `g1` and `g2`.\n\nArguments:\n\ng1 first computational graph\ng2 second computational graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:+-Union{Tuple{W}, Tuple{F}, Tuple{FeynmanGraph{F, W}, FeynmanGraph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:+","text":"function Base.:+(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}\n\nReturns a graph `g1 + g2` representing the addition of two Feynman diagrams `g2` with `g1`.\nDiagrams `g1` and `g2` must have the same diagram type, orders, and external vertices.\n\nArguments:\n\ng1 first Feynman graph\ng2 second Feynman graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:+-Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Graph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:+","text":"function Base.:+(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}\n\nReturns a graph `g1 + g2` representing the addition of `g2` with `g1`.\nGraphs `g1` and `g2` must have the same orders.\n\nArguments:\n\ng1 first computational graph\ng2 second computational graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:--Union{Tuple{W}, Tuple{F}, Tuple{FeynmanGraph{F, W}, FeynmanGraph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:-","text":"function Base.:-(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}\n\nReturns a graph `g1 - g2` representing the subtraction of `g2` from `g1`.\nDiagrams `g1` and `g2` must have the same diagram type, orders, and external vertices.\n\nArguments:\n\ng1 first Feynman graph\ng2 second Feynman graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.:--Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Graph{F, W}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"Base.:-","text":"function Base.:-(g1::Graph{F,W}, g2::Graph{F,W}) where {F,W}\n\nReturns a graph `g1 - g2` representing the subtraction of `g2` from `g1`.\nGraphs `g1` and `g2` must have the same orders.\n\nArguments:\n\ng1 first computational graph\ng2 second computational graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.convert-Union{Tuple{G}, Tuple{W}, Tuple{F}, Tuple{Type{G}, FeynmanGraph{F, W}}} where {F, W, G<:Graph}","page":"Computational graph for general feynman diagrams","title":"Base.convert","text":"function Base.convert(::Type{G}, g::FeynmanGraph{F,W}) where {F,W,G<:Graph}\n\nConverts a FeynmanGraph `g` into a Graph, discarding its Feynman properties.\nAfter conversion, graph `g` is no longer guaranteed to be a valid (group of) Feynman diagram(s).\n\n# Arguments:\n- `g` computational graph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#Base.show-Tuple{IO, AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"Base.show","text":"show(io::IO, graph::AbstractGraph; kwargs...)\n\nWrite a text representation of an AbstractGraph `graph` to the output stream `io`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.alleq-Tuple{Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.alleq","text":"Checks that all elements of an iterable x are equal.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.build_derivative_graph-Union{Tuple{N}, Tuple{G}, Tuple{AbstractVector{G}, Tuple{Vararg{Int64, N}}}} where {G<:Graph, N}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.build_derivative_graph","text":"function build_derivative_graph(graphs::AbstractVector{G}, orders::NTuple{N,Int};\n nodes_id=nothing) where {G<:Graph,N}\n\nConstructs a derivative graph using forward automatic differentiation with given graphs and derivative orders.\n\nArguments:\n\ngraphs: A vector of graphs.\norders::NTuple{N,Int}: A tuple indicating the orders of differentiation. N represents the number of independent variables to be differentiated.\nnodes_id: Optional node IDs to indicate saving their derivative graph.\n\nReturns:\n\nA dictionary containing the dual derivative graphs for all indicated nodes. \n\nIf isnothing(nodes_id), indicated nodes include all leaf and root nodes. Otherwise, indicated nodes include all root nodes and other nodes from nodes_id.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.burn_from_targetleaves!-Union{Tuple{G}, Tuple{AbstractVector{G}, AbstractVector{Int64}}} where G<:AbstractGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.burn_from_targetleaves!","text":"function burn_from_targetleaves!(graphs::AbstractVector{G}, targetleaves_id::AbstractVector{Int}; verbose=0) where {G <: AbstractGraph}\n\nRemoves all nodes connected to the target leaves in-place via \"Prod\" operators.\n\nArguments:\n\ngraphs: A vector of graphs.\ntargetleaves_id::AbstractVector{Int}: Vector of target leafs' id.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nThe id of a constant graph with a zero factor if any graph in graphs was completely burnt; otherwise, nothing.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.collect_labels-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.collect_labels","text":"function collect_labels(g::FeynmanGraph)\n\nReturns the list of sorted unique labels in graph `g`.\n\nArguments:\n\ng::FeynmanGraph: graph to find labels for\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.constant_graph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.constant_graph","text":"function constant_graph(factor=one(_dtype.factor))\n\nReturns a graph that represents a constant equal to f, where f is the factor with default value 1.\n\nArguments:\n\nf: constant factor\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.count_expanded_operation-Tuple{G} where G<:AbstractGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.count_expanded_operation","text":"function count_expanded_operation(g::G) where {G<:AbstractGraph}\n\nReturns the total number of operations in the totally expanded version (without any parentheses in the mathematical expression) of the graph.\n\nArguments:\n\ng::Graph: graph for which to find the total number of operations in its expanded version.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.count_leaves-Tuple{G} where G<:AbstractGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.count_leaves","text":"function count_leaves(g::G) where {G<:AbstractGraph}\n\nReturns the total number of leaves with unique id in the graph.\n\nArguments:\n\ng::Graph: graph for which to find the total number of leaves.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.count_operation-Tuple{G} where G<:AbstractGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.count_operation","text":"function count_operation(g::G) where {G<:AbstractGraph}\n\nReturns the total number of additions and multiplications in the graph.\n\nArguments:\n\ng::Graph: graph for which to find the total number of operations.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.diagram_type-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.diagram_type","text":"function diagram_type(g::FeynmanGraph)\n\nReturns the diagram type (::DiagramType) of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.disconnect_subgraphs!-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.disconnect_subgraphs!","text":"function disconnect_subgraphs!(g::G) where {G<:AbstractGraph}\n\nEmpty the subgraphs and subgraph_factors of graph `g`. Any child nodes of g\nnot referenced elsewhere in the full computational graph are effectively deleted.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.drop_topology-Tuple{FeynmanProperties}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.drop_topology","text":"function drop_topology(p::FeynmanProperties)\n\nReturns a copy of the given FeynmanProperties `p` modified to have no topology.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.eldest-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.eldest","text":"function eldest(g::AbstractGraph)\n\nReturns the first child (subgraph) of a graph g.\n\nArguments:\n\ng::AbstractGraph: graph for which to find the first child\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.external_indices-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.external_indices","text":"function external_indices(g::FeynmanGraph)\n\nReturns a list of indices (::Vector{Int}}) to the external vertices of the FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.external_labels-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.external_labels","text":"function external_labels(g::FeynmanGraph)\n\nReturns the labels of all physical external vertices of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.external_legs-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.external_legs","text":"function external_legs(g::FeynmanGraph)\n\nReturns a list of Boolean indices external_legs (::Vector{Bool}) indicating which external vertices of FeynmanGraph `g` have real legs (true: real leg, false: fake leg).\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.external_operators-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.external_operators","text":"function external_operators(g::FeynmanGraph)\n\nReturns all physical external operators (::OperatorProduct}) of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.external_vertex-Tuple{OperatorProduct}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.external_vertex","text":"function external_vertex(ops::OperatorProduct;\n name=\"\", factor=one(_dtype.factor), weight=zero(_dtype.weight), operator=Sum())\nCreate a ExternalVertex-type FeynmanGraph from given OperatorProduct `ops`, including several quantum operators for an purely external vertex.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.feynman_diagram-Union{Tuple{W}, Tuple{F}, Tuple{Array{FeynmanGraph{F, W}, 1}, Vector{Vector{Int64}}}, Tuple{Array{FeynmanGraph{F, W}, 1}, Vector{Vector{Int64}}, Union{Nothing, Vector{Int64}}}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.feynman_diagram","text":"function feynman_diagram(subgraphs::Vector{FeynmanGraph{F,W}}, topology::Vector{Vector{Int}}, perm_noleg::Union{Vector{Int},Nothing}=nothing;\n factor=one(_dtype.factor), weight=zero(_dtype.weight), name=\"\", diagtype::DiagramType=GenericDiag()) where {F,W}\n\nCreate a FeynmanGraph representing feynman diagram from all subgraphs and topology (connections between vertices),\nwhere each ExternalVertex is given in `vertices`, \nwhile internal vertices are constructed with external legs of graphs in `vertices`, or simply OperatorProduct in `vertices`.\n\nArguments:\n\nsubgraphs::Vector{FeynmanGraph{F,W}} all subgraphs of the diagram. All external operators of subgraphs constitute all operators of the new diagram.\ntopology::Vector{Vector{Int}} topology of the diagram. Each Vector{Int} stores operators' index connected with each other (as a propagator). \nperm_noleg::Union{Vector{Int},Nothing}=nothing permutation of all the nonleg external operators. By default, setting nothing means to use the default order from subgraphs.\nfactor::F overall scalar multiplicative factor for this diagram (e.g., permutation sign)\nweight weight of the diagram\nname name of the diagram\ndiagtype type of the diagram\n\nExample:\n\njulia> V = [𝑓⁺(1)𝑓⁻(2)𝜙(3), 𝑓⁺(4)𝑓⁻(5)𝜙(6), 𝑓⁺(7)𝑓⁻(8)𝜙(9)];\njulia> g = feynman_diagram(interaction.(V), [[1, 5], [3, 9], [4, 8]], [3, 1, 2])\n7:f⁺(1)f⁻(2)ϕ(3)|f⁺(4)f⁻(5)ϕ(6)|f⁺(7)f⁻(8)ϕ(9)=0.0=Ⓧ (1,2,3,4,5,6)\n\njulia> g.subgraphs\n6-element Vector{FeynmanGraph{Float64, Float64}}:\n 1:f⁺(1)f⁻(2)ϕ(3)=0.0\n 2:f⁺(4)f⁻(5)ϕ(6)=0.0\n 3:f⁺(7)f⁻(8)ϕ(9)=0.0\n 4:f⁺(1)|f⁻(5)⋅-1.0=0.0\n 5:ϕ(3)|ϕ(9)=0.0\n 6:f⁺(4)|f⁻(8)⋅-1.0=0.0\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.flatten_all_chains!-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.flatten_all_chains!","text":"function flatten_all_chains!(g::AbstractGraph; verbose=0)\n\nF Flattens all nodes representing trivial unary chains in-place in the given graph g. \n\nArguments:\n\ngraphs: The graph to be processed.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nThe mutated graph g with all chains flattened.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.flatten_all_chains!-Tuple{Union{Tuple, AbstractVector{<:AbstractGraph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.flatten_all_chains!","text":"function flatten_all_chains!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0)\n\nFlattens all nodes representing trivial unary chains in-place in the given graphs.\n\nArguments:\n\ngraphs: A collection of graphs to be processed.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nThe mutated collection graphs with all chains in each graph flattened.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.flatten_chains!-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.flatten_chains!","text":"function flatten_chains!(g::AbstractGraph)\n\nRecursively flattens chains of subgraphs within the given graph `g` by merging certain trivial unary subgraphs \ninto their parent graphs in the in-place form.\n\nActs only on subgraphs of `g` with the following structure: 𝓞 --- 𝓞' --- ⋯ --- 𝓞'' ⋯ (!),\nwhere the stop-case (!) represents a leaf, a non-trivial unary operator 𝓞'''(g) != g, or a non-unary operation.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.flatten_chains-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.flatten_chains","text":"function flatten_chains(g::AbstractGraph) \n\nRecursively flattens chains of subgraphs within a given graph `g` by merging certain trivial unary subgraphs into their parent graphs,\nThis function returns a new graph with flatten chains, derived from the input graph `g` remaining unchanged.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.flatten_prod!-Tuple{G} where G<:AbstractGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.flatten_prod!","text":"flatten_prod!(graph::G; map::Dict{Int,G}=Dict{Int,G}()) where {G<:AbstractGraph}\n\nRecursively merge multi-product sub-branches within the given graph `g by merging product subgraphs \ninto their parent product graphs in the in-place form.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\nmap::Dict{Int,G}=Dict{Int,G}(): A dictionary that maps the id of an original node with its corresponding new node after transformation. \n\nIn recursive transform, nodes can be visited several times by different parents. This map keeps track of those visited, and reuse those transformed sub-branches instead of recreating them.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.flatten_sum!-Tuple{G} where G<:AbstractGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.flatten_sum!","text":"flatten_sum!(graph::G; map::Dict{Int,G}=Dict{Int,G}()) where {G<:AbstractGraph}\n\nRecursively merge multi-product sub-branches within the given graph `g by merging sum subgraphs \ninto their parent sum graphs in the in-place form.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\nmap::Dict{Int,G}=Dict{Int,G}(): A dictionary that maps the id of an original node with its corresponding new node after transformation. \n\nIn recursive transform, nodes can be visited several times by different parents. This map keeps track of those visited, and reuse those transformed sub-branches instead of recreating them.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.forwardAD-Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Int64}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.forwardAD","text":"function forwardAD(diag::Graph{F,W}, ID::Int) where {F,W}\n\nGiven a graph G and an id of graph g, calculate the derivative d G / d g by forward propagation algorithm.\n\nArguments:\n\ndiag::Graph{F,W}: Graph G to be differentiated\nID::Int: ID of the graph g \n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.forwardAD_root!-Union{Tuple{AbstractVector{G}}, Tuple{N}, Tuple{G}, Tuple{AbstractVector{G}, Int64}, Tuple{AbstractVector{G}, Int64, Dict{Tuple{Int64, Tuple{Vararg{Bool, N}}}, G}}} where {G<:Graph, N}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.forwardAD_root!","text":"function forwardAD_root!(graphs::AbstractVector{G}, idx::Int=1,\n dual::Dict{Tuple{Int,NTuple{N,Bool}},G}=Dict{Tuple{Int,Tuple{Bool}},G}()) where {G<:Graph,N}\n\nComputes the forward automatic differentiation (AD) of the given graphs beginning from the roots.\n\nArguments:\n\ngraphs: A vector of graphs.\nidx: Index for differentiation (default: 1).\ndual: A dictionary that holds the result of differentiation.\n\nReturns:\n\nThe dual dictionary populated with all differentiated graphs, including the intermediate AD.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.group-Union{Tuple{G}, Tuple{AbstractVector{G}, Vector{Int64}}} where G<:FeynmanGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.group","text":"function group(gv::AbstractVector{G}, indices::Vector{Int}) where {G<:FeynmanGraph}\n\nGroup the graphs in gv by the external operators at the indices indices. Return a dictionary of Vector{OperatorProduct} to GraphVector.\n\nExample\n\njulia> p1 = propagator(𝑓⁺(1)𝑓⁻(2));\n\njulia> p2 = propagator(𝑓⁺(1)𝑓⁻(3));\n\njulia> p3 = propagator(𝑓⁺(2)𝑓⁻(3));\n\njulia> gv = [p1, p2, p3];\n\njulia> ComputationalGraphs.group(gv, [1, 2])\nDict{Vector{OperatorProduct}, Vector{FeynmanGraph{Float64, Float64}}} with 3 entries:\n [f⁻(2), f⁺(1)] => [1:f⁺(1)|f⁻(2)⋅-1.0=0.0]\n [f⁻(3), f⁺(1)] => [2:f⁺(1)|f⁻(3)⋅-1.0=0.0]\n [f⁻(3), f⁺(2)] => [3:f⁺(2)|f⁻(3)⋅-1.0=0.0]\n\njulia> ComputationalGraphs.group(gv, [1, ])\nDict{Vector{OperatorProduct}, Vector{FeynmanGraph{Float64, Float64}}} with 2 entries:\n [f⁻(3)] => [2:f⁺(1)|f⁻(3)⋅-1.0=0.0, 3:f⁺(2)|f⁻(3)⋅-1.0=0.0]\n [f⁻(2)] => [1:f⁺(1)|f⁻(2)⋅-1.0=0.0]\n\njulia> ComputationalGraphs.group(gv, [2, ])\nDict{Vector{OperatorProduct}, Vector{FeynmanGraph{Float64, Float64}}} with 2 entries:\n [f⁺(2)] => [3:f⁺(2)|f⁻(3)⋅-1.0=0.0]\n [f⁺(1)] => [1:f⁺(1)|f⁻(2)⋅-1.0=0.0, 2:f⁺(1)|f⁻(3)⋅-1.0=0.0]\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.has_zero_subfactors-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.has_zero_subfactors","text":"function has_zero_subfactors(g)\n\nReturns whether the graph g has only zero-valued subgraph factor(s). \nNote that this function does not recurse through subgraphs of g, so that one may have, e.g.,\n`isfactorless(g) == true` but `isfactorless(eldest(g)) == false`.\nBy convention, returns `false` if g is a leaf.\n\nArguments:\n\ng::AbstractGraph: graph to be analyzed\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.haschildren-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.haschildren","text":"function haschildren(g::AbstractGraph)\n\nReturns whether the graph has any children (subgraphs).\n\nArguments:\n\ng::AbstractGraph: graph to be analyzed\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.id-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.id","text":"function id(g::AbstractGraph)\n\nReturns the unique hash id of computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.interaction-Tuple{OperatorProduct}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.interaction","text":"function interaction(ops::OperatorProduct; name=\"\", reorder::Union{Function,Nothing}=nothing,\n factor=one(_dtype.factor), weight=zero(_dtype.weight), operator=Sum())\nCreate a Interaction-type FeynmanGraph from given OperatorProduct `ops`, including several quantum operators for a vertex.\nOne can call a reorder function for the operators ordering.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.is_external-Tuple{FeynmanGraph, Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.is_external","text":"function isexternaloperators(g::FeynmanGraph, i) \n\nCheck if `i` in the external indices of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.is_internal-Tuple{FeynmanGraph, Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.is_internal","text":"function is_internal(g::FeynmanGraph, i) \n\nCheck if `i` in the internal indices of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.isapprox_one-Tuple{Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.isapprox_one","text":"function isapprox_one(x)\n\nReturns true if x ≈ one(x).\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.isassociative-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.isassociative","text":"function isassociative(g::AbstractGraph)\n\nReturns true if the graph operation of node `g` is associative.\nOtherwise, returns false.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.isbranch-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.isbranch","text":"function isbranch(g::AbstractGraph)\n\nReturns whether the graph g is a branch-type (depth-1 and one-child) graph.\n\nArguments:\n\ng::AbstractGraph: graph to be analyzed\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.ischain-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.ischain","text":"function ischain(g::AbstractGraph)\n\nReturns whether the graph g is a chain-type graph (i.e., a unary string).\n\nArguments:\n\ng::AbstractGraph: graph to be analyzed\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.isequiv-Tuple{AbstractGraph, AbstractGraph, Vararg{Any}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.isequiv","text":"function isequiv(a::AbstractGraph, b::AbstractGraph, args...)\n\nDetermine whether graph `a` is equivalent to graph `b` without considering fields in `args`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.isleaf-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.isleaf","text":"function isleaf(g::AbstractGraph)\n\nReturns whether the graph g is a leaf (terminating tree node).\n\nArguments:\n\ng::AbstractGraph: graph to be analyzed\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.linear_combination-Union{Tuple{Array{FeynmanGraph{F, W}, 1}}, Tuple{W}, Tuple{F}, Tuple{Array{FeynmanGraph{F, W}, 1}, AbstractVector}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.linear_combination","text":"function linear_combination(graphs::Vector{FeynmanGraph{F,W}}, constants::AbstractVector=ones(F, length(graphs))) where {F,W}\n\nGiven a vector 𝐠 of graphs each with the same type and external/internal vertices and \nan equally-sized vector 𝐜 of constants, returns a new graph representing the linear combination (𝐜 ⋅ 𝐠). \nThe function identifies unique graphs from the input `graphs` and sums their associated `constants`.\nAll input Graphs must have the same diagram type, orders, and external vertices.\n\nArguments:\n\ngraphs vector of input FeymanGraphs\nconstants vector of scalar multiples (defaults to ones(F, length(graphs))).\n\nReturns:\n\nA new FeynmanGraph{F,W} object representing the linear combination of the unique input graphs weighted by the constants, \n\nwhere duplicate graphs in the input graphs are combined by summing their associated constants. \n\nExample:\n\nGiven graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1+c3)*g1 + c2*g2`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.linear_combination-Union{Tuple{Array{Graph{F, W}, 1}}, Tuple{W}, Tuple{F}, Tuple{Array{Graph{F, W}, 1}, AbstractVector}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.linear_combination","text":"function linear_combination(graphs::Vector{Graph{F,W}}, constants::AbstractVector=ones(F, length(graphs))) where {F,W}\n\nGiven a vector 𝐠 of graphs and an equally-sized vector 𝐜 of constants, returns a new\ngraph representing the linear combination (𝐜 ⋅ 𝐠). \nThe function identifies unique graphs from the input `graphs` and sums their associated `constants`.\nAll input graphs must have the same orders.\n\nArguments:\n\ngraphs vector of computational graphs\nconstants vector of scalar multiples (defaults to ones(F, length(graphs))).\n\nReturns:\n\nA new Graph{F,W} object representing the linear combination of the unique input graphs weighted by the constants, \n\nwhere duplicate graphs in the input graphs are combined by summing their associated constants. \n\nExample:\n\nGiven graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1+c3)*g1 + c2*g2`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.linear_combination-Union{Tuple{W}, Tuple{F}, Tuple{FeynmanGraph{F, W}, FeynmanGraph{F, W}}, Tuple{FeynmanGraph{F, W}, FeynmanGraph{F, W}, Any}, Tuple{FeynmanGraph{F, W}, FeynmanGraph{F, W}, Any, Any}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.linear_combination","text":"function linear_combination(g1::FeynmanGraph{F,W}, g2::FeynmanGraph{F,W}, c1, c2) where {F,W}\n\nReturns a graph representing the linear combination `c1*g1 + c2*g2`. If `g1 == g2`, it will return a graph representing `(c1+c2)*g1`\nFeynman Graphs `g1` and `g2` must have the same diagram type, orders, and external vertices.\n\nArguments:\n\ng1 first Feynman graph\ng2 second Feynman graph\nc1: first scalar multiple (defaults to 1).\nc2: second scalar multiple (defaults to 1).\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.linear_combination-Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Graph{F, W}}, Tuple{Graph{F, W}, Graph{F, W}, Any}, Tuple{Graph{F, W}, Graph{F, W}, Any, Any}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.linear_combination","text":"function linear_combination(g1::Graph{F,W}, g2::Graph{F,W}, c1, c2) where {F,W}\n\nReturns a graph representing the linear combination `c1*g1 + c2*g2`.\nIf `g1 == g2`, it will return a graph representing `(c1+c2)*g1`.\nGraphs `g1` and `g2` must have the same orders.\n\nArguments:\n\ng1 first computational graph\ng2 second computational graph\nc1 first scalar multiple\nc2 second scalar multiple\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_all_linear_combinations!-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_all_linear_combinations!","text":"function merge_all_linear_combinations!(g::AbstractGraph; verbose=0)\n\nMerges all nodes representing a linear combination of a non-unique list of subgraphs in-place in the given graph `g`.\n\nArguments:\n\ng: An AbstractGraph.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nOptimized graph.\n\n\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_all_linear_combinations!-Tuple{Union{Tuple, AbstractVector{<:AbstractGraph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_all_linear_combinations!","text":"function merge_all_linear_combinations!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0)\n\nMerges all nodes representing a linear combination of a non-unique list of subgraphs in-place in the given graphs.\n\nArguments:\n\ngraphs: A collection of graphs to be processed.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nOptimized graphs.\n\n\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_all_multi_products!-Tuple{Graph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_all_multi_products!","text":"function merge_all_multi_products!(g::Graph; verbose=0)\n\nMerges all nodes representing a multi product of a non-unique list of subgraphs in-place in the given graph `g`.\n\nArguments:\n\ng::Graph: A Graph.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nOptimized graph.\n\n\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_all_multi_products!-Tuple{Union{Tuple, AbstractVector{<:Graph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_all_multi_products!","text":"function merge_all_multi_products!(graphs::Union{Tuple,AbstractVector{<:Graph}}; verbose=0)\n\nMerges all nodes representing a multi product of a non-unique list of subgraphs in-place in the given graphs.\n\nArguments:\n\ngraphs: A collection of graphs to be processed.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nOptimized graphs.\n\n\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_linear_combination!-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_linear_combination!","text":"function merge_linear_combination!(g::AbstractGraph)\n\nModifies a computational graph `g` by factorizing multiplicative prefactors, e.g.,\n3*g1 + 5*g2 + 7*g1 + 9*g2 ↦ 10*g1 + 14*g2 = linear_combination(g1, g2, 10, 14).\nReturns a linear combination of unique subgraphs and their total prefactors. \nDoes nothing if the graph `g` does not represent a Sum operation.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_linear_combination-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_linear_combination","text":"function merge_linear_combination(g::AbstractGraph)\n\nReturns a copy of computational graph `g` with multiplicative prefactors factorized,\ne.g., 3*g1 + 5*g2 + 7*g1 + 9*g2 ↦ 10*g1 + 14*g2 = linear_combination(g1, g2, 10, 14).\nReturns a linear combination of unique subgraphs and their total prefactors. \nDoes nothing if the graph `g` does not represent a Sum operation.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_multi_product!-Union{Tuple{Graph{F, W}}, Tuple{W}, Tuple{F}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_multi_product!","text":"function merge_multi_product!(g::Graph{F,W}) where {F,W}\n\nMerge multiple products within a computational graph `g` if they share the same operator (`Prod`).\nIf `g.operator == Prod`, this function will merge `N` identical subgraphs into a single subgraph with a power operator `Power(N)`. \nThe function ensures each unique subgraph is counted and merged appropriately, preserving any distinct subgraph_factors associated with them.\n\nArguments:\n\ng::Graph: graph to be modified\n\nReturns\n\nA merged computational graph with potentially fewer subgraphs if there were repeating subgraphs with the Prod operator. If the input graph's operator isn't Prod, the function returns the input graph unchanged.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.merge_multi_product-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.merge_multi_product","text":"function merge_multi_product(g::Graph{F,W}) where {F,W}\n\nReturns a copy of computational graph `g` with multiple products merged if they share the same operator (`Prod`).\nIf `g.operator == Prod`, this function will merge `N` identical subgraphs into a single subgraph with a power operator `Power(N)`. \nThe function ensures each unique subgraph is counted and merged appropriately, preserving any distinct subgraph_factors associated with them.\n\nArguments:\n\ng::Graph: graph to be modified\n\nReturns\n\nA merged computational graph with potentially fewer subgraphs if there were repeating subgraphs with the Prod operator. If the input graph's operator isn't Prod, the function returns the input graph unchanged.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.multi_product-Union{Tuple{Array{Graph{F, W}, 1}}, Tuple{W}, Tuple{F}, Tuple{Array{Graph{F, W}, 1}, AbstractVector}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.multi_product","text":"multi_product(graphs::Vector{Graph{F,W}}, constants::AbstractVector=ones(F, length(graphs))) where {F,W,C}\n\nConstruct a product graph from multiple input graphs, where each graph can be weighted by a constant. \nFor graphs that are repeated more than once, it adds a power operator to the subgraph to represent the repetition.\nMoreover, it optimizes any trivial unary operators in the resulting product graph.\n\nArguments:\n\ngraphs::Vector{Graph{F,W}}: A vector of input graphs to be multiplied.\nconstants::AbstractVector: A vector of scalar multiples. If not provided, it defaults to a vector of ones of the same length as graphs.\n\nReturns:\n\nA new product graph with the unique subgraphs (or powered versions thereof) and the associated constants as subgraph factors.\n\nExample:\n\nGiven graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1*c3)*(g1)^2 * c2*g2`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.multi_product-Union{Tuple{W}, Tuple{F}, Tuple{Graph{F, W}, Graph{F, W}}, Tuple{Graph{F, W}, Graph{F, W}, Any}, Tuple{Graph{F, W}, Graph{F, W}, Any, Any}} where {F, W}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.multi_product","text":"function multi_product(g1::Graph{F,W}, g2::Graph{F,W}, c1=F(1), c2=F(1)) where {F,W,C}\n\nReturns a graph representing the multi product `c1*g1 * c2*g2`.\nIf `g1 == g2`, it will return a graph representing `c1*c2 * (g1)^2` with `Power(2)` operator.\n\nArguments:\n\ng1: first computational graph\ng2: second computational graph\nc1: first scalar multiple (defaults to 1).\nc2: second scalar multiple (defaults to 1).\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.name-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.name","text":"function name(g::AbstractGraph)\n\nReturns the name of computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.onechild-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.onechild","text":"function onechild(g::AbstractGraph)\n\nReturns whether the graph g has only one child (subgraph).\n\nArguments:\n\ng::AbstractGraph: graph to be analyzed\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.open_parenthesis!-Tuple{G} where G<:AbstractGraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.open_parenthesis!","text":"open_parenthesis!(graph::G; map::Dict{Int,G}=Dict{Int,G}()) where {G<:AbstractGraph}\n\nRecursively open parenthesis of subgraphs within the given graph `g`with in place form. The graph eventually becomes \na single Sum root node with multiple subgraphs that represents multi-product of nodes (not flattened).\n\nArguments:\n\ng::AbstractGraph: graph to be modified\nmap::Dict{Int,G}=Dict{Int,G}(): A dictionary that maps the id of an original node with its corresponding new node after transformation. \n\nIn recursive transform, nodes can be visited several times by different parents. This map keeps track of those visited, and reuse those transformed sub-branches instead of recreating them. parents\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.operator-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.operator","text":"function operator(g::AbstractGraph)\n\nReturns the operation associated with computational graph node `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.optimize!-Tuple{Union{Tuple, AbstractVector{<:AbstractGraph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.optimize!","text":"function optimize!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; level=0, verbose=0, normalize=nothing)\n\nIn-place optimization of given `graphs`. Removes duplicated leaves, flattens chains, \nmerges linear combinations, and removes zero-valued subgraphs. When `level > 0`, also removes duplicated intermediate nodes.\n\nArguments:\n\ngraphs: A tuple or vector of graphs.\nlevel: Optimization level (default: 0). A value greater than 0 triggers more extensive but slower optimization processes, such as removing duplicated intermediate nodes.\nverbose: Level of verbosity (default: 0).\nnormalize: Optional function to normalize the graphs (default: nothing).\n\nReturns\n\nReturns the optimized graphs. If the input graphs is empty, it returns nothing.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.optimize-Tuple{Union{Tuple, AbstractVector{<:AbstractGraph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.optimize","text":"function optimize(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; level=0, verbose=0, normalize=nothing)\n\nOptimizes a copy of given `graphs`. Removes duplicated nodes (when `level > 0`) or leaves, flattens chains, \nmerges linear combinations, and removing zero-valued subgraphs.\n\nArguments:\n\ngraphs: A tuple or vector of graphs.\nlevel: Optimization level (default: 0). A value greater than 0 triggers more extensive but slower optimization processes, such as removing duplicated nodes.\nverbose: Level of verbosity (default: 0).\nnormalize: Optional function to normalize the graphs (default: nothing).\n\nReturns:\n\nA tuple/vector of optimized graphs.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.orders-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.orders","text":"function orders(g::AbstractGraph)\n\nReturns the derivative orders (::Vector{Int}) of computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.plot_tree-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.plot_tree","text":"function plot_tree(graph::AbstractGraph; verbose = 0, maxdepth = 6)\n\nVisualize the computational graph as a tree using ete3 python package\n\n#Arguments\n\ngraph::AbstractGraph : the computational graph struct to visualize\nverbose=0 : the amount of information to show\nmaxdepth=6 : deepest level of the computational graph to show\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.propagator-Tuple{Union{OperatorProduct, Vector{QuantumOperator}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.propagator","text":"function propagator(ops::Union{OperatorProduct,Vector{QuantumOperator}};\n name=\"\", factor=one(_dtype.factor), weight=zero(_dtype.weight), operator=Sum())\n\nCreate a Propagator-type FeynmanGraph from given OperatorProduct or Vector{QuantumOperator} `ops`, including two quantum operators.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.relabel!-Tuple{FeynmanGraph, Dict{Int64, Int64}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.relabel!","text":"function relabel!(g::FeynmanGraph, map::Dict{Int,Int})\n\nRelabels the quantum operators in `g` and its subgraphs according to `map`.\nFor example, `map = {1=>2, 3=>2}`` will find all quantum operators with labels 1 and 3, and then map them to 2.\n\nArguments:\n\ng::FeynmanGraph: graph to be modified\nmap: mapping from old labels to the new ones\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.relabel-Tuple{FeynmanGraph, Dict{Int64, Int64}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.relabel","text":"function relabel(g::FeynmanGraph, map::Dict{Int,Int})\n\nReturns a copy of `g` with quantum operators in `g` and its subgraphs relabeled according to `map`.\nFor example, `map = {1=>2, 3=>2}` will find all quantum operators with labels 1 and 3, and then map them to 2.\n\nArguments:\n\ng::FeynmanGraph: graph to be modified\nmap: mapping from old labels to the new ones\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.remove_all_zero_valued_subgraphs!-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.remove_all_zero_valued_subgraphs!","text":"function remove_all_zero_valued_subgraphs!(g::AbstractGraph; verbose=0)\n\nRecursively removes all zero-valued subgraph(s) in-place in the given graph `g`.\n\nArguments:\n\ng: An AbstractGraph.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nOptimized graph.\n\n\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.remove_all_zero_valued_subgraphs!-Tuple{Union{Tuple, AbstractVector{<:AbstractGraph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.remove_all_zero_valued_subgraphs!","text":"function remove_all_zero_valued_subgraphs!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0)\n\nRecursively removes all zero-valued subgraph(s) in-place in the given graphs.\n\nArguments:\n\ngraphs: A collection of graphs to be processed.\nverbose: Level of verbosity (default: 0).\n\nReturns:\n\nOptimized graphs.\n\n\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.remove_duplicated_leaves!-Tuple{Union{Tuple, AbstractVector{<:AbstractGraph}}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.remove_duplicated_leaves!","text":"function remove_duplicated_leaves!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0, normalize=nothing, kwargs...)\n\nRemoves duplicated leaf nodes in-place from a collection of graphs. It also provides optional normalization for these leaves.\n\nArguments:\n\ngraphs: A collection of graphs to be processed.\nverbose: Level of verbosity (default: 0).\nnormalize: Optional function to normalize the graphs (default: nothing).\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.remove_zero_valued_subgraphs!-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.remove_zero_valued_subgraphs!","text":"function remove_zero_valued_subgraphs!(g::AbstractGraph)\n\nRemoves zero-valued (zero subgraph_factor) subgraph(s) of a computational graph `g`. If all subgraphs are zero-valued, the first one (`eldest(g)`) will be retained.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.remove_zero_valued_subgraphs-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.remove_zero_valued_subgraphs","text":"function remove_zero_valued_subgraphs(g::AbstractGraph)\n\nReturns a copy of graph `g` with zero-valued (zero subgraph_factor) subgraph(s) removed.\nIf all subgraphs are zero-valued, the first one (`eldest(g)`) will be retained.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.replace_subgraph!-Tuple{AbstractGraph, AbstractGraph, AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.replace_subgraph!","text":"function replace_subgraph!(g::AbstractGraph, w::AbstractGraph, m::AbstractGraph)\n\nModifies `g` by replacing the subgraph `w` with a new graph `m`.\nFor Feynman diagrams, subgraphs `w` and `m` should have the same diagram type, orders, and external indices.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\nw::AbstractGraph: subgraph to replace\nm::AbstractGraph: new subgraph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.replace_subgraph-Tuple{AbstractGraph, AbstractGraph, AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.replace_subgraph","text":"function replace_subgraph(g::AbstractGraph, w::AbstractGraph, m::AbstractGraph)\n\nCreates a modified copy of `g` by replacing the subgraph `w` with a new graph `m`.\nFor Feynman diagrams, subgraphs `w` and `m` should have the same diagram type, orders, and external indices.\n\nArguments:\n\ng::AbstractGraph: graph to be modified\nw::AbstractGraph: subgraph to replace\nm::AbstractGraph: new subgraph\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_id!-Tuple{AbstractGraph, Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_id!","text":"function set_id!(g::AbstractGraph, id)\n\nUpdate the id of graph `g` to `id`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_name!-Tuple{AbstractGraph, AbstractString}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_name!","text":"function set_name!(g::AbstractGraph, name::AbstractString)\n\nUpdate the name of graph `g` to `name`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_operator!-Tuple{AbstractGraph, AbstractOperator}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_operator!","text":"function set_operator!(g::AbstractGraph, operator::AbstractOperator)\n\nUpdate the operator of graph `g` to `typeof(operator)`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_operator!-Tuple{AbstractGraph, Type{<:AbstractOperator}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_operator!","text":"function set_operator!(g::AbstractGraph, operator::Type{<:AbstractOperator})\n\nUpdate the operator of graph `g` to `operator`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_orders!-Tuple{AbstractGraph, AbstractVector}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_orders!","text":"function set_orders!(g::AbstractGraph, orders::AbstractVector)\n\nUpdate the orders of graph `g` to `orders`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_subgraph!","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_subgraph!","text":"function set_subgraph!(g::AbstractGraph, subgraph::AbstractGraph, i=1)\n\nUpdate the `i`th subgraph of graph `g` to `subgraph`.\nDefaults to the first subgraph factor if an index `i` is not supplied.\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_subgraph_factor!","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_subgraph_factor!","text":"function setsubgraphfactor!(g::AbstractGraph, subgraph_factor, i=1)\n\nUpdate the `i`th subgraph factor of graph `g` to `subgraph_factor`.\nDefaults to the first subgraph factor if an index `i` is not supplied.\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_subgraph_factors!-Tuple{AbstractGraph, AbstractVector, AbstractVector{Int64}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_subgraph_factors!","text":"function setsubgraphfactors!(g::AbstractGraph, subgraph_factors::AbstractVector, indices::AbstractVector{Int})\n\nUpdate the specified subgraph factors of graph `g` at indices `indices` to `subgraph_factors`.\nBy default, calls `set_subgraph_factor!(g, subgraph_factors[i], i)` for each `i` in `indices`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_subgraph_factors!-Tuple{AbstractGraph, AbstractVector}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_subgraph_factors!","text":"function setsubgraphfactors!(g::AbstractGraph, subgraph_factors::AbstractVector)\n\nUpdate the subgraph factors of graph `g` to `subgraphs`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_subgraphs!-Tuple{AbstractGraph, AbstractVector{<:AbstractGraph}, AbstractVector{Int64}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_subgraphs!","text":"function set_subgraphs!(g::AbstractGraph, subgraphs::AbstractVector{<:AbstractGraph}, indices::AbstractVector{Int})\n\nUpdate the specified subgraphs of graph `g` at indices `indices` to `subgraphs`.\nBy default, calls `set_subgraph!(g, subgraphs[i], i)` for each `i` in `indices`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_subgraphs!-Tuple{AbstractGraph, AbstractVector{<:AbstractGraph}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_subgraphs!","text":"function set_subgraphs!(g::AbstractGraph, subgraphs::AbstractVector{<:AbstractGraph})\n\nUpdate the full list of subgraphs of graph `g` to `subgraphs`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.set_weight!-Tuple{AbstractGraph, Any}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.set_weight!","text":"function set_weight!(g::AbstractGraph, weight)\n\nUpdate the weight of graph `g` to `weight`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.standardize_labels!-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.standardize_labels!","text":"function standardize_labels!(g::FeynmanGraph)\n\nFinds all labels involved in `g` and its subgraphs and \nmodifies `g` by relabeling in standardized order, e.g.,\n(1, 4, 5, 7, ...) ↦ (1, 2, 3, 4, ....)\n\nArguments:\n\ng::FeynmanGraph: graph to be relabeled\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.standardize_labels-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.standardize_labels","text":"function standardize_labels!(g::FeynmanGraph)\n\nFinds all labels involved in `g` and its subgraphs and returns \na copy of `g` relabeled in a standardized order, e.g.,\n(1, 4, 5, 7, ...) ↦ (1, 2, 3, 4, ....)\n\nArguments:\n\ng::FeynmanGraph: graph to be relabeled\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.subgraph","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.subgraph","text":"function subgraph(g::AbstractGraph, i=1)\n\nReturns a copy of the `i`th subgraph of computational graph `g`.\nDefaults to the first subgraph if an index `i` is not supplied.\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.subgraph_factor","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.subgraph_factor","text":"function subgraph_factor(g::AbstractGraph, i=1)\n\nReturns a copy of the `i`th subgraph factor of computational graph `g`.\nDefaults to the first subgraph factor if an index `i` is not supplied.\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.subgraph_factors-Tuple{AbstractGraph, AbstractVector{Int64}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.subgraph_factors","text":"function subgraph_factors(g::AbstractGraph, indices::AbstractVector{Int})\n\nReturns the subgraph factors of computational graph `g` at indices `indices`.\nBy default, calls `subgraph_factor(g, i)` for each `i` in `indices`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.subgraph_factors-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.subgraph_factors","text":"function subgraph_factors(g::AbstractGraph)\n\nReturns the subgraph factors of computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.subgraphs-Tuple{AbstractGraph, AbstractVector{Int64}}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.subgraphs","text":"function subgraphs(g::AbstractGraph, indices::AbstractVector{Int})\n\nReturns the subgraphs of computational graph `g` at indices `indices`.\nBy default, calls `subgraph(g, i)` for each `i` in `indices`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.subgraphs-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.subgraphs","text":"function subgraphs(g::AbstractGraph)\n\nReturns the subgraphs of computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.topology-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.topology","text":"function topology(g::FeynmanGraph)\n\nReturns the topology (::Vector{Vector{Int}}) of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.unary_istrivial-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.unary_istrivial","text":"function unary_istrivial(g::AbstractGraph)\n\nReturns true if the unary form of the graph operation of node `g` is trivial.\nOtherwise, returns false.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.unique_nodes!","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.unique_nodes!","text":"function unique_nodes!(graphs::AbstractVector{<:AbstractGraph})\n\nIdentifies and retrieves unique nodes from a set of graphs.\n\nArguments:\n\ngraphs: A collection of graphs to be processed.\n\nReturns:\n\nA mapping dictionary from the id of each leaf to the unique leaf node.\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.vertex","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.vertex","text":"function vertex(g::FeynmanGraph, i=1)\n\nReturns the `i`th vertex (::OperatorProduct) of FeynmanGraph `g`.\nDefaults to the first vertex if an index `i` is not supplied.\n\n\n\n\n\n","category":"function"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.vertices-Tuple{FeynmanGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.vertices","text":"function vertices(g::FeynmanGraph)\n\nReturns all vertices (::Vector{OperatorProduct}) of FeynmanGraph `g`.\n\n\n\n\n\n","category":"method"},{"location":"lib/computgraph/#FeynmanDiagram.ComputationalGraphs.weight-Tuple{AbstractGraph}","page":"Computational graph for general feynman diagrams","title":"FeynmanDiagram.ComputationalGraphs.weight","text":"function weight(g::AbstractGraph)\n\nReturns the weight of the computational graph `g`.\n\n\n\n\n\n","category":"method"},{"location":"manual/interaction/#Interaction/Scattering-Amplitude-Convention","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"","category":"section"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"In general, the interaction (or scattering amplitude) between two spin-12 particles only has two independent spin components. Here we briefly review some of the common conventions of the spin components in literature, and show how to map between different conventions.","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"We assume a particle from the left collides with a particle from the right. Due to the interaction between the two particles, one of them scatters to the left, and the other to the right. ","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"We will use the index alphabetagammadelta to label the left incoming, the left outgoing, the right incoming and the right outgoing particles. We assume four legs associate with four momentum-frequency vectors k_1 k_2 k_3 k_4.","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"There are two possible scatterings: a direct scattering where the two particles don't permutate after the collision, and an exchange scattering where the two particles permutate. Therefore, the total scattering amplitude has two contributions,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v_alphabetagammadelta(1234) = v^d_alphabetagammadelta(1234)+v^e_alphabetagammadelta(1234)","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"where the exchange contribution is different from the direct counterpart up to an exchange of two outgoing legs and an overall particle statistic sign xi =pm 1,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^e_alphabetagammadelta(1234) = xi v^d_alphadeltagammabeta(1432)","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"where we have abbreviated the momentum-frequency vectors as indices.","category":"page"},{"location":"manual/interaction/#.-Spin-symmetric-and-asymmetric-convention:","page":"Interaction/Scattering-Amplitude Convention","title":"1. Spin symmetric and asymmetric convention:","text":"","category":"section"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"A interaction is split into a term that is independent of the spin (e.g., Coulomb interaction between electrons) and a term with spin dependence (e.g., ferromagnetic/antiferromagnetic interaction). This convention is commonly used in textbooks of Fermi liquid theory.","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^d_alphabetagammadelta(1234) equiv v^s_1234delta_alphabetadelta_gammadelta + v^a_1234 vecsigma_alphabetacdot vecsigma_gammadelta","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"where the superscript d means the scattering is direct.","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"If two particles permute after the collision, then one needs to exchange beta leftrightarrow gamma and other internal variables,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^e_alphabetagammadelta(1234) = xi v^s_1432delta_alphadeltadelta_gammabeta + xi v^a_1432 vecsigma_alphadeltacdot vecsigma_gammabeta","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^e_alphabetagammadelta(1234) = xifracv^s_1432+3v^a_14322delta_alphabetadelta_gammadelta + xi fracv^s_1432-v^a_14322 vecsigma_alphabetacdot vecsigma_gammadelta","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"To derive the above equations, we use the identity vecsigma_alphabetacdot vecsigma_gammadelta=2 delta_alpha delta delta_beta gamma-delta_alpha beta delta_gamma delta, which gives the following equations,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"delta_alphadeltadelta_gammabeta=frac12delta_alphabetadelta_gammadelta+frac12vecsigma_alphabetacdot vecsigma_gammadelta","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"and,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"vecsigma_alphadeltacdot vecsigma_gammabeta=frac32delta_alphabetadelta_gammadelta-frac12vecsigma_alphabetacdot vecsigma_gammadelta","category":"page"},{"location":"manual/interaction/#.-Spin-\\uparrow\\uparrow-and-\\uparrow\\downarrow-convention:","page":"Interaction/Scattering-Amplitude Convention","title":"2. Spin uparrowuparrow and uparrowdownarrow convention:","text":"","category":"section"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"An alternative parameterization of the interaction matrix is by specifiying the spin components v_uparrowuparrow equiv v_uparrowuparrowuparrowuparrow and v_uparrowdownarrow equiv v_uparrowuparrowdownarrowdownarrow. They can be derived from v_s and v_a by the simple relation,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^d_uparrowuparrow(1234) = v^s_1234+v^a_1234","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^d_uparrowdownarrow(1234) = v^s_1234-v^a_1234","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"If two particles permute after the collision, the exchange interaction v^e,","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^e_uparrowuparrow(1234) = xifracv^s_1432+3v^a_14322+xifracv^s_1432-v^s_14322 = xi v^s_1432+ xi v^a_1432","category":"page"},{"location":"manual/interaction/","page":"Interaction/Scattering-Amplitude Convention","title":"Interaction/Scattering-Amplitude Convention","text":"v^e_uparrowdownarrow(1234) = xifracv^s_1432+3v^a_14322-xifracv^s_1432-v^s_14322 = 2 xi v^a_1432","category":"page"},{"location":"manual/feynman_rule/#Feynman-Rules","page":"Feynman Rules","title":"Feynman Rules","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"In general, we follow the convention in the textbook \"Quantum Many-particle Systems\" by J. Negele and H. Orland, Page 95,","category":"page"},{"location":"manual/feynman_rule/#Fourier-Transform","page":"Feynman Rules","title":"Fourier Transform","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"G(tau) = frac1beta sum_n G(iomega_n) texte^-iomega_n tau","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"G(iomega_n) = int_0^beta G(tau) texte^iomega_n tau dtau","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where the Matsubara-frequency omega_n=2pi nbeta for boson and omega_n = 2pi (n+1)beta for fermion.","category":"page"},{"location":"manual/feynman_rule/#Action-and-Partition-Sum","page":"Feynman Rules","title":"Action and Partition Sum","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The partition sum associates with a generic action,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"Z = int mathcalDbarpsimathcalDpsi expleft(-Sright)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where the action takes a generic form,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"S = barpsi_1left(fracpartialpartial tau +epsilon_k right)psi_1 + V_1234barpsi_1barpsi_2psi_3psi_4","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where barpsi and psi are Grassman fields.","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"In the Matsubara-frequency domain, the action is,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"S = barpsi_1left(-iomega_n +epsilon_k right)psi_1 + V_1234barpsi_1barpsi_2psi_3psi_4","category":"page"},{"location":"manual/feynman_rule/#Bare-Propagator","page":"Feynman Rules","title":"Bare Propagator","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"Imaginary time","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"g(tau k) = leftmathcalT psi(k tau) barpsi(k 0) right_0= frace^-epsilon_k tau1+e^-epsilon_k betatheta(tau)+xi frace^-epsilon_k (beta+tau)1+e^-epsilon_k betatheta(-tau)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where xi is +1 for boson and -1 for fermion.","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"Matusbara frequency","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"g(iomega_n k) = -frac1iomega_n-epsilon_k","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"Then the action takes a simple form,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"S = barpsi_1g_12^-1psi_2 + V_1234barpsi_1barpsi_2psi_3psi_4","category":"page"},{"location":"manual/feynman_rule/#Dressed-Propagator-and-Self-energy","page":"Feynman Rules","title":"Dressed Propagator and Self-energy","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The dressed propagator is given by,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"G(tau k) = leftmathcalT psi(k tau) barpsi(k 0) right","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"and we define the self-energy Sigma as the one-particle irreducible vertex function,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"G^-1 = g^-1 + Sigma","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"so that","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"G = g - gSigma g + gSigma g Sigma g - ","category":"page"},{"location":"manual/feynman_rule/#Perturbative-Expansion-of-the-Green's-Function","page":"Feynman Rules","title":"Perturbative Expansion of the Green's Function","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"(Image: Sign rule for the Wick contractions.)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"(Image: Diagrammatic expansion of the Green's function.)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The sign of a Green's function diagram is given by (-1)^n_v xi^n_F, where","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"n_v is the number of interactions.\nn_F is the number of the fermionic loops.","category":"page"},{"location":"manual/feynman_rule/#Feynman-Rules-for-the-Self-energy","page":"Feynman Rules","title":"Feynman Rules for the Self-energy","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"From the Green's function diagrams, one can derive the negative self-energy diagram,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"(Image: Diagrammatic expansion of the self-energy.)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"beginaligned\n-Sigma = (-1) xi V_34 g_44+(-1) V_34 g_34 \n+(-1)^2 xi V_34 V_56 g_46 g_64 g_43+(-1)^2 V_34 V_56 g_35 g_54 g_42+cdots\nendaligned","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The sign of a negative self-energy -Sigma diagram is given by (-1)^n_v xi^n_F, where","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"n_v is the number of interactions.\nn_F is the number of the fermionic loops.","category":"page"},{"location":"manual/feynman_rule/#Feynman-Rules-for-the-3-point-Vertex-Function","page":"Feynman Rules","title":"Feynman Rules for the 3-point Vertex Function","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The self-energy is related to the 3-point vertex function through an equation,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"-left(Sigma_3 x -Sigma^Hartree_3 xright) = G_3y cdot left(-V_3 4right) cdot Gamma^3_4yx","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where the indices x y could be different from diagrams to diagrams, and Gamma_3 is the inproper three-vertex function. Eliminate the additional sign, one derives,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"Sigma_3 x -Sigma^Hartree_3 x = G_3y cdot V_3 4 cdot Gamma^3_4yx","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"(Image: Diagrammatic expansion of the 3-point vertex function.)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The diagram weights are given by,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"beginaligned\nGamma^(3)= 1 + (-1) xi V_56 g_46 g_64 + (-1) V_56 g_54 g_46\n+(-1)^2 xi^2 V_56 V_78 g_46 g_64 g_58 g_85+(-1)^2xi V_56 V_78 g_74 g_46+cdots\nendaligned","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The sign of Gamma^(3) diagram is given by (-1)^n_v xi^n_F.","category":"page"},{"location":"manual/feynman_rule/#Feynman-Rules-for-the-4-point-Vertex-Function","page":"Feynman Rules","title":"Feynman Rules for the 4-point Vertex Function","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The 4-point vertex function is related to the 3-point vertex function through an equation,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"Gamma^(3)_4yx = xi cdot G_4s cdot G_t 4 cdot Gamma^(4)_s t y x","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where the indices x y s t could be different from diagrams to diagrams.","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"(Image: Diagrammatic expansion of the 4-point vertex function.)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The diagram weights are given by,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"beginaligned\nGamma^(4)= (-1) V_56^textdirect + (-1)xi V_56^exchange\n+(-1)^2 xi V_56 V_78 g_58 g_85+(-1)^2 V_56 V_78+cdots\nendaligned","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"where we used the identity xi^2 = 1.","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The sign of Gamma^(4) diagram is given by (-1)^n_v xi^n_F multiplied with a sign from the permutation of the external legs.","category":"page"},{"location":"manual/feynman_rule/#Feynman-Rules-for-the-Susceptibility","page":"Feynman Rules","title":"Feynman Rules for the Susceptibility","text":"","category":"section"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"The susceptibility can be derived from Gamma^(4).","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"chi_12 equiv leftmathcalT n_1 n_2right_textconnected = xi G_12 G_2 1 + xi G_1s G_t 1 Gamma^(4)_s t y x G_2y G_x 2","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"(Image: Diagrammatic expansion of the susceptibility.)","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"We define the polarization P as the one-interaction irreducible (or proper) vertex function,","category":"page"},{"location":"manual/feynman_rule/","page":"Feynman Rules","title":"Feynman Rules","text":"chi^-1 = P^-1 + V","category":"page"},{"location":"lib/taylorseries/#Taylor-expansions-in-independent-variables-(support-AbstractGraph)","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"Taylor expansions in independent variables (support AbstractGraph)","text":"","category":"section"},{"location":"lib/taylorseries/#API","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"API","text":"","category":"section"},{"location":"lib/taylorseries/","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"Taylor expansions in independent variables (support AbstractGraph)","text":"Modules = [FeynmanDiagram.Taylor]","category":"page"},{"location":"lib/taylorseries/#FeynmanDiagram.Taylor","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"FeynmanDiagram.Taylor","text":"TaylorSeries\n\nA Julia package for Taylor expansions in one or more independent variables.\n\nThe basic constructors is TaylorSeries.\n\n\n\n\n\n","category":"module"},{"location":"lib/taylorseries/#FeynmanDiagram.Taylor.ParamsTaylor","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"FeynmanDiagram.Taylor.ParamsTaylor","text":"ParamsTaylor\n\nDataType holding the current parameters for `TaylorSeries`. \nThis part of code is adopted from TaylorSeries.jl (https://github.com/JuliaDiff/TaylorSeries.jl)\n\nFields:\n\norders :: Int Orders (degree) of the polynomials\nnum_vars :: Int Number of variables\nvariable_names :: Vector{String} Names of the variables\nvariable_symbols :: Vector{Symbol} Symbols of the variables\n\nThese parameters can be changed using set_variables\n\n\n\n\n\n","category":"type"},{"location":"lib/taylorseries/#FeynmanDiagram.Taylor.TaylorSeries","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"FeynmanDiagram.Taylor.TaylorSeries","text":"mutable struct TaylorSeries{T}\n\nA representation of a taylor series.\n\nMembers:\n\nname::Symbol name of the diagram\ncoeffs::Dict{Vector{Int},T} The taylor expansion coefficients. The integer array define the order of corresponding coefficient. \n\n\n\n\n\n","category":"type"},{"location":"lib/taylorseries/#FeynmanDiagram.Taylor.TaylorSeries-Union{Tuple{T}, Tuple{Type{T}, Int64}} where T","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"FeynmanDiagram.Taylor.TaylorSeries","text":"function TaylorSeries(::Type{T}, nv::Int) where {T}\n\nCreate a taylor series equal to variable with index nv. For example, if global variables are \"x y\", in put nv=2 generate series t=y.\n\nArguments:\n\n::Type{T} DataType of coefficients in taylor series.\nnv::Int Index of variable. \n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#Base.:*-Union{Tuple{T}, Tuple{FeynmanDiagram.Taylor.TaylorSeries{T}, FeynmanDiagram.Taylor.TaylorSeries{T}}} where T","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"Base.:*","text":"function Base.:*(g1::TaylorSeries{T}, g2::TaylorSeries{T}) where {T}\n\nReturns a taylor series `g1 * g2` representing the product of `g2` with `g1`.\n\nArguments:\n\ng1 First taylor series\ng2 Second taylor series\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#Base.:*-Union{Tuple{T}, Tuple{FeynmanDiagram.Taylor.TaylorSeries{T}, Number}} where T","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"Base.:*","text":"function Base.:*(g1::TaylorSeries{T}, c2::Number) where {T}\n\nReturns a TaylorSeries representing the scalar multiplication `g1*c2`.\n\nArguments:\n\ng1 TaylorSeries\nc2 scalar multiple\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#Base.:*-Union{Tuple{T}, Tuple{Number, FeynmanDiagram.Taylor.TaylorSeries{T}}} where T","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"Base.:*","text":"function Base.:*(c1::Number, g2::TaylorSeries{T}) where {T}\n\nReturns a TaylorSeries representing the scalar multiplication `g2*c1`.\n\nArguments:\n\ng2 TaylorSeries\nc1 scalar multiple\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#Base.:+-Union{Tuple{S}, Tuple{T}, Tuple{FeynmanDiagram.Taylor.TaylorSeries{T}, S}} where {T, S<:Number}","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"Base.:+","text":"function Base.:+(g1::TaylorSeries{T}, c::S) where {T,S<:Number}\n\nReturns a taylor series `g1 + c` representing the addition of constant `c` with `g1`.\n\nArguments:\n\ng1 Taylor series\nc Constant\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#Base.:+-Union{Tuple{T}, Tuple{FeynmanDiagram.Taylor.TaylorSeries{T}, FeynmanDiagram.Taylor.TaylorSeries{T}}} where T","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"Base.:+","text":"function Base.:+(g1::TaylorSeries{T}, g2::TaylorSeries{T}) where {T}\n\nReturns a taylor series `g1 + g2` representing the addition of `g2` with `g1`.\n\nArguments:\n\ng1 First taylor series\ng2 Second taylor series\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#Base.:+-Union{Tuple{T}, Tuple{S}, Tuple{S, FeynmanDiagram.Taylor.TaylorSeries{T}}} where {S<:Number, T}","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"Base.:+","text":"function Base.:+(c::S, g1::TaylorSeries{T}) where {S<:Number,T}\n\nReturns a taylor series `g1 + c` representing the addition of constant `c` with `g1`.\n\nArguments:\n\ng1 Taylor series\nc Constant\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#Base.:--Union{Tuple{T}, Tuple{FeynmanDiagram.Taylor.TaylorSeries{T}, FeynmanDiagram.Taylor.TaylorSeries{T}}} where T","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"Base.:-","text":"function Base.:-(g1::TaylorSeries{T,V}, g2::TaylorSeries{T,V}) where {T,V}\n\nReturns a taylor series `g1 - g2` representing the difference of `g2` with `g1`.\n\nArguments:\n\ng1 First taylor series\ng2 Second taylor series\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#Base.:^-Tuple{FeynmanDiagram.Taylor.TaylorSeries, Integer}","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"Base.:^","text":"function Base.:^(x::TaylorSeries, p::Integer)\n\nReturn the power of taylor series x^p, where p is an integer.\n\nArguments:\n\nx Taylor series\n'p' Power index\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#Base.one-Union{Tuple{FeynmanDiagram.Taylor.TaylorSeries{T}}, Tuple{T}} where T","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"Base.one","text":"function Base.one(g::TaylorSeries{T}) where {T}\n\nReturn a constant one for a given taylor series.\n\nArguments:\n\ng Taylor series\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#FeynmanDiagram.Taylor.displayBigO-Tuple{Bool}","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"FeynmanDiagram.Taylor.displayBigO","text":"displayBigO(d::Bool) --> nothing\n\nSet/unset displaying of the big 𝒪 notation in the output of Taylor1 and TaylorN polynomials. The initial value is true.\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#FeynmanDiagram.Taylor.getcoeff-Tuple{FeynmanDiagram.Taylor.TaylorSeries, Vector{Int64}}","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"FeynmanDiagram.Taylor.getcoeff","text":"function getcoeff(g::TaylorSeries, order::Vector{Int})\n\nReturn the taylor coefficients with given order in taylor series g.\n\nArguments:\n\ng Taylor series\norder Order of target coefficients\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#FeynmanDiagram.Taylor.getderivative-Tuple{FeynmanDiagram.Taylor.TaylorSeries, Vector{Int64}}","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"FeynmanDiagram.Taylor.getderivative","text":"function getderivative(g::TaylorSeries, order::Vector{Int})\n\nReturn the derivative with given order in taylor series g.\n\nArguments:\n\ng Taylor series\norder Order of derivative\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#FeynmanDiagram.Taylor.set_variables-Union{Tuple{T}, Tuple{R}, Tuple{Type{R}, Vector{T}}} where {R, T<:AbstractString}","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"FeynmanDiagram.Taylor.set_variables","text":"set_variables([T::Type], names::String; [orders=get_orders(), numvars=-1])\n\nReturn a TaylorSeries{T} vector with each entry representing an independent variable. names defines the output for each variable (separated by a space). The default type T is Float64, and the default for orders is the one defined globally.\n\nIf numvars is not specified, it is inferred from names. If only one variable name is defined and numvars>1, it uses this name with subscripts for the different variables.\n\njulia> set_variables(Int, \"x y z\", orders=[4,4,4])\n3-element Array{TaylorSeries.Taylor{Int},1}:\n 1 x + 𝒪(x⁵y⁵z⁵)\n 1 y + 𝒪(x⁵y⁵z⁵)\n 1 z + 𝒪(x⁵y⁵z⁵)\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#FeynmanDiagram.Taylor.taylor_binomial-Tuple{Vector{Int64}, Vector{Int64}}","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"FeynmanDiagram.Taylor.taylor_binomial","text":"function taylor_binomial(o1::Vector{Int}, o2::Vector{Int})\n\nReturn the taylor binomial prefactor when product two high-order derivatives with order o1 and o2.\n\n# Arguments:\n- `o1` Order of first derivative\n- `o2` Order of second derivative\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#FeynmanDiagram.Taylor.taylor_factorial-Tuple{Vector{Int64}}","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"FeynmanDiagram.Taylor.taylor_factorial","text":"function taylor_factorial(o::Vector{Int})\n\nReturn the taylor factorial prefactor with order o.\n\n# Arguments:\n- `o` Order of the taylor coefficient\n\n\n\n\n\n","category":"method"},{"location":"lib/taylorseries/#FeynmanDiagram.Taylor.use_show_default-Tuple{Bool}","page":"Taylor expansions in independent variables (support AbstractGraph)","title":"FeynmanDiagram.Taylor.use_show_default","text":"use_Base_show(d::Bool) --> nothing\n\nUse Base.show_default method (default show method in Base), or a custom display. The initial value is false, so customized display is used.\n\n\n\n\n\n","category":"method"},{"location":"manual/hubbard_atom/#Hubbard-Atom-as-a-Test-Case","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"","category":"section"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"One may use the Hubbard atom model to benchmark the Feynman diagrams generated by FeynmanDiagram.jl. In this note, we derive the vertex functions and their power expansion in interaction. The test is implemented in the test folder.","category":"page"},{"location":"manual/hubbard_atom/#Hamiltonian","page":"Hubbard Atom as a Test Case","title":"1 Hamiltonian","text":"","category":"section"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"hatH=U n_uparrow n_downarrow-mu (n_uparrow+n_downarrow)","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"where U is the on-site interaction, mu is the chemical potential.","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"The eigenstates are,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"left 0 right\n: E_0=0.\nleft uparrow right\nand left downarrow right : E_1=-mu.\nleft uparrow downarrow right\n: E_2=U-2mu.","category":"page"},{"location":"manual/hubbard_atom/#Partition-sum","page":"Hubbard Atom as a Test Case","title":"2 Partition sum","text":"","category":"section"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"Z=1+2e^mubeta+e^-beta(U-2mu)","category":"page"},{"location":"manual/hubbard_atom/#Two-point-Green's-function","page":"Hubbard Atom as a Test Case","title":"3 Two-point Green's function","text":"","category":"section"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"For the imaginary-time tau0,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"G(tau)=lefttextT c_uparrow(tau) c^+_uparrow(0) right=frac1Zsum_n left nrighte^-(beta-tau)Hc_uparrow e^-tau H c^+_uparrow left n right","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"Only the states left 0 right and left downarrow right contribute,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"G(tau)=frace^mu tau+e^mu betae^-(U-mu)tauZ","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"For example, at half filling mu=U2, there is one particle and,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"G(tau)=frace^-Utau2+e^-U(beta-tau)22(1+e^-Ubeta2)","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"Transform to the Matsubara frequency,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"G(iomega_n) = int_0^beta G(tau)e^iomega_ntau dtau","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"G(iomega_n)=-frac1Zleft(frac1+e^mu betaiomega_n+mu+e^mubetafrac1+e^-(U-mu)betaiomega_n-(U-mu)right)","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"By setting U=0, one can show that the above dressed Green's function reduce to the bare one,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"g(iomega_n) = -frac1iomega_n+mu","category":"page"},{"location":"manual/hubbard_atom/#Self-energy","page":"Hubbard Atom as a Test Case","title":"4 Self-energy","text":"","category":"section"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"The self-energy is defined as G^-1(iomega_n)=g^-1(iomega_n)-Sigma(iomega_n), so that","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"Sigma(iomega_n) = fracU e^beta mu (mu +i w) left(e^beta mu +e^beta Uright)e^beta U (-mu +U-i w)+e^beta (mu +U) (-2 mu +U-2 i w)-e^2 beta mu (mu +i w)","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"For benchmark purpose, here we also provide the power expansion of the self-energy at the low-energy limit omega_0 = pi beta with mu=0,","category":"page"},{"location":"manual/hubbard_atom/","page":"Hubbard Atom as a Test Case","title":"Hubbard Atom as a Test Case","text":"Sigma(iomega_0) = -fracU2+frac(pi +2 i) beta U^28 pi -fracleft(pi ^2-4right) beta ^2 U^332 pi ^2-fracleft(24 i-12 pi +6 i pi ^2+pi ^3right) beta ^3 U^4384 pi ^3+fracleft(-48-48 i pi -24 pi ^2+12 i pi ^3+5 pi ^4right) beta ^4 U^51536 pi ^4+Oleft(U^6right)","category":"page"},{"location":"","page":"Home","title":"Home","text":"CurrentModule = FeynmanDiagram","category":"page"},{"location":"#FeynmanDiagram","page":"Home","title":"FeynmanDiagram","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Documentation for FeynmanDiagram.","category":"page"},{"location":"","page":"Home","title":"Home","text":"","category":"page"},{"location":"","page":"Home","title":"Home","text":"Modules = [FeynmanDiagram]","category":"page"},{"location":"#Library-Outline","page":"Home","title":"Library Outline","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Pages = [\n \"lib/operator.md\",\n \"lib/computgraph.md\",\n \"lib/taylorseries.md\",\n \"lib/frontend.md\",\n \"lib/GV.md\",\n \"lib/parquet.md\",\n \"lib/backend.md\",\n]\nDepth = 2","category":"page"},{"location":"lib/GV/#GV-expansion-to-a-computational-graph","page":"GV expansion to a computational graph","title":"GV expansion to a computational graph","text":"","category":"section"},{"location":"lib/GV/#API","page":"GV expansion to a computational graph","title":"API","text":"","category":"section"},{"location":"lib/GV/","page":"GV expansion to a computational graph","title":"GV expansion to a computational graph","text":"Modules = [FeynmanDiagram.GV]","category":"page"},{"location":"lib/GV/#FeynmanDiagram.FrontEnds.GV.diagsGV","page":"GV expansion to a computational graph","title":"FeynmanDiagram.FrontEnds.GV.diagsGV","text":"function diagsGV(type::Symbol, order::Int, GOrder::Int=0, VerOrder::Int=0;\n labelProd::Union{Nothing,LabelProduct}=nothing, spinPolarPara::Float64=0.0,\n tau_labels::Union{Nothing,Vector{Int}}=nothing, filter::Vector{Filter}=[NoHartree])\n\nGenerates a `Vector{FeynmanGraph}`: the given-`type` diagrams with static interactions of a given order, where the actual order of diagrams equals to `order + VerOrder + 2 * GOrder`.\nGenerates a `LabelProduct`: `labelProd` with inputs `tau_labels` and all the possible momenta-loop basis. \nGenerates external tau labels Vector{Vector{Int}}. The i-th labels (Vector{Int}) corresponds to the i-th `FeynmanGraph` in `Vector{FeynmanGraph}`.\n\nArguments:\n\ntype (Symbol): The type of the diagrams, including :spinPolar, :chargePolar, :sigma, :green, or :freeEnergy.\norder (Int): The order of the diagrams without counterterms.\nGOrder (Int, optional): The order of self-energy counterterms (defaults to 0).\nVerOrder (Int, optional): The order of interaction counterterms (defaults to 0).\nlabelProd (Union{Nothing,LabelProduct}=nothing, optional): The initial cartesian QuantumOperator.label product (defaults to nothing).\nspinPolarPara (Float64, optional): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).\ntau_labels(Union{Nothing, Vector{Int}}, optional): The labels for the discrete time of each vertex. (defaults to nothing).\n\nReturns\n\nA tuple (diagrams, fermi_labelProd, bose_labelProd, extT_labels) where \n\ndiagrams is a Vector{FeynmanGraph} object representing the diagrams, \nlabelProd is a LabelProduct object containing the labels for the leaves of graphs, \nextT_labels is a Vector{Union{Tuple,Vector{Int}}} object containing the external tau labels for each FeynmanGraph in diagrams.\n\n\n\n\n\n","category":"function"},{"location":"lib/GV/#FeynmanDiagram.FrontEnds.GV.diagsGV_ver4-Tuple{Int64}","page":"GV expansion to a computational graph","title":"FeynmanDiagram.FrontEnds.GV.diagsGV_ver4","text":"function diagsGV_ver4(order::Int; spinPolarPara::Float64=0.0, filter::Vector{Filter}=[NoHartree], channels=[PHr, PHEr, PPr, Alli])\n\nGenerates a `Vector{Graph}`: the 4-point vertex diagrams with static interactions of a given order.\n\nArguments:\n\norder (Int): The order of the diagrams without counterterms.\nspinPolarPara (Float64, optional): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).\nchannels (optional): The channels for the diagrams, defaults to [PHr, PHEr, PPr, Alli].\nfilter (optional): Filter criteria for the diagrams, defaults to [NoHartree].\n\n\n\n\n\n","category":"method"},{"location":"lib/GV/#FeynmanDiagram.FrontEnds.GV.read_diagrams-Tuple{AbstractString}","page":"GV expansion to a computational graph","title":"FeynmanDiagram.FrontEnds.GV.read_diagrams","text":"function read_diagrams(filename::AbstractString; loopPool::Union{LoopPool,Nothing}=nothing,\n dim::Int=3, tau_labels::Union{Nothing,Vector{Int}}=nothing, GTypes=[0, 1], VTypes=[0, 1, 2],\n keywords::Vector{String}=[\"Polarization\", \"DiagNum\", \"Order\", \"GNum\", \"Ver4Num\", \"LoopNum\", \"ExtLoopIndex\",\n \"DummyLoopIndex\", \"TauNum\", \"ExtTauIndex\", \"DummyTauIndex\"])\n\nReads a GV_diagrams file and returns FeynmanGraph of diagrams in this file \nand the corresponding `LabelProduct` objects, which are used to keep track of QuantumOperator.label.\n\nArguments:\n\nfilename (AbstractString): The path to the file containing the diagrams.\nloopPool (Union{LoopPool,Nothing}): An optional LoopPool object. If not provided, a new one will be created.\nspinPolarPara (Float64): The spin-polarization parameter (nup - ndown) / (nup + ndown) (defaults to 0.0).\ndim (Int): The dimension of the system, used to initialize the LoopPool object. Default is 3.\ntau_labels (Union{Nothing,Vector{Int}}): The labels for the Tau objects in the diagrams. If not provided, they will be set to the integers from 1 to tauNum.\nGTypes (Vector{Int}): The labels for the fermionic G objects in the diagrams. Default is [0, 1].\nVTypes (Vector{Int}): The labels for the bosonic V objects in the diagrams. Default is [0, 1, 2].\nkeywords (Vector{String}): A set of keywords used to extract information from the file. Default is [\"Polarization\", \"DiagNum\", \"Order\", \"GNum\", \"Ver4Num\", \"LoopNum\", \"ExtLoopIndex\", \"DummyLoopIndex\", \"TauNum\", \"ExtTauIndex\", \"DummyTauIndex\"].\n\nReturns\n\nA tuple (diagrams, fermi_labelProd, bose_labelProd) where \n\ndiagrams is a FeynmanGraph object representing the diagrams, \nfermi_labelProd is a LabelProduct object containing the labels for the fermionic G objects in the diagrams, \nbose_labelProd is a LabelProduct object containing the labels for the bosonic W objects in the diagrams.\n\n\n\n\n\n","category":"method"}]
}