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 .
|
|
|
|
!
|
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
subroutine d3_symdyn (d3dyn, u, ug0, xq, s, invs, rtau, irt, irgq, &
|
|
|
|
at, bg, nsymq, nat, irotmq, minus_q, npert_i, npert_f)
|
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! This routine symmetrize the dynamical matrix written in the basis
|
|
|
|
! of the modes
|
|
|
|
!
|
|
|
|
!
|
2004-02-04 19:06:45 +08:00
|
|
|
USE kinds, only : DP
|
2008-01-24 01:50:56 +08:00
|
|
|
USE mp_global, ONLY : inter_pool_comm, intra_pool_comm
|
|
|
|
USE mp, ONLY : mp_sum
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
implicit none
|
2003-01-20 05:58:50 +08:00
|
|
|
integer :: nat, s (3, 3, 48), irt (48, nat), irgq (48), invs (48), &
|
|
|
|
nsymq, npert_i, npert_f, irotmq
|
|
|
|
! input: the number of atoms
|
|
|
|
! input: the symmetry matrices
|
|
|
|
! input: the rotated of each atom
|
|
|
|
! input: the small group of q
|
|
|
|
! input: the inverse of each matrix
|
|
|
|
! input: the order of the small gro
|
|
|
|
! input: the symmetry q -> -q+G
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
real (DP) :: xq (3), rtau (3, 48, nat), at (3, 3), bg (3, 3)
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: the coordinates of q
|
|
|
|
! input: the R associated at each r
|
|
|
|
! input: direct lattice vectors
|
|
|
|
! input: reciprocal lattice vectors
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
logical :: minus_q
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: if true symmetry sends q->
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
complex (DP) :: d3dyn (3 * nat, 3 * nat, 3 * nat), &
|
2003-01-20 05:58:50 +08:00
|
|
|
ug0 (3 * nat, 3 * nat), u (3 * nat, 3 * nat)
|
|
|
|
! inp/out: matrix to symmetr
|
|
|
|
! input: the q=0 patterns
|
|
|
|
! input: the patterns
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: i, j, i1, icart, jcart, kcart, na, nb, nc, mu, nu, om
|
2004-03-07 21:47:42 +08:00
|
|
|
! counters
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
complex (DP) :: work, wrk (3, 3)
|
2003-01-20 05:58:50 +08:00
|
|
|
! auxiliary variables
|
2005-08-28 22:09:42 +08:00
|
|
|
complex (DP), allocatable :: phi (:,:,:,:,:,:)
|
2003-01-20 05:58:50 +08:00
|
|
|
! the dynamical matrix
|
|
|
|
|
2010-08-30 01:28:28 +08:00
|
|
|
allocate (phi( 3, 3, 3, nat, nat, nat))
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! First we transform in the cartesian coordinates
|
|
|
|
!
|
2004-03-07 21:47:42 +08:00
|
|
|
phi = (0.d0, 0.d0)
|
2003-02-08 00:04:36 +08:00
|
|
|
do i1 = npert_i, npert_f
|
|
|
|
nc = (i1 - 1) / 3 + 1
|
|
|
|
kcart = i1 - 3 * (nc - 1)
|
|
|
|
do i = 1, 3 * nat
|
|
|
|
na = (i - 1) / 3 + 1
|
|
|
|
icart = i - 3 * (na - 1)
|
|
|
|
do j = 1, 3 * nat
|
|
|
|
nb = (j - 1) / 3 + 1
|
|
|
|
jcart = j - 3 * (nb - 1)
|
|
|
|
work = (0.d0, 0.d0)
|
|
|
|
do om = 1, 3 * nat
|
|
|
|
do mu = 1, 3 * nat
|
|
|
|
do nu = 1, 3 * nat
|
General cleanup of intrinsic functions:
conversion to real => DBLE
(including real part of a complex number)
conversion to complex => CMPLX
complex conjugate => CONJG
imaginary part => AIMAG
All functions are uppercase.
CMPLX is preprocessed by f_defs.h and performs an explicit cast:
#define CMPLX(a,b) cmplx(a,b,kind=DP)
This implies that 1) f_defs.h must be included whenever a CMPLX is present,
2) CMPLX should stay in a single line, 3) DP must be defined.
All occurrences of real, float, dreal, dfloat, dconjg, dimag, dcmplx
removed - please do not reintroduce any of them.
Tested only with ifc7 and g95 - beware unintended side effects
Maybe not the best solution (explicit casts everywhere would be better)
but it can be easily changed with a script if the need arises.
The following code might be used to test for possible trouble:
program test_intrinsic
implicit none
integer, parameter :: dp = selected_real_kind(14,200)
real (kind=dp) :: a = 0.123456789012345_dp
real (kind=dp) :: b = 0.987654321098765_dp
complex (kind=dp) :: c = ( 0.123456789012345_dp, 0.987654321098765_dp)
print *, ' A = ', a
print *, ' DBLE(A)= ', DBLE(a)
print *, ' C = ', c
print *, 'CONJG(C)= ', CONJG(c)
print *, 'DBLE(c),AIMAG(C) = ', DBLE(c), AIMAG(c)
print *, 'CMPLX(A,B,kind=dp)= ', CMPLX( a, b, kind=dp)
end program test_intrinsic
Note that CMPLX and REAL without a cast yield single precision numbers on
ifc7 and g95 !!!
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@2133 c92efa57-630b-4861-b058-cf58834340f0
2005-08-27 01:44:42 +08:00
|
|
|
work = work + CONJG(ug0 (i1, om) ) * u (i, mu) * &
|
|
|
|
d3dyn (om, mu, nu) * CONJG(u (j, nu) )
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
phi (kcart, icart, jcart, nc, na, nb) = work
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
2003-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2008-01-24 01:50:56 +08:00
|
|
|
call mp_sum( phi, inter_pool_comm )
|
2003-01-20 05:58:50 +08:00
|
|
|
#endif
|
|
|
|
!
|
|
|
|
! Then we transform to the crystal axis
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do nc = 1, nat
|
|
|
|
do na = 1, nat
|
|
|
|
do nb = 1, nat
|
|
|
|
call trntnsc_3 (phi (1, 1, 1, nc, na, nb), at, bg, - 1)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
!
|
|
|
|
! And we symmetrize in this basis
|
|
|
|
!
|
|
|
|
call d3_symdynph (xq, phi, s, invs, rtau, irt, irgq, nsymq, nat, &
|
|
|
|
irotmq, minus_q)
|
|
|
|
!
|
|
|
|
! Back to cartesian coordinates
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do nc = 1, nat
|
|
|
|
do na = 1, nat
|
|
|
|
do nb = 1, nat
|
|
|
|
call trntnsc_3 (phi (1, 1, 1, nc, na, nb), at, bg, + 1)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
!
|
|
|
|
! rewrite the dynamical matrix on the array dyn with dimension 3nat x 3
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do i1 = 1, 3 * nat
|
|
|
|
nc = (i1 - 1) / 3 + 1
|
|
|
|
kcart = i1 - 3 * (nc - 1)
|
|
|
|
do i = 1, 3 * nat
|
|
|
|
na = (i - 1) / 3 + 1
|
|
|
|
icart = i - 3 * (na - 1)
|
|
|
|
do j = 1, 3 * nat
|
|
|
|
nb = (j - 1) / 3 + 1
|
|
|
|
jcart = j - 3 * (nb - 1)
|
|
|
|
d3dyn (i1, i, j) = phi (kcart, icart, jcart, nc, na, nb)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
|
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
deallocate (phi)
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
end subroutine d3_symdyn
|