From ec7993eff371d803cc1442fafe570702c7d25f3e Mon Sep 17 00:00:00 2001 From: Pablo San-Jose Date: Thu, 28 Nov 2024 08:56:24 +0100 Subject: [PATCH] More general Quantica.gaps --- src/observables.jl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/observables.jl b/src/observables.jl index c5b472a4..40ccd5bf 100644 --- a/src/observables.jl +++ b/src/observables.jl @@ -760,7 +760,7 @@ end # gap(::Hamiltonian, µ = 0, ...) -> minimum gap in the bands around µ #region -function gaps(h::Hamiltonian{T,<:Any,1}, µ = 0, ϕstore = missing; atol = eps(T)) where {T} +function gaps(h::Hamiltonian{T,<:Any,1}, µ = 0, ϕstore = missing; atol = eps(T), nev = 1, kw...) where {T} g = greenfunction(h, GS.Schur()) λs = schur_eigvals(g, µ) cϕs = λs .= -im .* log.(λs) # saves one allocation @@ -771,9 +771,11 @@ function gaps(h::Hamiltonian{T,<:Any,1}, µ = 0, ϕstore = missing; atol = eps(T rϕs = real.(cϕs) iϕs = chopsmall.(abs.(imag.(cϕs)), atol) ϕstore === missing || copy!(ϕstore, cϕs) - solver = ES.ShiftInvert(ES.ArnoldiMethod(nev = 1), µ) + solver = ES.ShiftInvert(ES.ArnoldiMethod(; nev, kw...), µ) n = flatsize(h) - Δs = [iszero(iϕ) || rank(h(rϕ)-µ*I; tol=atol) < n ? zero(T) : abs(first(energies(spectrum(h, rϕ; solver)))-µ) for (rϕ, iϕ) in zip(rϕs, iϕs)] + Δs = [iszero(iϕ) || rank(h(rϕ)-µ*I; tol=atol) < n ? + zero(T) : + abs(minimum(x->abs(x-µ), energies(spectrum(h, rϕ; solver)))-µ) for (rϕ, iϕ) in zip(rϕs, iϕs)] return Δs end