Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release v1.0.0 #179

Merged
merged 167 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
a513f03
add FeynCalc.jl
Apr 4, 2023
112cb8f
refactor FeynCalc_FermiL
Apr 5, 2023
168822b
solve merge conflict
peter0627ustc Apr 10, 2023
3604247
Merge branch 'computgraph_pchou' into computgraph_zhiyi
peter0627ustc May 26, 2023
19219fc
add SelfEnergygraph
peter0627ustc Jun 25, 2023
66da488
Merge branch 'computgraph' into computgraph_zhiyi
peter0627ustc Nov 10, 2023
ab58931
merge new update
peter0627ustc Nov 11, 2023
f8829af
add mindspore.jl
Nov 20, 2023
5e5917d
add toMindspore.jl
peter0627ustc Nov 21, 2023
46566ec
update toMindspore.jl
peter0627ustc Nov 24, 2023
7c178c3
merge conflict
Nov 24, 2023
b23453c
fix bug
peter0627ustc Nov 24, 2023
0bdf095
Merge branch 'computgraph_zhiyi' of https://github.com/numericalEFT/F…
Nov 24, 2023
4b3f75b
refactor interface to mindspore for AD
peter0627ustc Nov 24, 2023
1442796
Merge branch 'computgraph_zhiyi' of https://github.com/numericalEFT/F…
Nov 24, 2023
8111fc9
fix bug
peter0627ustc Nov 24, 2023
d886b5b
Merge branch 'computgraph_zhiyi' of https://github.com/numericalEFT/F…
Nov 24, 2023
13c06f6
add a dict mapping the graph_id to the leaf_id
Nov 30, 2023
2d940c8
clean file
Nov 30, 2023
5eb3e05
Merge branch 'computgraph' into computgraph_zhiyi
Nov 30, 2023
221565f
Merge pull request #161 from numericalEFT/computgraph_zhiyi
peter0627ustc Nov 30, 2023
96834c7
add general leafstates (WIP)
houpc Dec 2, 2023
dada182
add properties field to Graph. Change taylor expansion api accordingly
fsxbhyy Dec 4, 2023
2e33293
Merge remote-tracking branch 'origin/master' into tao_AD
fsxbhyy Dec 4, 2023
dd29172
Merge pull request #162 from numericalEFT/tao_AD
houpc Dec 4, 2023
040952b
add parquet front end(WIP)
houpc Dec 4, 2023
13b00e8
Merge from computgraph
houpc Dec 4, 2023
71d2ee5
refactor compiler_python for supporting both jax and mindspore framework
Dec 4, 2023
39b4f28
use Graph's field orders in TaylorSeries
houpc Dec 4, 2023
f398cd0
add choices for mindspore or jax in the compilerfunction
Dec 4, 2023
13b2fbc
add parquet+AD in front end
houpc Dec 4, 2023
cfe8054
Merge pull request #163 from numericalEFT/computgraph_zhiyi
peter0627ustc Dec 6, 2023
4874728
add for creating dot file for ComputationalGraph
Dec 6, 2023
3d9ba4d
Merge branch 'computgraph_pchou' into computgraph_zhiyi
Dec 6, 2023
65aa72b
Merge pull request #164 from numericalEFT/computgraph_pchou
houpc Dec 7, 2023
9433920
Merge branch 'computgraph' into computgraph_zhiyi
peter0627ustc Dec 13, 2023
5378704
fix bugs for same subgraphs in to_dot.jl
peter0627ustc Dec 14, 2023
0f6c507
refactor the leaf name with its type in to_dot.jl
peter0627ustc Dec 14, 2023
c347b76
refactor the format to_dot.jl
peter0627ustc Dec 14, 2023
a4aec02
Merge branch 'computgraph_zhiyi' of https://github.com/numericalEFT/F…
Dec 14, 2023
7485eab
Merge pull request #166 from numericalEFT/computgraph_zhiyi
peter0627ustc Dec 19, 2023
ec8fdec
add count expanded operators
houpc Dec 19, 2023
9066881
restore settings.json
houpc Dec 19, 2023
f330d92
Merge branch 'computgraph' into computgraph_pchou
houpc Dec 19, 2023
7ef8905
modify compile_python for sampling
peter0627ustc Dec 19, 2023
9051a07
debug
peter0627ustc Dec 19, 2023
85debf7
Merge branch 'computgraph_zhiyi' of https://github.com/numericalEFT/F…
Dec 19, 2023
408ccae
debug
peter0627ustc Dec 19, 2023
16fed0e
Merge branch 'computgraph_zhiyi' of https://github.com/numericalEFT/F…
Dec 19, 2023
98ded11
debug
peter0627ustc Dec 19, 2023
a22c64b
Merge branches 'computgraph_zhiyi' and 'computgraph_zhiyi' of https:/…
Dec 19, 2023
f74169a
debug
peter0627ustc Dec 19, 2023
df74886
Merge branch 'computgraph_zhiyi' of https://github.com/numericalEFT/F…
Dec 19, 2023
bf78162
delete redundancy
Dec 19, 2023
f35f2be
delete redundancy
Dec 19, 2023
5dff476
delete redundancy
Dec 19, 2023
3cbe8c8
Add AbstractGraph function `disconnect_subgraphs!`
dcerkoney Dec 19, 2023
e1914fe
modify python compiler
Dec 20, 2023
69b8d02
Add transformation/optimization to remove zero-valued subgraphs
dcerkoney Dec 20, 2023
ad2b25d
Bugfix in function `to_dot_str`
dcerkoney Dec 20, 2023
1a74871
debug in compiler_python
peter0627ustc Dec 21, 2023
ba2c750
Merge branch 'computgraph_daniel' into computgraph_zhiyi
peter0627ustc Dec 21, 2023
dfa5e1b
merge daniel's branch and modified to_dot.jl
peter0627ustc Dec 21, 2023
aac010c
Merge pull request #168 from numericalEFT/computgraph_daniel
dcerkoney Dec 22, 2023
df678bd
Merge branch 'computgraph' into computgraph_pchou
houpc Dec 22, 2023
74e7257
Merge branch 'computgraph_zhiyi' into computgraph_pchou
houpc Dec 22, 2023
77236ef
modified fontsize in dot file
peter0627ustc Dec 22, 2023
466bddf
Merge branch 'computgraph' into computgraph_zhiyi
peter0627ustc Dec 22, 2023
3317708
Merge pull request #167 from numericalEFT/computgraph_zhiyi
peter0627ustc Dec 22, 2023
94d854d
update the optimization from DiagTree to Graph
houpc Dec 22, 2023
a50bc01
Merge from computgraph_zhiyi
houpc Dec 22, 2023
f256ae9
naive optimize for unique allnodes
houpc Dec 22, 2023
f7ef86e
add open_parenthese and merge_prod
fsxbhyy Dec 22, 2023
12af45e
Merge remote-tracking branch 'origin/computgraph' into tao_AD
fsxbhyy Dec 22, 2023
2a4419a
minor change
fsxbhyy Dec 22, 2023
a580242
wip
kunyuan Dec 23, 2023
d9a2c5c
optimize the G*G in parquet
kunyuan Dec 23, 2023
2fed8d9
fix isequiv bug (wip)
houpc Dec 23, 2023
adf1065
test spinless
kunyuan Dec 23, 2023
cd28fdb
bugfix
houpc Dec 23, 2023
ffb77c0
Merge branch 'computgraph_pchou_kun' into computgraph_pchou
houpc Dec 23, 2023
33a95ed
fix isequiv bug
houpc Dec 23, 2023
ca4d075
Merge branch 'tao_AD' into computgraph_pchou
houpc Dec 23, 2023
f777b1b
fix bug and polish to_dot_parquet
kunyuan Dec 23, 2023
09c1381
testing to_dot
kunyuan Dec 23, 2023
cd91faf
Merge pull request #170 from numericalEFT/tao_AD
fsxbhyy Dec 23, 2023
a59468c
Merge branch 'tao_AD' into computgraph_pchou
kunyuan Dec 23, 2023
09052c1
Merge branch 'computgraph_pchou' of https://github.com/numericalEFT/F…
houpc Dec 23, 2023
61d6798
bugfix in isequic
houpc Dec 23, 2023
9710b08
update remove_duplicated_nodes (wip)
houpc Dec 23, 2023
f1bf7a4
Merge branch 'computgraph_pchou' of https://github.com/numericalEFT/F…
kunyuan Dec 23, 2023
0f345d7
fix to_dot visualziation
kunyuan Dec 23, 2023
5193eeb
add flatten_sum
fsxbhyy Dec 23, 2023
6fee3c5
make inplace open_parenthese; add map to all new transforms
fsxbhyy Dec 24, 2023
f94f13c
minor change
fsxbhyy Dec 24, 2023
c3d9418
add an optimized version of remove_duplicated_nodes
houpc Dec 24, 2023
1624693
Merge branch 'computgraph_pchou' of https://github.com/numericalEFT/F…
houpc Dec 24, 2023
a126a67
Merge branch 'computgraph_pchou' into computgraph_zhiyi
peter0627ustc Dec 25, 2023
ed7c9b3
refactor to_dot
peter0627ustc Dec 25, 2023
c33b6e2
modify the arrowsize of the dot file
peter0627ustc Dec 25, 2023
cef74df
modify color
peter0627ustc Dec 25, 2023
5071110
fix bug in to_dot
peter0627ustc Dec 25, 2023
8fdf8e0
modify color
peter0627ustc Dec 25, 2023
34565c9
adjust the node color
peter0627ustc Dec 25, 2023
ba405b3
Merge pull request #171 from numericalEFT/tao_AD
fsxbhyy Dec 27, 2023
ec586d9
Merge pull request #169 from numericalEFT/computgraph_pchou
houpc Dec 28, 2023
e7e0efe
generating results
kunyuan Jan 4, 2024
f82be3c
remove weight datatype in DiagPara
kunyuan Jan 4, 2024
538057a
update vertex4 in GV
houpc Jan 7, 2024
4dc4408
Merge branch 'computgraph_parquet' into computgraph_pchou
houpc Jan 8, 2024
ee79c8f
remove factor
houpc Jan 9, 2024
63bbd9e
move diagram_tree, expression_tree, parquet_builder, and the relevant…
houpc Jan 10, 2024
690964d
remove factor field in AbstractGraph and clean up
houpc Jan 10, 2024
286cbbc
remove the archived codes
houpc Jan 10, 2024
80a93c2
bugfix and clean up
houpc Jan 10, 2024
c0b2894
Merge pull request #172 from numericalEFT/computgraph_pchou
houpc Jan 10, 2024
4ee9047
Relocation of DiagramId, Filter, Response, AnalyticalProperty, and Tw…
houpc Jan 11, 2024
9ec2358
remove para field and add isequal for PropagatorId
houpc Jan 11, 2024
e21e062
Merge pull request #173 from numericalEFT/computgraph_pchou
houpc Jan 11, 2024
9008fb2
improve the BareInteractionId comparison
kunyuan Jan 12, 2024
eec1017
simplify mirror symmetrization
kunyuan Jan 13, 2024
4f59de6
fix test
kunyuan Jan 13, 2024
d9d591d
Merge pull request #174 from numericalEFT/computgraph_diagramid
kunyuan Jan 13, 2024
29280ff
update vertex4I
houpc Jan 14, 2024
d03b858
Merge branch 'computgraph' into computgraph_pchou
houpc Jan 14, 2024
ed0acd6
update vertex4 in GV
houpc Jan 16, 2024
a6e4ec9
bugfix in test
houpc Jan 16, 2024
9d5a4a8
update leafstates in GV
houpc Jan 16, 2024
ff54ea9
update vertex4I and add level in optimize!
houpc Jan 21, 2024
52f695f
insert Alli in Parquet
houpc Jan 22, 2024
dc98853
add update_extKT in Parquet and refactor FrontEnds, GV, and Parquet
houpc Jan 23, 2024
a5d437e
update diagdict_parquet
houpc Jan 23, 2024
53567a9
bugfix and add reconstruct for DiagramId
houpc Jan 24, 2024
30cb522
bugfix
houpc Jan 25, 2024
7c0a759
utilize Hugenholtz in GV
houpc Jan 25, 2024
2233dd8
bugfix in updateKT
houpc Jan 27, 2024
c9c441c
bugfix in 4th-order vertex4
houpc Feb 6, 2024
e9a5498
update sigma in Parquet and addd docs
houpc Feb 6, 2024
9bc47f6
improve docs and clean up
houpc Feb 8, 2024
afe3ac6
clean up
houpc Feb 8, 2024
4811703
Merge pull request #177 from numericalEFT/computgraph_pchou
houpc Feb 8, 2024
91fec76
update readme
houpc Feb 9, 2024
9538e69
clean up. improve readme
kunyuan Feb 10, 2024
d8b37c2
improve readme
kunyuan Feb 10, 2024
6777c53
improve readme
kunyuan Feb 10, 2024
a4d5c0c
improve readme
houpc Feb 10, 2024
a188d68
Merge branch 'computgraph_pchou' of https://github.com/numericalEFT/F…
houpc Feb 10, 2024
caabb06
improve readme
kunyuan Feb 10, 2024
c3b3d33
improve readme
kunyuan Feb 10, 2024
9f5812e
update readme example
houpc Feb 10, 2024
9432b96
fix merge conflict
houpc Feb 10, 2024
8d5f9b3
simplify readme
houpc Feb 10, 2024
4db333b
improve readme
kunyuan Feb 11, 2024
9f06235
improve readme
kunyuan Feb 11, 2024
14b1eff
update Utility.taylorAD and README
houpc Feb 12, 2024
0995bea
fix merge conflicts
houpc Feb 12, 2024
9b43f9e
add docs for taylorAD
houpc Feb 12, 2024
7444091
update taylorAD()
houpc Feb 13, 2024
2517e39
improve readme
houpc Feb 13, 2024
77de7bb
remove diagram_orders in TaylorAD
houpc Feb 13, 2024
605ce58
udpate taylorAD()
houpc Feb 13, 2024
f607143
fix typos in readme
houpc Feb 13, 2024
d4e952e
improve docs and readme
houpc Feb 16, 2024
1a811b1
Merge pull request #178 from numericalEFT/computgraph_pchou
houpc Feb 16, 2024
eba996b
Merge from computgraph_zhiyi
houpc Feb 16, 2024
3623d75
Merge branch 'computgraph_pchou' into computgraph
houpc Feb 16, 2024
a3cae79
update Project.toml
houpc Feb 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ __pycache__
*.vscode

