Skip to content

Commit

Permalink
Bugfix: ensure correct dealiasing of lattices after attach
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosanjose committed Nov 26, 2024
1 parent 4b5fa25 commit d18203b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,7 @@ LinearAlgebra.ishermitian(h::ParametricHamiltonian) =
argerror("`ishermitian(::ParametricHamiltonian)` not supported, as the result can depend on the values of parameters.")

copy_lattice(p::ParametricHamiltonian) = ParametricHamiltonian(
copy_lattice(p.hparent), p.h, p.modifiers, p.allptrs, p.allparams)
p.hparent, copy_lattice(p.h), p.modifiers, p.allptrs, p.allparams)

copy_harmonics_shallow(p::ParametricHamiltonian) = ParametricHamiltonian(
copy_harmonics_shallow(p.hparent), copy_harmonics_shallow(p.h), p.modifiers, p.allptrs, p.allparams)
Expand Down
9 changes: 8 additions & 1 deletion test/test_greenfunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ end
@test typeof(ρ0sol) == typeof(ρsol)
end

@testset "aliasing" begin
@testset "greenfunction aliasing" begin
# Issue #267
g = LP.linear() |> hamiltonian(@hopping((; q = 1) -> q*I), orbitals = 2) |> greenfunction
= Quantica.minimal_callsafe_copy(g)
Expand Down Expand Up @@ -561,6 +561,13 @@ end
@test g.contacts.selfenergies[2].solver.hlead[(0,)] === g.contacts.selfenergies[1].solver.hlead[(0,)]
@test g.contacts.selfenergies[2].solver.hlead[(1,)] === g.contacts.selfenergies[1].solver.hlead[(-1,)]
@test g.contacts.selfenergies[2].solver.hlead[(-1,)] === g.contacts.selfenergies[1].solver.hlead[(1,)]

# ensure full dealiasing of lattices in attach
model = hopping(SA[1 0; 0 -1]) + @onsite((; µ = 0) -> SA[-µ 0; 0 µ])
h = LP.linear() |> hamiltonian(model, orbitals = 2)
glead = h |> greenfunction(GS.Schur(boundary = 0))
g = h |> attach(glead, cells = 1) |> greenfunction(GS.Schur(boundary = 0));
@test sites(lattice(h)) == [SA[0.0]]
end

@testset "meanfield" begin
Expand Down

0 comments on commit d18203b

Please sign in to comment.