# [QE-users] How is the wavefunction supposed to be normalized?

John McFarland jm18ec at my.fsu.edu
Sat Dec 15 00:49:09 CET 2018

```Hello,

I tried to write some code that orthonormalizes the wave function and it doesn't work.  The code is shown below:

! othornormalize
do ibnd = 1, nbnd

! orthogonalize  |psi_i>  to all  |psi_j>  for j<i
call s_1psi ( npwx , npw , tddft_psi(1,ibnd,1) , spsi )

do jbnd = 1, ibnd-1
! calculate |psi_i> - |psi_j><psi_j| S |psi_i>
do ipw = 1, npw
tddft_psi(ipw,ibnd,1) = tddft_psi(ipw,ibnd,1) - tddft_psi(ipw,jbnd,1) * conjg( tddft_psi(ipw,jbnd,1) ) * spsi(ipw)
enddo
enddo

! normalize |psi_i>
norm = 0
call s_1psi ( npwx , npw , tddft_psi(1,ibnd,1) , spsi )

! calculate <psi_i| S |psi_i>
do ipw = 1, npw
norm = norm + conjg( tddft_psi(ipw,ibnd,1) ) * spsi(ipw)
enddo
tddft_psi(:,ibnd,1) = tddft_psi(:,ibnd,1) / norm

enddo

Is there a subroutine that can calculate <psi_i| S |psi_j> ?

Also, what is the difference between npw and npwx ?

John

________________________________
From: users <users-bounces at lists.quantum-espresso.org> on behalf of Paolo Giannozzi <p.giannozzi at gmail.com>
Sent: Wednesday, December 12, 2018 7:18:09 AM
To: Quantum Espresso users Forum
Subject: Re: [QE-users] How is the wavefunction supposed to be normalized?

On Tue, Dec 11, 2018 at 7:09 PM John McFarland <jm18ec at my.fsu.edu<mailto:jm18ec at my.fsu.edu>> wrote:

I forgot to ask if different bands are orthogonal for the contraction over the S matrix.

yes, they are

Paolo

John

________________________________
From: users <users-bounces at lists.quantum-espresso.org<mailto:users-bounces at lists.quantum-espresso.org>> on behalf of Stefano de Gironcoli <degironc at sissa.it<mailto:degironc at sissa.it>>
Sent: Tuesday, December 11, 2018 10:26:15 AM
To: users at lists.quantum-espresso.org<mailto:users at lists.quantum-espresso.org>
Subject: Re: [QE-users] How is the wavefunction supposed to be normalized?

yes, except the S matrix is never stored anywhere but is applied to the wfc by the s_1psi routine,

so more something like

sum = 0.d0

call s_1psi( npwx, npw, evc(1,b), spsi )

DO  i = 1,npw

sum = sum + conjg(evc(i,b)) * spsi(i)
END DO

stefano

On 11/12/18 15:36, John McFarland wrote:

Dear all,

As I understand it, the wavefunction for each k-point is given by ecv(:,:), with the first index representing a single particle basis and the second index representing each band.  I'm guessing that when a normalized wavefunction is contracted over the S matrix, the result should equal one for each band.  What I think this would look like in code is:

sum = 0

DO  i = 1,npwx

DO j = 1,npwx

sum = sum + evc(i,b) * S(i,j) * evc(j,b)

END DO

END DO

and sum should equal 1 for any band b.  Is my understanding correct?

Best regards,

John McFarland

_______________________________________________
users mailing list
users at lists.quantum-espresso.org<mailto:users at lists.quantum-espresso.org>
https://lists.quantum-espresso.org/mailman/listinfo/users<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.quantum-2Despresso.org_mailman_listinfo_users&d=DwMD-g&c=MNHwOqQ8N1u91SoMLfIblwuGXKgp50OPUXjl8uRAbak&r=aBqxGb3Z1QZuWuPQzYblq8v7-w7hDZgkvgBYwm8sq8Y&m=0_ldi_kPdbF9G-LbLtc8g1MiFx1QDdFx9WUZmApxI8M&s=dRaIjvkziJzsYp5az0bdiOPHS0PsijOxraxkUi-8mkk&e=>

_______________________________________________
users mailing list
users at lists.quantum-espresso.org<mailto:users at lists.quantum-espresso.org>
https://lists.quantum-espresso.org/mailman/listinfo/users<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.quantum-2Despresso.org_mailman_listinfo_users&d=DwMFaQ&c=MNHwOqQ8N1u91SoMLfIblwuGXKgp50OPUXjl8uRAbak&r=aBqxGb3Z1QZuWuPQzYblq8v7-w7hDZgkvgBYwm8sq8Y&m=5F3TEhvdYp54Q0laoJShocEPobv6Fdwa8cVmK8bEpb4&s=dzgK3h4h1iiuyVnbojpCMP4RVyEqu9foD8UmwxkxEmo&e=>

--
Paolo Giannozzi, Dip. Scienze Matematiche Informatiche e Fisiche,
Univ. Udine, via delle Scienze 208, 33100 Udine, Italy
Phone +39-0432-558216, fax +39-0432-558222

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quantum-espresso.org/pipermail/users/attachments/20181214/ea5c6442/attachment.html>
```