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-07 21:47:42 +08:00
|
|
|
subroutine dyndia (xq, nmodes, nat, ntyp, ityp, amass, iudyn, dyn, w2)
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! This routine diagonalizes the dynamical matrix and returns
|
|
|
|
! displacement patterns in "dyn". The frequencies are written
|
|
|
|
! on output from this routine.
|
|
|
|
!
|
|
|
|
!
|
2004-01-23 23:08:03 +08:00
|
|
|
USE kinds, only : DP
|
2010-07-31 23:01:03 +08:00
|
|
|
USE io_global, ONLY : stdout
|
|
|
|
USE constants, ONLY : RY_TO_THZ, RY_TO_CMM1
|
2010-08-03 17:26:47 +08:00
|
|
|
USE io_dyn_mat, ONLY : write_dyn_mat_tail
|
|
|
|
USE control_ph, ONLY : xmldyn
|
2003-02-08 00:04:36 +08:00
|
|
|
implicit none
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! first the dummy variables
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: nmodes, nat, ntyp, ityp (nat), iudyn
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: the total number of modes
|
|
|
|
! input: the number of atoms
|
|
|
|
! input: the number of types
|
|
|
|
! input: the types of atoms
|
|
|
|
! input: the unit with the dynamical matrix
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
real(DP) :: xq (3), amass (ntyp), w2 (3 * nat)
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: q vector
|
|
|
|
! input: the masses
|
2004-03-07 21:47:42 +08:00
|
|
|
! output: the frequencies squared
|
2005-08-28 22:09:42 +08:00
|
|
|
complex(DP) :: dyn (3 * nat, nmodes)
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: the dynamical matrix
|
|
|
|
!
|
|
|
|
! here the local variables
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: nta, ntb, nu_i, nu_j, mu, na, nb, i
|
2004-03-07 21:47:42 +08:00
|
|
|
! counters
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2010-07-31 23:01:03 +08:00
|
|
|
real(DP) :: w1, unorm
|
2003-01-20 05:58:50 +08:00
|
|
|
! the frequency
|
|
|
|
! norm of u
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
complex(DP) :: z (3 * nat, 3 * nat)
|
2003-01-20 05:58:50 +08:00
|
|
|
! the eigenvectors
|
|
|
|
|
|
|
|
!
|
|
|
|
! fill the second half of the matrix (imposing hermiticity !)
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do nu_i = 1, nmodes
|
|
|
|
do nu_j = 1, nu_i
|
2004-03-07 21:47:42 +08:00
|
|
|
dyn (nu_i, nu_j) = 0.5d0 * (dyn (nu_i, nu_j) + &
|
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
|
|
|
CONJG(dyn (nu_j, nu_i) ) )
|
|
|
|
dyn (nu_j, nu_i) = CONJG(dyn (nu_i, nu_j) )
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
!
|
|
|
|
! divide the dynamical matrix by the masses
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do nu_i = 1, nmodes
|
|
|
|
na = (nu_i - 1) / 3 + 1
|
|
|
|
nta = ityp (na)
|
|
|
|
do nu_j = 1, nmodes
|
|
|
|
nb = (nu_j - 1) / 3 + 1
|
|
|
|
ntb = ityp (nb)
|
2004-03-07 21:47:42 +08:00
|
|
|
dyn (nu_i, nu_j) = dyn (nu_i, nu_j) / sqrt (amass (nta) * amass (ntb) )
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
!
|
|
|
|
! solve the eigenvalue problem
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
call cdiagh (nmodes, dyn, 3 * nat, w2, z)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Writes on output the displacements and the normalized frequencies.
|
|
|
|
!
|
2003-11-06 03:01:20 +08:00
|
|
|
WRITE( stdout, 9000) (xq (i), i = 1, 3)
|
2004-03-07 21:47:42 +08:00
|
|
|
if (iudyn /= 0) write (iudyn, 9000) (xq (i), i = 1, 3)
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
9000 format(/,5x,'Diagonalizing the dynamical matrix', &
|
|
|
|
& //,5x,'q = ( ',3f14.9,' ) ',//,1x,74('*'))
|
2004-03-07 21:47:42 +08:00
|
|
|
dyn (:,:) = (0.d0, 0.d0)
|
2003-02-08 00:04:36 +08:00
|
|
|
do nu_i = 1, nmodes
|
|
|
|
w1 = sqrt (abs (w2 (nu_i) ) )
|
2004-03-07 21:47:42 +08:00
|
|
|
if (w2 (nu_i) < 0.d0) w1 = - w1
|
2010-07-31 23:01:03 +08:00
|
|
|
WRITE( stdout, 9010) nu_i, w1 * RY_TO_THZ, w1 * RY_TO_CMM1
|
|
|
|
if (iudyn /= 0) write (iudyn, 9010) nu_i, w1 * RY_TO_THZ, w1 * RY_TO_CMM1
|
2003-02-08 00:04:36 +08:00
|
|
|
9010 format (5x,'omega(',i2,') =',f15.6,' [THz] =',f15.6,' [cm-1]')
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! write displacements onto matrix dyn
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
unorm = 0.d0
|
|
|
|
do mu = 1, 3 * nat
|
|
|
|
na = (mu - 1) / 3 + 1
|
|
|
|
dyn (mu, nu_i) = z (mu, nu_i) / sqrt (amass (ityp (na) ) )
|
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
|
|
|
unorm = unorm + dyn (mu, nu_i) * CONJG(dyn (mu, nu_i) )
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2010-08-03 17:26:47 +08:00
|
|
|
if (iudyn /= 0) then
|
|
|
|
write (iudyn, '(" (",6f10.6," ) ")') &
|
2004-03-07 21:47:42 +08:00
|
|
|
(dyn (mu, nu_i) / sqrt (unorm) , mu = 1, 3 * nat)
|
2010-08-03 17:26:47 +08:00
|
|
|
else
|
|
|
|
z(:,nu_i)=dyn (:, nu_i) / sqrt (unorm)
|
|
|
|
endif
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2003-11-06 03:01:20 +08:00
|
|
|
WRITE( stdout, '(1x,74("*"))')
|
2004-03-07 21:47:42 +08:00
|
|
|
if (iudyn /= 0) write (iudyn, '(1x,74("*"))')
|
2010-08-28 21:48:36 +08:00
|
|
|
IF (xmldyn) CALL write_dyn_mat_tail(nat, w2, z)
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
end subroutine dyndia
|