Skip to content

Reading Quantum ESPRESSO pw.x output file causes crash when Makov-Payne correction is calculated

The Problem

There is a bug in the read_espresso_out function that parses Quantum ESPRESSO pw.x output files from calculations in which the Makov-Payne correction has been computed. In some cases this bug raises an UnboundLocalError, and in others it returns an incorrect value for the computed dipole. This issue does remain in the development version of ASE, and a minimal example is included below.

When running a calculation in pw.x in which the tefield and dipfield options are set to .TRUE., pw.x will print something like the following in the output file for each SCF step:

Adding external electric field

Computed dipole along edir(1) : 
   Elec. dipole          0.0550 Ry au,          0.1399 Debye
   Ion. dipole           0.0633 Ry au,          0.1610 Debye
   Dipole                4.4628 Ry au,         11.3433 Debye
   Dipole field          0.0083 Ry au, 

   Potential amp.       -0.2827 Ry
   Total length         17.0075 bohr

When running a calculation in which assume_isolated is set to makov-payne, pw.x will print something like the following at the end of the calculation (after the computed dipole information has already been printed):

Dipole moments (with respect to x0):
Elect   2.7061  -0.0795  -0.0780 au (Ha),   6.8783  -0.2019  -0.1983 Debye
Ionic   0.0000   0.0000  -0.0000 au (Ha),   0.0000   0.0000  -0.0000 Debye
Total   2.7061  -0.0795  -0.0780 au (Ha),   6.8783  -0.2019  -0.1983 Debye

When read_espresso_out attempts to parse an output file created by pw.x, it places the numbers of any lines containing the word "Debye" in indexes[_PW_DIPOLE] and it places the numbers of any lines containing the string "Computed dipole along edir(" in indexes[_PW_DIPOLE_DIRECTION].

If it finds lines containing "Debye", it takes the value immediately before the last occurrence of "Debye", and then it attempts to get the direction (either "1", "2" or "3") immediately following last occurrence of the string "Computed dipole along edir(". If this string doesn't appear anywhere in the file, an UnboundLocalError is raised.

If assume-isolated is left with its default value, read_espresso_out works as intended. However, if assume-isolated is set to makov-payne and tefield and dipfield are not both set to .TRUE., then the output file will contain the word "Debye" but will not contain the string "Computed dipole along edir(", as explained above. So when attempting to parse the output from such a calculation, read_espresso_out will raise an UnboundLocalError. Additionally, if assume-isolated is set to makov-payne and tefield and dipfield are both set to .TRUE., then read_espresso_out will successfully take the value immediately before the final occurrence of "Debye" in the output file. However, this will be the value in the "Dipole moments" section that is printed due to the Makov-Payne correction, rather than the value in the final "Computed dipole" section, which is not desired. So for the example output sections given above, read_espresso_out will take the value -0.1983 instead of 11.3433. Then, because the output does contain the string "Computed dipole along edir(", read_espresso_out will successfully get the dipole direction, silently using the incorrect dipole value.

Possible Solution

Currently, read_espresso_out uses the presence or absence of the word "Debye" to determine whether or not it attempts to get the computed dipole. I believe it should instead use the presence of the string "Computed dipole along edir(" to make this determination, and if it finds this string, I believe it should then only take the dipole value if the word "Debye" is found within three lines after the final occurrence of "Computed dipole along edir(".

I say within three lines because the "Elec." and "Ion." lines aren't always printed depending on the verbosity level specified for the calculation, as can be seen in the source here.

I realize that this would make read_espresso_out rather fragile, as a minor change in a later version of pw.x could break this fix. However, it looks as though this particular part of the pw.x source hasn't been changed since 2021, so I'm not sure that this is a major issue. Nevertheless, I'd welcome other ideas.

Minimal Reproducible Example

Given below is a Python script that reproduces the UnboundLocalError.

from ase.io.espresso import read_espresso_out
from io import StringIO

