diff --git a/examples/pt2_test/_testdata_cmf_h8.jld2 b/examples/pt2_test/_testdata_cmf_h8.jld2 deleted file mode 100644 index 334db8f..0000000 Binary files a/examples/pt2_test/_testdata_cmf_h8.jld2 and /dev/null differ diff --git a/examples/pt2_test/_testdata_cmf_h9.jld2 b/examples/pt2_test/_testdata_cmf_h9.jld2 deleted file mode 100644 index 6c7d6be..0000000 Binary files a/examples/pt2_test/_testdata_cmf_h9.jld2 and /dev/null differ diff --git a/examples/pt2_test/h8.jl b/examples/pt2_test/h8.jl deleted file mode 100644 index 4863f79..0000000 --- a/examples/pt2_test/h8.jl +++ /dev/null @@ -1,65 +0,0 @@ -using QCBase -using RDM -using FermiCG -using Printf -using Test -using JLD2 - - -@load "_testdata_cmf_h8.jld2" -ref_fock = FockConfig(init_fspace) -# Do TPS -M=20 -cluster_bases = FermiCG.compute_cluster_eigenbasis_spin(ints, clusters, d1, [3,3], ref_fock, max_roots=M, verbose=1); -#cluster_bases = FermiCG.compute_cluster_eigenbasis(ints, clusters, verbose=0, max_roots=M, init_fspace=init_fspace, rdm1a=d1.a, rdm1b=d1.b, T=Float64) - -clustered_ham = FermiCG.extract_ClusteredTerms(ints, clusters) -cluster_ops = FermiCG.compute_cluster_ops(cluster_bases, ints); - -FermiCG.add_cmf_operators!(cluster_ops, cluster_bases, ints, d1.a, d1.b); - -nroots=1 - -# TPSCI -# -ci_vector = FermiCG.TPSCIstate(clusters, ref_fock, R=nroots) - -ci_vector = FermiCG.add_spin_focksectors(ci_vector) - -display(ci_vector) -etpsci, vtpsci = FermiCG.tps_ci_direct(ci_vector, cluster_ops, clustered_ham); - -ept1 = FermiCG.compute_pt2_energy(vtpsci, cluster_ops, clustered_ham, thresh_foi=1e-12) - - - -# BST -# - -# start by defining P/Q spaces -p_spaces = Vector{ClusterSubspace}() - -for ci in clusters - ssi = ClusterSubspace(clusters[ci.idx]) - - num_states_in_p_space = 1 - # our clusters are near triangles, with degenerate gs, so keep two states - add_subspace!(ssi, ref_fock[ci.idx], 1:num_states_in_p_space) - add_subspace!(ssi, (ref_fock[ci.idx][2], ref_fock[ci.idx][1]), 1:num_states_in_p_space) # add flipped spin - push!(p_spaces, ssi) -end - -ci_vector = BSTstate(clusters, p_spaces, cluster_bases, R=1) - -na = 4 -nb = 4 -FermiCG.fill_p_space!(ci_vector, na, nb) -FermiCG.eye!(ci_vector) -ebst, vbst = FermiCG.ci_solve(ci_vector, cluster_ops, clustered_ham) - -ept2 = FermiCG.compute_pt2_energy(vbst, cluster_ops, clustered_ham, thresh_foi=1e-64) - -println(" PT2 - tpsci") -display(ept1) -println(" PT2 - bst") -display(ept2) diff --git a/examples/pt2_test/h9.jl b/examples/pt2_test/h9.jl deleted file mode 100644 index 33b9214..0000000 --- a/examples/pt2_test/h9.jl +++ /dev/null @@ -1,65 +0,0 @@ -using QCBase -using RDM -using FermiCG -using Printf -using Test -using JLD2 - -@load "_testdata_cmf_h9.jld2" -ref_fock = FockConfig(init_fspace) -# Do TPS -M=20 -cluster_bases = FermiCG.compute_cluster_eigenbasis_spin(ints, clusters, d1, [3,3,3], ref_fock, max_roots=M, verbose=1); -#cluster_bases = FermiCG.compute_cluster_eigenbasis(ints, clusters, verbose=0, max_roots=M, init_fspace=init_fspace, rdm1a=d1.a, rdm1b=d1.b, T=Float64) - -clustered_ham = FermiCG.extract_ClusteredTerms(ints, clusters) -cluster_ops = FermiCG.compute_cluster_ops(cluster_bases, ints); - -FermiCG.add_cmf_operators!(cluster_ops, cluster_bases, ints, d1.a, d1.b); - -nroots=3 - -# TPSCI -# -nroots=3 -ci_vector = FermiCG.TPSCIstate(clusters, ref_fock, R=nroots) - -ci_vector = FermiCG.add_spin_focksectors(ci_vector) - -display(ci_vector) -etpsci, vtpsci = FermiCG.tps_ci_direct(ci_vector, cluster_ops, clustered_ham); - -@time ept1 = FermiCG.compute_pt2_energy(vtpsci, cluster_ops, clustered_ham, thresh_foi=1e-12) - - - -# BST -# - -# start by defining P/Q spaces -p_spaces = Vector{ClusterSubspace}() - -for ci in clusters - ssi = ClusterSubspace(clusters[ci.idx]) - - num_states_in_p_space = 1 - # our clusters are near triangles, with degenerate gs, so keep two states - add_subspace!(ssi, ref_fock[ci.idx], 1:num_states_in_p_space) - add_subspace!(ssi, (ref_fock[ci.idx][2], ref_fock[ci.idx][1]), 1:num_states_in_p_space) # add flipped spin - push!(p_spaces, ssi) -end - -ci_vector = BSTstate(clusters, p_spaces, cluster_bases, R=3) - -na = 5 -nb = 4 -FermiCG.fill_p_space!(ci_vector, na, nb) -FermiCG.eye!(ci_vector) -ebst, vbst = FermiCG.ci_solve(ci_vector, cluster_ops, clustered_ham) - -@time ept2 = FermiCG.compute_pt2_energy(vbst, cluster_ops, clustered_ham, thresh_foi=1e-64,prescreen = true,compress_twice = true) -@time ept2 = FermiCG.compute_pt2_energy2(vbst, cluster_ops, clustered_ham, thresh_foi=1e-64,prescreen = true,compress_twice = true) -println(" PT2 - tpsci") -display(ept1) -println(" PT2 - bst") -display(ept2) diff --git a/examples/tetracene_dimer/spt_direct.jl b/examples/tetracene_dimer/spt_direct.jl index 444e932..8b4d189 100644 --- a/examples/tetracene_dimer/spt_direct.jl +++ b/examples/tetracene_dimer/spt_direct.jl @@ -39,24 +39,9 @@ FermiCG.add_double_excitons!(ci_vector,FermiCG.FockConfig(init_fspace),nroots) fspace_0 = FermiCG.FockConfig(init_fspace) # FermiCG.add_1electron_transfers!(ci_vector, fspace_0, 1) FermiCG.add_spin_flip_states!(ci_vector, fspace_0,1) -# # Spin-flip states -# ## ba -# tmp_fspace = FermiCG.replace(fspace_0, (1,2), ([4,2],[2,4])) -# FermiCG.add_fockconfig!(ci_vector, tmp_fspace) -# ci_vector[tmp_fspace][FermiCG.TuckerConfig((1:1,1:1))]=FermiCG.Tucker(tuple([zeros(Float64, 1, 1) for _ in 1:nroots]...)) -# ## ab -# tmp_fspace = FermiCG.replace(fspace_0, (1,2), ([2,4],[4,2])) -# FermiCG.add_fockconfig!(ci_vector, tmp_fspace) -# ci_vector[tmp_fspace][FermiCG.TuckerConfig((1:1,1:1))]=FermiCG.Tucker(tuple([zeros(Float64, 1, 1) for _ in 1:nroots]...)) display(ci_vector.data) FermiCG.eye!(ci_vector) display(ci_vector) -# σ = FermiCG.build_compressed_1st_order_state(ci_vector, cluster_ops, clustered_ham, -# nbody=4, -# thresh=1e-3) -# σ = FermiCG.compress(σ, thresh=1e-5) -# v2 = BSTstate(σ,R=10) -# FermiCG.eye!(v2) e_ci, v2 = FermiCG.ci_solve(ci_vector, cluster_ops, clustered_ham); e_var, v_var = FermiCG.block_sparse_tucker(v2, cluster_ops, clustered_ham, max_iter = 200, @@ -70,6 +55,8 @@ e_var, v_var = FermiCG.block_sparse_tucker(v2, cluster_ops, clustered_ham, resolve_ss = false, tol_tucker = 1e-4, solver = "davidson") +@time ept2 = FermiCG.compute_pt2_energy(v_var, cluster_ops, clustered_ham, thresh_foi=1e-6,prescreen = true,compress_twice = true) +@time ept2 = FermiCG.compute_pt2_energy2(v_var, cluster_ops, clustered_ham, thresh_foi=1e-6,prescreen = true,compress_twice = true) e_var, v_var = FermiCG.block_sparse_tucker(v_var, cluster_ops, clustered_ham, max_iter = 200, nbody = 4, diff --git a/src/tpsci_pt2_energy.jl b/src/tpsci_pt2_energy.jl index 5d3c301..9ae527c 100644 --- a/src/tpsci_pt2_energy.jl +++ b/src/tpsci_pt2_energy.jl @@ -292,7 +292,7 @@ end threaded = true, verbose=1) where {T,N,R} this function computes the second-order energy correction using the Quasidegenerate perturbation theory - Approximation: Taking ∂S=0 in denominator of the perturbation theory expression + Approximation: Taking ∂E_S=0 in denominator of the perturbation theory expression args:: TPSCIstate{T,N,R} : TPSCIstate object cluster_ops::Dict{Int64,Dict{String,Any}} : cluster operators