Skip to content

Commit

Permalink
single and double excitations function added for spt (though for full…
Browse files Browse the repository at this point in the history
… space)
  • Loading branch information
arnab82 committed Mar 15, 2024
1 parent 72408b8 commit 5d517fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 68 deletions.
67 changes: 0 additions & 67 deletions src/type_BSTstate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -565,73 +565,6 @@ end
#=}}}=#


"""
function add_single_excitons!(ts::BSTstate{T,N,R},
fock::FockConfig{N},
cluster_bases::Vector{ClusterBasis}) where {T,N,R}
Modify the current state by adding the "single excitonic" basis for the specified `FockConfig`.
This basically, starts from a reference state where only the p-spaces are included,
and then adds the excited states. E.g.,
|PPPP> += |QPPP> + |PQPP> + |PPQP> + |PPPQ>
"""
function add_single_excitons!(ts::BSTstate{T,N,R},
fock::FockConfig{N}) where {T,N,R}
#={{{=#
#length(size(v)) == 1 || error(" Only takes vectors", size(v))

ref_config = [ts.p_spaces[ci.idx][fock[ci.idx]] for ci in ts.clusters]


println(ref_config)
println(TuckerConfig(ref_config))
for ci in ts.clusters
conf_i = deepcopy(ref_config)

# Check to make sure there is a q space for this fock sector (e.g., (0,0) fock sector only has a P space
# since it is 1 dimensional)
fock[ci.idx] in keys(ts.q_spaces[ci.idx].data) || continue

conf_i[ci.idx] = ts.q_spaces[ci.idx][fock[ci.idx]]
tconfig_i = TuckerConfig(conf_i)

#factors = tuple([cluster_bases[j.idx][fock[j.idx]][:,tconfig_i[j.idx]] for j in ts.clusters]...)
core = tuple([zeros(length.(tconfig_i)...) for r in 1:R]...)
factors = tuple([Matrix{T}(I, length(tconfig_i[j.idx]), length(tconfig_i[j.idx])) for j in ts.clusters]...)
ts.data[fock][tconfig_i] = Tucker(core, factors)
end
return
end
#=}}}=#
function add_double_excitons!(ts::BSTstate{T,N,R}, fock::FockConfig{N}) where {T,N,R}
ref_config = [ts.p_spaces[ci.idx][fock[ci.idx]] for ci in ts.clusters]

for ci in ts.clusters
conf_i = deepcopy(ref_config)

# Check if there is a q space for this fock sector
fock[ci.idx] in keys(ts.q_spaces[ci.idx].data) || continue

conf_i[ci.idx] = ts.q_spaces[ci.idx][fock[ci.idx]]
# Loop over clusters to set factors for double excitations
for cj in ts.clusters
# Skip if the cluster is the same as ci
if ci.idx == cj.idx
continue
end

# Check if there is a q space for this fock sector
fock[cj.idx] in keys(ts.q_spaces[cj.idx].data) || continue
conf_i[cj.idx] = ts.q_spaces[cj.idx][fock[cj.idx]]
tconfig_j = TuckerConfig(conf_i)
core = tuple([zeros(length.(tconfig_j)...) for r in 1:R]...)
factors = tuple([Matrix{T}(I, length(tconfig_j[j.idx]), length(tconfig_j[j.idx])) for j in ts.clusters]...)
ts.data[fock][tconfig_j] = Tucker(core, factors)
end
end
return
end

"""
"""
function randomize!(s::BSTstate{T,N,R}; seed=nothing) where {T,N,R}
Expand Down
6 changes: 5 additions & 1 deletion src/type_BSstate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ function BSstate(clusters::Vector{MOCluster},
tss[fconfig[ci.idx]] = 1:1
push!(p_spaces, tss)
end

# define q spaces
for tssp in p_spaces
tss = get_ortho_compliment(tssp, cluster_bases[tssp.cluster.idx])
Expand All @@ -75,6 +74,11 @@ function BSstate(clusters::Vector{MOCluster},

data = OrderedDict{FockConfig{N},OrderedDict{TuckerConfig{N},Array{T,2}} }()
state = BSstate{T,N,R}(clusters, data, p_spaces, q_spaces)
add_fockconfig!(state, fconfig)

tconfig = TuckerConfig([p_spaces[ci.idx].data[fconfig[ci.idx]] for ci in clusters])

state[fconfig][tconfig] = zeros(T,dim(tconfig),R)
return state
end
#=}}}=#
Expand Down

0 comments on commit 5d517fc

Please sign in to comment.