# Temporarily unignore vscode settings
!.vscode/
.vscode/

*.DS_Store
*.pb.gz
.DS_Store
*.history

*.pdf
*.dot
6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FeynmanDiagram"
uuid = "e424a512-dbd9-41ff-9883-094748823e72"
authors = ["Kun Chen", "Pengcheng Hou", "Daniel Cerkoney"]
version = "0.2.8"
version = "1.0.0"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
134 changes: 108 additions & 26 deletions README.md

Large diffs are not rendered by default.

557 changes: 554 additions & 3 deletions assets/diagram_compiler.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,363 changes: 3,363 additions & 0 deletions assets/sigmaDyn_ete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,489 changes: 1,489 additions & 0 deletions assets/sigmaIns_ete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
430 changes: 430 additions & 0 deletions assets/sigma_o2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/ver4tree.png
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ makedocs(;
"API reference" => Any[
"lib/operator.md",
"lib/computgraph.md",
"lib/taylorseries.md",
"lib/frontend.md",
"lib/GV.md",
"lib/parquet.md",
"lib/diagtree.md",
"lib/exprtree.md",
"lib/backend.md",
]
]
)
Expand Down
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Modules = [FeynmanDiagram]
Pages = [
"lib/operator.md",
"lib/computgraph.md",
"lib/taylorseries.md",
"lib/frontend.md",
"lib/GV.md",
"lib/parquet.md",
"lib/diagtree.md",
"lib/exprtree.md",
"lib/backend.md",
]
Depth = 2
```
7 changes: 7 additions & 0 deletions docs/src/lib/backend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Compilers compile computational graphs to optimized source code for diverse platforms

## API

```@autodocs
Modules = [FeynmanDiagram.Compilers]
```
7 changes: 0 additions & 7 deletions docs/src/lib/diagtree.md

This file was deleted.

7 changes: 0 additions & 7 deletions docs/src/lib/exprtree.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/src/lib/frontend.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Front-end translates a source code into a computational graph
# Front-end generates Feynman diagrams and translates then into a computational graph

## API

Expand Down
7 changes: 7 additions & 0 deletions docs/src/lib/taylorseries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Taylor expansions in independent variables (support AbstractGraph)

## API

```@autodocs
Modules = [FeynmanDiagram.Taylor]
```
213 changes: 180 additions & 33 deletions example/benchmark.jl
Original file line number Diff line number Diff line change
@@ -1,43 +1,190 @@
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")
import FeynmanDiagram.ComputationalGraphs as IR
using MCIntegration, Lehmann
using Random, LinearAlgebra

const TAU_CUTOFF = 1e-10
inds = [12, 33, 37, 82, 83, 88, 102, 123, 127, 172, 173, 178]

function main()
dim = 3
kF = 1.919
β = 3.0
para = Parquet.DiagPara(type=Parquet.Ver4Diag, innerLoopNum=4)

# partition = [(0, 0, 0), (1, 0, 0), (2, 0, 0), (3, 0, 0), (3, 1, 0), (3, 0, 1), (4, 0, 0)]
partition = [(4, 0, 0)]
randseed = 1234
λ = 1.2
# MaxLoopNum = maximum([p[1] for p in partition]) + 3
MaxLoopNum = 7
Random.seed!(randseed)

ver4df = Parquet.vertex4(para)
diags = ver4df.diagram
IR.optimize!(diags)
# extT_labels = Vector{Vector{Int}}[]
# spin_conventions = Vector{FrontEnds.Response}[]
leaf_maps = Vector{Dict{Int,Graph}}()

# for p in partition
# push!(extT_labels, FeynGraphs[p][2])
# push!(spin_conventions, FeynGraphs[p][3])
# end

# for (i, key) in enumerate(partition)
# _, leafmap = Compilers.compile(FeynGraphs[key][1])
# push!(leaf_maps, leafmap)
# end
_, leafmap = Compilers.compile(diags)
push!(leaf_maps, leafmap)

leafStat, loopBasis, leafval_map = _leafstates(leaf_maps, MaxLoopNum)

momLoopPool = FrontEnds.LoopPool(:K, dim, loopBasis)
# root = zeros(Float64, maximum(length.(extT_labels)))
varK = MCIntegration.FermiK(dim, kF, 0.2 * kF, 10.0 * kF, offset=3)
varK.data[:, 1] .= [kF, 0.0, 0.0]
varK.data[:, 2] .= [kF, 0.0, 0.0]
varK.data[:, 3] .= 0.0
varK.data[:, 4:9] = rand(Float64, (dim, 6))
varT = MCIntegration.Continuous(0.0, β, offset=1)
varT.data[1] = 0.0
# varT.data[2:end] .= rand(16) * β


leafval, leafType, leafOrders, leafτ_i, leafτ_o, leafMomIdx = leafStat

FrontEnds.update(momLoopPool, varK.data[:, 1:MaxLoopNum])

for (idx, p) in enumerate(partition)
for (i, lftype) in enumerate(leafType[idx])
if lftype == 0
continue
elseif lftype == 1 #fermionic
τ = varT[leafτ_o[idx][i]] - varT[leafτ_i[idx][i]]
# kq = varK.data[:, leafMomIdx[idx][i]]
kq = FrontEnds.loop(momLoopPool, leafMomIdx[idx][i])
ϵ = dot(kq, kq) - kF^2
order = leafOrders[idx][i][1]
leafval[idx][i] = green_derive(τ, ϵ, β, order)
elseif lftype == 2 #bosonic
# kq = varK.data[:, leafMomIdx[idx][i]]
kq = FrontEnds.loop(momLoopPool, leafMomIdx[idx][i])
order = leafOrders[idx][i][2]
# leafval[idx][i] = Propagator.interaction_derive(τ1, τ2, kq, para, idorder; idtype=Instant, tau_num=1)
invK = 1.0 / (dot(kq, kq) + λ)
leafval[idx][i] = 8π / invK * (λ * invK)^order
else
error("this leaftype $lftype not implemented!")
end
end
# graphfuncs! = funcGraphs![idx]
# graphfuncs!(root, leafval[idx])
for g in diags
IR.eval!(g, leafval_map[idx], leafval[idx])
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)]
return diags
# return [FeynGraphs[p][1] for p in partition]
end

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)
function green_derive(τ, ϵ, β, order)
if order == 0
result = green(τ, ϵ, β)
elseif order == 1
result = -Spectral.kernelFermiT_dω(τ, ϵ, β)
elseif order == 2
result = Spectral.kernelFermiT_dω2(τ, ϵ, β) / 2.0
elseif order == 3
result = -Spectral.kernelFermiT_dω3(τ, ϵ, β) / 6.0
elseif order == 4
result = Spectral.kernelFermiT_dω4(τ, ϵ, β) / 24.0
elseif order == 5
result = -Spectral.kernelFermiT_dω5(τ, ϵ, β) / 120.0
else
error("not implemented!")
# result = Propagator.green(τ, ϵ, β) * 0.0
end
return result
end

for (order, graph) in dict_g
if graph[2][1] == g[2][1]
idx = 1
function green(τ::T, ω::T, β::T) where {T}
#generate green function of fermion
if τ ≈ T(0.0)
τ = -TAU_CUTOFF
end
if τ > T(0.0)
return ω > T(0.0) ?
exp(-ω * τ) / (1 + exp(-ω * β)) :
exp(ω * (β - τ)) / (1 + exp(ω * β))
else
idx = 2
return ω > T(0.0) ?
-exp(-ω * (τ + β)) / (1 + exp(-ω * β)) :
-exp(-ω * τ) / (1 + exp(ω * β))
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

function _leafstates(leaf_maps::Vector{Dict{Int,G}}, maxloopNum::Int) where {G<:Graph}

num_g = length(leaf_maps)
leafType = [Vector{Int}() for _ in 1:num_g]
leafOrders = [Vector{Vector{Int}}() for _ in 1:num_g]
leafInTau = [Vector{Int}() for _ in 1:num_g]
leafOutTau = [Vector{Int}() for _ in 1:num_g]
leafLoopIndex = [Vector{Int}() for _ in 1:num_g]
leafValue = [Vector{Float64}() for _ in 1:num_g]
leafval_map = [Dict{Int,Int}() for _ in 1:num_g]

loopbasis = Vector{Float64}[]
# tau_labels = Vector{Int}[]
for (ikey, leafmap) in enumerate(leaf_maps)
len_leaves = length(keys(leafmap))
sizehint!(leafType[ikey], len_leaves)
sizehint!(leafOrders[ikey], len_leaves)
sizehint!(leafInTau[ikey], len_leaves)
sizehint!(leafOutTau[ikey], len_leaves)
sizehint!(leafLoopIndex[ikey], len_leaves)
leafValue[ikey] = ones(Float64, len_leaves)

valIdx = 1
for idx in 1:len_leaves
leaf = leafmap[idx]
@assert IR.isleaf(leaf)
diagId, leaf_orders = leaf.properties, leaf.orders
loopmom = copy(diagId.extK)
len = length(loopmom)
@assert maxloopNum >= len

if maxloopNum > length(loopmom)
Base.append!(loopmom, zeros(Float64, maxloopNum - len))
end
flag = true
for bi in eachindex(loopbasis)
if loopbasis[bi] ≈ loopmom
push!(leafLoopIndex[ikey], bi)
flag = false
break
end
end
if flag
push!(loopbasis, loopmom)
push!(leafLoopIndex[ikey], length(loopbasis))
end

# push!(tau_labels, collect(diagId.extT))
push!(leafInTau[ikey], diagId.extT[1])
push!(leafOutTau[ikey], diagId.extT[2])

push!(leafOrders[ikey], leaf_orders)
push!(leafType[ikey], FrontEnds.index(typeof(diagId)))
leafval_map[ikey][leaf.id] = valIdx
valIdx += 1
end
end

return (leafValue, leafType, leafOrders, leafInTau, leafOutTau, leafLoopIndex), loopbasis, leafval_map
end

# main()
Loading
Loading