Skip to content

Conversation

@niklasschmitz
Copy link
Collaborator

@niklasschmitz niklasschmitz commented Feb 11, 2025

This is a problem I encountered from AD, but the underlying problem seems to lie in src/response/chi0.jl:

Currently, for zero temperature the variation of the Fermi level returned by apply_χ0_4P is always exactly zero (see chi0.jl). This is inconsistent with the zero-temperature convention to define the Fermi level as $\varepsilon_F = (HOMO + LUMO)/2$ which we also use in DFTK (cf src/occupation.jl), and disagrees with finite differences.

However, another problem to anticipate is that the zero-temperature definition will be non-differentiable at eigenvalue crossings. I'm not yet sure what the best solution is in such a case. Maybe we can throw a warning if we have near-degenerate eigenvalues at HOMO or LUMO with very different derivatives, indicating an eigenvalue splitting.

TODO list:

  • Add (failing) extra tests on apply_χ0_4P for the variation δεF of the Fermi level against finite differences.
  • Fix the problem at zero temperature

@antoine-levitt
Copy link
Member

It's fair to move epsF as well for consistency , although you shouldn't depend on its result for anything (since it's just a convention)

If there is no gap at zero temperature, the system is not well behaved and we just have to tell the user to add temperature (currently; this may eventually change)

@niklasschmitz
Copy link
Collaborator Author

I think it's even worse, since the problem even appears in a system with a large gap: In the case that either HOMO or LUMO has a degeneracy (e.g. GaAs band structure at gamma point) which splits due to an external perturbation (for example due to strain, breaking lattice symmetry - something I am currently looking at, so that's how I got here :) ).

@antoine-levitt
Copy link
Member

Ah, I see what you mean. Why do you care about this anyway? the variations of eps_F are not observable

@niklasschmitz
Copy link
Collaborator Author

I'm thinking about applications of AD to inverse design problems for engineering band structure properties. That led me to correctness questions around our AD ForwardDiff SCF rule in particular for bands & fermi level.

Since at zero temperature εF has a wrong derivative wrt external perturbation but eigenvalues has the correct derivative, then the shifted bands eigenvalues - εF get a (uniformly) wrong derivative, which is what currently happens.

abussy and others added 23 commits November 17, 2025 10:23
Bumps [julia-actions/setup-julia](https://github.com/julia-actions/setup-julia) from 1 to 2.
- [Release notes](https://github.com/julia-actions/setup-julia/releases)
- [Changelog](https://github.com/julia-actions/setup-julia/blob/master/devdocs/making_a_new_release.md)
- [Commits](julia-actions/setup-julia@v1...v2)

---
updated-dependencies:
- dependency-name: julia-actions/setup-julia
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Port XC term instantiation and forces to GPU

* Implemented suggested changes

* Type instabilit yfix

* Suggested changes + fix type instability

---------

Co-authored-by: Michael F. Herbst <[email protected]>
Co-authored-by: Michael F. Herbst <[email protected]>
* Extend GPU documentation

* fix

* GPU doc up
* Add failing testcases for strain DFPT

* Make ResponseOptions verbose=true default, as for SCF

* Adjust tolerance on strain-forwarddiff test

* Fix ForwardDiff response for strain perturbation

* Replace deepcopy by type promotion in allocating Hamiltonian multiplication

* Update comment on *(H, ψ) allocation + type promotion

* Add anisotropic strain ForwardDiff case

* Simplify basis response combination of explicit (basis_dual) and implicit (\delta results) contributions
Technici4n and others added 30 commits November 17, 2025 10:25
Probably a copy/paste mistake when I changed how the test matrix is produced...
BTW, naming the term Entropy is confusing, because what's computed is -TS, not S. Should we rename it to Entropic?
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Increase GPU robustness of LOBPCG

* Introduce safe_cholesky function in LOBPCG

* Add reference to CUDA.jl issue
---------

Co-authored-by: Bruno Ploumhans <[email protected]>
Co-authored-by: Michael F. Herbst <[email protected]>
)

Co-authored-by: CompatHelper Julia <[email protected]>
Co-authored-by: Michael F. Herbst <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.