Advertisement
golubchick

MAIN.F59

Nov 4th, 2015
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. tau_orig = tauin
  2. FtsvdW_exact = FtsvdW
  3.  
  4. do s = 1, nat, 1
  5. do i = 1, 3, 1
  6. do is = 1, 2, 1
  7. grad = 0.0_DP
  8. plus = 0.0_DP
  9. minus = 0.0_DP
  10. tau_temp = tau_orig
  11. if(is.eq.1) tau_temp(i, s) = tau_orig(i, s) + dx
  12. if(is.eq.2) tau_temp(i, s) = tau_orig(i, s) - dx
  13. CALL tsvdw_para_init()
  14. CALL tsvdw_pbc(tau_temp)
  15. CALL tsvdw_unique_pair()
  16. CALL tsvdw_rhotot( rhor )
  17. CALL tsvdw_screen()
  18. CALL tsvdw_veff()
  19. CALL tsvdw_dveff()
  20. CALL tsvdw_effqnts()
  21. CALL tsvdw_energy()
  22. CALL tsvdw_cleanup()
  23. if(is.eq.1) plus = EtsvdW
  24. if(is.eq.2) minus = EtsvdW
  25. end do
  26. grad = (plus-minus)/(2.0_DP*dx)
  27. write(stdout, *), i, s, minus, grad, FtsvdW_exact(i, s)
  28. end do
  29. end do
  30.  
  31. end subroutine tsvdw_check_dEdr
  32.  
  33. subroutine tsvdw_check_dEdh(tauin, rhor)
  34. implicit none
  35. REAL(DP), INTENT(IN) :: rhor(:,:)
  36. REAL(DP) :: tauin(3,nat)
  37. real(dp) :: dx, ainv_orig(3,3), h_orig(3,3), HtsvdW_exact(3,3), ainv_temp(3,3), h_temp(3,3), plus, minus, grad
  38. integer :: i, s, is
  39. dx = 0.00001_DP
  40.  
  41. ainv_orig = ainv_
  42. h_orig = h_
  43. HtsvdW_exact = HtsvdW
  44.  
  45. do s = 1, 3, 1
  46. do i = 1, 3, 1
  47. do is = 1, 2, 1
  48. grad = 0.0_DP
  49. plus = 0.0_DP
  50. minus = 0.0_DP
  51. h_temp = h_orig
  52. if(is.eq.1) h_temp(s, i) = h_orig(s, i) + dx
  53. if(is.eq.2) h_temp(s, i) = h_orig(s, i) - dx
  54. call inv3x3_mat(h_temp, ainv_temp)
  55. h_ = h_temp
  56. ainv_ = ainv_temp
  57. CALL tsvdw_para_init()
  58. CALL tsvdw_pbc(tauin)
  59. CALL tsvdw_unique_pair()
  60. CALL tsvdw_rhotot( rhor )
  61. CALL tsvdw_screen()
  62. CALL tsvdw_veff()
  63. CALL tsvdw_dveff()
  64. CALL tsvdw_effqnts()
  65. CALL tsvdw_energy()
  66. CALL tsvdw_cleanup()
  67. if(is.eq.1) plus = EtsvdW
  68. if(is.eq.2) minus = EtsvdW
  69. end do
  70. grad = (plus-minus)/(2.0_DP*dx)
  71. write(stdout, *), i, s, minus, grad, HtsvdW_exact(i, s)
  72. end do
  73. end do
  74.  
  75. end subroutine tsvdw_check_dEdh
  76.  
  77. subroutine tsvdw_check_dEdn(tauin, rhor)
  78. implicit none
  79. REAL(DP), INTENT(IN) :: rhor(:,:)
  80. REAL(DP) :: tauin(3,nat)
  81. real(dp) :: plus, minus, grad, rhotot_temp(nr1*nr2*nr3), UtsvdW_exact(nr1*nr2*nr3), dx
  82. integer :: is, ir
  83.  
  84. dx = 0.00001_DP
  85. UtsvdW_exact = UtsvdW
  86.  
  87. write(stdout, *), "ir Numerical Analytic"
  88. write(stdout, *), "-------------------------------------------"
  89. do ir = 1, nr1*nr2*nr3, 1
  90. grad = 0.0_DP
  91. plus = 0.0_DP
  92. minus = 0.0_DP
  93. do is = 1, 2, 1
  94. vdw_lstep0 = .true.
  95. vdw_lscreen = .true.
  96. CALL tsvdw_para_init()
  97. CALL tsvdw_pbc(tauin)
  98. CALL tsvdw_unique_pair()
  99. CALL tsvdw_rhotot( rhor )
  100. if(is.eq.1) rhotot(ir) = rhotot(ir) + dx
  101. if(is.eq.2) rhotot(ir) = rhotot(ir) - dx
  102. CALL tsvdw_screen()
  103. CALL tsvdw_veff()
  104. CALL tsvdw_dveff()
  105. CALL tsvdw_effqnts()
  106. CALL tsvdw_energy()
  107. CALL tsvdw_cleanup()
  108. if(is.eq.1) plus = EtsvdW
  109. if(is.eq.2) minus = EtsvdW
  110. end do
  111. grad = (plus-minus)/(2.0_DP*dx)*(nr1*nr2*nr3)/(omega*8.0_DP)
  112. write(stdout, *), ir, grad, UtsvdW_exact(ir)
  113. end do
  114. end subroutine tsvdw_check_dEdn
  115.  
  116. subroutine inv3x3_mat(A,T)
  117. use kinds, ONLY : DP
  118. IMPLICIT NONE
  119. real(DP), intent(in) :: A(3,3)
  120. real(DP) :: D
  121. real(DP), intent(out) :: T(3,3)
  122. D = A(1,1)*A(2,2)*A(3,3)-A(1,1)*A(2,3)*A(3,2)- &
  123. A(1,2)*A(2,1)*A(3,3)+A(1,2)*A(2,3)*A(3,1)+ &
  124. A(1,3)*A(2,1)*A(3,2)-A(1,3)*A(2,2)*A(3,1)
  125. T(1,1) = (A(2,2)*A(3,3)-A(2,3)*A(3,2))/D
  126. T(1,2) = -(A(1,2)*A(3,3)-A(1,3)*A(3,2))/D
  127. T(1,3) = (A(1,2)*A(2,3)-A(1,3)*A(2,2))/D
  128. T(2,1) = -(A(2,1)*A(3,3)-A(2,3)*A(3,1))/D
  129. T(2,2) = (A(1,1)*A(3,3)-A(1,3)*A(3,1))/D
  130. T(2,3) = -(A(1,1)*A(2,3)-A(1,3)*A(2,1))/D
  131. T(3,1) = (A(2,1)*A(3,2)-A(2,2)*A(3,1))/D
  132. T(3,2) = -(A(1,1)*A(3,2)-A(1,2)*A(3,1))/D
  133. T(3,3) = (A(1,1)*A(2,2)-A(1,2)*A(2,1))/D
  134. return
  135. end subroutine inv3x3_mat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement