Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
bc0e2eb
Adding Hubbard
fsicignano Sep 25, 2025
d4dfa7b
Complex Spherical Harmonics have been removed
fsicignano Sep 25, 2025
48a33f0
Correction to testcases.jl
fsicignano Sep 25, 2025
6c77122
Added test for hubbard term
fsicignano Sep 25, 2025
5540b22
Added explicit import of Hubbard in testcases.jl
fsicignano Sep 25, 2025
9e894bf
Speed up of the hubbard test
fsicignano Sep 25, 2025
4a1d0e2
Hubbard test now functional
fsicignano Sep 25, 2025
db7d948
Still errors in the consistency test
fsicignano Sep 26, 2025
e0a1002
Some comments have been resolved
fsicignano Sep 29, 2025
7045a6d
Some comments have been resolved
fsicignano Sep 29, 2025
fab6fb5
Comments have been resolved
fsicignano Sep 29, 2025
ae13ba7
Comments have been resolved
fsicignano Sep 29, 2025
5aefec2
Added nhubbard field to scfres in forwarddiff_rules.
fsicignano Sep 30, 2025
0d69edd
Update to Wigner_sym, now wigner_d_matrix and relative test
fsicignano Sep 30, 2025
d0cf01a
Change in testing
fsicignano Sep 30, 2025
16a3f6f
New example in examples/hubbard.jl
fsicignano Oct 2, 2025
c9d8328
use_nlcc=false for all mgga tests
fsicignano Oct 3, 2025
f905197
Most comments have been addressed
fsicignano Oct 7, 2025
7ea2342
Several issues solved
fsicignano Oct 7, 2025
3b72e16
Merge branch 'master' into hubbard-v2
fsicignano Oct 7, 2025
42b5f85
Semplification in compute_nhubbard
fsicignano Oct 9, 2025
5a95c9d
Simplification to the apply!(HubbardUOperator)
fsicignano Oct 9, 2025
20b1370
Merge branch 'hubbard-v2' of https://github.com/fsicignano/DFTK.jl in…
fsicignano Oct 9, 2025
914bbe6
Simplification to the apply!(HubbardUOperator)
fsicignano Oct 9, 2025
b31874d
New comments addressed
fsicignano Oct 9, 2025
d4cb53c
New comments addressed
fsicignano Oct 10, 2025
aeab561
Merge branch 'master' into hubbard-v2
fsicignano Oct 10, 2025
1fad1c8
Issue solved with mpi
fsicignano Oct 10, 2025
efc83f5
ntermediate version
fsicignano Oct 21, 2025
074f539
New simplified version
fsicignano Oct 22, 2025
41bebad
New simplified version
fsicignano Oct 22, 2025
a431717
New simplified version
fsicignano Oct 22, 2025
8a87487
Test issue solved
fsicignano Oct 23, 2025
52a20d8
Merge branch 'master' into hubbard-v2
fsicignano Oct 23, 2025
8de7498
Updating branch
fsicignano Oct 23, 2025
8f636d7
Merge branch 'hubbard-v2' of https://github.com/fsicignano/DFTK.jl in…
fsicignano Oct 23, 2025
75cc62c
Test hubbard.jl fixed for mpi case
fsicignano Oct 24, 2025
b2da690
New comments addressed
fsicignano Oct 24, 2025
761ee8b
New comments have been addressed
fsicignano Oct 28, 2025
ea48cca
Update examples/hubbard.jl
fsicignano Oct 28, 2025
b7e90bb
New comments have been addressed
fsicignano Oct 29, 2025
3cf787e
Merge branch 'master' into hubbard-v2
fsicignano Oct 29, 2025
0e17b63
Merge branch 'hubbard-v2' of https://github.com/fsicignano/DFTK.jl in…
fsicignano Oct 29, 2025
2fe39dc
Be more explicit
mfherbst Oct 29, 2025
3c611b1
Cosmetic fixes to example
mfherbst Oct 29, 2025
aecf0bd
Announce feature
mfherbst Oct 29, 2025
1d4d73c
Minor changes
fsicignano Nov 5, 2025
15304e7
Modifications to the OrbitalManifold interface
fsicignano Nov 10, 2025
253931d
Merge branch 'hubbard-v2' of https://github.com/fsicignano/DFTK.jl in…
fsicignano Nov 10, 2025
f649481
Name 'nhubbard' converted to 'hubbard_n'
fsicignano Nov 10, 2025
df51495
Merge branch 'master' into hubbard-v2
fsicignano Nov 10, 2025
5c05a9f
New constructors added for OrbitalManifold. Testing
fsicignano Nov 11, 2025
a021e32
Various changes
Technici4n Nov 12, 2025
e2d97d6
Minor tweaks
Technici4n Nov 12, 2025
2da2d03
Fix tests not testing anything
Technici4n Nov 12, 2025
9f7dbcd
Reorder OrbitalManifold constructors
Technici4n Nov 12, 2025
ca16a44
Move hubbard_n computation down
Technici4n Nov 12, 2025
7aab38e
Review comments
Technici4n Nov 12, 2025
3533669
Minor typo in documentation
fsicignano Nov 13, 2025
99bddba
Merge branch 'master' into hubbard-v2
fsicignano Nov 13, 2025
872c29a
Reduce example running time, update manifold naming comment
Technici4n Nov 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/DFTK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export AtomicNonlocal
export Ewald
export PspCorrection
export Entropy
export Hubbard
export Magnetic
export PairwisePotential
export Anyonic
Expand Down
7 changes: 5 additions & 2 deletions src/postprocess/band_structure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All kwargs not specified below are passed to [`diagonalize_all_kblocks`](@ref):
kgrid::Union{AbstractKgrid,AbstractKgridGenerator};
n_bands=default_n_bands_bandstructure(basis.model),
n_extra=3, ρ=nothing, τ=nothing, εF=nothing,
occupation=nothing, nhubbard=nothing,
eigensolver=lobpcg_hyper, tol=1e-3, kwargs...)
# kcoords are the kpoint coordinates in fractional coordinates
if isnothing(ρ)
Expand All @@ -34,7 +35,7 @@ All kwargs not specified below are passed to [`diagonalize_all_kblocks`](@ref):
# Create new basis with new kpoints
bs_basis = PlaneWaveBasis(basis, kgrid)

