Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excited states #269

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
18 changes: 17 additions & 1 deletion src/fciqmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,20 @@ end
function advance!(algorithm, report, state::ReplicaState, replica::SpectralState{1})
return advance!(algorithm, report, state, only(replica.single_states))
end
# TODO: add advance! for SpectralState{N} where N > 1

function advance!(algorithm, report, state::ReplicaState, replica::SpectralState{N, <:Any, GramSchmidt{N}}) where {N}
proceed = true
if state.step[] % replica.spectral_strategy.orthogonalisation_interval == 0
for i in 1:N
for j in 1:i-1
u = replica[i].v
v = replica[j].v
add!(u, v, -dot(u, v) / dot(v, v))
jamie-tay marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
for i in 1:N
proceed &= advance!(algorithm, report, state, replica[i])
end
return proceed
end
11 changes: 6 additions & 5 deletions src/strategies_and_params/spectralstrategy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ num_spectral_states(::SpectralStrategy{S}) where {S} = S
GramSchmidt{S} <: SpectralStrategy{S}

Use the Gram-Schmidt procedure to orthogonalize the excited states. A total of `S` spectral
states are used in the simulation.
states are used in the simulation, and they are orthogonalised every `orthogonalisation_interval` steps.
jamie-tay marked this conversation as resolved.
Show resolved Hide resolved
"""
struct GramSchmidt{S} <: SpectralStrategy{S} end
struct GramSchmidt{S} <: SpectralStrategy{S}
orthogonalization_interval::Int
end

function GramSchmidt(num_spectral_states = 1)
num_spectral_states > 1 && throw(ArgumentError("num_spectral_states > 1 is currently not supported."))
GramSchmidt{num_spectral_states}()
function GramSchmidt(S = 1; orthogonalization_interval = 1)
return GramSchmidt{S}(orthogonalization_interval)
end
Loading