Skip to content

Commit

Permalink
update sigma in Parquet and addd docs
Browse files Browse the repository at this point in the history
  • Loading branch information
houpc committed Feb 6, 2024
1 parent c9c441c commit e9a5498
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
15 changes: 11 additions & 4 deletions src/computational_graph/optimize.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
"""
function optimize!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0, normalize=nothing)
function optimize!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; level=0, verbose=0, normalize=nothing)
In-place optimization of given `graphs`. Removes duplicated leaves, merges chains, and merges linear combinations.
In-place optimization of given `graphs`. Removes duplicated nodes (when `level > 0`) or leaves, flattens chains,
merges linear combinations, and removing zero-valued subgraphs.
# Arguments:
- `graphs`: A tuple or vector of graphs.
- `level`: Optimization level (default: 0). A value greater than 0 triggers more extensive but slower optimization processes, such as removing duplicated nodes.
- `verbose`: Level of verbosity (default: 0).
- `normalize`: Optional function to normalize the graphs (default: nothing).
# Returns
- Returns the optimized graphs. If the input graphs is empty, it returns nothing.
"""
function optimize!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; level=0, verbose=0, normalize=nothing)
if isempty(graphs)
Expand All @@ -31,12 +36,14 @@ function optimize!(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; level=0
end

"""
function optimize(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; verbose=0, normalize=nothing)
function optimize(graphs::Union{Tuple,AbstractVector{<:AbstractGraph}}; level=0, verbose=0, normalize=nothing)
Optimizes a copy of given `graphs`. Removes duplicated leaves, merges chains, and merges linear combinations.
Optimizes a copy of given `graphs`. Removes duplicated nodes (when `level > 0`) or leaves, flattens chains,
merges linear combinations, and removing zero-valued subgraphs.
# Arguments:
- `graphs`: A tuple or vector of graphs.
- `level`: Optimization level (default: 0). A value greater than 0 triggers more extensive but slower optimization processes, such as removing duplicated nodes.
- `verbose`: Level of verbosity (default: 0).
- `normalize`: Optional function to normalize the graphs (default: nothing).
Expand Down
2 changes: 0 additions & 2 deletions src/computational_graph/tree_properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ end
"""
function count_leaves(g::G) where {G<:AbstractGraph}
leaves = collect(Leaves(g))
sort!(leaves, by=x -> x.id)
unique!(x -> x.id, leaves)

return length(leaves)
Expand All @@ -151,7 +150,6 @@ function count_leaves(graphs::Vector{G}) where {G<:AbstractGraph}
for g in graphs
append!(leaves, collect(Leaves(g)))
end
sort!(leaves, by=x -> x.id)
unique!(x -> x.id, leaves)

return length(leaves)
Expand Down
16 changes: 16 additions & 0 deletions src/frontend/parquet/parquet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,28 @@ include("filter.jl")
include("to_graph.jl")

const vertex4I_diags = Dict{Int,Vector{Graph}}()

"""
initialize_vertex4I_diags(; filter=[NoHartree], spinPolarPara::Float64=0.0)
Initialize the vertex4I_diags dictionary with the diagrams of the 3- and 4-point fully-irreducible (Alli) vertex functions.
# Parameters
- `filter (optional)` : a list of filter conditions to select the diagrams. Default is `[NoHartree]`.
- `spinPolarPara (optional)` : the spin-polarization parameter. Default is `0.0`.
"""
function initialize_vertex4I_diags(; filter=[NoHartree], spinPolarPara::Float64=0.0)
dict_graphs = diagdictGV_ver4([(3, 0, 0), (4, 0, 0)], channels=[Alli], filter=filter, spinPolarPara=spinPolarPara)
vertex4I_diags[3] = dict_graphs[(3, 0, 0)][1]
vertex4I_diags[4] = dict_graphs[(4, 0, 0)][1]
end

"""
get_ver4I()
Retrieves the global dictionary `vertex4I_diags` that contains graph initialized by `initialize_vertex4I_diags`.
This function is a getter that provides access to the stored graph data of the 3- and 4-point fully-irreducible (Alli) vertex functions.
"""
get_ver4I() = vertex4I_diags

initialize_vertex4I_diags()
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/parquet/sigma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function sigma(para::DiagPara, extK=getK(para.totalLoopNum, 1), subdiagram=false
# if compact
# ver4 = ep_coupling(paraW; extK=legK, subdiagram=true, name=:W, blocks=blocks)
# else
ver4 = vertex4(paraW, legK, true; channels=[PHr,], blocks=blocks, blockstoplevel=ParquetBlocks(phi=[], Γ4=[PHr, PHEr, PPr]))
ver4 = vertex4(paraW, legK, true; channels=[PHr,], blocks=blocks, blockstoplevel=ParquetBlocks(phi=[], Γ4=[PHr, PHEr, PPr, Alli]))
# end
end
#transform extT coloum intwo extT for Σ and extT for G
Expand Down

0 comments on commit e9a5498

Please sign in to comment.