ham = Hamiltonian(bs_basis; ρ, τ)
ham = Hamiltonian(bs_basis; ρ, τ, nhubbard, occupation)
eigres = diagonalize_all_kblocks(eigensolver, ham, n_bands + n_extra;
n_conv_check=n_bands, tol, kwargs...)
if !eigres.converged
Expand Down Expand Up @@ -66,7 +67,9 @@ function compute_bands(scfres::NamedTuple,
kgrid::Union{AbstractKgrid,AbstractKgridGenerator};
n_bands=default_n_bands_bandstructure(scfres), kwargs...)
τ = haskey(scfres, :τ) ? scfres.τ : nothing
compute_bands(scfres.basis, kgrid; scfres.ρ, τ, scfres.εF, n_bands, kwargs...)
nhubbard = haskey(scfres, :nhubbard) ? scfres.nhubbard : nothing
occupation = scfres.occupation
compute_bands(scfres.basis, kgrid; scfres.ρ, τ, nhubbard, occupation, scfres.εF, n_bands, kwargs...)
end

"""
Expand Down
26 changes: 1 addition & 25 deletions src/postprocess/dos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,31 +119,6 @@ function compute_pdos(εs, bands; kwargs...)
compute_pdos(εs, bands.basis, bands.ψ, bands.eigenvalues; kwargs...)
end

"""
Structure for manifold choice and projectors extraction.

Overview of fields:
- `iatom`: Atom position in the atoms array.
- `species`: Chemical Element as in ElementPsp.
- `label`: Orbital name, e.g.: "3S".

All fields are optional, only the given ones will be used for selection.
Can be called with an orbital NamedTuple and returns a boolean
stating whether the orbital belongs to the manifold.
"""
@kwdef struct OrbitalManifold
iatom ::Union{Int64, Nothing} = nothing
species ::Union{Symbol, AtomsBase.ChemicalSpecies, Nothing} = nothing
label ::Union{String, Nothing} = nothing
end
function (s::OrbitalManifold)(orb)
iatom_match = isnothing(s.iatom) || (s.iatom == orb.iatom)
# See JuliaMolSim/AtomsBase.jl#139 why both species equalities are needed
species_match = isnothing(s.species) || (s.species == orb.species) || (orb.species == s.species)
label_match = isnothing(s.label) || (s.label == orb.label)
iatom_match && species_match && label_match
end

"""
atomic_orbital_projectors(basis; [isonmanifold, positions])

