1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
!
! Written by Leandro MartÃnez, 2009-2011.
! Copyright (c) 2009-2018, Leandro MartÃnez, Jose Mario Martinez,
! Ernesto G. Birgin.
!
!
! Subroutine comprest: Compute the function value relative to
! to the restrictions for one atom
!
subroutine comprest(icart,f)
use sizes
use compute_data, only : xcart, restpars, scale, scale2, nratom, ityperest, iratom
implicit none
integer :: iratcount, irest, icart
double precision :: xmin, ymin, zmin, clength, a1, a2, a3, a4, w, b1, b2, b3, d, a5, a6
double precision :: f
double precision :: xmax, ymax, zmax
double precision :: v1, v2, v3
double precision :: vnorm
f = 0.d0
do iratcount = 1, nratom(icart)
irest = iratom(icart,iratcount)
if(ityperest(irest).eq.2) then
clength = restpars(irest,4)
xmin = restpars(irest,1)
ymin = restpars(irest,2)
zmin = restpars(irest,3)
xmax = restpars(irest,1) + clength
ymax = restpars(irest,2) + clength
zmax = restpars(irest,3) + clength
a1 = dmin1(xcart(icart,1) - xmin, 0.d0)
a2 = dmin1(xcart(icart,2) - ymin, 0.d0)
a3 = dmin1(xcart(icart,3) - zmin, 0.d0)
f = f + scale*(a1 * a1 + a2 * a2 + a3 * a3)
a1 = dmax1(xcart(icart,1) - xmax, 0.d0)
a2 = dmax1(xcart(icart,2) - ymax, 0.d0)
a3 = dmax1(xcart(icart,3) - zmax, 0.d0)
f = f + scale*(a1 * a1 + a2 * a2 + a3 * a3)
else if(ityperest(irest).eq.3) then
xmin = restpars(irest,1)
ymin = restpars(irest,2)
zmin = restpars(irest,3)
xmax = restpars(irest,4)
ymax = restpars(irest,5)
zmax = restpars(irest,6)
a1 = dmin1(xcart(icart,1) - xmin, 0.d0)
a2 = dmin1(xcart(icart,2) - ymin, 0.d0)
a3 = dmin1(xcart(icart,3) - zmin, 0.d0)
f = f + scale*(a1 * a1 + a2 * a2 + a3 * a3)
a1 = dmax1(xcart(icart,1) - xmax, 0.d0)
a2 = dmax1(xcart(icart,2) - ymax, 0.d0)
a3 = dmax1(xcart(icart,3) - zmax, 0.d0)
f = f + scale*(a1 * a1 + a2 * a2 + a3 * a3)
else if(ityperest(irest).eq.4) then
w = (xcart(icart,1)-restpars(irest,1))**2 + &
(xcart(icart,2)-restpars(irest,2))**2 + &
(xcart(icart,3)-restpars(irest,3))**2 - &
restpars(irest,4)**2
a1 = dmax1(w,0.d0)
f = f + scale2*a1*a1
else if(ityperest(irest).eq.5) then
a1 = (xcart(icart,1)-restpars(irest,1))**2 / restpars(irest,4)**2
a2 = (xcart(icart,2)-restpars(irest,2))**2 / restpars(irest,5)**2
a3 = (xcart(icart,3)-restpars(irest,3))**2 / restpars(irest,6)**2
a4 = restpars(irest,7)**2
w = a1 + a2 + a3 - a4
a1 = dmax1(w,0.d0)
f = f + scale2*a1*a1
else if(ityperest(irest).eq.6) then
xmin = restpars(irest,1)
ymin = restpars(irest,2)
zmin = restpars(irest,3)
xmax = restpars(irest,1) + restpars(irest,4)
ymax = restpars(irest,2) + restpars(irest,4)
zmax = restpars(irest,3) + restpars(irest,4)
a1 = dmax1(xcart(icart,1) - xmin,0.d0)
a2 = dmax1(xcart(icart,2) - ymin,0.d0)
a3 = dmax1(xcart(icart,3) - zmin,0.d0)
a4 = dmax1(xmax - xcart(icart,1),0.d0)
a5 = dmax1(ymax - xcart(icart,2),0.d0)
a6 = dmax1(zmax - xcart(icart,3),0.d0)
f = f + a1*a2*a3*a4*a5*a6
else if(ityperest(irest).eq.7) then
xmin = restpars(irest,1)
ymin = restpars(irest,2)
zmin = restpars(irest,3)
xmax = restpars(irest,4)
ymax = restpars(irest,5)
zmax = restpars(irest,6)
a1 = dmax1(xcart(icart,1) - xmin,0.d0)
a2 = dmax1(xcart(icart,2) - ymin,0.d0)
a3 = dmax1(xcart(icart,3) - zmin,0.d0)
a4 = dmax1(xmax - xcart(icart,1),0.d0)
a5 = dmax1(ymax - xcart(icart,2),0.d0)
a6 = dmax1(zmax - xcart(icart,3),0.d0)
f = f + a1*a2*a3*a4*a5*a6
else if(ityperest(irest).eq.8) then
w = (xcart(icart,1)-restpars(irest,1))**2 + &
(xcart(icart,2)-restpars(irest,2))**2 + &
(xcart(icart,3)-restpars(irest,3))**2 - &
restpars(irest,4)**2
a1 = dmin1(w,0.d0)
f = f + scale2*a1*a1
else if(ityperest(irest).eq.9) then
a1 = (xcart(icart,1)-restpars(irest,1))**2 / restpars(irest,4)**2
a2 = (xcart(icart,2)-restpars(irest,2))**2 / restpars(irest,5)**2
a3 = (xcart(icart,3)-restpars(irest,3))**2 / restpars(irest,6)**2
a4 = restpars(irest,7)**2
w = a1 + a2 + a3 - a4
a1 = dmin1(w,0.d0)
f = f + a1*a1
else if(ityperest(irest).eq.10) then
w = restpars(irest,1)*xcart(icart,1) + &
restpars(irest,2)*xcart(icart,2) + &
restpars(irest,3)*xcart(icart,3) - &
restpars(irest,4)
a1 = dmin1(w,0.d0)
f = f + scale * a1*a1
else if(ityperest(irest).eq.11) then
w = restpars(irest,1)*xcart(icart,1) + &
restpars(irest,2)*xcart(icart,2) + &
restpars(irest,3)*xcart(icart,3) - &
restpars(irest,4)
a1 = dmax1(w,0.d0)
f = f + scale * a1*a1
else if(ityperest(irest).eq.12) then
a1 = xcart(icart,1) - restpars(irest,1)
a2 = xcart(icart,2) - restpars(irest,2)
a3 = xcart(icart,3) - restpars(irest,3)
vnorm = sqrt(restpars(irest,4)**2 + restpars(irest,5)**2 + restpars(irest,6)**2)
v1 = restpars(irest,4)/vnorm
v2 = restpars(irest,5)/vnorm
v3 = restpars(irest,6)/vnorm
b1 = v1 * a1
b2 = v2 * a2
b3 = v3 * a3
w = b1 + b2 + b3
d = ( a1 - v1*w )**2 + ( a2 - v2*w )**2 + ( a3 - v3*w )**2
f = f + scale2 * ( &
dmax1(-w , 0.d0)**2 + &
dmax1(w - restpars(irest,9), 0.d0)**2 + &
dmax1(d - restpars(irest,7)**2 , 0.d0 )**2 )
else if(ityperest(irest).eq.13) then
a1 = xcart(icart,1) - restpars(irest,1)
a2 = xcart(icart,2) - restpars(irest,2)
a3 = xcart(icart,3) - restpars(irest,3)
vnorm = sqrt(restpars(irest,4)**2 + restpars(irest,5)**2 + restpars(irest,6)**2)
v1 = restpars(irest,4)/vnorm
v2 = restpars(irest,5)/vnorm
v3 = restpars(irest,6)/vnorm
b1 = v1 * a1
b2 = v2 * a2
b3 = v3 * a3
w = b1 + b2 + b3
d = ( a1 - v1*w )**2 +( a2 - v2*w )**2 + ( a3 - v3*w )**2
f = f + scale2 * ( &
dmin1(-w , 0.d0)**2 * &
dmin1(w - restpars(irest,9), 0.d0)**2 * &
dmin1(d - restpars(irest,7)**2 , 0.d0 )**2 )
end if
end do
return
end subroutine comprest
|