electronic-structure / SIRIUS

Domain specific library for electronic structure calculations
BSD 3-Clause "New" or "Revised" License
127 stars 40 forks source link

Magnetization of Ni from QE and q-e-sirius #786

Closed gsavva closed 1 year ago

gsavva commented 1 year ago

Quantum ESPRESSO and SIRIUS-enabled QE calculate different total and absolute magnetization for Ni.

The input file is taken from the PW examples of QE: qe/PW/examples/example01

Quantum ESPRESSO:

!    total energy              =     -85.72256763 Ry
     estimated scf accuracy    <          5.5E-17 Ry
     smearing contrib. (-TS)   =       0.00034633 Ry
     internal energy E=F+TS    =     -85.72291396 Ry

     The total energy is F=E-TS. E is the sum of the following terms:
     one-electron contribution =       0.29268335 Ry
     hartree contribution      =      14.34695258 Ry
     xc contribution           =     -29.60850553 Ry
     ewald contribution        =     -70.75404435 Ry

     total magnetization       =     0.62 Bohr mag/cell
     absolute magnetization    =     0.69 Bohr mag/cell

SIRIUS-enabled QE:

!    total energy              =     -85.72256763 Ry
     estimated scf accuracy    <          0.0E+00 Ry
     smearing contrib. (-TS)   =       0.00034633 Ry
     internal energy E=F+TS    =     -85.72291396 Ry

     The total energy is F=E-TS. E is the sum of the following terms:
     one-electron contribution =       0.29268278 Ry
     hartree contribution      =      14.34695338 Ry
     xc contribution           =     -29.60850579 Ry
     ewald contribution        =     -70.75404435 Ry
     scf correction            =       0.00000002 Ry

     total magnetization       =     7.00 Bohr mag/cell
     absolute magnetization    =     7.00 Bohr mag/cell

The input file, the pseudopotential used and the outputs from QE and SIRIUS are attached below. The output files contain all the information on the exact versions of QE and SIRIUS used.

Ni_in_out_pseudo.zip

toxa81 commented 1 year ago

It's fetching of the magnetisation that is wrong. The total energies (and thus ground state) are identical. I'll check

toxa81 commented 1 year ago

The fix is easy

diff --git a/PW/src/electrons.f90 b/PW/src/electrons.f90
index cde64f349..4a47e8886 100644
--- a/PW/src/electrons.f90
+++ b/PW/src/electrons.f90
@@ -639,6 +639,7 @@ SUBROUTINE electrons_scf ( printout, exxen )
       etot = etot + descf
     ENDIF

+    CALL get_density_from_sirius()
     IF ( lsda .OR. noncolin ) CALL compute_magnetization()
     CALL print_energies ( printout )

There is one caveat. In the edge cases when G-vectors don't match completely the fetching of plane-wave coefficients will fail. There are two ways out of it: 1) introduce QE order of G-vectors in SIRIUS, or 2) fetch magnetisation and absolute magnetisation from SIRIUS. Both will require a small change in API. Second option is easy to implement. I can explain how to do it

toxa81 commented 1 year ago

3rd option is to fetch only the existing G-vectors. This is a most simple options.

toxa81 commented 1 year ago

This is fiexed but has to be tested on the QE side.