Utility
API
FeynmanDiagram.Utility.taylorAD
— Methodfunction taylorAD(graphs::Vector{G}, deriv_orders::Vector{Int}, leaf_dep_funcs::Vector{Function};
dict_graphs::Dict{Vector{Int},Vector{Graph}}=Dict{Vector{Int},Vector{Graph}}()
) where {G<:Graph}
Performs Taylor-mode automatic differentiation (AD) on a vector of graphs, with the differentiation process tailored based on specified maximum orders of differentiation
and leaf dependency functions. It categorizes the differentiated graphs in a dictionary based on their derivative orders.
Parameters
graphs
: A vector of graphs to be differentiated.deriv_orders
: A vector of integers specifying the maximum orders of differentiation to apply to the graphs.leaf_dep_funcs
: A vector of functions determining the dependency of differentiation variables on the properties of leaves in the graphs.dict_graphs
: Optional. A dictionary for storing the output graphs, keyed by vectors of integers representing the specific differentiation orders. Defaults to an empty dictionary.
Returns
Dict{Vector{Int},Vector{Graph}}
: A dictionary containing the graphs processed through Taylor-mode AD, categorized by their differentiation orders.
Example Usage
# Define a vector of graphs
graphs = [g1, g2]
# Specify the maximum orders of differentiation
deriv_orders = [2, 3, 3]
# Define a vector of differentiation dependency functions for the properties of leaf.
# The first and second functions specify identify `BareGreenId` and `BareInteractionId` properties as the Green's function and interaction counterterms, respectively.
# The third function specifies the dependence of on the first external momentum of the leaf.
leaf_dep_funcs = [pr -> pr isa FrontEnds.BareGreenId, pr -> pr isa FrontEnds.BareInteractionId, pr -> pr.extK[1] != 0]
# Perform Taylor-mode AD and categorize the results. `result_dict` holds the AD results, organized by differentiation orders `[0:2, 0:3, 0:3]`.
result_dict = taylorAD(graphs, deriv_orders, leaf_dep_funcs)
FeynmanDiagram.Utility.taylorexpansion!
— Methodfunction taylorexpansion!(graph::FeynmanGraph{F,W}, var_dependence::Dict{Int,Vector{Bool}}=Dict{Int,Vector{Bool}}(); to_coeff_map::Dict{Int,TaylorSeries{G}}=Dict{Int,TaylorSeries{G}}()) where {F,W}
Return a taylor series of FeynmanGraph g, together with a map of between nodes of g and correponding taylor series.
Arguments:
graph
Target FeynmanGraphvar_dependence::Dict{Int,Vector{Bool}}
A dictionary that specifies the variable dependence of target graph leaves. Should map the id of each leaf to a Bool vector. The length of the vector should be the same as number of variables.to_coeff_map::Dict{Int,TaylorSeries}
A dicitonary that maps id of each node of target graph to its correponding taylor series.
FeynmanDiagram.Utility.taylorexpansion!
— Methodfunction taylorexpansion!(graph::G, var_dependence::Dict{Int,Vector{Bool}}=Dict{Int,Vector{Bool}}(); to_coeff_map::Dict{Int,TaylorSeries{G}}=Dict{Int,TaylorSeries{G}}()) where {G<:Graph}
Return a taylor series of graph g, together with a map of between nodes of g and correponding taylor series.
Arguments:
graph
Target graphvar_dependence::Dict{Int,Vector{Bool}}
A dictionary that specifies the variable dependence of target graph leaves. Should map the id of each leaf to a Bool vector. The length of the vector should be the same as number of variables.to_coeff_map::Dict{Int,TaylorSeries}
A dicitonary that maps id of each node of target graph to its correponding taylor series.
FeynmanDiagram.Utility.taylorexpansion!
— Methodfunction taylorexpansion!(graph::FeynmanGraph{F,W}, propagator_var::Tuple{Vector{Bool},Vector{Bool}}, label::Tuple{LabelProduct,LabelProduct}; to_coeff_map::Dict{Int,TaylorSeries{Graph{F,W}}}=Dict{Int,TaylorSeries{Graph{F,W}}}()) where {F,W}
Return a taylor series of FeynmanGraph g, together with a map of between nodes of g and correponding taylor series. In this set up, the leaves that are the same type of propagators (fermi or bose) depend on the same set of variables,
whereas other types of Feynman diagrams (such as vertices) depends on no variables that need to be differentiated (for AD purpose, they are just constants).
Arguments:
graph
Target FeynmanGraphpropagator_var::Tuple{Vector{Bool},Vector{Bool}}
A Tuple that specifies the variable dependence of fermi (first element) and bose propagator (second element). The dependence is given by a vector of the length same as the number of variables.label::Tuple{LabelProduct,LabelProduct}
A Tuple fermi (first element) and bose LabelProduct (second element).to_coeff_map::Dict{Int,TaylorSeries}
A dicitonary that maps id of each node of target diagram to its correponding taylor series.
FeynmanDiagram.Utility.taylorexpansion!
— Methodfunction taylorexpansion!(graph::Graph{F,W}, propagator_var::Dict{DataType,Vector{Bool}};
to_coeff_map::Dict{Int,TaylorSeries{Graph{F,W}}}=Dict{Int,TaylorSeries{Graph{F,W}}}()) where {F,W}
Return a taylor series of Graph g, together with a map of between nodes of g and correponding taylor series. In this set up, the leaves that are the same type of diagrams (such as Green functions) depend on the same set of variables.
Arguments:
graph
Target Graphpropagator_var::Dict{DataType,Vector{Bool}}
A dictionary that specifies the variable dependence of different types of diagrams. Should be a map between DataTypes in DiagramID and Bool vectors. The dependence is given by a vector of the length same as the number of variables.to_coeff_map::Dict{Int,TaylorSeries}
A dicitonary that maps id of each node of target diagram to its correponding taylor series.
FeynmanDiagram.Utility.taylorexpansion_withmap
— Methodtaylorexpansion_withmap(g::G; coeffmode=true, var::Vector{Int}=collect(1:get_numvars())) where {G<:Graph}
Return a taylor series of graph g, together with a map of chain relationships between generated derivatives.
This function is only internally used for constructing high order derivatives by naive nested forward AD.
It is only for banch mark purpose and not exported.
Arguments:
g
Target graphcoeffmode
If true, the generated taylor series saves taylor coefficients with the factorial prefactor. If false, the taylor series saves derivatives insteadvar
The index of variables graph depends on