Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
houpc committed Feb 8, 2024
1 parent 9bc47f6 commit afe3ac6
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 118 deletions.
38 changes: 0 additions & 38 deletions src/FeynmanDiagram.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ export Graph, FeynmanGraph, FeynmanProperties
export isequiv, drop_topology, is_external, is_internal, diagram_type, orders, vertices, topology
export external_legs, external_indices, external_operators, external_labels
export multi_product, linear_combination, feynman_diagram, propagator, interaction, external_vertex
# export DiagramType, Interaction, ExternalVertex, Propagator, SelfEnergy, VertexDiag, GreenDiag, GenericDiag

# export standardize_order!
# export reducibility, connectivity
# export 𝐺ᶠ, 𝐺ᵇ, 𝐺ᵠ, 𝑊, Green2, Interaction
# export Coupling_yukawa, Coupling_phi3, Coupling_phi4, Coupling_phi6
export haschildren, onechild, isleaf, isbranch, ischain, has_zero_subfactors, eldest, count_operation
export relabel!, standardize_labels!, replace_subgraph!, merge_linear_combination!, merge_multi_product!, remove_zero_valued_subgraphs!
export relabel, standardize_labels, replace_subgraph, merge_linear_combination, merge_multi_product, remove_zero_valued_subgraphs
Expand Down Expand Up @@ -63,37 +58,4 @@ include("backend/compiler.jl")
using .Compilers
export Compilers


# ##################### precompile #######################
# # precompile as the final step of the module definition:
# if ccall(:jl_generating_output, Cint, ()) == 1 # if we're precompiling the package
# let
# para = DiagParaF64(type=Ver4Diag, innerLoopNum=2, hasTau=true)
# # ver4 = Parquet.vertex4(para) # this will force precompilation
# ver4 = Parquet.build(para) # this will force precompilation

# mergeby(ver4, [:response])
# mergeby(ver4.diagram)
# mergeby(ver4.diagram, [:response]; idkey=[:extT, :response])

# para = DiagParaF64(type=SigmaDiag, innerLoopNum=2, hasTau=true)
# Parquet.build(para) # this will force precompilation
# para = DiagParaF64(type=GreenDiag, innerLoopNum=2, hasTau=true)
# Parquet.green(para) # this will force precompilation
# para = DiagParaF64(type=PolarDiag, innerLoopNum=2, hasTau=true)
# # Parquet.polarization(para) # this will force precompilation
# Parquet.build(para) # this will force precompilation
# para = DiagParaF64(type=Ver3Diag, innerLoopNum=2, hasTau=true)
# # Parquet.vertex3(para) # this will force precompilation
# Parquet.build(para) # this will force precompilation

# DiagTree.removeHartreeFock!(ver4.diagram)
# DiagTree.derivative(ver4.diagram, BareGreenId)
# DiagTree.derivative(ver4.diagram, BareInteractionId)
# # DiagTree.removeHartreeFock!(ver4.diagram)
# ExprTree.build(ver4.diagram, 3)
# end
# end


