Skip to content

Commit

Permalink
add selector_hartree to meanfield
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosanjose committed Dec 10, 2024
1 parent 8a8b193 commit 9ea20da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/docstrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/meanfield.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)))

Expand Down
2 changes: 1 addition & 1 deletion src/solvers/green/schur.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 9ea20da

Please sign in to comment.