Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Band structure calculations and SCF restarts wrong for meta-GGA functionals #1065

Open
aouinaayoub opened this issue Feb 20, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@aouinaayoub
Copy link

Hi,

For NaCl, when using the r2SCAN meta-GGA functional in DFTK.jl, I observe a difference in the band gap at the Γ point between the SCF calculation and the band structure calculation. The band gap at Γ changes from ~5.83 eV in the SCF calculation to ~5.16 eV in the band structure calculation, even though the same converged density and orbitals are used. In Quantum ESPRESSO, the band gaps at Γ are consistent (both are 5.84 eV).

Here is how I got these results:

model = model_DFT(lattice, atoms, positions, functionals=[:mgga_x_r2scan, :mgga_c_r2scan])
basis = PlaneWaveBasis(model, Ecut=20, kgrid=(6, 6, 6))
scfres = self_consistent_field(basis, tol=1e-8)
gap_scf = 27.211 * (scfres.eigenvalues[1][9] - scfres.eigenvalues[1][8])

result: ~5.83 eV

Compute bands:

bands = compute_bands(scfres, MonkhorstPack(12, 12, 12), ψguess=scfres.ψ, tol=1e-8)
gap_bands = 27.211 * (bands.eigenvalues[1][9] - bands.eigenvalues[1][8])

result: ~5.16 eV

This also happens when I do an extra SCF loop after convergence:

scfres_pp = self_consistent_field(basis, ρ=scfres.ρ, ψ=scfres.ψ, maxiter=1)
gap_scf_pp = 27.211 * (scfres_pp.eigenvalues[1][9] - scfres_pp.eigenvalues[1][8])

result: ~5.16 eV

  • Why does the band gap at Γ change between the SCF and band structure calculations?

An unrelated question:

  • In this example, with Ecut=20, the fft_size in DFTK.jl is (36, 36, 36), while in QE/Abinit, it is (32, 32, 32). Is there a way to ensure the same fft_size as QE, without using DFTK.interpolate_density?
@mfherbst
Copy link
Member

mfherbst commented Feb 20, 2025

Thanks for reporting. My suspicion is this has to do with the way we handle the kinetic energy density, which right now is not part of the scf state. I should add, that our meta-GGA implementation is not yet as widely tested as the other methods.

So if my suspicion is true, try also passing the occupations to compute bands.

Regarding the fft size: We use a different algorithm than the other codes,which is less tight. You can always pass a custom fft_size when constructing a basis as a kwarg.

@mfherbst mfherbst added the bug Something isn't working label Feb 20, 2025
@mfherbst
Copy link
Member

mfherbst commented Feb 20, 2025

I just realise occupation cannot be currently passed to an SCF or a compute_bands and honestly I'm not sure it would be the right thing to do here. I think what we need to do is put the kinetic energy density in the SCF state in the same way as the density itself. Feel free to give this a go @aouinaayoub if you want ... I will not have the time to get to this in the next weeks.

Right now one option to get the correct meta-GGA bands is to manually execute https://github.com/JuliaMolSim/DFTK.jl/blob/master/src/postprocess/band_structure.jl#L14-L50 and in https://github.com/JuliaMolSim/DFTK.jl/blob/master/src/postprocess/band_structure.jl#L31 setup the Hamiltonian as

τ =  DFTK.compute_kinetic_energy_density(basis, scfres.ψ, scfres.occupation)
ham = Hamiltonian(bs_basis; ρ, τ)

@mfherbst mfherbst changed the title Difference in Band Gap at Γ Between SCF and Band Structure Calculation for r2SCAN Meta-GGA Functional Band structure calculations and SCF restarts wrong for meta-GGA functionals Feb 20, 2025
@antoine-levitt
Copy link
Member

We don't currently have a good way to express "the things that are needed to express the hamiltonian, and that should be mixed during an scf". We will need such an extended API for eg noncollinear spin, hybrid functionals, etc, so we should tackle it in a relatively generic way.

@aouinaayoub
Copy link
Author

I just realise occupation cannot be currently passed to an SCF or a compute_bands and honestly I'm not sure it would be the right thing to do here. I think what we need to do is put the kinetic energy density in the SCF state in the same way as the density itself. Feel free to give this a go @aouinaayoub if you want ... I will not have the time to get to this in the next weeks.

Right now one option to get the correct meta-GGA bands is to manually execute https://github.com/JuliaMolSim/DFTK.jl/blob/master/src/postprocess/band_structure.jl#L14-L50 and in https://github.com/JuliaMolSim/DFTK.jl/blob/master/src/postprocess/band_structure.jl#L31 setup the Hamiltonian as

τ = DFTK.compute_kinetic_energy_density(basis, scfres.ψ, scfres.occupation)
ham = Hamiltonian(bs_basis; ρ, τ)

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants