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 qstar_d3 (d3dyn, at, bg, nat, nsym, s, invs, irt, rtau, &
|
|
|
|
nq, sxq, isq, imq, iudyn, wrmode)
|
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
!
|
2004-02-04 19:06:45 +08:00
|
|
|
USE kinds, only : DP
|
2003-02-08 00:04:36 +08:00
|
|
|
implicit none
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! input variables
|
|
|
|
!
|
|
|
|
integer :: nat, nsym, s (3, 3, 48), invs (48), irt (48, nat), &
|
|
|
|
nq, isq (48), imq, iudyn
|
|
|
|
! number of atoms in the unit cell
|
|
|
|
! number of symmetry operations
|
|
|
|
! the symmetry operations
|
|
|
|
! index of the inverse operations
|
|
|
|
! index of the rotated atom
|
|
|
|
! degeneracy of the star of q
|
|
|
|
! symmetry op. giving the rotated q
|
|
|
|
! index of -q in the star (0 if nont present)
|
|
|
|
! unit number
|
|
|
|
|
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
|
|
|
! the dynmatrix derivative
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
real (DP) :: at (3, 3), bg (3, 3), rtau (3, 48, nat), sxq (3, 48)
|
2003-01-20 05:58:50 +08:00
|
|
|
! direct lattice vectors
|
|
|
|
! reciprocal lattice vectors
|
2004-03-07 21:47:42 +08:00
|
|
|
! position of rotated atoms for each sym.op.
|
2003-01-20 05:58:50 +08:00
|
|
|
! list of q in the star
|
2003-02-08 00:04:36 +08:00
|
|
|
logical :: wrmode (3 * nat )
|
2003-01-20 05:58:50 +08:00
|
|
|
! if .true. this mode is to be written
|
|
|
|
!
|
|
|
|
! local variables
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: iq, nsq, isym, na, nb, nc, icar, jcar, kcar, i, j, k
|
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), allocatable :: phi (:,:,:,:,:,:), phi2 (:,:,:,:,:,:)
|
2004-03-07 21:47:42 +08:00
|
|
|
! work space
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
allocate (phi (3,3,3,nat,nat,nat))
|
|
|
|
allocate (phi2(3,3,3,nat,nat,nat))
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Sets number of symmetry operations giving each q in the list
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
nsq = nsym / nq
|
2004-03-07 21:47:42 +08:00
|
|
|
if (nsq * nq /= nsym) call errore ('qstar_d3', 'wrong degeneracy', 1)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Writes dyn.mat d3dyn(3*nat,3*nat,3*nat)
|
|
|
|
! on the 6-index array phi(3,3,3,nat,nat,nat)
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do i = 1, 3 * nat
|
|
|
|
na = (i - 1) / 3 + 1
|
|
|
|
icar = i - 3 * (na - 1)
|
|
|
|
do j = 1, 3 * nat
|
|
|
|
nb = (j - 1) / 3 + 1
|
|
|
|
jcar = j - 3 * (nb - 1)
|
|
|
|
do k = 1, 3 * nat
|
|
|
|
nc = (k - 1) / 3 + 1
|
|
|
|
kcar = k - 3 * (nc - 1)
|
|
|
|
phi (icar, jcar, kcar, na, nb, nc) = d3dyn (i, j, k)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
!
|
|
|
|
! Goes to crystal coordinates
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do na = 1, nat
|
|
|
|
do nb = 1, nat
|
|
|
|
do nc = 1, nat
|
|
|
|
call trntnsc_3 (phi (1, 1, 1, na, nb, nc), at, bg, - 1)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
!
|
|
|
|
! For each q of the star rotates phi with the appropriate sym.op. -> phi
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do iq = 1, nq
|
2004-03-07 21:47:42 +08:00
|
|
|
phi2 (:,:,:,:,:,:) = (0.d0, 0.d0)
|
2003-02-08 00:04:36 +08:00
|
|
|
do isym = 1, nsym
|
2004-03-07 21:47:42 +08:00
|
|
|
if (isq (isym) == iq) then
|
2003-01-20 05:58:50 +08:00
|
|
|
call rotate_and_add_d3 (phi, phi2, nat, isym, s, invs, irt, &
|
|
|
|
rtau, sxq (1, iq) )
|
|
|
|
endif
|
|
|
|
enddo
|
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
|
|
|
phi2 = phi2 / DBLE (nsq)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Back to cartesian coordinates
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do na = 1, nat
|
|
|
|
do nb = 1, nat
|
|
|
|
do nc = 1, nat
|
|
|
|
call trntnsc_3 (phi2 (1, 1, 1, na, nb, nc), at, bg, + 1)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
!
|
|
|
|
! Writes the dynamical matrix in cartesian coordinates on file
|
|
|
|
!
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
call write_d3dyn (sxq (1, iq), phi2, nat, iudyn, wrmode)
|
2004-03-07 21:47:42 +08:00
|
|
|
if (imq == 0) then
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! if -q is not in the star recovers its matrix by time reversal
|
|
|
|
!
|
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
|
|
|
phi2 (:,:,:,:,:,:) = CONJG(phi2 (:,:,:,:,:,:) )
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! and writes it (changing temporarily sign to q)
|
|
|
|
!
|
2004-03-07 21:47:42 +08:00
|
|
|
sxq (:, iq) = - sxq (:, iq)
|
2003-02-08 00:04:36 +08:00
|
|
|
call write_d3dyn (sxq (1, iq), phi2, nat, iudyn, wrmode)
|
2004-03-07 21:47:42 +08:00
|
|
|
sxq (:, iq) = - sxq (:, iq)
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
deallocate (phi)
|
|
|
|
deallocate (phi2)
|
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine qstar_d3
|