Expand Down Expand Up @@ -191,6 +166,7 @@ function atomic_orbital_projectors(basis::PlaneWaveBasis{T};
labels = []
for (iatom, atom) in enumerate(basis.model.atoms)
psp = atom.psp
@assert !iszero(size(psp.r2_pswfcs[1], 1)) "FATAL ERROR: No Atomic projector found within the provided PseudoPotential."
for l in 0:psp.lmax, n in 1:DFTK.count_n_pswfc_radial(psp, l)
label = DFTK.pswfc_label(psp, n, l)
if !isonmanifold((; iatom, atom.species, label))
Expand Down
22 changes: 14 additions & 8 deletions src/scf/self_consistent_field.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Overview of parameters:
basis::PlaneWaveBasis{T};
ρ=guess_density(basis),
τ=any(needs_τ, basis.terms) ? zero(ρ) : nothing,
nhubbard=nothing,
ψ=nothing,
tol=1e-6,
is_converged=ScfConvergenceDensity(tol),
Expand All @@ -157,12 +158,12 @@ Overview of parameters:
# We do density mixing in the real representation
# TODO support other mixing types
function fixpoint_map(ρin, info)
(; ψ, occupation, eigenvalues, εF, n_iter, converged, timedout, τ) = info
(; ψ, occupation, eigenvalues, εF, n_iter, converged, timedout, τ, nhubbard) = info
n_iter += 1

# Note that ρin is not the density of ψ, and the eigenvalues
# are not the self-consistent ones, which makes this energy non-variational
energies, ham = energy_hamiltonian(basis, ψ, occupation; ρ=ρin, τ, eigenvalues, εF)
energies, ham = energy_hamiltonian(basis, ψ, occupation; ρ=ρin, τ, nhubbard, eigenvalues, εF)

# Diagonalize `ham` to get the new state
nextstate = next_density(ham, nbandsalg, fermialg; eigensolver, ψ, eigenvalues,
Expand All @@ -178,16 +179,21 @@ Overview of parameters:
if any(needs_τ, basis.terms)
τ = compute_kinetic_energy_density(basis, ψ, occupation)
end
for (iterm, term) in enumerate(basis.terms)
if typeof(term)==DFTK.TermHubbard{Vector{Matrix{ComplexF64}}, Vector{Any}}
nhubbard = compute_nhubbard(term.manifold, basis, ψ, occupation; projectors=term.P, labels=term.labels).nhubbard
end
end

# Update info with results gathered so far
info_next = (; ham, basis, converged, stage=:iterate, algorithm="SCF",
ρin, τ, α=damping, n_iter, nbandsalg.occupation_threshold,
ρin, τ, nhubbard, α=damping, n_iter, nbandsalg.occupation_threshold,
runtime_ns=time_ns() - start_ns, nextstate...,
diagonalization=[nextstate.diagonalization])

# Compute the energy of the new state
if compute_consistent_energies
(; energies) = energy(basis, ψ, occupation; ρ=ρout, τ, eigenvalues, εF)
(; energies) = energy(basis, ψ, occupation; ρ=ρout, τ, nhubbard, eigenvalues, εF)
end
history_Etot = vcat(info.history_Etot, energies.total)
history_Δρ = vcat(info.history_Δρ, norm(Δρ) * sqrt(basis.dvol))
Expand All @@ -209,7 +215,7 @@ Overview of parameters:
ρnext, info_next
end

info_init = (; ρin=ρ, τ, ψ, occupation=nothing, eigenvalues=nothing, εF=nothing,
info_init = (; ρin=ρ, τ, nhubbard, ψ, occupation=nothing, eigenvalues=nothing, εF=nothing,
n_iter=0, n_matvec=0, timedout=false, converged=false,
history_Etot=T[], history_Δρ=T[])

Expand All @@ -219,13 +225,13 @@ Overview of parameters:
# We do not use the return value of solver but rather the one that got updated by fixpoint_map
# ψ is consistent with ρout, so we return that. We also perform a last energy computation
# to return a correct variational energy
(; ρin, ρout, τ, ψ, occupation, eigenvalues, εF, converged) = info
energies, ham = energy_hamiltonian(basis, ψ, occupation; ρ=ρout, τ, eigenvalues, εF)
(; ρin, ρout, τ, nhubbard, ψ, occupation, eigenvalues, εF, converged) = info
energies, ham = energy_hamiltonian(basis, ψ, occupation; ρ=ρout, τ, nhubbard, eigenvalues, εF)

# Callback is run one last time with final state to allow callback to clean up
scfres = (; ham, basis, energies, converged, nbandsalg.occupation_threshold,
ρ=ρout, τ, α=damping, eigenvalues, occupation, εF, info.n_bands_converge,
info.n_iter, info.n_matvec, ψ, info.diagonalization, stage=:finalize,
info.n_iter, info.n_matvec, ψ, nhubbard, info.diagonalization, stage=:finalize,
info.history_Δρ, info.history_Etot, info.timedout, mixing,
runtime_ns=time_ns() - start_ns, algorithm="SCF")
callback(scfres)
Expand Down
2 changes: 1 addition & 1 deletion src/symmetry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function accumulate_over_symmetries!(ρaccu, ρin, basis::PlaneWaveBasis{T}, sym
# Looping over symmetries inside of map! on G vectors allow for a single GPU kernel launch
map!(ρaccu, Gs) do G
acc = zero(complex(T))
# Explicit loop over indicies because AMDGPU does not support zip() in map!
# Explicit loop over indices because AMDGPU does not support zip() in map!
for i_symm in 1:n_symm
invS = symm_invS[i_symm]
τ = symm_τ[i_symm]
Expand Down
Loading
Loading