example_espresso_output = """

     Program PWSCF v.7.4 starts on 10Jul2025 at 17:40:45 

     This program is part of the open-source Quantum ESPRESSO suite
     for quantum simulation of materials; please cite
         "P. Giannozzi et al., J. Phys.:Condens. Matter 21 395502 (2009);
         "P. Giannozzi et al., J. Phys.:Condens. Matter 29 465901 (2017);
         "P. Giannozzi et al., J. Chem. Phys. 152 154105 (2020);
          URL http://www.quantum-espresso.org", 
     in publications or presentations arising from this work. More details at
     http://www.quantum-espresso.org/quote

     Parallel version (MPI), running on    10 processors

     MPI processes distributed on     1 nodes
     20264 MiB available memory on the printing compute node when the environment starts

     Reading input from espresso.pwi
Warning: card &CELL ignored
Warning: card / ignored
Warning: card &FCP ignored
Warning: card / ignored
Warning: card &RISM ignored
Warning: card / ignored
Warning: card &PSEUDOPOTENTIALS ignored
Warning: card    HE               = 'HE.PBE-KJPAW_PSL.1.0.0.UPF' ignored
Warning: card / ignored

     Current dimensions of program PWSCF are:
     Max number of different atomic species (ntypx) = 10
     Max number of k-points (npk) =  40000
     Max angular momentum in pseudopotentials (lmaxx) =  4
     file He.pbe-kjpaw_psl.1.0.0.UPF: wavefunction(s)  1S renormalized

     IMPORTANT: XC functional enforced from input :
     Exchange-correlation= PBE
                           (   1   4   3   4   0   0   0)
     Any further DFT definition will be discarded
     Please, verify this is what you really want


     gamma-point specific algorithms are used
     Message from routine setup:
     using ibrav=0 with symmetry is DISCOURAGED, use correct ibrav instead

     K-points division:     npool     =       2
     R & G space division:  proc/nbgrp/npool/nimage =       5
     Subspace diagonalization in iterative solution of the eigenvalue problem:
     a serial algorithm will be used


     Parallelization info
     --------------------
     sticks:   dense  smooth     PW     G-vecs:    dense   smooth      PW
     Min        1816    1816    449               130532   130532   16258
     Max        1819    1819    452               130538   130538   16266
     Sum        9085    9085   2253               652671   652671   81313

     Using Pencil Decomposition



     bravais-lattice index     =            0
     lattice parameter (alat)  =      18.8973  a.u.
     unit-cell volume          =    6748.3345 (a.u.)^3
     number of atoms/cell      =            2
     number of atomic types    =            1
     number of electrons       =         5.00
     number of Kohn-Sham states=            7
     kinetic-energy cutoff     =      80.0000  Ry
     charge density cutoff     =     320.0000  Ry
     scf convergence threshold =      1.0E-06
     mixing beta               =       0.5000
     number of iterations used =            8  plain     mixing
     Exchange-correlation= PBE
                           (   1   4   3   4   0   0   0)

     celldm(1)=  18.897261  celldm(2)=   0.000000  celldm(3)=   0.000000
     celldm(4)=   0.000000  celldm(5)=   0.000000  celldm(6)=   0.000000

     crystal axes: (cart. coord. in units of alat)
               a(1) = (   1.000000   0.000000   0.000000 )  
               a(2) = (   0.000000   1.000000   0.000000 )  
               a(3) = (   0.000000   0.000000   1.000000 )  

     reciprocal axes: (cart. coord. in units 2 pi/alat)
               b(1) = (  1.000000  0.000000  0.000000 )  
               b(2) = (  0.000000  1.000000  0.000000 )  
               b(3) = (  0.000000  0.000000  1.000000 )  


     PseudoPot. # 1 for He read from file:
     /home/jamestelzrow/pseudopotentials/He.pbe-kjpaw_psl.1.0.0.UPF
     MD5 check sum: ba8ac08120567012566e15769dfe53e7
     Pseudo is Projector augmented-wave, Zval =  2.0
     Generated using "atomic" code by A. Dal Corso  v.6.3MaX
     Shape of augmentation charge: PSQ
     Using radial grid of  985 points,  2 beta functions with: 
                l(1) =   0
                l(2) =   0
     Q(r) pseudized with 0 coefficients 


     atomic species   valence    mass     pseudopotential
     He                2.00     4.00260     He( 1.00)

     Starting magnetic structure 
     atomic species   magnetization
     He              0.850

     16 Sym. Ops., with inversion, found


                                    s                        frac. trans.

      isym =  1     identity                                     

 cryst.   s( 1) = (     1          0          0      )
                  (     0          1          0      )
                  (     0          0          1      )

 cart.    s( 1) = (  1.0000000  0.0000000  0.0000000 )
                  (  0.0000000  1.0000000  0.0000000 )
                  (  0.0000000  0.0000000  1.0000000 )


      isym =  2     180 deg rotation - cart. axis [0,0,1]        

 cryst.   s( 2) = (    -1          0          0      )
                  (     0         -1          0      )
                  (     0          0          1      )

 cart.    s( 2) = ( -1.0000000  0.0000000  0.0000000 )
                  (  0.0000000 -1.0000000  0.0000000 )
                  (  0.0000000  0.0000000  1.0000000 )


      isym =  3     180 deg rotation - cart. axis [0,1,0]        

 cryst.   s( 3) = (    -1          0          0      )
                  (     0          1          0      )
                  (     0          0         -1      )

 cart.    s( 3) = ( -1.0000000  0.0000000  0.0000000 )
                  (  0.0000000  1.0000000  0.0000000 )
                  (  0.0000000  0.0000000 -1.0000000 )


      isym =  4     180 deg rotation - cart. axis [1,0,0]        

 cryst.   s( 4) = (     1          0          0      )
                  (     0         -1          0      )
                  (     0          0         -1      )

 cart.    s( 4) = (  1.0000000  0.0000000  0.0000000 )
                  (  0.0000000 -1.0000000  0.0000000 )
                  (  0.0000000  0.0000000 -1.0000000 )


      isym =  5     180 deg rotation - cart. axis [1,1,0]        

 cryst.   s( 5) = (     0          1          0      )
                  (     1          0          0      )
                  (     0          0         -1      )

 cart.    s( 5) = (  0.0000000  1.0000000  0.0000000 )
                  (  1.0000000  0.0000000  0.0000000 )
                  (  0.0000000  0.0000000 -1.0000000 )


      isym =  6     180 deg rotation - cart. axis [1,-1,0]       

 cryst.   s( 6) = (     0         -1          0      )
                  (    -1          0          0      )
                  (     0          0         -1      )

 cart.    s( 6) = (  0.0000000 -1.0000000  0.0000000 )
                  ( -1.0000000  0.0000000  0.0000000 )
                  (  0.0000000  0.0000000 -1.0000000 )


      isym =  7      90 deg rotation - cart. axis [0,0,-1]       

 cryst.   s( 7) = (     0         -1          0      )
                  (     1          0          0      )
                  (     0          0          1      )

 cart.    s( 7) = (  0.0000000  1.0000000  0.0000000 )
                  ( -1.0000000  0.0000000  0.0000000 )
                  (  0.0000000  0.0000000  1.0000000 )


      isym =  8      90 deg rotation - cart. axis [0,0,1]        

 cryst.   s( 8) = (     0          1          0      )
                  (    -1          0          0      )
                  (     0          0          1      )

 cart.    s( 8) = (  0.0000000 -1.0000000  0.0000000 )
                  (  1.0000000  0.0000000  0.0000000 )
                  (  0.0000000  0.0000000  1.0000000 )


      isym =  9     inversion                                    

 cryst.   s( 9) = (    -1          0          0      )
                  (     0         -1          0      )
                  (     0          0         -1      )

 cart.    s( 9) = ( -1.0000000  0.0000000  0.0000000 )
                  (  0.0000000 -1.0000000  0.0000000 )
                  (  0.0000000  0.0000000 -1.0000000 )


      isym = 10     inv. 180 deg rotation - cart. axis [0,0,1]   

 cryst.   s(10) = (     1          0          0      )
                  (     0          1          0      )
                  (     0          0         -1      )

 cart.    s(10) = (  1.0000000  0.0000000  0.0000000 )
                  (  0.0000000  1.0000000  0.0000000 )
                  (  0.0000000  0.0000000 -1.0000000 )


      isym = 11     inv. 180 deg rotation - cart. axis [0,1,0]   

 cryst.   s(11) = (     1          0          0      )
                  (     0         -1          0      )
                  (     0          0          1      )

 cart.    s(11) = (  1.0000000  0.0000000  0.0000000 )
                  (  0.0000000 -1.0000000  0.0000000 )
                  (  0.0000000  0.0000000  1.0000000 )


      isym = 12     inv. 180 deg rotation - cart. axis [1,0,0]   

 cryst.   s(12) = (    -1          0          0      )
                  (     0          1          0      )
                  (     0          0          1      )

 cart.    s(12) = ( -1.0000000  0.0000000  0.0000000 )
                  (  0.0000000  1.0000000  0.0000000 )
                  (  0.0000000  0.0000000  1.0000000 )


      isym = 13     inv. 180 deg rotation - cart. axis [1,1,0]   

 cryst.   s(13) = (     0         -1          0      )
                  (    -1          0          0      )
                  (     0          0          1      )

 cart.    s(13) = (  0.0000000 -1.0000000  0.0000000 )
                  ( -1.0000000  0.0000000  0.0000000 )
                  (  0.0000000  0.0000000  1.0000000 )


      isym = 14     inv. 180 deg rotation - cart. axis [1,-1,0]  

 cryst.   s(14) = (     0          1          0      )
                  (     1          0          0      )
                  (     0          0          1      )

 cart.    s(14) = (  0.0000000  1.0000000  0.0000000 )
                  (  1.0000000  0.0000000  0.0000000 )
                  (  0.0000000  0.0000000  1.0000000 )


      isym = 15     inv.  90 deg rotation - cart. axis [0,0,-1]  

 cryst.   s(15) = (     0          1          0      )
                  (    -1          0          0      )
                  (     0          0         -1      )

 cart.    s(15) = (  0.0000000 -1.0000000  0.0000000 )
                  (  1.0000000  0.0000000  0.0000000 )
                  (  0.0000000  0.0000000 -1.0000000 )


      isym = 16     inv.  90 deg rotation - cart. axis [0,0,1]   

 cryst.   s(16) = (     0         -1          0      )
                  (     1          0          0      )
                  (     0          0         -1      )

 cart.    s(16) = (  0.0000000  1.0000000  0.0000000 )
                  ( -1.0000000  0.0000000  0.0000000 )
                  (  0.0000000  0.0000000 -1.0000000 )


   Cartesian axes

     site n.     atom                  positions (alat units)
         1        He     tau(   1) = (   0.5000000   0.5000000   0.4000000  )
         2        He     tau(   2) = (   0.5000000   0.5000000   0.6000000  )

   Crystallographic axes

     site n.     atom                  positions (cryst. coord.)
         1        He     tau(   1) = (  0.5000000  0.5000000  0.4000000  )
         2        He     tau(   2) = (  0.5000000  0.5000000  0.6000000  )

     number of k points=     1  Gaussian smearing, width (Ry)=  0.0010
                       cart. coord. in units 2pi/alat
        k(    1) = (   0.0000000   0.0000000   0.0000000), wk =   1.0000000

                       cryst. coord.
        k(    1) = (   0.0000000   0.0000000   0.0000000), wk =   1.0000000

     Dense  grid:   326336 G-vectors     FFT dimensions: ( 150, 150, 150)

     Dynamical RAM for                 wfc:       0.87 MB

     Dynamical RAM for     wfc (w. buffer):       0.87 MB

     Dynamical RAM for           str. fact:       1.00 MB

     Dynamical RAM for           local pot:       0.00 MB

     Dynamical RAM for          nlocal pot:       0.50 MB

     Dynamical RAM for                qrad:       0.04 MB

     Dynamical RAM for          rho,v,vnew:      36.87 MB

     Dynamical RAM for               rhoin:      12.29 MB

     Dynamical RAM for            rho*nmix:      31.87 MB

     Dynamical RAM for           G-vectors:       4.23 MB

     Dynamical RAM for          h,s,v(r/c):       0.00 MB

     Dynamical RAM for          <psi|beta>:       0.00 MB

     Dynamical RAM for                 psi:       1.74 MB

     Dynamical RAM for                hpsi:       1.74 MB

     Dynamical RAM for                spsi:       1.74 MB

     Dynamical RAM for      wfcinit/wfcrot:       1.74 MB

     Dynamical RAM for           addusdens:       5.48 MB

     Dynamical RAM for          addusforce:       5.98 MB

     Estimated static dynamical RAM per process >      88.70 MB

     Estimated max dynamical RAM per process >     126.54 MB

     Estimated total dynamical RAM >       1.08 GB
     Generating pointlists ...
     new r_m :   0.0825 (alat units)  1.5590 (a.u.) for type    1

     Initial potential from superposition of free atoms

     starting charge       4.0000, renormalised to       5.0000

     negative rho (up, down):  3.761E-04 3.049E-05
     Starting wfcs are    2 randomized atomic wfcs +    5 random wfcs
     Checking if some PAW data can be deallocated... 

     total cpu time spent up to now is        1.4 secs

     Self-consistent Calculation

     iteration #  1     ecut=    80.00 Ry     beta= 0.50
     Davidson diagonalization with overlap

---- Real-time Memory Report at c_bands before calling an iterative solver
           228 MiB given to the printing process from OS
             0 MiB allocation reported by mallinfo(arena+hblkhd)
         19251 MiB available memory on the node where the printing process lives
------------------
     ethr =  1.00E-02,  avg # of iterations =  8.5

     total cpu time spent up to now is        3.2 secs

     total energy              =     -10.11458287 Ry
     estimated scf accuracy    <       3.31475548 Ry

     total magnetization       =     1.00 Bohr mag/cell
     absolute magnetization    =     1.46 Bohr mag/cell

     iteration #  2     ecut=    80.00 Ry     beta= 0.50
     Davidson diagonalization with overlap

---- Real-time Memory Report at c_bands before calling an iterative solver
           264 MiB given to the printing process from OS
             0 MiB allocation reported by mallinfo(arena+hblkhd)
         18868 MiB available memory on the node where the printing process lives
------------------
     ethr =  1.00E-02,  avg # of iterations =  2.0

     total cpu time spent up to now is        4.4 secs

     total energy              =     -11.57246388 Ry
     estimated scf accuracy    <       0.20952231 Ry

     total magnetization       =     1.00 Bohr mag/cell
     absolute magnetization    =     1.28 Bohr mag/cell

     iteration #  3     ecut=    80.00 Ry     beta= 0.50
     Davidson diagonalization with overlap

---- Real-time Memory Report at c_bands before calling an iterative solver
           270 MiB given to the printing process from OS
             0 MiB allocation reported by mallinfo(arena+hblkhd)
         18836 MiB available memory on the node where the printing process lives
------------------
     ethr =  4.19E-03,  avg # of iterations =  1.0

     negative rho (up, down):  0.000E+00 3.719E-02

     total cpu time spent up to now is        5.4 secs

     total energy              =     -11.66855065 Ry
     estimated scf accuracy    <       0.07364161 Ry

     total magnetization       =     1.00 Bohr mag/cell
     absolute magnetization    =     1.14 Bohr mag/cell

     iteration #  4     ecut=    80.00 Ry     beta= 0.50
     Davidson diagonalization with overlap

---- Real-time Memory Report at c_bands before calling an iterative solver
           274 MiB given to the printing process from OS
             0 MiB allocation reported by mallinfo(arena+hblkhd)
         18809 MiB available memory on the node where the printing process lives
------------------
     ethr =  1.47E-03,  avg # of iterations =  1.5

     negative rho (up, down):  0.000E+00 1.006E-02

     total cpu time spent up to now is        6.6 secs

     total energy              =     -11.67971172 Ry
     estimated scf accuracy    <       0.00346922 Ry

     total magnetization       =     1.00 Bohr mag/cell
     absolute magnetization    =     1.01 Bohr mag/cell

     iteration #  5     ecut=    80.00 Ry     beta= 0.50
     Davidson diagonalization with overlap

---- Real-time Memory Report at c_bands before calling an iterative solver
           278 MiB given to the printing process from OS
             0 MiB allocation reported by mallinfo(arena+hblkhd)
         18793 MiB available memory on the node where the printing process lives
------------------
     ethr =  6.94E-05,  avg # of iterations = 10.0

     negative rho (up, down):  0.000E+00 4.860E-03

     total cpu time spent up to now is        8.6 secs

     total energy              =     -11.68040526 Ry
     estimated scf accuracy    <       0.00017992 Ry

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

     iteration #  6     ecut=    80.00 Ry     beta= 0.50
     Davidson diagonalization with overlap

---- Real-time Memory Report at c_bands before calling an iterative solver
           282 MiB given to the printing process from OS
             0 MiB allocation reported by mallinfo(arena+hblkhd)
         18773 MiB available memory on the node where the printing process lives
------------------
     ethr =  3.60E-06,  avg # of iterations = 12.0

     negative rho (up, down):  0.000E+00 2.071E-03

     total cpu time spent up to now is       10.5 secs

     total energy              =     -11.68052631 Ry
     estimated scf accuracy    <       0.00004580 Ry

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

     iteration #  7     ecut=    80.00 Ry     beta= 0.50
     Davidson diagonalization with overlap

---- Real-time Memory Report at c_bands before calling an iterative solver
           286 MiB given to the printing process from OS
             0 MiB allocation reported by mallinfo(arena+hblkhd)
         18746 MiB available memory on the node where the printing process lives
------------------
     ethr =  9.16E-07,  avg # of iterations =  3.0

     negative rho (up, down):  0.000E+00 7.809E-05

     total cpu time spent up to now is       11.8 secs

     total energy              =     -11.68011361 Ry
     estimated scf accuracy    <       0.00002920 Ry

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

     iteration #  8     ecut=    80.00 Ry     beta= 0.50
     Davidson diagonalization with overlap

---- Real-time Memory Report at c_bands before calling an iterative solver
           290 MiB given to the printing process from OS
             0 MiB allocation reported by mallinfo(arena+hblkhd)
         18730 MiB available memory on the node where the printing process lives
------------------
     ethr =  5.84E-07,  avg # of iterations =  6.5

     negative rho (up, down):  0.000E+00 7.572E-05

     total cpu time spent up to now is       13.4 secs

     total energy              =     -11.68034661 Ry
     estimated scf accuracy    <       0.00005884 Ry

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

     iteration #  9     ecut=    80.00 Ry     beta= 0.50
     Davidson diagonalization with overlap

---- Real-time Memory Report at c_bands before calling an iterative solver
           294 MiB given to the printing process from OS
             0 MiB allocation reported by mallinfo(arena+hblkhd)
         18708 MiB available memory on the node where the printing process lives
------------------
     ethr =  5.84E-07,  avg # of iterations =  1.0

     negative rho (up, down):  0.000E+00 5.726E-05

     total cpu time spent up to now is       14.5 secs

     total energy              =     -11.68035487 Ry
     estimated scf accuracy    <       0.00006073 Ry

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

     iteration # 10     ecut=    80.00 Ry     beta= 0.50
     Davidson diagonalization with overlap

---- Real-time Memory Report at c_bands before calling an iterative solver
           298 MiB given to the printing process from OS
             0 MiB allocation reported by mallinfo(arena+hblkhd)
         18682 MiB available memory on the node where the printing process lives
------------------
     ethr =  5.84E-07,  avg # of iterations =  4.0

     negative rho (up, down):  0.000E+00 2.422E-04

     total cpu time spent up to now is       15.8 secs

     total energy              =     -11.68048848 Ry
     estimated scf accuracy    <       0.00000745 Ry

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

     iteration # 11     ecut=    80.00 Ry     beta= 0.50
     Davidson diagonalization with overlap

---- Real-time Memory Report at c_bands before calling an iterative solver
           298 MiB given to the printing process from OS
             0 MiB allocation reported by mallinfo(arena+hblkhd)
         18688 MiB available memory on the node where the printing process lives
------------------
     ethr =  1.49E-07,  avg # of iterations =  4.5

     negative rho (up, down):  0.000E+00 1.979E-04

     total cpu time spent up to now is       17.0 secs

     total energy              =     -11.68048831 Ry
     estimated scf accuracy    <       0.00000173 Ry

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

     iteration # 12     ecut=    80.00 Ry     beta= 0.50
     Davidson diagonalization with overlap

---- Real-time Memory Report at c_bands before calling an iterative solver
           298 MiB given to the printing process from OS
             0 MiB allocation reported by mallinfo(arena+hblkhd)
         18686 MiB available memory on the node where the printing process lives
------------------
     ethr =  3.47E-08,  avg # of iterations =  3.0

     negative rho (up, down):  0.000E+00 2.269E-04

     Magnetic moment per site  (integrated on atomic sphere of radius R)
     atom   1 (R=0.082)  charge=  1.7925  magn=  0.0007
     atom   2 (R=0.082)  charge=  1.7925  magn=  0.0007

     total cpu time spent up to now is       18.1 secs

     End of self-consistent calculation

 ------ SPIN UP ------------


          k = 0.0000 0.0000 0.0000 ( 40657 PWs)   bands (ev):

   -16.5022 -15.4538  -2.0041  -0.5891  -0.5867  -0.5828  -0.5174

     occupation numbers 
     1.0000   1.0000   1.0000   0.0000   0.0000   0.0000   0.0000

 ------ SPIN DOWN ----------


          k = 0.0000 0.0000 0.0000 ( 40657 PWs)   bands (ev):

   -16.4883 -15.4393  -1.6394  -0.2961  -0.2949  -0.2015  -0.1837

     occupation numbers 
     1.0000   1.0000   0.0000   0.0000   0.0000   0.0000   0.0000

     the Fermi energy is    -1.8623 ev

!    total energy              =     -11.68050294 Ry
     total all-electron energy =       -11.680478 Ry
     estimated scf accuracy    <       0.00000062 Ry
     smearing contrib. (-TS)   =      -0.00000000 Ry
     internal energy E=F+TS    =     -11.68050294 Ry

     The total energy is F=E-TS. E is the sum of the following terms:
     one-electron contribution =     -14.91247786 Ry
     hartree contribution      =       7.71692102 Ry
     xc contribution           =      -4.25886240 Ry
     ewald contribution        =      -0.24799396 Ry
     one-center paw contrib.   =       0.02191026 Ry
      -> PAW hartree energy AE =       3.32833435 Ry
      -> PAW hartree energy PS =      -3.28742682 Ry
      -> PAW xc energy AE      =      -1.93583890 Ry
      -> PAW xc energy PS      =       1.90588650 Ry
      -> total E_H with PAW    =       7.75782856 Ry
      -> total E_XC with PAW   =      -4.28881481 Ry

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

     charge density inside the Wigner-Seitz cell:    5.00000000

     reference position (x0):         9.44863062    9.44863062    9.44863062 bohr

     Dipole moments (with respect to x0):
     Elect  -0.0700  -0.0697  -0.0733 au (Ha),  -0.1779  -0.1772  -0.1864 Debye
     Ionic   0.0000   0.0000  -0.0000 au (Ha),   0.0000   0.0000  -0.0000 Debye
     Total  -0.0700  -0.0697  -0.0733 au (Ha),  -0.1779  -0.1772  -0.1864 Debye

     Electrons quadrupole moment       -117.68758328 a.u. (Ha)
          Ions quadrupole moment         14.28425930 a.u. (Ha)
         Total quadrupole moment       -103.40332398 a.u. (Ha)

     *********    MAKOV-PAYNE CORRECTION    *********

     Makov-Payne correction with Madelung constant =   2.8373

     Makov-Payne correction     0.15014345 Ry =  2.043 eV (1st order, 1/a0)
                               -0.06417456 Ry = -0.873 eV (2nd order, 1/a0^3)
                                0.08596889 Ry =  1.170 eV (total)

!    Total+Makov-Payne energy  =     -11.59453405 Ry
     Corrected vacuum level    =      -1.22568140 eV

     convergence has been achieved in  12 iterations

     Forces acting on atoms (cartesian axes, Ry/au):

     atom    1 type  1   force =     0.00000000    0.00000000   -0.00949967
     atom    2 type  1   force =     0.00000000    0.00000000    0.00949967
     The non-local contrib.  to forces
     atom    1 type  1   force =     0.00000000    0.00000000    0.00025857
     atom    2 type  1   force =     0.00000000    0.00000000   -0.00025857
     The ionic contribution  to forces
     atom    1 type  1   force =    -0.00000000   -0.00000000   -0.53902888
     atom    2 type  1   force =     0.00000000    0.00000000    0.53902888
     The local contribution  to forces
     atom    1 type  1   force =    -0.00015135   -0.00022360    0.52954461
     atom    2 type  1   force =    -0.00021154   -0.00016433   -0.52941952
     The core correction contribution to forces
     atom    1 type  1   force =     0.00000000    0.00000000    0.00000000
     atom    2 type  1   force =     0.00000000    0.00000000    0.00000000
     The Hubbard contrib.    to forces
     atom    1 type  1   force =     0.00000000    0.00000000    0.00000000
     atom    2 type  1   force =     0.00000000    0.00000000    0.00000000
     The SCF correction term to forces
     atom    1 type  1   force =     0.00024574    0.00036318   -0.00031913
     atom    2 type  1   force =     0.00034226    0.00026524    0.00010373

     Total force =     0.013435     Total SCF correction =     0.000702

     Writing all to output data dir ./qe_output_ground/espresso_ground/he_dimer.save/ :
     XML data file, charge density, pseudopotentials, collected wavefunctions

     init_run     :      0.83s CPU      1.36s WALL (       1 calls)
     electrons    :     12.85s CPU     16.76s WALL (       1 calls)
     forces       :      0.10s CPU      0.14s WALL (       1 calls)

     Called by init_run:
     wfcinit      :      0.10s CPU      0.14s WALL (       1 calls)
     wfcinit:atom :      0.00s CPU      0.00s WALL (       1 calls)
     wfcinit:wfcr :      0.10s CPU      0.14s WALL (       1 calls)
     potinit      :      0.54s CPU      0.94s WALL (       1 calls)
     hinit0       :      0.09s CPU      0.14s WALL (       1 calls)

     Called by electrons:
     c_bands      :      4.61s CPU      6.48s WALL (      12 calls)
     sum_band     :      1.27s CPU      1.76s WALL (      12 calls)
     v_of_rho     :      5.94s CPU      7.47s WALL (      13 calls)
     v_h          :      0.27s CPU      0.35s WALL (      13 calls)
     v_xc         :      5.67s CPU      7.12s WALL (      13 calls)
     newd         :      0.53s CPU      0.71s WALL (      13 calls)
     PAW_pot      :      0.31s CPU      0.34s WALL (      13 calls)
     mix_rho      :      0.38s CPU      0.45s WALL (      12 calls)

     Called by c_bands:
     init_us_2    :      0.01s CPU      0.01s WALL (      26 calls)
     regterg      :      4.08s CPU      5.93s WALL (      12 calls)

     Called by sum_band:
     sum_band:wei :      0.01s CPU      0.01s WALL (      12 calls)
     sum_band:loo :      0.61s CPU      0.81s WALL (      12 calls)
     sum_band:buf :      0.00s CPU      0.00s WALL (      12 calls)
     sum_band:ini :      0.00s CPU      0.01s WALL (      12 calls)
     sum_band:cal :      0.03s CPU      0.04s WALL (      12 calls)
     sum_band:bec :      0.00s CPU      0.00s WALL (      12 calls)
     addusdens    :      0.06s CPU      0.09s WALL (      12 calls)
                                        0.00s GPU  (      12 calls)
     addusd:skk   :      0.00s CPU      0.00s WALL (      12 calls)
                                        0.00s GPU  (      12 calls)

     Called by *egterg:
     rdiaghg      :      0.00s CPU      0.00s WALL (      77 calls)
     regterg:over :      0.19s CPU      0.25s WALL (      65 calls)
     regterg:upda :      0.02s CPU      0.03s WALL (      65 calls)
     regterg:last :      0.06s CPU      0.09s WALL (      41 calls)
     h_psi        :      3.78s CPU      5.49s WALL (      78 calls)
     s_psi        :      0.01s CPU      0.01s WALL (      78 calls)
     g_psi        :      0.00s CPU      0.00s WALL (      65 calls)

     Called by h_psi:
     h_psi:calbec :      0.09s CPU      0.13s WALL (      78 calls)
     vloc_psi     :      3.67s CPU      5.34s WALL (      78 calls)
                                        0.00s GPU  (      78 calls)
     add_vuspsi   :      0.01s CPU      0.01s WALL (      78 calls)

     General routines
     calbec       :      0.12s CPU      0.17s WALL (      94 calls)
     fft          :      4.04s CPU      5.37s WALL (     198 calls)
     ffts         :      0.22s CPU      0.30s WALL (      12 calls)
     fftw         :      3.95s CPU      5.60s WALL (     428 calls)

     Parallel routines
     fft_scatt_xy :      0.78s CPU      1.23s WALL (     638 calls)
     fft_scatt_yz :      3.76s CPU      4.85s WALL (     638 calls)

     PAW routines
     PAW_pot      :      0.31s CPU      0.34s WALL (      13 calls)
     PAW_symme    :      0.01s CPU      0.02s WALL (      25 calls)

     PWSCF        :     13.81s CPU     18.35s WALL


   This run was terminated on:  17:41: 3  10Jul2025            

=------------------------------------------------------------------------------=
   JOB DONE.
=------------------------------------------------------------------------------=

"""

next(read_espresso_out(StringIO(example_espresso_output)))