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
16 changes: 15 additions & 1 deletion src/fciqmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,18 @@ 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, NS, GramSchmidt{N}}) where {N, NS}
jamie-tay marked this conversation as resolved.
Show resolved Hide resolved
proceed = true
if state.step[] % replica.spectral_strategy.orthogonalisation_interval == 0
for i in 1:N
for j in 1:i-1
add!(replica[i].v, replica[j].v, -1*dot(replica[j].v,replica[i].v)/dot(replica[j].v, replica[j].v), One())
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
jamie-tay marked this conversation as resolved.
Show resolved Hide resolved
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}
orthogonalisation_interval::Int
jamie-tay marked this conversation as resolved.
Show resolved Hide resolved
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(num_spectral_states = 1, orthogonalisation_interval = 1)
return GramSchmidt{num_spectral_states}(orthogonalisation_interval)
jamie-tay marked this conversation as resolved.
Show resolved Hide resolved
end
Loading