-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from numericalEFT/computgraph
Computgraph
- Loading branch information
Showing
134 changed files
with
325,585 additions
and
14,785 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
version: | ||
- "1.6" | ||
# - "1.6" | ||
# - "nightly" | ||
- "1.9" | ||
os: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using FeynmanDiagram | ||
using FeynmanDiagram.Taylor | ||
using FeynmanDiagram.ComputationalGraphs: | ||
eval!, Leaves | ||
using FeynmanDiagram.Utility: | ||
taylorexpansion!, count_operation | ||
|
||
|
||
function assign_leaves(g::FeynmanGraph, taylormap) | ||
leafmap = Dict{Int,Int}() | ||
leafvec = Vector{Float64}() | ||
idx = 0 | ||
for leaf in Leaves(g) | ||
taylor = taylormap[leaf.id] | ||
for (order, coeff) in taylor.coeffs | ||
idx += 1 | ||
push!(leafvec, 1.0 / taylor_factorial(order)) | ||
leafmap[coeff.id] = idx | ||
print("assign $(order) $(coeff.id) $(taylor_factorial(order)) $(leafvec[idx])\n") | ||
end | ||
end | ||
return leafmap, leafvec | ||
end | ||
|
||
#dict_g, fl, bl, leafmap = diagdictGV(:sigma, [(2, 0, 0), (2, 0, 1), (2, 0, 2), (2, 1, 0), (2, 1, 1), (2, 2, 0), (2, 1, 2), (2, 2, 2)], 3) | ||
dict_g, lp, leafmap = diagdictGV(:sigma, [(3, 0, 0), (3, 0, 3), (3, 0, 2), (3, 0, 1)]) | ||
g = dict_g[(3, 0, 0)] | ||
|
||
set_variables("x y", orders=[1, 3]) | ||
propagator_var = ([true, false], [false, true]) # Specify variable dependence of fermi (first element) and bose (second element) particles. | ||
t, taylormap, from_coeff_map = taylorexpansion!(g[1][1], propagator_var) | ||
|
||
for (order, graph) in dict_g | ||
if graph[2][1] == g[2][1] | ||
idx = 1 | ||
else | ||
idx = 2 | ||
end | ||
print("$(count_operation(t.coeffs[[order[2],order[3]]]))\n") | ||
print("$(count_operation(graph[1][idx]))\n") | ||
print("$(order) $(eval!(graph[1][idx])) $(eval!(t.coeffs[[order[2],order[3]]]))\n") | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using FeynmanDiagram | ||
using FeynmanDiagram.Taylor | ||
using FeynmanDiagram.ComputationalGraphs: | ||
eval!, forwardAD, node_derivative, backAD, build_all_leaf_derivative | ||
using FeynmanDiagram.Utility: | ||
taylorexpansion!, build_derivative_backAD!, count_operation | ||
|
||
function benchmark_AD(glist::Vector{T}) where {T<:Graph} | ||
#taylormap = Dict{Int,TaylorSeries{T}}() | ||
totaloperation = [0, 0] | ||
taylorlist = Vector{TaylorSeries{T}}() | ||
for g in glist | ||
var_dependence = Dict{Int,Vector{Bool}}() | ||
for leaf in FeynmanDiagram.Leaves(g) | ||
var_dependence[leaf.id] = [true for _ in 1:get_numvars()] | ||
end | ||
@time t, taylormap, from_coeff_map = taylorexpansion!(g, var_dependence) | ||
|
||
|
||
operation = count_operation(t) | ||
totaloperation = totaloperation + operation | ||
push!(taylorlist, t) | ||
print("operation number: $(operation)\n") | ||
t_compare, leaftaylor = build_derivative_backAD!(g) | ||
for (order, coeff) in (t_compare.coeffs) | ||
@assert (eval!(coeff)) == (eval!(Taylor.taylor_factorial(order) * t.coeffs[order])) | ||
end | ||
end | ||
|
||
total_uniqueoperation = count_operation(taylorlist) | ||
print(" total operation number: $(length(taylorlist)) $(totaloperation) $(total_uniqueoperation)\n") | ||
return total_uniqueoperation | ||
end | ||
g1 = Graph([]) | ||
g2 = Graph([]) | ||
g3 = Graph([]) #, factor=2.0) | ||
g4 = Graph([]) | ||
g5 = Graph([]) | ||
g6 = Graph([]) | ||
G3 = g1 | ||
G4 = 1.0 * g1 * g2 | ||
G5 = 1.0 * (3.0 * G3 + 0.5 * G4) | ||
G6 = (1.0 * g1 + 2.0 * g2) * (g1 + g3) | ||
|
||
using FeynmanDiagram.Taylor: | ||
TaylorSeries, getcoeff, set_variables | ||
|
||
set_variables("x y", orders=[3, 2]) | ||
|
||
benchmark_AD([G3, G4, G5, G6]) | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
TaylorSeries | ||
A Julia package for Taylor expansions in one or more independent variables. | ||
The basic constructors is [`TaylorSeries`](@ref). | ||
""" | ||
module Taylor | ||
|
||
using ..ComputationalGraphs | ||
#using Markdown | ||
|
||
|
||
#export show_params_TaylorN, show_monomials, displayBigO, use_show_default, | ||
|
||
include("parameter.jl") | ||
include("constructors.jl") | ||
include("print.jl") | ||
include("arithmetic.jl") | ||
export TaylorSeries | ||
|
||
export get_orders, get_numvars, | ||
set_variables, get_variables, | ||
get_variable_names, get_variable_symbols, | ||
displayBigO, use_show_default, | ||
getcoeff, taylor_factorial | ||
|
||
end # module |
Oops, something went wrong.