Sure, attached
ccd.jl (3.7 KB)
ccd-helper.jl (23.8 KB)
is the current code after making some minor modifications as suggested in this and the other thread. The first file is the main executable with the second having all the important function definitions. Please note that many of the functions are not needed and have been left there for legacy purposes.
And below is the:
@code_warntype output
MethodInstance for ccd_by_hand(::Int64)
from ccd_by_hand(maxitr) @ Main ~/Desktop/Andreas Köhn/phase 1.5/code/tensoroperations/ccd.jl:3
Arguments
#self#::Core.Const(ccd_by_hand)
maxitr::Int64
Locals
@_3::Union{Nothing, Tuple{Int64, Int64}}
R2_storage::Vector{Array{Float64, 4}}
T2_storage::Vector{Array{Float64, 4}}
R_iter_storage::Vector{Array{Float64, 4}}
p_min::Int64
p_max::Int64
etol::Float64
earr::Vector{Any}
e_old::Float64
e_new::Float64
normtol::Float64
T2_old::Array{Float64, 4}
Scaled_R2::Array{Float64, 4}
R_iter::Array{Float64, 4}
R2::Array{Float64, 4}
R2u::Array{Float64, 4}
erhf::Float64
nocc::Int64
nv::Int64
@_22::Int64
i::Int64
diis_result::Array{Float64, 4}
p::Int64
r2norm::Float64
conv::Bool
@_28::Any
@_29::Any
@_30::Any
Body::Nothing
1 ── Core.NewvarNode(:(@_3))
│ Core.NewvarNode(:(R2_storage))
│ Core.NewvarNode(:(T2_storage))
│ Core.NewvarNode(:(R_iter_storage))
│ Core.NewvarNode(:(p_min))
│ Core.NewvarNode(:(p_max))
│ Core.NewvarNode(:(etol))
│ Core.NewvarNode(:(earr))
│ Core.NewvarNode(:(e_old))
│ Core.NewvarNode(:(e_new))
│ Core.NewvarNode(:(normtol))
│ Core.NewvarNode(:(T2_old))
│ Core.NewvarNode(:(Scaled_R2))
│ Core.NewvarNode(:(R_iter))
│ Core.NewvarNode(:(R2))
│ Core.NewvarNode(:(R2u))
│ Core.NewvarNode(:(erhf))
│ Core.NewvarNode(:(nocc))
│ Core.NewvarNode(:(nv))
│ Main.initialize_cc_variables()
│ %21 = Main.deserialize("nv.jlbin")::Any
│ (@_28 = %21)
│ %23 = (@_28 isa Main.Int64)::Bool
└─── goto #3 if not %23
2 ── goto #4
3 ── %26 = Base.convert(Main.Int64, @_28)::Any
└─── (@_28 = Core.typeassert(%26, Main.Int64))
4 ┄─ (nv = @_28::Int64)
│ %29 = Main.deserialize("nocc.jlbin")::Any
│ (@_29 = %29)
│ %31 = (@_29 isa Main.Int64)::Bool
└─── goto #6 if not %31
5 ── goto #7
6 ── %34 = Base.convert(Main.Int64, @_29)::Any
└─── (@_29 = Core.typeassert(%34, Main.Int64))
7 ┄─ (nocc = @_29::Int64)
│ %37 = Main.deserialize("erhf.jlbin")::Any
│ (@_30 = %37)
│ %39 = (@_30 isa Main.Float64)::Bool
└─── goto #9 if not %39
8 ── goto #10
9 ── %42 = Base.convert(Main.Float64, @_30)::Any
└─── (@_30 = Core.typeassert(%42, Main.Float64))
10 ┄ (erhf = @_30::Float64)
│ %45 = Main.zeros(Main.Float64, nv, nv, nocc, nocc)::Array{Float64, 4}
│ %46 = Main.zeros(Main.Float64, nv, nv, nocc, nocc)::Array{Float64, 4}
│ (R2u = %45)
│ (R2 = %46)
│ %49 = Main.Float64::Core.Const(Float64)
│ %50 = Main.size(R2)::NTuple{4, Int64}
│ (R_iter = Main.zeros(%49, %50))
│ %52 = Main.Float64::Core.Const(Float64)
│ %53 = Main.size(R2)::NTuple{4, Int64}
│ (Scaled_R2 = Main.zeros(%52, %53))
│ (T2_old = Main.initialize_t2_only())
│ (normtol = 1.0e-8)
│ (e_new = Main.calculate_ECCD(T2_old))
│ (e_old = Main.copy(0.0))
│ (earr = Base.vect())
│ (etol = 1.0e-10)
│ (p_max = 6)
│ (p_min = 2)
│ %63 = Main.Array::Core.Const(Array)
│ %64 = Main.typeof(R2)::Core.Const(Array{Float64, 4})
│ %65 = Core.apply_type(%63, %64)::Core.Const(Array{Array{Float64, 4}})
│ %66 = Main.undef::Core.Const(UndefInitializer())
│ (R_iter_storage = (%65)(%66, 0))
│ %68 = Main.Array::Core.Const(Array)
│ %69 = Main.typeof(T2_old)::Core.Const(Array{Float64, 4})
│ %70 = Core.apply_type(%68, %69)::Core.Const(Array{Array{Float64, 4}})
│ %71 = Main.undef::Core.Const(UndefInitializer())
│ (T2_storage = (%70)(%71, 0))
│ %73 = Main.Array::Core.Const(Array)
│ %74 = Main.typeof(R2)::Core.Const(Array{Float64, 4})
│ %75 = Core.apply_type(%73, %74)::Core.Const(Array{Array{Float64, 4}})
│ %76 = Main.undef::Core.Const(UndefInitializer())
│ (R2_storage = (%75)(%76, 0))
│ %78 = earr::Vector{Any}
│ %79 = Base.getindex(e_new, 1)::Float64
│ %80 = (%79 + erhf)::Float64
│ Main.push!(%78, %80)
│ %82 = Base.string("Starting CCD Iterations with Convergence Criteria as ||R₂||<", normtol::Core.Const(1.0e-8), " , ΔE<", etol::Core.Const(1.0e-10), " and max iterations=", maxitr)::String
│ Main.println(%82)
│ Main.println("-----------------------------------------------------------------------------------------------")
│ %85 = (1:maxitr)::Core.PartialStruct(UnitRange{Int64}, Any[Core.Const(1), Int64])
│ (@_3 = Base.iterate(%85))
│ %87 = (@_3 === nothing)::Bool
│ %88 = Base.not_int(%87)::Bool
└─── goto #24 if not %88
11 ┄ Core.NewvarNode(:(diis_result))
│ Core.NewvarNode(:(p))
│ %92 = @_3::Tuple{Int64, Int64}
│ (i = Core.getfield(%92, 1))
│ %94 = Core.getfield(%92, 2)::Int64
│ %95 = Base.getproperty(Printf, :format)::Core.Const(Printf.format)
│ %96 = Main.stdout::IO
│ %97 = i::Int64
│ %98 = Base.getindex(e_new, 1)::Float64
│ %99 = (%98 + erhf)::Float64
│ (%95)(%96, Printf.Format{Base.CodeUnits{UInt8, String}, Tuple{Printf.Spec{Val{'d'}}, Printf.Spec{Val{'f'}}}}(UInt8[0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x53, 0x74, 0x61, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x25, 0x64, 0x20, 0x20, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x20, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x3a, 0x20, 0x25, 0x2e, 0x38, 0x66, 0x0a], UnitRange{Int64}[1:47, 50:73, 78:78], (%.0d, %.8f), 2), %97, %99)
│ %101 = Base.getindex(e_old, 1)::Float64
│ %102 = (%101 + erhf)::Float64
│ %103 = Base.string("Energy before updating = ", %102)::String
│ Main.println(%103)
│ (R2 = Main.calculate_residual(T2_old, R2u, R2))
│ (T2_old = Main.update_T2(T2_old, R2, Scaled_R2))
│ %107 = Main.check_convergence(R2, normtol::Core.Const(1.0e-8), e_old, e_new, etol::Core.Const(1.0e-10))::Tuple{Bool, Float64}
│ %108 = Base.indexed_iterate(%107, 1)::Core.PartialStruct(Tuple{Bool, Int64}, Any[Bool, Core.Const(2)])
│ (conv = Core.getfield(%108, 1))
│ (@_22 = Core.getfield(%108, 2))
│ %111 = Base.indexed_iterate(%107, 2, @_22::Core.Const(2))::Core.PartialStruct(Tuple{Float64, Int64}, Any[Float64, Core.Const(3)])
│ (r2norm = Core.getfield(%111, 1))
└─── goto #13 if not conv
12 ─ %114 = Base.getproperty(Printf, :format)::Core.Const(Printf.format)
│ %115 = Main.stdout::IO
│ %116 = i::Int64
│ %117 = r2norm::Float64
│ %118 = Base.getindex(e_old, 1)::Float64
│ %119 = Base.getindex(e_new, 1)::Float64
│ %120 = (%118 - %119)::Float64
│ %121 = Main.abs(%120)::Float64
│ %122 = Base.getindex(e_new, 1)::Float64
│ %123 = (%122 + erhf)::Float64
│ (%114)(%115, Printf.Format{Base.CodeUnits{UInt8, String}, Tuple{Printf.Spec{Val{'d'}}, Printf.Spec{Val{'f'}}, Printf.Spec{Val{'f'}}, Printf.Spec{Val{'f'}}}}(UInt8[0x43, 0x43, 0x44, 0x20, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x20, 0x25, 0x64, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2c, 0x20, 0x6e, 0x6f, 0x20, 0x66, 0x75, 0x72, 0x74, 0x68, 0x65, 0x72, 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x73, 0x20, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x2c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x7c, 0x7c, 0x52, 0x32, 0x7c, 0x7c, 0x3d, 0x25, 0x2e, 0x31, 0x30, 0x66, 0x20, 0x61, 0x6e, 0x64, 0x20, 0xce, 0x94, 0x45, 0x20, 0x3d, 0x20, 0x25, 0x2e, 0x31, 0x32, 0x66, 0x0a, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x45, 0x5f, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x20, 0x3d, 0x20, 0x25, 0x2e, 0x38, 0x66, 0x0a], UnitRange{Int64}[1:17, 20:75, 81:91, 97:134, 139:139], (%.0d, %.10f, %.12f, %.8f), 4), %116, %117, %121, %123)
└─── goto #24
13 ─ (R_iter = Main.calculate_R_iter(R_iter, R2))
│ %127 = Base.getproperty(Printf, :format)::Core.Const(Printf.format)
│ %128 = Main.stdout::IO
│ %129 = i::Int64
│ %130 = r2norm::Float64
│ %131 = Base.getindex(e_old, 1)::Float64
│ %132 = Base.getindex(e_new, 1)::Float64
│ %133 = (%131 - %132)::Float64
│ %134 = Main.abs(%133)::Float64
│ (%127)(%128, Printf.Format{Base.CodeUnits{UInt8, String}, Tuple{Printf.Spec{Val{'d'}}, Printf.Spec{Val{'f'}}, Printf.Spec{Val{'f'}}}}(UInt8[0x43, 0x43, 0x44, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x20, 0x25, 0x64, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2c, 0x20, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x7c, 0x7c, 0x52, 0x32, 0x7c, 0x7c, 0x20, 0x3d, 0x20, 0x25, 0x2e, 0x31, 0x30, 0x66, 0x20, 0x61, 0x6e, 0x64, 0x20, 0xce, 0x94, 0x45, 0x20, 0x3d, 0x20, 0x25, 0x2e, 0x31, 0x32, 0x66, 0x20, 0x0a], UnitRange{Int64}[1:21, 24:53, 59:69, 75:76], (%.0d, %.10f, %.12f), 3), %129, %130, %134)
│ %136 = (i >= p_min::Core.Const(2))::Bool
└─── goto #19 if not %136
14 ─ %138 = Base.string("DIIS is being implemented in iteration ", i)::String
│ Main.println(%138)
│ %140 = Main.length(R_iter_storage)::Int64
│ %141 = (%140 >= p_max::Core.Const(6))::Bool
└─── goto #16 if not %141
15 ─ Main.popfirst!(R_iter_storage)
│ Main.popfirst!(T2_storage)
└─── Main.popfirst!(R2_storage)
16 ┄ %146 = R_iter_storage::Vector{Array{Float64, 4}}
│ %147 = Main.copy(R_iter)::Array{Float64, 4}
│ Main.push!(%146, %147)
│ %149 = T2_storage::Vector{Array{Float64, 4}}
│ %150 = Main.copy(T2_old)::Array{Float64, 4}
│ Main.push!(%149, %150)
│ %152 = R2_storage::Vector{Array{Float64, 4}}
│ %153 = Main.copy(R2)::Array{Float64, 4}
│ Main.push!(%152, %153)
│ (p = Main.length(R_iter_storage))
│ (diis_result = Main.PerformDiis(R_iter_storage, p, T2_storage, R2_storage))
│ %157 = (diis_result == false)::Core.Const(false)
└─── goto #18 if not %157
17 ─ Core.Const(:(Main.nothing))
└─── Core.Const(:(goto %162))
18 ┄ (T2_old = diis_result)
└─── goto #22
19 ─ %163 = i::Int64
│ %164 = (p_min::Core.Const(2) - 1)::Core.Const(1)
│ %165 = (%163 == %164)::Bool
└─── goto #21 if not %165
20 ─ Main.println("DIIS will start in next iteration")
│ %168 = R_iter_storage::Vector{Array{Float64, 4}}
│ %169 = Main.copy(R_iter)::Array{Float64, 4}
│ Main.push!(%168, %169)
│ %171 = T2_storage::Vector{Array{Float64, 4}}
│ %172 = Main.copy(T2_old)::Array{Float64, 4}
│ Main.push!(%171, %172)
│ %174 = R2_storage::Vector{Array{Float64, 4}}
│ %175 = Main.copy(R2)::Array{Float64, 4}
│ Main.push!(%174, %175)
│ %177 = R_iter_storage::Vector{Array{Float64, 4}}
│ %178 = Main.length(R_iter_storage)::Int64
│ %179 = T2_storage::Vector{Array{Float64, 4}}
│ Main.just_show_Bmatrix(%177, %178, %179, R2_storage)
└─── goto #22
21 ─ Main.println("DIIS start is still far away")
22 ┄ (e_old = e_new)
│ (e_new = Main.calculate_ECCD(T2_old))
│ %185 = Base.getindex(e_new, 1)::Float64
│ %186 = (%185 + erhf)::Float64
│ %187 = Base.string("Energy after updating = ", %186, "\n-------------------------\n")::String
│ Main.println(%187)
│ %189 = earr::Vector{Any}
│ %190 = Base.getindex(e_new, 1)::Float64
│ %191 = (%190 + erhf)::Float64
│ Main.push!(%189, %191)
│ (@_3 = Base.iterate(%85, %94))
│ %194 = (@_3 === nothing)::Bool
│ %195 = Base.not_int(%194)::Bool
└─── goto #24 if not %195
23 ─ goto #11
24 ┄ return nothing