diff --git a/src/docstrings.jl b/src/docstrings.jl index 7a919af7..9ee2e319 100644 --- a/src/docstrings.jl +++ b/src/docstrings.jl @@ -2670,7 +2670,8 @@ where `U` is the onsite interaction. - `charge`: a number (in single-orbital systems) or a matrix (in multi-orbital systems) representing the charge operator on each site. Default: `I` - `nambu::Bool`: specifies whether the model is defined in Nambu space. In such case, `charge` should also be in Nambu space, typically `SA[1 0; 0 -1]` or similar. Default: `false` - `namburotation::Bool`: if `nambu == true` and spinful systems, specifies whether the spinor basis is `[c↑, c↓, c↓⁺, -c↑⁺]` (`namburotation = true`) or `[c↑, c↓, c↑⁺, c↓⁺]` (`namburotation = false`). Default: `false` -- `selector::NamedTuple`: a collection of `hopselector` directives that defines the pairs of sites (`pair_selection` above) that interact through the charge-charge potential. Default: `(; range = 0)` (i.e. onsite) +- `selector::NamedTuple`: a collection of `hopselector` directives that defines the pairs of sites (`pair_selection` above) that interact through the charge-charge potential. Default: `(; range = 0)` (i.e. only onsite) +- `selector_hartree::NamedTuple`: same as `selector`, but restricted to the Hartree interaction. Useful to do efficient Hartree-only simulations, by setting `fock = 0` and leaving `selector` at its `(; range =0)` default. Then, having a large range in `selector_hartree` will be cheap. Default: `selector`. Any additional keywords `kw` are passed to the `densitymatrix` function used to compute the mean field, see above diff --git a/src/meanfield.jl b/src/meanfield.jl index bdff0887..de666312 100644 --- a/src/meanfield.jl +++ b/src/meanfield.jl @@ -26,7 +26,7 @@ struct ZeroField end function meanfield(g::GreenFunction{T,E}, args...; potential = Returns(1), hartree = potential, fock = hartree, onsite = missing, charge = I, nambu::Bool = false, namburotation = missing, - selector::NamedTuple = (; range = 0), kw...) where {T,E} + selector::NamedTuple = (; range = 0), selector_hartree = selector, kw...) where {T,E} Vh = sanitize_potential(hartree) Vf = sanitize_potential(fock) @@ -46,8 +46,8 @@ function meanfield(g::GreenFunction{T,E}, args...; lat = lattice(hamiltonian(g)) # The sparse structure of hFock will be inherited by the evaluated mean field. Need onsite. 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) + hHartree = (Uf == U && Vh == Vf && selector == selector_hartree) ? hFock : + lat |> hopping((r, dr) -> iszero(dr) ? U : T(Vh(dr)); selector_hartree..., includeonsite = true) # this drops zeros potHartree = T.(sum(unflat, harmonics(hHartree))) diff --git a/src/solvers/green/schur.jl b/src/solvers/green/schur.jl index de3174c1..4ff3acbc 100644 --- a/src/solvers/green/schur.jl +++ b/src/solvers/green/schur.jl @@ -697,7 +697,7 @@ function (s::DensityMatrixSchurSolver)(µ, kBT; params...) xs = sort!(ϕs ./ (2π)) pushfirst!(xs, -0.5) push!(xs, 0.5) - xs = [mean(view(xs, rng)) for rng in approxruns(xs)] # elliminate approximate duplicates + xs = [mean(view(xs, rng)) for rng in approxruns(xs)] # eliminate approximate duplicates result = call!_output(s.gs) integrand!(x) = fermi_h!(result, s, 2π * x, µ, inv(kBT); params...) fx! = (y, x) -> (y .= integrand!(x))