2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Copyright (C) 2001 PWSCF group
|
|
|
|
! This file is distributed under the terms of the
|
|
|
|
! GNU General Public License. See the file `License'
|
|
|
|
! in the root directory of the present distribution,
|
|
|
|
! or http://www.gnu.org/copyleft/gpl.txt .
|
|
|
|
!
|
2004-03-24 17:36:50 +08:00
|
|
|
#include "machine.h"
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
!-----------------------------------------------------------------------
|
2003-02-08 00:04:36 +08:00
|
|
|
subroutine d3_exc
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! Calculates the contribution to the derivative of the dynamical
|
|
|
|
! matrix due to the third derivative of the exchange and correlation
|
|
|
|
! energy
|
2004-06-14 15:30:47 +08:00
|
|
|
!
|
|
|
|
USE ions_base, ONLY : nat
|
2004-03-24 17:36:50 +08:00
|
|
|
USE kinds, ONLY : DP
|
2003-01-20 05:58:50 +08:00
|
|
|
use pwcom
|
|
|
|
use phcom
|
|
|
|
use d3com
|
|
|
|
use para
|
2004-03-09 01:21:27 +08:00
|
|
|
USE io_global, ONLY : ionode_id
|
2004-03-24 17:36:50 +08:00
|
|
|
USE mp_global, ONLY : inter_pool_comm, my_image_id
|
2004-03-09 01:21:27 +08:00
|
|
|
USE mp, ONLY : mp_bcast
|
2004-03-24 17:36:50 +08:00
|
|
|
|
2003-01-20 05:58:50 +08:00
|
|
|
implicit none
|
2004-03-24 17:36:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: errcode, ir, ipert, jpert, kpert, npert1, npert2
|
2004-02-04 19:06:45 +08:00
|
|
|
real (kind = dp) :: d2mxc, rhotot, xq0 (3)
|
|
|
|
real (kind = dp), allocatable :: d2muxc (:)
|
|
|
|
complex (kind = dp) :: aux
|
|
|
|
complex (kind = dp), allocatable :: work1 (:), work2 (:), work3 (:), d3dyn1 (:,:,:)
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
allocate (d2muxc( nrxx))
|
|
|
|
allocate (work1 ( nrxx))
|
|
|
|
allocate (work2 ( nrxx))
|
|
|
|
allocate (work3 ( nrxx))
|
|
|
|
allocate (d3dyn1( 3*nat, 3*nat, 3*nat))
|
2003-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2003-02-08 00:04:36 +08:00
|
|
|
if (mypool.ne.1) goto 100
|
2003-01-20 05:58:50 +08:00
|
|
|
#endif
|
|
|
|
!
|
|
|
|
! Calculates third derivative of Exc
|
|
|
|
!
|
2004-03-07 21:47:42 +08:00
|
|
|
d2muxc(:) = 0.d0
|
2003-02-08 00:04:36 +08:00
|
|
|
do ir = 1, nrxx
|
|
|
|
rhotot = rho (ir, 1) + rho_core (ir)
|
2004-03-07 21:47:42 +08:00
|
|
|
if (rhotot > 1.d-30) d2muxc (ir) = d2mxc (rhotot)
|
|
|
|
if (rhotot < - 1.d-30) d2muxc (ir) = - d2mxc ( - rhotot)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
!
|
|
|
|
! Calculates the contribution to d3dyn
|
|
|
|
!
|
2004-03-07 21:47:42 +08:00
|
|
|
d3dyn1 (:,:,:) = (0.d0, 0.d0)
|
2003-02-08 00:04:36 +08:00
|
|
|
do ipert = 1, 3 * nat
|
|
|
|
if (q0mode (ipert) ) then
|
|
|
|
call davcio_drho (work1, lrdrho, iud0rho, ipert, - 1)
|
|
|
|
do jpert = 1, 3 * nat
|
|
|
|
call davcio_drho (work2, lrdrho, iudrho, jpert, - 1)
|
|
|
|
do kpert = 1, 3 * nat
|
|
|
|
call davcio_drho (work3, lrdrho, iudrho, kpert, - 1)
|
|
|
|
aux = DCMPLX (0.d0, 0.d0)
|
|
|
|
do ir = 1, nrxx
|
2003-01-20 05:58:50 +08:00
|
|
|
aux = aux + d2muxc (ir) * work1 (ir) * conjg (work2 (ir) ) &
|
|
|
|
* work3 (ir)
|
|
|
|
enddo
|
2003-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2003-02-08 00:04:36 +08:00
|
|
|
call reduce (2, aux)
|
2003-01-20 05:58:50 +08:00
|
|
|
#endif
|
2003-02-08 00:04:36 +08:00
|
|
|
d3dyn1 (ipert, jpert, kpert) = omega * aux / (nr1 * nr2 * nr3)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
|
|
|
|
enddo
|
2003-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2004-03-10 02:01:31 +08:00
|
|
|
100 continue
|
2004-03-24 17:36:50 +08:00
|
|
|
IF ( npool /= 1 ) &
|
2004-03-25 00:30:44 +08:00
|
|
|
CALL mp_bcast( d3dyn1, ionode_id, inter_pool_comm )
|
2003-01-20 05:58:50 +08:00
|
|
|
#endif
|
|
|
|
|
2004-03-07 21:47:42 +08:00
|
|
|
d3dyn = d3dyn + d3dyn1
|
|
|
|
d3dyn_aux9 = d3dyn1
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
deallocate (d2muxc)
|
|
|
|
deallocate (work1)
|
|
|
|
deallocate (work2)
|
|
|
|
deallocate (work3)
|
|
|
|
deallocate (d3dyn1)
|
|
|
|
|
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine d3_exc
|