Skip to content

Commit

Permalink
Loosen some test bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Feb 15, 2024
1 parent 8acf211 commit ffe16bc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 34 deletions.
6 changes: 5 additions & 1 deletion test/test_dmrg_x.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ using Test

@test ITensors.scalartype(ϕ̃) == elt
@test inner', H, ψ) / inner(ψ, ψ) inner(ϕ̃', H, ϕ̃) / inner(ϕ̃, ϕ̃) rtol = 1e-1
@test inner(H, ϕ̃, H, ϕ̃) inner(ϕ̃', H, ϕ̃)^2 rtol = (eps(real(elt))) * 10^3

scale(::Type{Float32}) = 10^2
scale(::Type{Float64}) = 10^5

@test inner(H, ϕ̃, H, ϕ̃) inner(ϕ̃', H, ϕ̃)^2 rtol = (eps(real(elt))) * scale(real(elt))
# Sometimes broken, sometimes not
# @test abs(loginner(ϕ̃, ϕ) / n) ≈ 0.0 atol = 1e-6
end
Expand Down
63 changes: 30 additions & 33 deletions test/test_tdvp_time_dependent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,39 @@ using Test
include(joinpath(pkgdir(ITensorTDVP), "examples", "03_models.jl"))
include(joinpath(pkgdir(ITensorTDVP), "examples", "03_solvers.jl"))

# Functions need to be defined in global scope (outside
# of the @testset macro)

function ode_solver(H⃗₀, time_step, ψ₀; kwargs...)
ω₁ = typeof(time_step)(0.1)
ω₂ = typeof(time_step)(0.2)
ω⃗ = [ω₁, ω₂]
f⃗ = [t -> cos* t) for ω in ω⃗]
ode_alg = Tsit5()
tol = eps(real(time_step))
ode_kwargs = (; reltol=tol, abstol=tol)
return ode_solver(
-im * TimeDependentSum(f⃗, H⃗₀),
time_step,
ψ₀;
solver_alg=ode_alg,
ode_kwargs...,
kwargs...,
)
end

function krylov_solver(H⃗₀, time_step, ψ₀; kwargs...)
ω₁ = typeof(time_step)(0.1)
ω₂ = typeof(time_step)(0.2)
ω⃗ = [ω₁, ω₂]
f⃗ = [t -> cos* t) for ω in ω⃗]
tol = eps(real(time_step))
krylov_kwargs = (; tol, eager=true)
return krylov_solver(
-im * TimeDependentSum(f⃗, H⃗₀), time_step, ψ₀; krylov_kwargs..., kwargs...
)
end

@testset "Time dependent Hamiltonian (eltype=$elt)" for elt in (
Float32, Float64, Complex{Float32}, Complex{Float64}
)
function ode_solver(H⃗₀, time_step, ψ₀; kwargs...)
ω₁ = typeof(time_step)(0.1)
ω₂ = typeof(time_step)(0.2)
ω⃗ = [ω₁, ω₂]
f⃗ = [t -> cos* t) for ω in ω⃗]
ode_alg = Tsit5()
tol = eps(real(time_step))
ode_kwargs = (; reltol=tol, abstol=tol)
return ode_solver(
-im * TimeDependentSum(f⃗, H⃗₀),
time_step,
ψ₀;
solver_alg=ode_alg,
ode_kwargs...,
kwargs...,
)
end

function krylov_solver(H⃗₀, time_step, ψ₀; kwargs...)
ω₁ = typeof(time_step)(0.1)
ω₂ = typeof(time_step)(0.2)
ω⃗ = [ω₁, ω₂]
f⃗ = [t -> cos* t) for ω in ω⃗]
tol = eps(real(time_step))
krylov_kwargs = (; tol, eager=true)
return krylov_solver(
-im * TimeDependentSum(f⃗, H⃗₀), time_step, ψ₀; krylov_kwargs..., kwargs...
)
end

n = 4
J₁ = elt(1)
J₂ = elt(0.1)
Expand Down

0 comments on commit ffe16bc

Please sign in to comment.