-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move solver_funcs to separate directory. Adapt dmrg and dmrg-x to new…
… solver interface.
- Loading branch information
Showing
10 changed files
with
145 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function applyexp_solver() | ||
function solver( | ||
Check warning on line 2 in src/solvers/applyexp.jl GitHub Actions / format
|
||
init; | ||
psi_ref!, | ||
PH_ref!, | ||
region, | ||
sweep_regions, | ||
sweep_step, | ||
solver_krylovdim=30, | ||
solver_outputlevel=0, | ||
solver_tol=1E-8, | ||
substep, | ||
time_step, | ||
normalize, | ||
) | ||
H=PH_ref![] | ||
#applyexp tol is absolute, compute from tol_per_unit_time: | ||
tol = abs(time_step) * tol_per_unit_time | ||
psi, exp_info = applyexp( | ||
H, time_step, init; tol, maxiter=solver_krylovdim, outputlevel=solver_outputlevel | ||
) | ||
return psi, (; info=exp_info) | ||
end | ||
return solver | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function dmrg_x_solver( | ||
init; | ||
Check warning on line 2 in src/solvers/dmrg_x_solver.jl GitHub Actions / format
|
||
psi_ref!, | ||
PH_ref!, | ||
normalize=nothing, | ||
region, | ||
sweep_regions, | ||
sweep_step, | ||
half_sweep, | ||
step_kwargs... | ||
) | ||
H = contract(PH_ref![], ITensor(1.0)) | ||
D, U = eigen(H; ishermitian=true) | ||
Check warning on line 13 in src/solvers/dmrg_x_solver.jl GitHub Actions / format
|
||
u = uniqueind(U, H) | ||
max_overlap, max_ind = findmax(abs, array(dag(init) * U)) | ||
U_max = U * dag(onehot(u => max_ind)) | ||
# TODO: improve this to return the energy estimate too | ||
return U_max, NamedTuple() | ||
end | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
function eigsolve_solver(; | ||
solver_which_eigenvalue=:SR, #TODO: settle on pattern to pass solver kwargs | ||
Check warning on line 3 in src/solvers/eigsolve.jl GitHub Actions / format
|
||
ishermitian=true, | ||
solver_tol=1e-14, | ||
solver_krylovdim=3, | ||
solver_maxiter=1, | ||
solver_verbosity=0, | ||
) | ||
|
||
Check warning on line 10 in src/solvers/eigsolve.jl GitHub Actions / format
|
||
function solver( | ||
init; | ||
psi_ref!, | ||
PH_ref!, | ||
normalize, | ||
region, | ||
sweep_regions, | ||
sweep_step, | ||
sweep_kwargs... | ||
# slurp solver_kwargs? #TODO: homogenize how the solver kwargs are passed | ||
) | ||
howmany = 1 | ||
which = solver_which_eigenvalue | ||
vals, vecs, info = eigsolve( | ||
PH_ref![], | ||
init, | ||
howmany, | ||
which; | ||
ishermitian, | ||
tol=solver_tol, | ||
krylovdim=solver_krylovdim, | ||
maxiter=solver_maxiter, | ||
verbosity=solver_verbosity, | ||
) | ||
phi = vecs[1] | ||
return phi, (; solver_info=info, energies=vals) | ||
end | ||
return solver | ||
end | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
function exponentiate_solver() | ||
function solver( | ||
init; | ||
psi_ref!, | ||
PH_ref!, | ||
ishermitian=true, | ||
issymmetric=true, | ||
region, | ||
sweep_regions, | ||
sweep_step, | ||
solver_krylovdim=30, | ||
solver_maxiter=100, | ||
solver_outputlevel=0, | ||
solver_tol=1E-12, | ||
substep, | ||
normalize, | ||
time_step, | ||
) | ||
#H=copy(PH_ref![]) | ||
H=PH_ref![] ###since we are not changing H we don't need the copy | ||
# let's test whether given region and sweep regions we can find out what the previous and next region were | ||
# this will be needed in subspace expansion | ||
region_ind=sweep_step | ||
next_region=region_ind==length(sweep_regions) ? nothing : first(sweep_regions[region_ind+1]) | ||
previous_region=region_ind==1 ? nothing : first(sweep_regions[region_ind-1]) | ||
|
||
phi, exp_info = KrylovKit.exponentiate( | ||
H, | ||
time_step, | ||
init; | ||
ishermitian, | ||
issymmetric, | ||
tol=solver_tol, | ||
krylovdim=solver_krylovdim, | ||
maxiter=solver_maxiter, | ||
verbosity=solver_outputlevel, | ||
eager=true, | ||
) | ||
return phi, (; info=exp_info) | ||
end | ||
return solver | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,4 @@ | ||
function dmrg_x_solver( | ||
PH, init; normalize=nothing, region=nothing, half_sweep=nothing, reverse_step=nothing | ||
) | ||
H = contract(PH, ITensor(1.0)) | ||
D, U = eigen(H; ishermitian=true) | ||
u = uniqueind(U, H) | ||
max_overlap, max_ind = findmax(abs, array(dag(init) * U)) | ||
U_max = U * dag(onehot(u => max_ind)) | ||
# TODO: improve this to return the energy estimate too | ||
return U_max, NamedTuple() | ||
end | ||
|
||
function dmrg_x(PH, init::AbstractTTN; kwargs...) | ||
psi = alternating_update(dmrg_x_solver, PH, init; kwargs...) | ||
psi = alternating_update(ITensorNetworks.dmrg_x_solver, PH, init; kwargs...) | ||
return psi | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters