[QE-users] Question about code in ccgdiagg.f90 (conjugate gradient solver)

H Wang whf956 at icloud.com
Sat May 4 09:30:28 CEST 2024


Dear QE community,

I am new to ab initio program implementation. Recently I am studying the cg solver in KS_Solvers/CG/ccgdiagg.f90. And I found the algorithm in the paper https://arxiv.org/pdf/0906.2569  (QUANTUM ESPRESSO: a modular and open-source software project for quantum simulations of materials), which published in 2009. I carefully read the Appendix A.2. Iterative diagonalization and formula (A.8) to (A.22) which corresponds to conjugate gradient method. However, I am struggling in understanding some pieces of code in the ccgdiagg.f90.

For the code in the No.164 to No.188 as listed here:

‘’’
     !
     ! ... start iteration for this band
     !
     iterate: DO iter = 1, maxter
        !
        ! ... calculate  P (PHP)|y>
        ! ... ( P = preconditioning matrix, assumed diagonal )
        !
        g(:)    = hpsi(:) / precondition(:)
        ppsi(:) = spsi(:) / precondition(:)
        !
        ! ... ppsi is now S P(P^2)|y> = S P^2|psi>)
        !
        es(1) = ddot( kdim2, spsi(1), 1, g(1), 1 )
        es(2) = ddot( kdim2, spsi(1), 1, ppsi(1), 1 )
        !
        CALL mp_sum( es , intra_bgrp_comm )
        !
        es(1) = es(1) / es(2)
        !
        g(:) = g(:) - es(1) * ppsi(:)
        !
        ! ... e1 = <y| S P^2 PHP|y> / <y| S S P^2|y>  ensures that 
        ! ... <g| S P^2|y> = 0
        ! ... orthogonalize to lowest eigenfunctions (already calculated)
        !
        ! ... scg is used as workspace
        !
‘’’
As we know that hpsi = H |psi> = H P |y>, since |y> = P^(-1) |psi> and P is precondition matrix. Then g(:) = hpsi(:) / precondition(:) , seems imply g(:) ==>  P^(-1) H P |y>, and similarly that ppsi(:) ==> P^(-1) S P |y>. Now the question arrives, why the comment inside the code says that   “! ... ppsi is now S P(P^2)|y> = S P^2|psi>)” ?

And as for es(1) and es(2), it seems es(1) ==> <y| P S P^(-1) H P |y>,  es(2) ==>  <y| P S P^(-1) S P |y >.  That are quiet different from that in the comment “ e1 = <y| S P^2 PHP|y> / <y| S S P^2|y>”.

Is there any clue or reference materials to help understand that? 

Sincerely,
HF Wang

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quantum-espresso.org/pipermail/users/attachments/20240504/807df18f/attachment.html>


More information about the users mailing list