Skip to content

Commit

Permalink
don't drop structural zeros in Fock potential
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosanjose committed Nov 21, 2024
1 parent 63d0465 commit b02ac86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/meanfield.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function meanfield(g::GreenFunction{T,E}, args...;
hFock = lat |> hopping((r, dr) -> iszero(dr) ? Uf : T(Vf(dr)); selector..., includeonsite = true)
hHartree = (Uf == U && Vh === Vf) ? hFock :
lat |> hopping((r, dr) -> iszero(dr) ? U : T(Vh(dr)); selector..., includeonsite = true)

# this drops zeros
potHartree = T.(sum(unflat, harmonics(hHartree)))

oaxes = orbaxes(call!_output(gs))
Expand All @@ -61,7 +61,8 @@ function meanfield(g::GreenFunction{T,E}, args...;

# this is important for the fast orbrange-based implementation of MeanField evaluation
check_cell_order(hFock_slice, rho)
potFock = T.(parent(hFock_slice))
# this does not drop zeros. Important to keep diagonal zeros
potFock = convert(SparseMatrixCSC{T,Int}, parent(hFock_slice))

encoder, decoder = nambu ? NambuEncoderDecoder(is_nambu_rotated´) : (identity, identity)
S = typeof(encoder(zero(Q)))
Expand Down Expand Up @@ -208,7 +209,7 @@ function maybe_nambufy_traces!(traces, m::MeanField{B}) where {B}
end

diag_real_tr_rho_Q(ρ, Q) =
[real(unsafe_trace_prod(Q, view(ρ, rng, rng))) for rng in siteindexdict(orbaxes(ρ, 2))]
[real(unsafe_trace_prod(Q, view(parent(ρ), rng, rng))) for rng in siteindexdict(orbaxes(ρ, 2))]

hole_id(::Type{<:SMatrix{2,2}}) = SA[0 0; 0 1]
hole_id(::Type{<:SMatrix{4,4}}) = SA[0 0 0 0; 0 0 0 0; 0 0 1 0; 0 0 0 1]
Expand Down
1 change: 0 additions & 1 deletion test/test_greenfunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ end
@test_throws ArgumentError meanfield(g)
g = LP.honeycomb() |> hamiltonian(hopping(I), orbitals = (2,1)) |> greenfunction
@test_throws ArgumentError meanfield(g)

end

@testset begin "OrbitalSliceArray serialization"
Expand Down

0 comments on commit b02ac86

Please sign in to comment.