diff --git a/src/frontend/diagram_id.jl b/src/frontend/diagram_id.jl index 25698c00..b6d49000 100644 --- a/src/frontend/diagram_id.jl +++ b/src/frontend/diagram_id.jl @@ -17,34 +17,32 @@ abstract type PropagatorId <: DiagramId end # Base.isequal(a::DiagramId, b::DiagramId) = error("Base.isequal not implemented!") Base.:(==)(a::DiagramId, b::DiagramId) = Base.isequal(a, b) -struct BareGreenId{P} <: PropagatorId - para::P +struct BareGreenId <: PropagatorId type::AnalyticProperty #Instant, Dynamic extK::Vector{Float64} extT::Tuple{Int,Int} #all possible extT from different interactionType - function BareGreenId(para::P, type::AnalyticProperty=Dynamic; k, t) where {P} + function BareGreenId(type::AnalyticProperty=Dynamic; k, t) idx = findfirst(!iszero, k) if isnothing(idx) || k[idx] > 0 - return new{P}(para, type, k, Tuple(t)) + return new(type, k, Tuple(t)) else - return new{P}(para, type, -k, Tuple(t)) + return new(type, -k, Tuple(t)) end end end Base.show(io::IO, v::BareGreenId) = print(io, "$(short(v.type)), k$(v.extK), t$(v.extT)") -struct BareInteractionId{P} <: PropagatorId # bare W-type interaction, with only one extK - para::P +struct BareInteractionId <: PropagatorId # bare W-type interaction, with only one extK response::Response #UpUp, UpDown, ... type::AnalyticProperty #Instant, Dynamic extK::Vector{Float64} extT::Tuple{Int,Int} #all possible extT from different interactionType - function BareInteractionId(para::P, response::Response, type::AnalyticProperty=Instant; k, t=(0, 0)) where {P} + function BareInteractionId(response::Response, type::AnalyticProperty=Instant; k, t=(0, 0)) idx = findfirst(!iszero, k) if isnothing(idx) || k[idx] > 0 - return new{P}(para, response, type, k, Tuple(t)) + return new(response, type, k, Tuple(t)) else - return new{P}(para, response, type, -k, Tuple(t)) + return new(response, type, -k, Tuple(t)) end end end @@ -232,14 +230,24 @@ function Base.isequal(a::DiagramId, b::DiagramId) if typeof(a) != typeof(b) return false end + bothIns = false + for field in fieldnames(typeof(a)) + if getproperty(a, field) != getproperty(b, field) + return false + end + end + return true +end + +function Base.isequal(a::BareInteractionId, b::BareInteractionId) bothIns = false for field in fieldnames(typeof(a)) if field == :type a.type != b.type && return false if a.type == Instant bothIns = true - continue end + continue end bothIns && field == :extT && continue if getproperty(a, field) != getproperty(b, field) diff --git a/src/frontend/parquet/green.jl b/src/frontend/parquet/green.jl index 0bab8c62..cec6e786 100644 --- a/src/frontend/parquet/green.jl +++ b/src/frontend/parquet/green.jl @@ -40,7 +40,7 @@ function green(para::DiagPara, extK=getK(para.totalLoopNum, 1), extT=para.hasTau # end if para.innerLoopNum == 0 - return Graph([]; properties=BareGreenId(para, k=extK, t=extT), name=name) + return Graph([]; properties=BareGreenId(k=extK, t=extT), name=name) end # ################# after this step, the Green's function must be nontrivial! ################## @@ -61,8 +61,8 @@ function green(para::DiagPara, extK=getK(para.totalLoopNum, 1), extT=para.hasTau return Graph([group[:diagram], G]; properties=GenericId(para, pairT), operator=Prod(), name=:ΣG) end - para0 = reconstruct(para, innerLoopNum=0) #parameter for g0 - g0 = Graph([]; properties=BareGreenId(para0, k=extK, t=(tin, t0)), name=:g0) + # para0 = reconstruct(para, innerLoopNum=0) #parameter for g0 + g0 = Graph([]; properties=BareGreenId(k=extK, t=(tin, t0)), name=:g0) ΣGpairs = Vector{Graph{Ftype,Wtype}}() for p in orderedPartition(para.innerLoopNum, 2, 0) oΣ, oG = p diff --git a/src/frontend/parquet/vertex4.jl b/src/frontend/parquet/vertex4.jl index 95a3b8a4..4330144a 100644 --- a/src/frontend/parquet/vertex4.jl +++ b/src/frontend/parquet/vertex4.jl @@ -280,7 +280,7 @@ function _bare(para::DiagPara, diex::Vector{Permutation}, response::Response, ty if notProper(para, _q) == false && _diex in diex #create new bare ver4 only if _diex is required in the diex table - vid = BareInteractionId(para, response, type, k=_q, t=_innerT) + vid = BareInteractionId(response, type, k=_q, t=_innerT) return Graph([]; factor=sign * _factor, properties=vid) else return nothing diff --git a/test/front_end.jl b/test/front_end.jl index 74015e6c..a9271852 100644 --- a/test/front_end.jl +++ b/test/front_end.jl @@ -194,15 +194,15 @@ end # #construct the propagator table gK = [[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 0.0, 1.0]] gT = [(1, 2), (2, 1)] - g = [Graph([], properties=BareGreenId(paraG, k=gK[i], t=gT[i]), name=:G) for i in 1:2] + g = [Graph([], properties=BareGreenId(k=gK[i], t=gT[i]), name=:G) for i in 1:2] vdK = [[0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 1.0, 0.0]] # vdT = [[1, 1], [2, 2]] - vd = [Graph([], properties=BareInteractionId(paraV, ChargeCharge, k=vdK[i]), name=:Vd) for i in 1:2] + vd = [Graph([], properties=BareInteractionId(ChargeCharge, k=vdK[i]), name=:Vd) for i in 1:2] veK = [[1, 0, -1, -1], [0, 1, 0, -1]] # veT = [[1, 1], [2, 2]] - ve = [Graph([], properties=BareInteractionId(paraV, ChargeCharge, k=veK[i]), name=:Ve) for i in 1:2] + ve = [Graph([], properties=BareInteractionId(ChargeCharge, k=veK[i]), name=:Ve) for i in 1:2] Id = GenericId(paraV) # contruct the tree @@ -250,7 +250,7 @@ end # autodiff factor = 1 / (2π)^D Taylor.set_variables("x y"; orders=[1, 1]) - propagator_var = Dict(BareGreenId{DiagPara} => [true, false], BareInteractionId{DiagPara} => [false, true]) # Specify variable dependence of fermi (first element) and bose (second element) particles. + propagator_var = Dict(BareGreenId => [true, false], BareInteractionId => [false, true]) # Specify variable dependence of fermi (first element) and bose (second element) particles. t, taylormap = Utility.taylorexpansion!(root, propagator_var) taylorleafmap, taylorleafvec = assign_leaves(root, taylormap) diff --git a/test/taylor.jl b/test/taylor.jl index 711a34fb..b7092f25 100644 --- a/test/taylor.jl +++ b/test/taylor.jl @@ -141,15 +141,15 @@ function getdiagram(spin=2.0, D=3, Nk=4, Nt=2) # #construct the propagator table gK = [[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 0.0, 1.0]] gT = [(1, 2), (2, 1)] - g = [Graph([], properties=BareGreenId(paraG, k=gK[i], t=gT[i]), name=:G) for i in 1:2] + g = [Graph([], properties=BareGreenId(k=gK[i], t=gT[i]), name=:G) for i in 1:2] vdK = [[0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 1.0, 0.0]] # vdT = [[1, 1], [2, 2]] - vd = [Graph([], properties=BareInteractionId(paraV, ChargeCharge, k=vdK[i]), name=:Vd) for i in 1:2] + vd = [Graph([], properties=BareInteractionId(ChargeCharge, k=vdK[i]), name=:Vd) for i in 1:2] veK = [[1, 0, -1, -1], [0, 1, 0, -1]] # veT = [[1, 1], [2, 2]] - ve = [Graph([], properties=BareInteractionId(paraV, ChargeCharge, k=veK[i]), name=:Ve) for i in 1:2] + ve = [Graph([], properties=BareInteractionId(ChargeCharge, k=veK[i]), name=:Ve) for i in 1:2] Id = GenericId(paraV) # contruct the tree @@ -198,7 +198,7 @@ end # autodiff factor = 1 / (2π)^D set_variables("x y"; orders=[2, 2]) - propagator_var = Dict(BareGreenId{DiagPara} => [true, false], BareInteractionId{DiagPara} => [false, true]) # Specify variable dependence of fermi (first element) and bose (second element) particles. + propagator_var = Dict(BareGreenId => [true, false], BareInteractionId => [false, true]) # Specify variable dependence of fermi (first element) and bose (second element) particles. t, taylormap = taylorexpansion!(root, propagator_var) taylorleafmap, taylorleafvec = assign_leaves(root, taylormap)