end
60 changes: 0 additions & 60 deletions src/backend/compiler_python.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,63 +131,3 @@ function compile_python(graphs::AbstractVector{<:AbstractGraph}, framework::Symb
end
return leafnum, leafmap
end

# function to_python_str(graphs::AbstractVector{<:AbstractGraph}, framework::Symbol=:jax)
# if framework == :jax
# head = ""
# elseif framework == :mindspore
# head = "import mindspore as ms\[email protected]\n"
# else
# error("no support for $type framework")
# end
# body = ""
# leafidx = 1
# root = [id(g) for g in graphs]
# inds_visitedleaf = Int[]
# inds_visitednode = Int[]
# gid_to_leafid = Dict{String, Int64}()
# rootidx = 1
# for graph in graphs
# for g in PostOrderDFS(graph) #leaf first search
# g_id = id(g)
# target = "g$(g_id)"
# isroot = false
# if g_id in root
# isroot = true
# end
# if isempty(subgraphs(g)) #leaf
# g_id in inds_visitedleaf && continue
# factor_str = factor(g) == 1 ? "" : " * $(factor(g))"
# body *= " $target = l$(leafidx)$factor_str\n"
# gid_to_leafid[target] = leafidx
# leafidx += 1
# push!(inds_visitedleaf, g_id)
# else
# g_id in inds_visitednode && continue
# factor_str = factor(g) == 1 ? "" : " * $(factor(g))"
# body *= " $target = $(to_pystatic(operator(g), subgraphs(g), subgraph_factors(g)))$factor_str\n"
# push!(inds_visitednode, g_id)
# end
# if isroot
# body *= " out$(rootidx)=$target\n"
# rootidx +=1
# end
# end
# end
# input = ["l$(i)" for i in 1:leafidx-1]
# input = join(input,",")
# output = ["out$(i)" for i in 1:rootidx-1]
# output = join(output,",")
# head *="def graphfunc($input):\n"
# tail = " return $output\n"
# # tail*= "def to_StaticGraph(leaf):\n"
# # tail*= " output = graphfunc(leaf)\n"
# # tail*= " return output"
# expr = head * body * tail
# println(expr)
# # return head * body * tail
# f = open("GraphFunc.py", "w")
# write(f, expr)
# return expr, leafidx-1, gid_to_leafid
# end

14 changes: 6 additions & 8 deletions src/computational_graph/abstractgraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,12 @@ function Base.isequal(a::AbstractGraph, b::AbstractGraph)
subgraphs(a)[pa] != subgraphs(b)[pb] && return false

for field in fieldnames(typeof(a))
if field in [:weight, :subgraphs, :subgraph_factors]
continue
# if field == :weight && getproperty(a, :weight) == weight(a) && getproperty(b, :weight) == weight(b)
# continue # skip graph weights if already accounted for
# elseif field == :subgraphs && getproperty(a, :subgraphs) == subgraphs(a) && getproperty(b, :subgraphs) == subgraphs(b)
# continue # skip subgraphs if already accounted for
# elseif field == :subgraph_factors && getproperty(a, :subgraph_factors) == subgraph_factors(a) && getproperty(b, :subgraph_factors) == subgraph_factors(b)
# continue # skip subgraph_factors if already accounted for
if field == :weight # && getproperty(a, :weight) == weight(a) && getproperty(b, :weight) == weight(b)
continue # skip graph weights if already accounted for
elseif field == :subgraphs # && getproperty(a, :subgraphs) == subgraphs(a) && getproperty(b, :subgraphs) == subgraphs(b)
continue # skip subgraphs if already accounted for
elseif field == :subgraph_factors # && getproperty(a, :subgraph_factors) == subgraph_factors(a) && getproperty(b, :subgraph_factors) == subgraph_factors(b)
continue # skip subgraph_factors if already accounted for
else
getproperty(a, field) != getproperty(b, field) && return false
end
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/GV.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ include("GV_diagrams/readfile.jl")
- `MinOrder` (Int): The minmimum actual order of the diagrams (defaults to `1`).
- `has_counterterm` (Bool, optional): `false` for G0W0, `true` for GW with self-energy and interaction counterterms (defaults to `false`).
- `spinPolarPara` (Float64, optional): The spin-polarization parameter (n_up - n_down) / (n_up + n_down) (defaults to `0.0`).
- `optimize_level` (Int, optional): The optimization level for the diagrams, defaults to `0`.
# Returns
A tuple `(dict_graphs, labelProd)` where
Expand Down Expand Up @@ -111,6 +112,7 @@ end
- `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 (n_up - n_down) / (n_up + n_down) (defaults to `0.0`).
- `optimize_level` (Int, optional): The optimization level for the diagrams, defaults to `0`.
# Returns
A tuple `(dict_graphs, labelProd)` where
Expand Down Expand Up @@ -343,7 +345,6 @@ function leafstates(leaf_maps::Vector{Dict{Int,G}}, maxloopNum::Int) where {G<:G
leafValue = [Vector{Float64}() 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)
Expand Down Expand Up @@ -377,7 +378,6 @@ function leafstates(leaf_maps::Vector{Dict{Int,G}}, maxloopNum::Int) where {G<:G
push!(leafLoopIndex[ikey], length(loopbasis))
end

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

Expand Down
1 change: 0 additions & 1 deletion src/frontend/diagram_id.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ abstract type PropagatorId <: DiagramId end

# Base.Dict(x::DiagramId) = Dict{Symbol,Any}([fn => getfield(x, fn) for fn ∈ fieldnames(typeof(x))])
# Base.show(io::IO, d::DiagramId) = error("Base.show not implemented!")
# Base.isequal(a::DiagramId, b::DiagramId) = error("Base.isequal not implemented!")
Base.:(==)(a::DiagramId, b::DiagramId) = Base.isequal(a, b)

struct BareGreenId <: PropagatorId
Expand Down
8 changes: 0 additions & 8 deletions src/frontend/parquet/vertex4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ function vertex4(para::DiagPara,
else # loopNum>0
for c in channels
if c == Alli
# continue
if 3 loopNum 4
addAlli!(ver4df, para, legK)
else
Expand All @@ -92,9 +91,7 @@ function vertex4(para::DiagPara,
# add RPA bubble counter-diagram to remove the bubble
RPA_chain!(ver4df, para, legK, c, level, name, -1.0)
end
# println(bub)
end
# # TODO: add envolpe diagrams
end
ver4df = merge_vertex4(para, ver4df, name, legK)
@assert all(x -> x[1] == para.firstTauIdx, ver4df.extT) "not all extT[1] are equal to the first Tau index $(para.firstTauIdx)! $ver4df"
Expand Down Expand Up @@ -152,8 +149,6 @@ function bubble!(ver4df::DataFrame, para::DiagPara, legK, chan::TwoBodyChannel,
gxPara = reconstruct(para, type=GreenDiag, innerLoopNum=oGx, firstLoopIdx=GxfirstLoopIdx, firstTauIdx=GxfirstTauIdx)
g0Para = reconstruct(para, type=GreenDiag, innerLoopNum=oG0, firstLoopIdx=G0firstLoopIdx, firstTauIdx=G0firstTauIdx)

# println("$lPara, $rPara, $gxPara, $g0Para")

phi, ppi, Γ4 = blocks.phi, blocks.ppi, blocks.Γ4
phi_toplevel, ppi_toplevel, Γ4_toplevel = blockstoplevel.phi, blockstoplevel.ppi, blockstoplevel.Γ4
if chan == PHr || chan == PHEr
Expand All @@ -167,7 +162,6 @@ function bubble!(ver4df::DataFrame, para::DiagPara, legK, chan::TwoBodyChannel,
end

LLegK, K, RLegK, Kx = legBasis(chan, legK, LoopIdx)
# println(K, ", ", Kx)

Lver = vertex4(lPara, LLegK, true; channels=Γi, level=level + 1, name=:Γi, blocks=blocks)
isempty(Lver) && return
Expand All @@ -182,7 +176,6 @@ function bubble!(ver4df::DataFrame, para::DiagPara, legK, chan::TwoBodyChannel,
g0 = green(g0Para, K, G0T, true, name=:G0, blocks=blocks)
gx = green(gxPara, Kx, GxT, true, name=:Gx, blocks=blocks)
@assert g0 isa Graph && gx isa Graph
# append!(diag, bubble2diag(para, chan, ldiag, rdiag, legK, g0, gx, extrafactor))
bubble2diag!(ver8, para, chan, ldiag, rdiag, legK, g0, gx, extrafactor)
end
end
Expand All @@ -203,7 +196,6 @@ function bubble!(ver4df::DataFrame, para::DiagPara, legK, chan::TwoBodyChannel,
ver4diag = Graph([diag, g0, gx]; properties=id, operator=Prod())
push!(ver4df, (response=Vresponse, type=vtype, extT=extT, diagram=ver4diag))
end
# push!(ver4df, (response=Vresponse, type=vtype, extT=extT, diagram=diag))
end

return
Expand Down
1 change: 0 additions & 1 deletion src/utility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ function count_expanded_operation(graphs::Vector{TaylorSeries{G}}, order::Vector
if length(graphs) == 0
return [0, 0]
else
# allcoeffs = Vector{G}()
total_sumprod = [0, 0]
for g in graphs
total_sumprod += count_expanded_operation(g.coeffs[order])
Expand Down

0 comments on commit afe3ac6

Please sign in to comment.