root / src / egrad_LEPS.f90 @ 3
Historique | Voir | Annoter | Télécharger (4,06 ko)
| 1 | 3 | pfleura2 | SUBROUTINE egrad_LEPS(nat,e,geom,grad) |
|---|---|---|---|
| 2 | 3 | pfleura2 | ! This program computes the ernergy and gradien in cartesian coordinates |
| 3 | 3 | pfleura2 | ! for the cartesian geometry Geom |
| 4 | 3 | pfleura2 | |
| 5 | 3 | pfleura2 | IMPLICIT NONE |
| 6 | 3 | pfleura2 | integer, parameter :: KINT = kind(1) |
| 7 | 3 | pfleura2 | integer, parameter :: KREAL = kind(1.0d0) |
| 8 | 3 | pfleura2 | |
| 9 | 3 | pfleura2 | ! Number of atoms |
| 10 | 3 | pfleura2 | INTEGER(KINT), INTENT(IN) :: Nat |
| 11 | 3 | pfleura2 | ! Input geometry |
| 12 | 3 | pfleura2 | REAL(KREAL), INTENT(IN) :: Geom(Nat,3) |
| 13 | 3 | pfleura2 | ! output energy and gradient |
| 14 | 3 | pfleura2 | REAL(KREAL), INTENT(OUT) :: E,grad(Nat*3) |
| 15 | 3 | pfleura2 | |
| 16 | 3 | pfleura2 | |
| 17 | 3 | pfleura2 | ! Bohr --> Angstr |
| 18 | 3 | pfleura2 | real(KREAL), parameter :: BOHR = 0.52917726D+00 |
| 19 | 3 | pfleura2 | ! |
| 20 | 3 | pfleura2 | ! Parameters to define the surface |
| 21 | 3 | pfleura2 | INTEGER(KINT), DIMENSION(6), PARAMETER :: IECOEF = (/-1,9,-45,45,-9,1/) |
| 22 | 3 | pfleura2 | INTEGER(KINT), DIMENSION(6), PARAMETER :: ISCOEF = (/-3,-2,-1,1,2,3/) |
| 23 | 3 | pfleura2 | REAL(KREAL), PARAMETER :: hh=0.001d0 |
| 24 | 3 | pfleura2 | |
| 25 | 3 | pfleura2 | ! Variables |
| 26 | 3 | pfleura2 | INTEGER(KINT) :: i,j,iat,jat |
| 27 | 3 | pfleura2 | REAL(KREAL), ALLOCATABLE :: Xyztmp(:,:),GradTmp(:,:) |
| 28 | 3 | pfleura2 | REAL(KREAL) :: xp,yp |
| 29 | 3 | pfleura2 | |
| 30 | 3 | pfleura2 | CHARACTER(132) :: Line |
| 31 | 3 | pfleura2 | LOGICAL :: Debug |
| 32 | 3 | pfleura2 | |
| 33 | 3 | pfleura2 | real(KREAL), parameter :: zero = 0.0_KREAL, one = 1.0_KREAL |
| 34 | 3 | pfleura2 | REAL(KREAL), external :: ELEPS_xyz |
| 35 | 3 | pfleura2 | |
| 36 | 3 | pfleura2 | |
| 37 | 3 | pfleura2 | INTERFACE |
| 38 | 3 | pfleura2 | function valid(string) result (isValid) |
| 39 | 3 | pfleura2 | CHARACTER(*), intent(in) :: string |
| 40 | 3 | pfleura2 | logical :: isValid |
| 41 | 3 | pfleura2 | END function VALID |
| 42 | 3 | pfleura2 | |
| 43 | 3 | pfleura2 | END INTERFACE |
| 44 | 3 | pfleura2 | |
| 45 | 3 | pfleura2 | debug=valid('egrad_leps')
|
| 46 | 3 | pfleura2 | |
| 47 | 3 | pfleura2 | if (debug) WRITE(*,*) '================ Entering Egrad_leps ===================' |
| 48 | 3 | pfleura2 | if (debug) THEN |
| 49 | 3 | pfleura2 | WRITE(*,*) "Cartesian Geometry" |
| 50 | 3 | pfleura2 | DO I=1,Nat |
| 51 | 3 | pfleura2 | WRITE(*,'(1X,I5,3(1X,F12.6))') I,Geom(i,1:3) |
| 52 | 3 | pfleura2 | END DO |
| 53 | 3 | pfleura2 | END IF |
| 54 | 3 | pfleura2 | |
| 55 | 3 | pfleura2 | ALLOCATE(XyZTmp(Nat,3),GradTmp(Nat,3)) |
| 56 | 3 | pfleura2 | |
| 57 | 3 | pfleura2 | e=ELEPS_xyz(nat,Geom) |
| 58 | 3 | pfleura2 | |
| 59 | 3 | pfleura2 | ! We now calculate the gradients using numerical derivatives |
| 60 | 3 | pfleura2 | Grad=0.d0 |
| 61 | 3 | pfleura2 | GradTmp=0.d0 |
| 62 | 3 | pfleura2 | do iat=1,3 |
| 63 | 3 | pfleura2 | do jat=1,nat |
| 64 | 3 | pfleura2 | xyztmp=geom |
| 65 | 3 | pfleura2 | do i=1,6 |
| 66 | 3 | pfleura2 | xyztmp(jat,iat)=geom(jat,iat)+ISCoef(i)*hh |
| 67 | 3 | pfleura2 | gradTmp(jat,iat)=gradTmp(jat,iat)+IECoef(i)*ELEPS_xyz(nat,xyztmp) |
| 68 | 3 | pfleura2 | end do |
| 69 | 3 | pfleura2 | end do |
| 70 | 3 | pfleura2 | end do |
| 71 | 3 | pfleura2 | gradTmp=gradTmp/(60.*hh) |
| 72 | 3 | pfleura2 | do iat=1,nat |
| 73 | 3 | pfleura2 | grad(3*iat-2:3*iat)=gradTmp(iat,1:3) |
| 74 | 3 | pfleura2 | end do |
| 75 | 3 | pfleura2 | |
| 76 | 3 | pfleura2 | if (debug) THEN |
| 77 | 3 | pfleura2 | WRITE(*,*) "Cartesian gradient " |
| 78 | 3 | pfleura2 | DO I=1,Nat |
| 79 | 3 | pfleura2 | WRITE(*,'(1X,I5,3(1X,F12.6))') I,Gradtmp(i,1:3) |
| 80 | 3 | pfleura2 | END DO |
| 81 | 3 | pfleura2 | END IF |
| 82 | 3 | pfleura2 | |
| 83 | 3 | pfleura2 | |
| 84 | 3 | pfleura2 | deallocate(xyztmp,gradTmp) |
| 85 | 3 | pfleura2 | |
| 86 | 3 | pfleura2 | |
| 87 | 3 | pfleura2 | if (debug) WRITE(*,*) '================ Exiting Egrad_leps ===================' |
| 88 | 3 | pfleura2 | |
| 89 | 3 | pfleura2 | ! ====================================================================== |
| 90 | 3 | pfleura2 | end |
| 91 | 3 | pfleura2 | |
| 92 | 3 | pfleura2 | |
| 93 | 3 | pfleura2 | |
| 94 | 3 | pfleura2 | function ELEPS_xyz(natoms,Xyz) |
| 95 | 3 | pfleura2 | |
| 96 | 3 | pfleura2 | use Path_module, only : order |
| 97 | 3 | pfleura2 | |
| 98 | 3 | pfleura2 | IMPLICIT NONE |
| 99 | 3 | pfleura2 | integer, parameter :: KINT = kind(1) |
| 100 | 3 | pfleura2 | integer, parameter :: KREAL = kind(1.0d0) |
| 101 | 3 | pfleura2 | |
| 102 | 3 | pfleura2 | |
| 103 | 3 | pfleura2 | INTEGER(KINT) ,INTENT(IN) :: natoms |
| 104 | 3 | pfleura2 | REAL(KREAL) ,INTENT(IN) :: Xyz(natoms,3) |
| 105 | 3 | pfleura2 | REAL(KREAL) :: ELEPS_xyz |
| 106 | 3 | pfleura2 | |
| 107 | 3 | pfleura2 | INTEGER(KINT) :: i |
| 108 | 3 | pfleura2 | REAL(KREAL) :: rAB, rBC, rAC |
| 109 | 3 | pfleura2 | |
| 110 | 3 | pfleura2 | REAL(KREAL), PARAMETER :: a=0.05, b=0.30, c=0.05 |
| 111 | 3 | pfleura2 | REAL(KREAL), PARAMETER :: dAB=4.746, dBC=4.747, dAC=3.445 |
| 112 | 3 | pfleura2 | REAL(KREAL), PARAMETER :: r0=0.742, alpha=1.942 |
| 113 | 3 | pfleura2 | |
| 114 | 3 | pfleura2 | REAL(KREAL) :: Qbc,QAc,Qab,Jab,Jbc,Jac |
| 115 | 3 | pfleura2 | |
| 116 | 3 | pfleura2 | Real(KREAL), Parameter :: autoA=0.52917715d0,autoeV=27.21183d0 |
| 117 | 3 | pfleura2 | |
| 118 | 3 | pfleura2 | rAB=0. |
| 119 | 3 | pfleura2 | rAC=0. |
| 120 | 3 | pfleura2 | rBC=0. |
| 121 | 3 | pfleura2 | do i=1,3 |
| 122 | 3 | pfleura2 | rBC=rBC+(xyz(Order(3),i)-xyz(order(2),i))**2 |
| 123 | 3 | pfleura2 | rAB=rAB+(xyz(order(1),i)-xyz(order(2),i))**2 |
| 124 | 3 | pfleura2 | rAC=rAC+(xyz(order(1),i)-xyz(order(3),i))**2 |
| 125 | 3 | pfleura2 | end do |
| 126 | 3 | pfleura2 | rAB=sqrt(rAB) |
| 127 | 3 | pfleura2 | rBC=sqrt(rBC) |
| 128 | 3 | pfleura2 | rAC=sqrt(rAC) |
| 129 | 3 | pfleura2 | |
| 130 | 3 | pfleura2 | ! For consistency with previous articles : rAC is constrained to be 3.742 |
| 131 | 3 | pfleura2 | rAC=3.742 |
| 132 | 3 | pfleura2 | |
| 133 | 3 | pfleura2 | Qab = dab*(1.5*exp(-2*alpha*(rAB-r0))-exp(-alpha*(rAB-r0)))/(2+2*a) |
| 134 | 3 | pfleura2 | Qbc = dbc*(1.5*exp(-2*alpha*(rBC-r0))-exp(-alpha*(rBC-r0)))/(2+2*b) |
| 135 | 3 | pfleura2 | Qac = dac*(1.5*exp (-2*alpha*(rAC-r0))-exp(-alpha*(rAC-r0)))/(2+2*c) |
| 136 | 3 | pfleura2 | Jab = dab*(exp(-2*alpha*(rAB-r0))-6*exp(-alpha*(rAB-r0)))/(4+4*a) |
| 137 | 3 | pfleura2 | Jbc = dbc*(exp(-2*alpha*(rBC-r0))-6*exp(-alpha*(rBC-r0)))/(4+4*b) |
| 138 | 3 | pfleura2 | Jac = dac*(exp(-2*alpha*(rAC-r0))-6*exp(-alpha*(rAC-r0)))/(4+4*c) |
| 139 | 3 | pfleura2 | |
| 140 | 3 | pfleura2 | ! V(x,y) = Qab(x)+Qbc(y)+Qac(rac)-sqrt(Jab(x)**2+Jbc(y)**2+Jac(x)**2-Jab(x)*Jbc(y)-Jbc(y)*Jac(rac)-Jab(x)*Jac(rac)) |
| 141 | 3 | pfleura2 | |
| 142 | 3 | pfleura2 | |
| 143 | 3 | pfleura2 | ELEPS_xyz=(Qab+Qbc+Qac-sqrt(Jab**2+Jbc**2+Jac**2-Jab*Jbc-Jbc*Jac-Jab*Jac))/autoeV |
| 144 | 3 | pfleura2 | |
| 145 | 3 | pfleura2 | return |
| 146 | 3 | pfleura2 | end function ELEPS_xyz |