2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Copyright (C) 2002 CP90 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 .
|
|
|
|
!
|
|
|
|
|
|
|
|
module stre
|
|
|
|
implicit none
|
|
|
|
save
|
|
|
|
real(kind=8) stress(3,3)
|
|
|
|
end module stre
|
|
|
|
|
|
|
|
module dqrad_mod
|
|
|
|
implicit none
|
|
|
|
save
|
|
|
|
real(kind=8),allocatable:: dqrad(:,:,:,:,:,:,:)
|
2004-02-16 17:53:00 +08:00
|
|
|
contains
|
|
|
|
subroutine deallocate_dqrad_mod
|
|
|
|
IF( ALLOCATED( dqrad ) ) DEALLOCATE( dqrad )
|
|
|
|
end subroutine
|
2003-01-20 05:58:50 +08:00
|
|
|
end module dqrad_mod
|
|
|
|
|
|
|
|
module betax
|
|
|
|
implicit none
|
|
|
|
save
|
|
|
|
integer, parameter:: mmx=5001
|
|
|
|
real(kind=8) :: refg
|
|
|
|
real(kind=8),allocatable:: betagx(:,:,:), dbetagx(:,:,:), &
|
|
|
|
qradx(:,:,:,:,:), dqradx(:,:,:,:,:)
|
2004-02-16 17:53:00 +08:00
|
|
|
contains
|
|
|
|
subroutine deallocate_betax
|
|
|
|
IF( ALLOCATED( betagx ) ) DEALLOCATE( betagx )
|
|
|
|
IF( ALLOCATED( dbetagx ) ) DEALLOCATE( dbetagx )
|
|
|
|
IF( ALLOCATED( qradx ) ) DEALLOCATE( qradx )
|
|
|
|
IF( ALLOCATED( dqradx ) ) DEALLOCATE( dqradx )
|
|
|
|
end subroutine
|
2003-01-20 05:58:50 +08:00
|
|
|
end module betax
|
|
|
|
|
2004-07-15 18:48:54 +08:00
|
|
|
module cpr_subroutines
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2004-07-15 18:48:54 +08:00
|
|
|
implicit none
|
|
|
|
save
|
|
|
|
|
|
|
|
contains
|
|
|
|
|
|
|
|
subroutine compute_stress( stress, detot, h, omega )
|
|
|
|
real(kind=8) :: stress(3,3), detot(3,3), h(3,3), omega
|
|
|
|
integer :: i, j
|
|
|
|
do i=1,3
|
|
|
|
do j=1,3
|
|
|
|
stress(i,j)=-1.d0/omega*(detot(i,1)*h(j,1)+ &
|
|
|
|
& detot(i,2)*h(j,2)+detot(i,3)*h(j,3))
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
return
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
subroutine print_atomic_var( var, na, nsp, head, iunit )
|
|
|
|
use io_global, only: stdout
|
2004-08-27 18:20:42 +08:00
|
|
|
real(kind=8) :: var(:,:)
|
2004-07-15 18:48:54 +08:00
|
|
|
integer :: na(:), nsp
|
|
|
|
integer, optional :: iunit
|
|
|
|
character(len=*), optional :: head
|
2004-08-27 18:20:42 +08:00
|
|
|
integer :: i, ia, is, iu, isa
|
2004-07-15 18:48:54 +08:00
|
|
|
if( present( iunit ) ) then
|
|
|
|
iu = iunit
|
|
|
|
else
|
|
|
|
iu = stdout
|
|
|
|
end if
|
|
|
|
if( present( head ) ) then
|
|
|
|
WRITE( iu,*) head
|
|
|
|
end if
|
2004-08-27 18:20:42 +08:00
|
|
|
isa = 0
|
|
|
|
DO is = 1, nsp
|
|
|
|
DO ia = 1, na(is)
|
|
|
|
isa = isa + 1
|
|
|
|
WRITE( iu,'(3f14.8)') ( var(i,isa), i=1, 3 )
|
|
|
|
END DO
|
|
|
|
END DO
|
2004-07-15 18:48:54 +08:00
|
|
|
return
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
subroutine print_cell_var( var, head, iunit )
|
|
|
|
use io_global, only: stdout
|
|
|
|
real(kind=8) :: var(3,3)
|
|
|
|
integer, optional :: iunit
|
|
|
|
character(len=*), optional :: head
|
|
|
|
integer :: i, j, iu
|
|
|
|
if( present( iunit ) ) then
|
|
|
|
iu = iunit
|
|
|
|
else
|
|
|
|
iu = stdout
|
|
|
|
end if
|
|
|
|
if( present( head ) ) then
|
|
|
|
WRITE( iu,*)
|
|
|
|
WRITE( iu,*) head
|
|
|
|
WRITE( iu, 5555 ) ((var(i,j),j=1,3),i=1,3)
|
|
|
|
5555 format(1x,f12.5,1x,f12.5,1x,f12.5/ &
|
|
|
|
& 1x,f12.5,1x,f12.5,1x,f12.5/ &
|
|
|
|
& 1x,f12.5,1x,f12.5,1x,f12.5//)
|
|
|
|
else
|
|
|
|
write(iu,3340) ((var(i,j),i=1,3),j=1,3)
|
|
|
|
3340 format(9(1x,f9.5))
|
|
|
|
end if
|
|
|
|
return
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
|
|
|
|
subroutine ions_cofmsub( tausp, na, nsp, cdm, cdm0 )
|
|
|
|
implicit none
|
2004-08-27 18:20:42 +08:00
|
|
|
real( kind=8 ), intent(inout) :: tausp( :, : )
|
2004-07-15 18:48:54 +08:00
|
|
|
integer, intent(in) :: na(:), nsp
|
|
|
|
real( kind=8 ), intent(in) :: cdm( : ), cdm0( : )
|
2004-08-27 18:20:42 +08:00
|
|
|
integer :: i, ia, is, isa
|
|
|
|
isa = 0
|
2004-07-15 18:48:54 +08:00
|
|
|
do is=1,nsp
|
|
|
|
do ia=1,na(is)
|
2004-08-27 18:20:42 +08:00
|
|
|
isa = isa + 1
|
2004-07-15 18:48:54 +08:00
|
|
|
do i=1,3
|
2004-08-27 18:20:42 +08:00
|
|
|
tausp(i,isa)=tausp(i,isa)+cdm0(i)-cdm(i)
|
2004-07-15 18:48:54 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
return
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
|
2004-08-27 18:20:42 +08:00
|
|
|
subroutine elec_fakekine( ekincm, ema0bg, emass, c0, cm, ngw, n, delt )
|
|
|
|
use mp, only: mp_sum
|
|
|
|
use reciprocal_vectors, only: gstart
|
|
|
|
use wave_base, only: wave_speed2
|
|
|
|
real(kind=8), intent(out) :: ekincm
|
|
|
|
real(kind=8), intent(in) :: ema0bg(:), delt, emass
|
|
|
|
complex(kind=8), intent(in) :: c0(:,:,:,:), cm(:,:,:,:)
|
|
|
|
integer, intent(in) :: ngw, n
|
|
|
|
real(kind=8), allocatable :: emainv(:)
|
|
|
|
real(kind=8) :: ftmp
|
|
|
|
integer :: i
|
2004-07-15 18:48:54 +08:00
|
|
|
|
2004-08-27 18:20:42 +08:00
|
|
|
ALLOCATE( emainv( ngw ) )
|
|
|
|
emainv = 1.0d0 / ema0bg
|
|
|
|
ftmp = 1.0d0
|
|
|
|
if( gstart == 2 ) ftmp = 0.5d0
|
2004-07-15 18:48:54 +08:00
|
|
|
|
2004-08-27 18:20:42 +08:00
|
|
|
ekincm=0.0d0
|
|
|
|
do i=1,n
|
|
|
|
ekincm = ekincm + 2.0d0 * &
|
|
|
|
wave_speed2( c0(:,i,1,1), cm(:,i,1,1), emainv, ftmp )
|
2004-07-15 18:48:54 +08:00
|
|
|
end do
|
2004-08-27 18:20:42 +08:00
|
|
|
ekincm = ekincm * emass / ( delt * delt )
|
|
|
|
|
|
|
|
CALL mp_sum( ekincm )
|
|
|
|
DEALLOCATE( emainv )
|
|
|
|
|
2004-07-15 18:48:54 +08:00
|
|
|
return
|
|
|
|
end subroutine
|
|
|
|
|
2004-08-27 18:20:42 +08:00
|
|
|
subroutine elec_fakekine2( ekincm, ema0bg, emass, c0, cm, ngw, n, delt )
|
2004-07-15 18:48:54 +08:00
|
|
|
use mp, only: mp_sum
|
|
|
|
use reciprocal_vectors, only: gstart
|
|
|
|
use wave_base, only: wave_speed2
|
|
|
|
real(kind=8), intent(out) :: ekincm
|
|
|
|
real(kind=8), intent(in) :: ema0bg(:), delt, emass
|
2004-08-27 18:20:42 +08:00
|
|
|
complex(kind=8), intent(in) :: c0(:,:), cm(:,:)
|
2004-07-15 18:48:54 +08:00
|
|
|
integer, intent(in) :: ngw, n
|
|
|
|
real(kind=8), allocatable :: emainv(:)
|
|
|
|
real(kind=8) :: ftmp
|
|
|
|
integer :: i
|
|
|
|
|
|
|
|
ALLOCATE( emainv( ngw ) )
|
|
|
|
emainv = 1.0d0 / ema0bg
|
|
|
|
ftmp = 1.0d0
|
|
|
|
if( gstart == 2 ) ftmp = 0.5d0
|
|
|
|
|
|
|
|
ekincm=0.0d0
|
|
|
|
do i=1,n
|
|
|
|
ekincm = ekincm + 2.0d0 * &
|
2004-08-27 18:20:42 +08:00
|
|
|
wave_speed2( c0(:,i), cm(:,i), emainv, ftmp )
|
2004-07-15 18:48:54 +08:00
|
|
|
end do
|
|
|
|
ekincm = ekincm * emass / ( delt * delt )
|
|
|
|
|
|
|
|
CALL mp_sum( ekincm )
|
|
|
|
DEALLOCATE( emainv )
|
|
|
|
|
|
|
|
return
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
|
2004-08-27 18:20:42 +08:00
|
|
|
subroutine print_lambda( lambda, n, nshow, ccc, iunit )
|
|
|
|
use io_global, only: stdout, ionode
|
|
|
|
real(kind=8), intent(in) :: lambda(:,:), ccc
|
|
|
|
integer, intent(in) :: n, nshow
|
|
|
|
integer, intent(in), optional :: iunit
|
|
|
|
integer :: nnn, j, un, i
|
|
|
|
if( present( iunit ) ) then
|
|
|
|
un = iunit
|
|
|
|
else
|
|
|
|
un = stdout
|
|
|
|
end if
|
|
|
|
nnn=min(n,nshow)
|
|
|
|
if( ionode ) then
|
|
|
|
WRITE( un,*)
|
|
|
|
WRITE( un,3370) ' lambda n = ', n
|
|
|
|
IF( nnn < n ) WRITE( un,3370) ' print only first ', nnn
|
|
|
|
do i=1,nnn
|
|
|
|
WRITE( un,3380) (lambda(i,j)*ccc,j=1,nnn)
|
|
|
|
end do
|
|
|
|
end if
|
|
|
|
3370 format(26x,a,i4)
|
|
|
|
3380 format(9f8.4)
|
|
|
|
return
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
subroutine add_thermal_stress( stress, pmass, omega, h, vels, nsp, na )
|
|
|
|
real(kind=8) :: stress(3,3)
|
|
|
|
real(kind=8), intent(in) :: pmass(:), omega, h(3,3), vels(:,:)
|
|
|
|
integer, intent(in) :: nsp, na(:)
|
|
|
|
integer :: i, j, is, ia, isa
|
|
|
|
isa = 0
|
|
|
|
do is=1,nsp
|
|
|
|
do ia=1,na(is)
|
|
|
|
isa = isa + 1
|
|
|
|
do i=1,3
|
|
|
|
do j=1,3
|
|
|
|
stress(i,j)=stress(i,j)+pmass(is)/omega* &
|
|
|
|
& ((h(i,1)*vels(1,isa)+h(i,2)*vels(2,isa)+ &
|
|
|
|
& h(i,3)*vels(3,isa))*(h(j,1)*vels(1,isa)+ &
|
|
|
|
& h(j,2)*vels(2,isa)+h(j,3)*vels(3,isa)))
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
return
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
|
2004-07-15 18:48:54 +08:00
|
|
|
end module cpr_subroutines
|