Skip to content

Commit

Permalink
fix algorithm bug
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimbrand committed May 20, 2024
1 parent 069f972 commit fa142cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/ExactDiagonalization/ExactDiagonalization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ using CommonSolve: CommonSolve, solve, init
using VectorInterface: VectorInterface, add
using OrderedCollections: freeze
using NamedTupleTools: delete
using Setfield: @set

using Rimu: Rimu, DictVectors, Hamiltonians, Interfaces, BitStringAddresses, replace_keys,
clean_and_warn_if_others_present
Expand Down
4 changes: 2 additions & 2 deletions src/ExactDiagonalization/init_and_solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function CommonSolve.init( # no algorithm specified as positional argument
kw_nt = (; p.kw_nt..., kwargs...) # remove duplicates
algorithm = get(kw_nt, :algorithm, LinearAlgebraSolver())
kw_nt = delete(kw_nt, (:algorithm,))

return init(p, algorithm; kw_nt...)
new_prp = ExactDiagonalizationProblem(p.hamiltonian, p.v0; kw_nt...)
return init(new_prp, algorithm)
end


Expand Down
11 changes: 11 additions & 0 deletions test/ExactDiagonalization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,15 @@ Random.seed!(1234) # for reproducibility, as some solvers start with random vect
s3 = init(p3, KrylovKitSolver(); howmany=5)
r3 = solve(s3)
@test r3.success

# specify algorithm in ExactDiagonalizationProblem
p4 = ExactDiagonalizationProblem(
HubbardReal1D(BoseFS(1, 2, 3)), DVec(BoseFS(1, 2, 3) => 2.3),
algorithm=KrylovKitSolver(; howmany=3)
)
solver = init(p4)
@test solver.algorithm isa KrylovKitSolver
@test solver.kw_nt == (howmany=3,)
res = solve(solver)
@test res.success
end

0 comments on commit fa142cb

Please sign in to comment.