# [Pw_forum] Making density matrix in sum_band subroutine

Min Seung Kyu min0220 at postech.ac.kr
Tue Jan 15 09:26:15 CET 2008

```Dear users and developers,

I'm studying PWSCF source code.

Looking in 'sum_band_gamma' subroutine in 'sum_band.f90', this subroutine
does two FFTs at the same time.

DO ibnd = 1, nbnd, 2
psic(:) = ( 0.D0, 0.D0 )
IF ( ibnd < nbnd ) THEN
!
! ... two ffts at the same time
!
psic(nls(igk(1:npw)))  = evc(1:npw,ibnd) + &
( 0.D0, 1.D0 ) * evc(1:npw,ibnd+1)
psic(nlsm(igk(1:npw))) = CONJG( evc(1:npw,ibnd) - &
( 0.D0, 1.D0 ) * evc(1:npw,ibnd+1) )
ELSE
psic(nls(igk(1:npw)))  = evc(1:npw,ibnd)
psic(nlsm(igk(1:npw))) = CONJG( evc(1:npw,ibnd) )
END IF
CALL cft3s( psic, nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s, 2 )
w1 = wg(ibnd,ik) / omega
!
! ... increment the charge density ...
!
IF ( ibnd < nbnd ) THEN
!
! ... two ffts at the same time
!
w2 = wg(ibnd+1,ik) / omega
ELSE
w2 = w1
END IF
DO ir = 1, nrxxs
rho(ir,current_spin) = rho(ir,current_spin) + &
w1 *  DBLE( psic(ir) )**2 + &
w2 * AIMAG( psic(ir) )**2
END DO
ENDDO

I changed above lines into below.

DO ibnd = 1, nbnd
psic(:) = ( 0.D0, 0.D0 )
psic(nls(igk(1:npw)))  = evc(1:npw,ibnd)
CALL cft3s( psic, nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s, 2 )
w1 = wg(ibnd,ik) / omega
!
! ... increment the charge density ...
!
DO ir = 1, nrxxs
rho(ir,current_spin) = rho(ir,current_spin) + &
w1 * ( DBLE( psic(ir) )**2 + &
AIMAG( psic(ir) )**2 )
END DO
END DO

But I failed to reproduce charge densities.

For 'co.rx.in' in example03 folder, I got this message.

WARNING: integrated charge=     6.86602003, expected=    10.00000000

Could you tell me what is wrong?

Sincerely, Min.

-------------------------------Sig.---------------------------
Center for Superfunctional Materials, Department of Chemistry,
Pohang University of Science and Technology (POSTECH)

Mr. Seung Kyu, Min

Ph.D. Candidate

E-Mail: min0220 at postech.ac.kr
Tel.  : 82-54-279-5858
----------------------------------------------

```