Feynman Diagram
Diagrams as an AbstractTree
NumericalEFT.FeynmanDiagram.DiagTree.BareGreenNId
— Typetime-ordered N-point Bare Green's function
NumericalEFT.FeynmanDiagram.DiagTree.BareHoppingId
— Typehopping function c⁺c⁻
NumericalEFT.FeynmanDiagram.DiagTree.ConnectedGreenNId
— Typetime-ordered N-point Composite Green's function
NumericalEFT.FeynmanDiagram.DiagTree.Diagram
— Typemutable struct Diagram{W}
struct of a diagram. A diagram of a sum or produce of various subdiagrams.
Members
- hash::Int : the unique hash number to identify the diagram
- name::Symbol : name of the diagram
- id::DiagramId : diagram id
- operator::Operator : operation, support Sum() and Prod()
- factor::W : additional factor of the diagram
- subdiagram::Vector{Diagram{W}} : vector of sub-diagrams
- weight::W : weight of the diagram
NumericalEFT.FeynmanDiagram.DiagTree.DiagramId
— Typeabstract type DiagramId end
The abstract type of all diagrams/subdiagrams/bare propagators
NumericalEFT.FeynmanDiagram.DiagTree.GreenNId
— Typetime-ordered N-point Composite Green's function
NumericalEFT.FeynmanDiagram.DiagTree.PropagatorId
— Typeabstract type PropagatorId <: DiagramId end
The abstract type of all bare propagators
NumericalEFT.FeynmanDiagram.DiagTree.derivative
— Methodfunction derivative(diags::Union{Diagram,Tuple,AbstractVector}, ::Type{ID}, order::Int) where {ID<:PropagatorId}
Automatic differentiation derivative on the diagrams
Arguments
- diags : diagrams to take derivative
- ID : DiagramId to apply the differentiation
- order::Int : derivative order
NumericalEFT.FeynmanDiagram.DiagTree.derivative
— Methodfunction 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
NumericalEFT.FeynmanDiagram.DiagTree.plot_tree
— Methodfunction plot_tree(diag::Diagram; verbose = 0, maxdepth = 6)
Visualize the diagram tree using ete3 python package
#Arguments
diag
: the Diagram struct to visualizeverbose=0
: the amount of information to showmaxdepth=6
: deepest level of the diagram tree to show
NumericalEFT.FeynmanDiagram.DiagTree.removeDuplicatedLeaves!
— MethodremoveDuplicatedLeaves!(diags::AbstractVector; verbose = 0)
remove duplicated nodes such as: ---> ver4 ---> InteractionId. Leaf will not be touched!
NumericalEFT.FeynmanDiagram.DiagTree.removeHartreeFock!
— Methodfunction 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!
- The return value is always nothing
NumericalEFT.FeynmanDiagram.DiagTree.removeOneChildParent!
— MethodremoveOneChildParent!(diags::AbstractVector; verbose = 0)
remove duplicated nodes such as: ---> ver4 ---> InteractionId. Leaf will not be touched!
Diagrams as an Expression Tree
NumericalEFT.FeynmanDiagram.ExprTree.CachedPool
— Typestruct CachedPool{O,T}
Use this pool to host the objects that are heavy to evaluate so that one wants to cache their status.
The user should defines a compare
Members
- name::Symbol : name of the pool
- object::O : object
- current::T : current status
- new::T : the new status wants to assign later
- version::Int128 : the current version
- excited::Bool : if set to excited, then the current status needs to be replaced with the new status
NumericalEFT.FeynmanDiagram.ExprTree.ExpressionTree
— Typemutable struct ExpressionTree{V,PARA,F,W}
Diagram Object represents a set of Feynman diagrams in an experssion tree (forest) structure
Members
- name::Symbol : Name of the tree
- loopBasis::V : Tuple of pools of cached basis in a format of (BasisPool1, BasisPool2, ...)
- node::CachedPool{Node{PARA,F},W} : Pool of the nodes in the diagram tree
- root::Vector{Int} : indices of the cached nodes that are the root(s) of the diagram tree. Each element corresponds to one root.
NumericalEFT.FeynmanDiagram.ExprTree.LoopPool
— Typestruct 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).
NumericalEFT.FeynmanDiagram.ExprTree.Node
— Typemutable 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.
NumericalEFT.FeynmanDiagram.ExprTree.addnode!
— Methodfunction 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.
Arguments
- diag::ExpressionTree : diagrammatic experssion tree.
- operator::Int : #1: multiply, 2: add, ...
- name : name of the node
- 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.
NumericalEFT.FeynmanDiagram.ExprTree.addpropagator!
— Methodfunction 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.
NumericalEFT.FeynmanDiagram.ExprTree.getNode
— Methodfunction getNode(diag::Diagrams, nidx::Int)
get Node in the diag with the index nidx.
NumericalEFT.FeynmanDiagram.ExprTree.getNodeWeight
— Methodfunction getNodeWeight(tree, nidx::Int)
get Node weight in the diagram experssion tree with the index nidx.
NumericalEFT.FeynmanDiagram.ExprTree.showTree
— MethodshowTree(diag::Diagrams, _root = diag.root[end]; verbose = 0, depth = 999)
Visualize the diagram tree using ete3 python package
#Arguments
diag
: the Diagrams struct to visualize_root
: the index of the root node to visualizeverbose=0
: the amount of information to showdepth=999
: deepest level of the diagram tree to show
Parquet Algorithm to Build Diagrams
NumericalEFT.FeynmanDiagram.Parquet.ParquetBlocks
— Typestruct ParquetBlocks
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 bubblesppi
: channels of left sub-vertex for the particle-particle bubbleΓ4
: channels of right sub-vertex of all channels
NumericalEFT.FeynmanDiagram.Parquet.green
— Methodgreen(para::DiagPara, extK = DiagTree.getK(para.totalLoopNum, 1), extT = para.hasTau ? (1, 2) : (0, 0), subdiagram = false;
name = :G, resetuid = false, blocks::ParquetBlocks=ParquetBlocks())
Build composite Green's function.
By definition, para.firstTauIdx is the first Tau index of the left most self-energy subdiagram.
Arguments
para
: parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdxextK
: basis of external loop.extT
: [Tau index of the left leg, Tau index of the right leg]subdiagram
: a sub-vertex or notname
: name of the diagramresetuid
: restart uid count from 1blocks
: building blocks of the Parquet equation. See the struct ParquetBlocks for more details.
Output
- A Diagram object or nothing if the Green's function is illegal.
NumericalEFT.FeynmanDiagram.Parquet.polarization
— Methodfunction polarization(para, extK = DiagTree.getK(para.totalLoopNum, 1), subdiagram = false; name = :Π, resetuid = false, blocks::ParquetBlocks=ParquetBlocks())
Generate polarization diagrams using Parquet Algorithm.
Arguments
para
: parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdxextK
: basis of external loop.subdiagram
: a sub-vertex or notname
: name of the vertexresetuid
: restart uid count from 1blocks
: building blocks of the Parquet equation. See the struct ParquetBlocks for more details.
Output
- A DataFrame with fields
:response
,:diagram
,:hash
. - All polarization share the same external Tau index. With imaginary-time variables, they are extT = (para.firstTauIdx, para.firstTauIdx+1)
NumericalEFT.FeynmanDiagram.Parquet.sigma
— Methodfunction 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, firstTauIdxextK
: basis of external loop.subdiagram
: a sub-vertex or notname
: name of the diagramresetuid
: restart uid count from 1blocks
: 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
NumericalEFT.FeynmanDiagram.Parquet.vertex3
— Methodfunction vertex3(para, extK = [DiagTree.getK(para.totalLoopNum, 1), DiagTree.getK(para.totalLoopNum, 2)],
subdiagram = false; name = :Γ3, chan = [PHr, PHEr, PPr, Alli], resetuid = false,
blocks::ParquetBlocks=ParquetBlocks()
)
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, firstTauIdxextK
: basis of external loops as a vector [bosonic leg, fermionic in, fermionic out].subdiagram
: a sub-vertex or notname
: name of the vertexchan
: vector of channels of the current 4-vertex.resetuid
: restart uid count from 1blocks
: building blocks of the Parquet equation. See the struct ParquetBlocks for more details.
Output
- A DataFrame with fields :response, :extT, :diagram, :hash.
NumericalEFT.FeynmanDiagram.Parquet.vertex4
— Methodvertex4(para::DiagPara,
extK = [DiagTree.getK(para.totalLoopNum, 1), DiagTree.getK(para.totalLoopNum, 2), DiagTree.getK(para.totalLoopNum, 3)],
chan::AbstractVector = [PHr, PHEr, PPr, Alli],
subdiagram = false;
level = 1, name = :none, resetuid = false,
subchannel::Symbol=:All, #:All, :W, :Lver3, :Rver3, :RPA
blocks::ParquetBlocks=ParquetBlocks(),
blockstoplevel::ParquetBlocks=blocks
)
Generate 4-vertex diagrams using Parquet Algorithm
Arguments
para
: parameters. It should provide internalLoopNum, interactionTauNum, firstTauIdxextK
: basis of external loops as a vector [left in, left out, right in, right out].chan
: vector of channels of the current 4-vertex.subdiagram
: a sub-vertex or notname
: name of the vertexlevel
: level in the diagram treeresetuid
: restart uid count from 1subchannel
: :All, :W, :Lver3, :Rver3, :RPA to select all, W-interaction, left-vertex-correction, right-vertex-correction or RPA-interaction diagramsblocks
: building blocks of the Parquet equation. See the struct ParquetBlocks for more details.blockstoplevel
: building blocks of the Parquet equation at the toplevel. See the struct ParquetBlocks for more details.
Output
- A DataFrame with fields :response, :type, :extT, :diagram, :hash
Usage
julia> using FeynmanDiagram
ERROR: ArgumentError: Package FeynmanDiagram not found in current path, maybe you meant `import/using ..FeynmanDiagram`. - Otherwise, run `import Pkg; Pkg.add("FeynmanDiagram")` to install the FeynmanDiagram package.
julia> para = GenericPara(diagType = Ver4Diag, innerLoopNum = 1, hasTau = true);
ERROR: UndefVarError: Ver4Diag not defined
julia> Parquet.vertex4(para)
ERROR: UndefVarError: Parquet not defined
julia> para = GenericPara(diagType = Ver3Diag, innerLoopNum = 1, hasTau = true);
ERROR: UndefVarError: Ver3Diag not defined
julia> Parquet.vertex3(para)
ERROR: UndefVarError: Parquet not defined
julia> para = GenericPara(diagType = SigmaDiag, innerLoopNum = 1, hasTau = true);
ERROR: UndefVarError: SigmaDiag not defined
julia> Parquet.sigma(para)
ERROR: UndefVarError: Parquet not defined
julia> para = GenericPara(diagType = PolarDiag, innerLoopNum = 1, hasTau = true);
ERROR: UndefVarError: PolarDiag not defined
julia> Parquet.polarization(para)
ERROR: UndefVarError: Parquet not defined