Skip to content

Commit

Permalink
skip contact evaluation when building GreenSlice identity
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosanjose committed Feb 27, 2025
1 parent 08ac987 commit 13c9e50
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/greenfunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ end
function call!(g::GreenFunction{T}, ω::Complex{T}; params...) where {T}
gsolver = solver(g)
contacts´ = contacts(g)
Σblocks = call!(contacts´, ω; params...)
Σblocks = supports_contacts(gsolver) ? call!(contacts´, ω; params...) : missing
corbs = contactorbitals(contacts´)
slicer = build_slicer(gsolver, g, ω, Σblocks, corbs; params...)
return GreenSolution(g, slicer, Σblocks, corbs)
Expand All @@ -79,6 +79,8 @@ retarded_omega(ω::T, s::AppliedGreenSolver) where {T<:Real} =
# fallback, may be overridden
needs_omega_shift(s::AppliedGreenSolver) = true

supports_contacts(s::AppliedGreenSolver) = true

#endregion

############################################################################################
Expand Down
5 changes: 3 additions & 2 deletions src/observables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,14 @@ function densitymatrix(gs::GreenSlice{T}, path::AbstractIntegrationPath; omegama
end

# we need to add the arc path segment from -∞ to ∞ * p.cisinf
# we use the syntax gs(::UniformScaling) to find the identity matrix of our slice, see internal.jl
function post_transform_rho(p::RadialPath, gs)
arc = gs((p.angle/π)*I)
function post(x)
function post!(x)
x .+= arc
return x
end
return post
return post!
end

post_transform_rho(::AbstractIntegrationPath, _) = identity
Expand Down
4 changes: 4 additions & 0 deletions src/solvers/green/internal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Given a function f(ω) that returns a function fω(::CellOrbital, ::CellOrbital),
# implement an AppliedGreenSolver that returns a s::ModelGreenSlicer that returns fω(i,j)
# for each single orbital when calling getindex(s, ::CellOrbitals...). view not supported.
# Contact self energies are ignored.
#region

struct AppliedModelGreenSolver{F} <: AppliedGreenSolver
Expand All @@ -18,6 +19,7 @@ end

## API ##

# build an identity matrix over the slice. We use an AppliedModelGreenSolver for this
function (g::GreenSlice)(x::UniformScaling)
s = AppliedModelGreenSolver(Returns((i, j) -> ifelse(i == j, x.λ, zero(x.λ))))
= swap_solver(g, s)
Expand All @@ -37,6 +39,8 @@ end

needs_omega_shift(s::AppliedModelGreenSolver) = false

supports_contacts(s::AppliedModelGreenSolver) = false

minimal_callsafe_copy(s::AppliedModelGreenSolver, args...) = s

Base.getindex(s::ModelGreenSlicer, is::CellOrbitals, js::CellOrbitals) =
Expand Down
5 changes: 5 additions & 0 deletions test/test_greenfunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ end
@test real(only(ρ(0, 0; o = -1.5))) < 1e-7
d = Quantica.integrand(ρ)
@test_throws MethodError d(2; o = 0.8)

# test that contacts are ignored when building a GreenSlice identity
g = LP.linear() |> supercell(2) |> hopping(1) |> attach(@onsite->error())) |> greenfunction
@test_throws ErrorException g(0)[]
@test g[sites(1), sites(1:2)](2I) == SA[2 0] # doesn't throw
end

@testset "greenfunction aliasing" begin
Expand Down

0 comments on commit 13c9e50

Please sign in to comment.