| 1 |
! |
| 2 |
! This is iAPBS/sander module for performing APBS calculations in sander. |
| 3 |
! |
| 4 |
! For more information please see http://mccammon.ucsd.edu/iapbs/ |
| 5 |
! |
| 6 |
#include "../include/dprec.fh" |
| 7 |
|
| 8 |
MODULE apbs |
| 9 |
#ifdef APBS |
| 10 |
|
| 11 |
! rokFIXME add timer calls |
| 12 |
|
| 13 |
CONTAINS |
| 14 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 15 |
SUBROUTINE apbs_read() |
| 16 |
! |
| 17 |
! read in APBS user input parameters and set defaults |
| 18 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 19 |
|
| 20 |
use apbs_vars |
| 21 |
use file_io_dat, only : mdin_apbs, sp_apbs |
| 22 |
IMPLICIT NONE |
| 23 |
|
| 24 |
INTEGER :: i |
| 25 |
INTEGER :: nonlin, bcfl, nion, srfm, calcenergy, calcforce |
| 26 |
INTEGER :: calc_type, nlev, cmeth, ccmeth, fcmeth, chgm |
| 27 |
INTEGER :: calcnpenergy, calcnpforce |
| 28 |
INTEGER :: wpot, wchg, wsmol, wkappa, wdiel |
| 29 |
INTEGER :: rchg, rkappa, rdiel, watompot, rpot |
| 30 |
_REAL_ :: pdie, sdie, srad, swin, temp, gamma, sdens |
| 31 |
_REAL_ :: smvolume, smsize |
| 32 |
NAMELIST /apbs/ dime, pdime, cglen, fglen, grid, nlev, & |
| 33 |
nonlin, bcfl, nion, pdie, sdie, srfm, chgm, srad, swin, & |
| 34 |
temp, gamma, sdens, calc_type, calcnpenergy, calcnpforce, & |
| 35 |
cmeth, ccmeth, fcmeth, ionq, ionc, ionrr, & |
| 36 |
smvolume, smsize, & |
| 37 |
calcenergy, calcforce, apbs_debug, sp_apbs, apbs_print, & |
| 38 |
wpot, wchg, wsmol, ispara, radiopt, geom_upd_limit, & |
| 39 |
evdw_upd_limit, pqr, dime_updates, & |
| 40 |
wkappa, wdiel, rchg, rkappa, rdiel, watompot, rpot |
| 41 |
|
| 42 |
! rokFIXME: also add maps-related and centering-related (center) keywords |
| 43 |
|
| 44 |
! Default values |
| 45 |
! PBEparm |
| 46 |
ispara = 0 |
| 47 |
! i_pbeparm(1) = 1 ! molid |
| 48 |
nonlin = 0 |
| 49 |
bcfl = 1 |
| 50 |
nion = 0 |
| 51 |
srfm = 2 |
| 52 |
pdie = 2.0 |
| 53 |
sdie = 78.4 |
| 54 |
srad = 1.4 |
| 55 |
swin = 0.3 |
| 56 |
temp = 298.15 |
| 57 |
gamma = 0.105 |
| 58 |
sdens = 10.0 |
| 59 |
gamma = 0.105 |
| 60 |
smvolume = 10.0 |
| 61 |
smsize = 1000.0 |
| 62 |
|
| 63 |
calcenergy = 2 |
| 64 |
calcforce = 2 |
| 65 |
calcnpenergy = 1 |
| 66 |
calcnpforce = 2 |
| 67 |
wpot = 0 |
| 68 |
wchg = 0 |
| 69 |
wsmol = 0 |
| 70 |
wkappa = 0 |
| 71 |
wdiel= 0 |
| 72 |
watompot = 0 |
| 73 |
rchg = 0 |
| 74 |
rkappa = 0 |
| 75 |
rdiel = 0 |
| 76 |
rpot = 0 |
| 77 |
|
| 78 |
! MGparm |
| 79 |
calc_type = 1 ! 0 - manual MG, 1- autoMG, 2- parallel MG |
| 80 |
nlev = 4 |
| 81 |
cmeth = 1 |
| 82 |
ccmeth = 1 |
| 83 |
fcmeth = 1 |
| 84 |
chgm = 1 |
| 85 |
|
| 86 |
pdime = (/ 0, 0, 0 /) |
| 87 |
ofrac = 0.1 |
| 88 |
|
| 89 |
! ionq = (/ 1.0, -1.0 /) |
| 90 |
! ionc = (/ 0.15, 0.15 /) |
| 91 |
! ionrr = (/ 2.0, 2.0 /) |
| 92 |
|
| 93 |
dime = (/ 0, 0, 0 /) |
| 94 |
grid = (/ 0.0, 0.0, 0.0 /) |
| 95 |
glen = (/ 0.0, 0.0, 0.0 /) |
| 96 |
center = (/ 0.0, 0.0, 0.0 /) |
| 97 |
cglen = (/ 0.0, 0.0, 0.0 /) |
| 98 |
fglen = (/ 0.0, 0.0, 0.0 /) |
| 99 |
ccenter = (/ 0.0, 0.0, 0.0 /) |
| 100 |
fcenter = (/ 0.0, 0.0, 0.0 /) |
| 101 |
|
| 102 |
! is this a single point energy calculation? |
| 103 |
! default is no |
| 104 |
sp_apbs = .FALSE. |
| 105 |
! printing verbosity |
| 106 |
apbs_print = 1 |
| 107 |
! debuging flag |
| 108 |
apbs_debug = 0 |
| 109 |
! radii optimization option |
| 110 |
radiopt = 0 |
| 111 |
|
| 112 |
! number of PB steps |
| 113 |
napbs = 0 |
| 114 |
! APBS update forces schema geom limit |
| 115 |
! 0.0 means: do updates every apbs_force call |
| 116 |
geom_upd_limit = 0.0 |
| 117 |
evdw_upd_limit = 0.0 |
| 118 |
|
| 119 |
! read in APBS input parameters |
| 120 |
IF (mdin_apbs) THEN |
| 121 |
REWIND 5 |
| 122 |
READ(5, nml=apbs) |
| 123 |
ELSE |
| 124 |
WRITE(6, '(a)') 'iAPBS: WARNING: did NOT read in any APBS parameters!' |
| 125 |
WRITE(6, '(a)') 'iAPBS: Exiting ...' |
| 126 |
CALL mexit(6,1) |
| 127 |
END IF |
| 128 |
|
| 129 |
i_param(1) = calc_type |
| 130 |
i_param(2) = nlev |
| 131 |
i_param(3) = cmeth |
| 132 |
i_param(4) = ccmeth |
| 133 |
i_param(5) = fcmeth |
| 134 |
i_param(6) = chgm |
| 135 |
i_param(7) = nonlin |
| 136 |
i_param(8) = bcfl |
| 137 |
i_param(9) = srfm |
| 138 |
i_param(10) = calcenergy |
| 139 |
i_param(11) = calcforce |
| 140 |
i_param(12) = wpot |
| 141 |
i_param(13) = wchg |
| 142 |
i_param(14) = wsmol |
| 143 |
i_param(15) = wkappa |
| 144 |
i_param(16) = wdiel |
| 145 |
i_param(17) = watompot |
| 146 |
i_param(18) = rpot |
| 147 |
i_param(19) = 0 |
| 148 |
i_param(20) = calcnpforce |
| 149 |
i_param(21) = calcnpenergy |
| 150 |
i_param(22) = nion |
| 151 |
i_param(23) = rchg |
| 152 |
i_param(24) = rkappa |
| 153 |
i_param(25) = rdiel |
| 154 |
|
| 155 |
r_param(1) = pdie |
| 156 |
r_param(2) = sdie |
| 157 |
r_param(3) = srad |
| 158 |
r_param(4) = swin |
| 159 |
r_param(5) = temp |
| 160 |
r_param(6) = sdens |
| 161 |
r_param(7) = gamma |
| 162 |
r_param(8) = smvolume |
| 163 |
r_param(9) = smsize |
| 164 |
|
| 165 |
END SUBROUTINE apbs_read |
| 166 |
|
| 167 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 168 |
SUBROUTINE apbs_init(natom, x, cg, radii) |
| 169 |
! |
| 170 |
! initialize APBS charges and radii |
| 171 |
! in: natom |
| 172 |
! cg (atomic charges) |
| 173 |
! radii (atomi radii) |
| 174 |
! |
| 175 |
! on exit pbcg and pbradii are modified (via 'use apbs_vars') |
| 176 |
! |
| 177 |
! these values are then constant during simulation |
| 178 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 179 |
|
| 180 |
use apbs_vars |
| 181 |
|
| 182 |
IMPLICIT NONE |
| 183 |
! passed in variables |
| 184 |
INTEGER, INTENT(in) :: natom |
| 185 |
_REAL_, INTENT(in) :: x(3*natom), cg(natom), radii(natom) |
| 186 |
|
| 187 |
! local variables |
| 188 |
INTEGER :: i, j, dummyi, ios, numline=0, error |
| 189 |
CHARACTER :: dummyc |
| 190 |
CHARACTER (len = 128) string |
| 191 |
_REAL_ :: dummyr, maxx, minx, maxy, miny, maxz, minz |
| 192 |
_REAL_ :: cx(natom), cy(natom), cz(natom) |
| 193 |
_REAL_ :: tmpcg, tmprad, tot_charge |
| 194 |
|
| 195 |
WRITE(6, '(a)') 'iAPBS: Initializing APBS interface' |
| 196 |
|
| 197 |
ALLOCATE(pbradii(natom), pbcg(natom), stat=error) |
| 198 |
IF (error .NE. 0) THEN |
| 199 |
WRITE(6, '(a)') 'iAPBS: pbradii/pbcg memory allocation failed!' |
| 200 |
WRITE(6, '(a)') 'iAPBS: Exiting ...' |
| 201 |
CALL mexit(6,1) |
| 202 |
ENDIF |
| 203 |
|
| 204 |
! possible additions: |
| 205 |
! - call pb_aaradi() (from sa_driver.f) |
| 206 |
! - call phi_aaradi() (from sa_driver.f) |
| 207 |
! CALL pb_aaradi( natom, nbonh, ibh, jbh, pbradii, acrg, ucrgh, ucrga, & |
| 208 |
! resid, igraph, isymbl, radii ) |
| 209 |
! |
| 210 |
IF (radiopt == 0) THEN |
| 211 |
WRITE(6, '(a)') & |
| 212 |
'iAPBS: Using charge/radii definition from prmtop file' |
| 213 |
pbradii = radii |
| 214 |
pbcg = cg / 18.2223d0 ! 18.2223d0 is used to convert amber charge |
| 215 |
! to units of the electron charge |
| 216 |
ELSE IF (radiopt == 1) THEN |
| 217 |
! read from a file |
| 218 |
! file format: atom chrg radius |
| 219 |
WRITE(6, '(a)') & |
| 220 |
'iAPBS: Reading chg/radii definition from pbparamsin file' |
| 221 |
OPEN(21, file="pbparamsin", status="old") |
| 222 |
DO i = 1, natom |
| 223 |
READ(21,*) dummyc, pbcg(i), pbradii(i) |
| 224 |
END DO |
| 225 |
CLOSE(21) |
| 226 |
|
| 227 |
ELSE IF (radiopt == 2) THEN |
| 228 |
! read cg and rad from PQR file |
| 229 |
WRITE(6, '(2a)') & |
| 230 |
'iAPBS: Reading charge/radii definition from pqr filename: ', pqr |
| 231 |
OPEN(21, file=pqr, status="old") |
| 232 |
DO |
| 233 |
READ (21, '(a)', iostat=ios) string |
| 234 |
IF ( ios /= 0 ) EXIT |
| 235 |
IF (string(1:4) == 'ATOM' ) THEN |
| 236 |
READ(string, * , iostat=ios) & |
| 237 |
dummyc, dummyi, dummyc, dummyc, dummyi, & |
| 238 |
dummyr, dummyr, dummyr, tmpcg, tmprad |
| 239 |
IF ( ios /= 0 ) EXIT |
| 240 |
numline = numline + 1 |
| 241 |
pbcg(numline) = tmpcg |
| 242 |
pbradii(numline) = tmprad |
| 243 |
END IF |
| 244 |
END DO |
| 245 |
IF (numline /= natom) THEN |
| 246 |
WRITE(6, '(a)') 'Wrong number of atoms in PQR file!' |
| 247 |
CALL mexit(6,1) |
| 248 |
END IF |
| 249 |
CLOSE(21) |
| 250 |
|
| 251 |
ELSE IF (radiopt == 3) THEN |
| 252 |
! read rad PQR file |
| 253 |
WRITE(6, '(2a)') & |
| 254 |
'iAPBS: Reading radii definition from pqr filename: ', pqr |
| 255 |
OPEN(21, file=pqr, status="old") |
| 256 |
DO |
| 257 |
READ (21, '(a)', iostat=ios ) string |
| 258 |
IF ( ios /= 0 ) EXIT |
| 259 |
IF (string(1:4) == 'ATOM' ) THEN |
| 260 |
READ(string, * , iostat=ios) & |
| 261 |
dummyc, dummyi, dummyc, dummyc, dummyi, & |
| 262 |
dummyr, dummyr, dummyr, dummyr, tmprad |
| 263 |
IF ( ios /= 0 ) EXIT |
| 264 |
numline = numline + 1 |
| 265 |
pbradii(numline) = tmprad |
| 266 |
END IF |
| 267 |
END DO |
| 268 |
IF (numline /= natom) THEN |
| 269 |
WRITE(6, '(a)') 'Wrong number of atoms in PQR file!' |
| 270 |
CALL mexit(6,1) |
| 271 |
END IF |
| 272 |
CLOSE(21) |
| 273 |
pbcg = cg / 18.2223d0 ! 18.2223d0 is used to convert amber charge |
| 274 |
! to units of the electron charge |
| 275 |
ELSE |
| 276 |
WRITE(6,'(a)') 'iAPBS: Unknown radiopt option.' |
| 277 |
CALL mexit(6,1) |
| 278 |
END IF |
| 279 |
|
| 280 |
! unpack coordinates |
| 281 |
DO i = 1, natom |
| 282 |
j = 3*(i-1) |
| 283 |
cx(i) = x(j+1) |
| 284 |
cy(i) = x(j+2) |
| 285 |
cz(i) = x(j+3) |
| 286 |
END DO |
| 287 |
|
| 288 |
IF (apbs_print > 1) THEN |
| 289 |
WRITE(6, '(a)') 'iAPBS: natom, x, y, z, PB charge, PB radius' |
| 290 |
DO i = 1, natom |
| 291 |
WRITE(6, '(i6, 5f8.3)') i, cx(i), cy(i), cz(i), pbcg(i), pbradii(i) |
| 292 |
END DO |
| 293 |
WRITE(6,'()') |
| 294 |
END IF |
| 295 |
|
| 296 |
maxx = cx(1) |
| 297 |
minx = cx(1) |
| 298 |
maxy = cy(1) |
| 299 |
miny = cy(1) |
| 300 |
maxz = cz(1) |
| 301 |
minz = cz(1) |
| 302 |
tot_charge = 0.0 |
| 303 |
DO i = 1, natom |
| 304 |
IF(maxx < cx(i)+pbradii(i)) maxx = cx(i)+pbradii(i) |
| 305 |
IF(minx > cx(i)-pbradii(i)) minx = cx(i)-pbradii(i) |
| 306 |
IF(maxy < cy(i)+pbradii(i)) maxy = cy(i)+pbradii(i) |
| 307 |
IF(miny > cy(i)-pbradii(i)) miny = cy(i)-pbradii(i) |
| 308 |
IF(maxz < cz(i)+pbradii(i)) maxz = cz(i)+pbradii(i) |
| 309 |
IF(minz > cz(i)-pbradii(i)) minz = cz(i)-pbradii(i) |
| 310 |
tot_charge = tot_charge + pbcg(i) |
| 311 |
END DO |
| 312 |
|
| 313 |
IF (apbs_print > 1) THEN |
| 314 |
WRITE(6,'(a, 3f8.3)') 'iAPBS: Molecular dimensions: ', & |
| 315 |
maxx-minx, maxy-miny, maxz-minz |
| 316 |
WRITE(6,'(a, f8.3)') 'iAPBS: Total charge: ', tot_charge |
| 317 |
END IF |
| 318 |
|
| 319 |
! for mg-auto calculate missing grid parameters if dime = 0 |
| 320 |
IF ((i_param(1) == 0 .OR. i_param(1) == 1) .AND. dime(1) == 0) THEN |
| 321 |
cglen(1) = 1.7 * (maxx-minx) |
| 322 |
cglen(2) = 1.7 * (maxy-miny) |
| 323 |
cglen(3) = 1.7 * (maxz-minz) |
| 324 |
fglen(1) = 20.0 + (maxx-minx) |
| 325 |
fglen(2) = 20.0 + (maxy-miny) |
| 326 |
fglen(3) = 20.0 + (maxz-minz) |
| 327 |
|
| 328 |
DO i = 1, 3 |
| 329 |
IF (fglen(i) > cglen(i)) cglen(i) = fglen(i) |
| 330 |
END DO |
| 331 |
|
| 332 |
WRITE(6, '(a)') 'iAPBS: Grid dime not specified, calculating ...' |
| 333 |
WRITE(6, '(a)') & |
| 334 |
'iAPBS: Requesting dime re-calculation on the fly' |
| 335 |
dime_updates = .TRUE. |
| 336 |
DO i = 1, 3 |
| 337 |
dime(i) = & |
| 338 |
32*(INT((INT(fglen(i)/grid(i) + 0.5) - 1)/32.0 + 0.5)) + 1 |
| 339 |
IF (dime(i) < 33) dime(i) = 33 |
| 340 |
END DO |
| 341 |
END IF |
| 342 |
|
| 343 |
IF (apbs_print > 0) THEN |
| 344 |
WRITE(6, '(a)') 'iAPBS: Grid values: ' |
| 345 |
WRITE(6, '(a, 3f8.3)') 'iAPBS: fglen: ', fglen(1), fglen(2), fglen(3) |
| 346 |
WRITE(6, '(a, 3f8.3)') 'iAPBS: cglen: ', cglen(1), cglen(2), cglen(3) |
| 347 |
WRITE(6, '(a, 3i6)') 'iAPBS: dime: ', dime(1), dime(2), dime(3) |
| 348 |
WRITE(6, '(a, 3f8.3)') 'iAPBS: grid: ', grid(1), grid(2), grid(3) |
| 349 |
|
| 350 |
WRITE(6, '(a, f10.3)') 'iAPBS: Required memory (in MB): ', & |
| 351 |
dime(1)*dime(2)*dime(3)*200.0/1024/1024 |
| 352 |
END IF |
| 353 |
|
| 354 |
CALL apbs_print_info() |
| 355 |
|
| 356 |
END SUBROUTINE apbs_init |
| 357 |
|
| 358 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 359 |
SUBROUTINE apbs_print_info() |
| 360 |
! |
| 361 |
! Print out APBS calculation parameters |
| 362 |
! |
| 363 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 364 |
|
| 365 |
use apbs_vars |
| 366 |
IMPLICIT NONE |
| 367 |
|
| 368 |
WRITE(6,'()') |
| 369 |
WRITE(6, '(a)') ' APBS calculation parameters:' |
| 370 |
WRITE(6,'()') |
| 371 |
|
| 372 |
! nonlin |
| 373 |
IF (i_param(7) == 0) THEN |
| 374 |
WRITE(6, '(a)')'Linearized traditional PBE' |
| 375 |
ELSE IF (i_param(7) == 1) THEN |
| 376 |
WRITE(6, '(a)')'Nonlinear traditional PBE' |
| 377 |
ELSE IF (i_param(7) == 2) THEN |
| 378 |
WRITE(6, '(a)')'Linearized RPBE' |
| 379 |
ELSE IF (i_param(7) == 3) THEN |
| 380 |
WRITE(6, '(a)')'Nonlinear RPBE' |
| 381 |
ELSE IF (i_param(7) == 4) THEN |
| 382 |
WRITE(6, '(a)')'Size-Modified PBE' |
| 383 |
ELSE |
| 384 |
WRITE(6, '(a)')'Unknown PBE option' |
| 385 |
CALL mexit(6,1) |
| 386 |
END IF |
| 387 |
|
| 388 |
! boundary conditions, bcfl |
| 389 |
IF (i_param(8) == 0) THEN |
| 390 |
WRITE(6, '(a)') 'Zero boundary conditions' |
| 391 |
ELSE IF (i_param(8) == 1) THEN |
| 392 |
WRITE(6, '(a)') 'Single Debye-Huckel sphere boundary conditions' |
| 393 |
ELSE IF (i_param(8) == 2) THEN |
| 394 |
WRITE(6, '(a)') 'Multiple Debye-Huckel sphere boundary conditions' |
| 395 |
ELSE IF (i_param(8) == 4) THEN |
| 396 |
WRITE(6, '(a)') 'Focusing boundary conditions' |
| 397 |
ELSE |
| 398 |
WRITE(6, '(a)') 'Unknown boundary conditions option' |
| 399 |
CALL mexit(6,1) |
| 400 |
END IF |
| 401 |
|
| 402 |
! surface definition, srfm |
| 403 |
IF (i_param(9) == 0) THEN |
| 404 |
WRITE (6, '(a)') 'Molecular surface definition' |
| 405 |
ELSE IF (i_param(9) == 1) THEN |
| 406 |
WRITE (6, '(a)') 'Smoothed molecular surface definition' |
| 407 |
ELSE IF (i_param(9) == 2) THEN |
| 408 |
WRITE (6, '(a)') 'Using cubic-spline surface definition' |
| 409 |
ELSE IF (i_param(9) == 3) THEN |
| 410 |
WRITE (6, '(a)') 'Using 7-order polynomial spline surface' |
| 411 |
ELSE |
| 412 |
WRITE(6, '(a)') 'Unknown surface definition' |
| 413 |
CALL mexit(6,1) |
| 414 |
END IF |
| 415 |
|
| 416 |
! charge discretization, chgm |
| 417 |
IF (i_param(6) == 0) THEN |
| 418 |
WRITE(6, '(a)') 'Using trilinear interpolation (linear splines)' |
| 419 |
ELSE IF(i_param(6) == 1) THEN |
| 420 |
WRITE(6, '(a)') 'Using cubic B-spline charge discretization' |
| 421 |
ELSE IF(i_param(6) == 2) THEN |
| 422 |
WRITE(6, '(a)') 'Using quintic B-spline charge discretization' |
| 423 |
ELSE |
| 424 |
WRITE(6, '(a)') 'Unknown charge discretization' |
| 425 |
CALL mexit(6,1) |
| 426 |
END IF |
| 427 |
|
| 428 |
! WRITE(6,*) 'Number of grid points for grid-based discretization:', dime |
| 429 |
WRITE(6,'(a, 3i4)') 'Grid dimension:', dime(1), dime(2), dime(3) |
| 430 |
IF (cglen(1) > 0.) THEN |
| 431 |
WRITE(6,'(a, 3f8.3, a)') 'Coarse grid lengths:', & |
| 432 |
cglen(1), cglen(2), cglen(3), ' A' |
| 433 |
END IF |
| 434 |
IF (fglen(1) > 0.) THEN |
| 435 |
WRITE(6,'(a, 3f8.3, a)') 'Fine grid lengths:', & |
| 436 |
fglen(1), fglen(2), fglen(3), ' A' |
| 437 |
! WRITE(6,'(a, 3f8.3)') ' Grid spacings:', fglen(1)/dime(1), & |
| 438 |
! fglen(2)/dime(2), fglen(3)/dime(3) |
| 439 |
END IF |
| 440 |
IF (grid(1) > 0.) THEN |
| 441 |
WRITE(6,'(a, 3f8.3, a)') 'Grid spacings:', & |
| 442 |
grid(1), grid(2), grid(3), ' A' |
| 443 |
END IF |
| 444 |
WRITE(6,'(a, f8.3)') 'Solute dielectric (pdie):', r_param(1) |
| 445 |
WRITE(6,'(a, f8.3)') 'Solvent dielectric (sdie):', r_param(2) |
| 446 |
WRITE(6,'(a, f8.3, a)') 'Temperature:', r_param(5), ' K' |
| 447 |
WRITE(6,'(a, f8.3, a)') 'Surface sphere density (sdens):', & |
| 448 |
r_param(6), ' grid points/A^2' |
| 449 |
WRITE(6,'(a, f8.3, a)') 'Surface tension:', r_param(7), ' kJ/mol/A' |
| 450 |
|
| 451 |
IF (radiopt == 0) THEN |
| 452 |
WRITE(6, '(a)') 'Using charge/radii information from prmtop file' |
| 453 |
ELSE IF (radiopt == 1) THEN |
| 454 |
WRITE(6, '(a)') 'Using charge/radii information from pbparamsin file' |
| 455 |
ELSE IF (radiopt == 2) THEN |
| 456 |
WRITE(6, '(a)') 'Using charge/radii information from PQR file' |
| 457 |
ELSE IF (radiopt == 3) THEN |
| 458 |
WRITE(6, '(a)') 'Using radii information from PQR file' |
| 459 |
ELSE |
| 460 |
WRITE(6, '(a)') 'Unknown radiopt selection' |
| 461 |
CALL mexit(6,1) |
| 462 |
END IF |
| 463 |
|
| 464 |
IF (i_param(10) == 0) THEN |
| 465 |
WRITE(6, '(a)') 'No electrostatic energy will be calculated' |
| 466 |
ELSE IF (i_param(10) == 1) THEN |
| 467 |
WRITE(6, '(a)') 'Total electrostatic energy will be calculated' |
| 468 |
ELSE IF (i_param(10) == 2) THEN |
| 469 |
WRITE(6, '(a)') 'Total and per atom electrostatic energy will be calculated' |
| 470 |
ELSE |
| 471 |
WRITE(6, '(a)') 'Unknown calcenergy selection' |
| 472 |
CALL mexit(6,1) |
| 473 |
END IF |
| 474 |
|
| 475 |
IF (i_param(21) == 0) THEN |
| 476 |
WRITE(6, '(a)') 'No apolar energy will be calculated' |
| 477 |
ELSE IF (i_param(21) == 1) THEN |
| 478 |
WRITE(6, '(a)') 'Total apolar energy will be calculated' |
| 479 |
ELSE IF (i_param(21) == 2) THEN |
| 480 |
WRITE(6, '(a)') 'Total and per atom apolar energy calculation is not supported' |
| 481 |
ELSE |
| 482 |
WRITE(6, '(a)') 'Unknown calcnpenergy selection' |
| 483 |
CALL mexit(6,1) |
| 484 |
END IF |
| 485 |
|
| 486 |
IF (i_param(11) == 0) THEN |
| 487 |
WRITE(6, '(a)') 'No electrostatic forces will be calculated' |
| 488 |
ELSE IF (i_param(11) == 1) THEN |
| 489 |
WRITE(6, '(a)') 'Total electrostatic forces will be calculated' |
| 490 |
ELSE IF (i_param(11) == 2) THEN |
| 491 |
WRITE(6, '(a)') 'Total and per atom electrostatic forces will be calculated' |
| 492 |
ELSE |
| 493 |
WRITE(6, '(a)') 'Unknown calcforce selection' |
| 494 |
CALL mexit(6,1) |
| 495 |
END IF |
| 496 |
|
| 497 |
IF (i_param(20) == 0) THEN |
| 498 |
WRITE(6, '(a)') 'No apolar forces will be calculated' |
| 499 |
ELSE IF (i_param(20) == 1) THEN |
| 500 |
WRITE(6, '(a)') 'Total apolar forces will be calculated' |
| 501 |
ELSE IF (i_param(20) == 2) THEN |
| 502 |
WRITE(6, '(a)') 'Total and per atom apolar forces will be calculated' |
| 503 |
ELSE |
| 504 |
WRITE(6, '(a)') 'Unknown calcnpforce selection' |
| 505 |
CALL mexit(6,1) |
| 506 |
END IF |
| 507 |
|
| 508 |
IF (i_param(12) == 1) THEN |
| 509 |
WRITE(6, '(a)') 'Writing potential to iapbs-pot.dx.' |
| 510 |
END IF |
| 511 |
IF (i_param(13) == 1) THEN |
| 512 |
WRITE(6, '(a)') 'Writing charge distribution to iapbs-charge.dx.' |
| 513 |
END IF |
| 514 |
IF (i_param(14) == 1) THEN |
| 515 |
WRITE(6, '(a)') 'Writing molecular accessibility to iapbs-smol.dx.' |
| 516 |
END IF |
| 517 |
IF (i_param(15) == 1) THEN |
| 518 |
WRITE(6, '(a)') 'Writing kappa map to iapbs-kappa.dx.' |
| 519 |
END IF |
| 520 |
IF (i_param(16) == 1) THEN |
| 521 |
WRITE(6, '(a)') 'Writing dielectric map to iapbs-dielXYZ.dx' |
| 522 |
END IF |
| 523 |
IF (i_param(17) == 1) THEN |
| 524 |
WRITE(6, '(a)') 'Writing atomic potential map to iapbs-atompot.dx' |
| 525 |
END IF |
| 526 |
IF (i_param(23) == 1) THEN |
| 527 |
WRITE(6, '(a)') 'Reading charge map data from iapbs-charge.dx.' |
| 528 |
END IF |
| 529 |
IF (i_param(24) == 1) THEN |
| 530 |
WRITE(6, '(a)') 'Reading kappa map data from iapbs-kappa.dx.' |
| 531 |
END IF |
| 532 |
IF (i_param(25) == 1) THEN |
| 533 |
WRITE(6, '(a)') 'Reading dielectric map data from iapbs-dielXYZ.dx.' |
| 534 |
END IF |
| 535 |
IF (i_param(18) == 1) THEN |
| 536 |
WRITE(6, '(a)') 'Reading potential map data from iapbs-pot.dx.' |
| 537 |
END IF |
| 538 |
|
| 539 |
WRITE(6,'()') |
| 540 |
|
| 541 |
END SUBROUTINE apbs_print_info |
| 542 |
|
| 543 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 544 |
SUBROUTINE apbs_spenergy(natom, x, f, eelt, enpol) |
| 545 |
! |
| 546 |
! single point PB energy calculation |
| 547 |
! |
| 548 |
! in: |
| 549 |
! natom |
| 550 |
! x: coords |
| 551 |
! f: forces |
| 552 |
! out: |
| 553 |
! eelt: electrostatic energy (polar) |
| 554 |
! enpol: apolar energy |
| 555 |
! |
| 556 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 557 |
|
| 558 |
use apbs_vars |
| 559 |
|
| 560 |
IMPLICIT NONE |
| 561 |
|
| 562 |
! passed in variables |
| 563 |
INTEGER, INTENT(in) :: natom |
| 564 |
_REAL_, INTENT(in) :: x(3*natom) |
| 565 |
_REAL_ :: f(3*natom) |
| 566 |
_REAL_, INTENT(out) :: eelt, enpol |
| 567 |
|
| 568 |
! local variables |
| 569 |
INTEGER :: i, j, rc, apbsdrv, ncalc(1) |
| 570 |
LOGICAL :: skip |
| 571 |
_REAL_ :: cx(natom), cy(natom), cz(natom) |
| 572 |
_REAL_ :: maxx, minx, maxy, miny, maxz, minz |
| 573 |
_REAL_ :: esenerg(15) |
| 574 |
_REAL_ :: npenerg(15) |
| 575 |
_REAL_ :: apbsdx(natom), apbsdy(natom), apbsdz(natom) |
| 576 |
_REAL_ :: apbsqfx(natom), apbsqfy(natom), apbsqfz(natom) |
| 577 |
_REAL_ :: apbsibx(natom), apbsiby(natom), apbsibz(natom) |
| 578 |
_REAL_ :: apbsnpx(natom), apbsnpy(natom), apbsnpz(natom) |
| 579 |
_REAL_ :: apbsdbx(natom), apbsdby(natom), apbsdbz(natom) |
| 580 |
_REAL_ :: apbsgrid_meta(13), apbsgrid(3*natom) |
| 581 |
|
| 582 |
! eelt = 0.d0; enpol = 0.d0 rokFIXME ? |
| 583 |
|
| 584 |
! initialization |
| 585 |
DO i = 1, 13 |
| 586 |
apbsgrid_meta(i) = 0.0 |
| 587 |
END DO |
| 588 |
DO i = 1, 3*natom |
| 589 |
apbsgrid(i) = 0.0 |
| 590 |
END DO |
| 591 |
|
| 592 |
! unpack coordinates |
| 593 |
DO i = 1, natom |
| 594 |
j = 3*(i-1) |
| 595 |
cx(i) = x(j+1) |
| 596 |
cy(i) = x(j+2) |
| 597 |
cz(i) = x(j+3) |
| 598 |
END DO |
| 599 |
|
| 600 |
esenerg(1) = 0.0 |
| 601 |
npenerg(1) = 0.0 |
| 602 |
|
| 603 |
IF (apbs_debug > 5) THEN |
| 604 |
WRITE(6, '(a)') 'iAPBS: unpacked coordinates, charge and radius:' |
| 605 |
DO i = 1, natom |
| 606 |
WRITE(6, '(i6, 5f8.3)') i, cx(i), cy(i), cz(i), & |
| 607 |
pbcg(i), pbradii(i) |
| 608 |
END DO |
| 609 |
END IF |
| 610 |
|
| 611 |
! adjust dime parameters if mg-manual and grid only is set |
| 612 |
! dime_updates == .TRUE. |
| 613 |
IF (dime_updates) THEN |
| 614 |
IF (apbs_print > 1) WRITE(6, '(a)') & |
| 615 |
'iAPBS: Grid dime recalculating on the fly ...' |
| 616 |
maxx = cx(1) |
| 617 |
minx = cx(1) |
| 618 |
maxy = cy(1) |
| 619 |
miny = cy(1) |
| 620 |
maxz = cz(1) |
| 621 |
minz = cz(1) |
| 622 |
DO i = 1, natom |
| 623 |
IF(maxx < cx(i)+pbradii(i)) maxx = cx(i)+pbradii(i) |
| 624 |
IF(minx > cx(i)-pbradii(i)) minx = cx(i)-pbradii(i) |
| 625 |
IF(maxy < cy(i)+pbradii(i)) maxy = cy(i)+pbradii(i) |
| 626 |
IF(miny > cy(i)-pbradii(i)) miny = cy(i)-pbradii(i) |
| 627 |
IF(maxz < cz(i)+pbradii(i)) maxz = cz(i)+pbradii(i) |
| 628 |
IF(minz > cz(i)-pbradii(i)) minz = cz(i)-pbradii(i) |
| 629 |
END DO |
| 630 |
|
| 631 |
IF (apbs_print > 1) THEN |
| 632 |
WRITE(6,'(a, 3f8.3)') 'iAPBS: Molecular dimensions: ', & |
| 633 |
maxx-minx, maxy-miny, maxz-minz |
| 634 |
END IF |
| 635 |
|
| 636 |
cglen(1) = 1.7 * (maxx-minx) |
| 637 |
cglen(2) = 1.7 * (maxy-miny) |
| 638 |
cglen(3) = 1.7 * (maxz-minz) |
| 639 |
fglen(1) = 20.0 + (maxx-minx) |
| 640 |
fglen(2) = 20.0 + (maxy-miny) |
| 641 |
fglen(3) = 20.0 + (maxz-minz) |
| 642 |
|
| 643 |
DO i = 1, 3 |
| 644 |
IF (fglen(i) > cglen(i)) cglen(i) = fglen(i) |
| 645 |
END DO |
| 646 |
|
| 647 |
DO i = 1, 3 |
| 648 |
dime(i) = & |
| 649 |
32*(INT((INT(fglen(i)/grid(i) + 0.5) - 1)/32.0 + 0.5)) + 1 |
| 650 |
IF (dime(i) < 33) dime(i) = 33 |
| 651 |
END DO |
| 652 |
|
| 653 |
IF (apbs_print > 1) THEN |
| 654 |
WRITE(6, '(a)') 'iAPBS: New grid values: ' |
| 655 |
WRITE(6, '(a, 3f8.3)') 'fglen: ', fglen(1), fglen(2), fglen(3) |
| 656 |
WRITE(6, '(a, 3f8.3)') 'cglen: ', cglen(1), cglen(2), cglen(3) |
| 657 |
WRITE(6, '(a, 3i6)') 'dime: ', dime(1), dime(2), dime(3) |
| 658 |
WRITE(6, '(a, 3f8.3)') 'grid: ', grid(1), grid(2), grid(3) |
| 659 |
WRITE(6, '(a, f10.3)') 'Required memory (in MB): ', & |
| 660 |
dime(1)*dime(2)*dime(3)*200.0/1024/1024 |
| 661 |
WRITE(6,'()') |
| 662 |
END IF |
| 663 |
|
| 664 |
END IF |
| 665 |
|
| 666 |
|
| 667 |
IF (apbs_debug > 1) WRITE(6, '(a)') 'iAPBS: Calling apbsdrv in apbs_spenergy().' |
| 668 |
|
| 669 |
! call APBS as a function |
| 670 |
|
| 671 |
rc = apbsdrv(natom, cx, cy, cz, pbradii, pbcg, & |
| 672 |
r_param, i_param, & |
| 673 |
grid, dime, pdime, glen, center, & |
| 674 |
cglen, fglen, ccenter, fcenter, & |
| 675 |
ofrac, apbs_debug, & |
| 676 |
ionq, ionc, ionrr, & |
| 677 |
esenerg, npenerg, & |
| 678 |
apbsdx, apbsdy, apbsdz, & |
| 679 |
apbsqfx, apbsqfy, apbsqfz, apbsibx, apbsiby, apbsibz, & |
| 680 |
apbsnpx, apbsnpy, apbsnpz, apbsdbx, apbsdby, apbsdbz, & |
| 681 |
apbsgrid_meta, apbsgrid) |
| 682 |
|
| 683 |
IF (apbs_debug > 1) WRITE(6, '(a, i2)') ' iAPBS> apbs return code: ', rc |
| 684 |
IF (rc > 0) THEN |
| 685 |
WRITE(6, '(a)') 'iAPBS Bomb: apbs failed' |
| 686 |
CALL mexit(6,1) |
| 687 |
END IF |
| 688 |
|
| 689 |
! update total returned energy (in kcal/mol) |
| 690 |
eelt = esenerg(1) / 4.184D0 |
| 691 |
enpol = npenerg(1) / 4.184D0 |
| 692 |
! write(*,*)'APBSFRC>after energy...' |
| 693 |
IF (apbs_print > 1) THEN |
| 694 |
WRITE (6, '(a, f10.3, a)') & |
| 695 |
"APBSSP> Electrostatic energy: ", & |
| 696 |
eelt, " kcal/mol" |
| 697 |
WRITE (6, '(a, f10.3, a)') & |
| 698 |
"APBSSP> Nonpolar energy: ", & |
| 699 |
enpol, " kcal/mol" |
| 700 |
END IF |
| 701 |
|
| 702 |
END SUBROUTINE apbs_spenergy |
| 703 |
|
| 704 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 705 |
SUBROUTINE apbs_force(natom, x, f, evdw, eelt, enpol) |
| 706 |
! |
| 707 |
! PB solvation force calculation |
| 708 |
! |
| 709 |
! in: |
| 710 |
! natom |
| 711 |
! x: coords |
| 712 |
! f: forces |
| 713 |
! evdw: van der Waals energy |
| 714 |
! out: |
| 715 |
! eelt: electrostatic solvation energy (polar) |
| 716 |
! enpol: apolar solvation energy |
| 717 |
! |
| 718 |
! on exit f gets updated with solvation forces |
| 719 |
! |
| 720 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 721 |
|
| 722 |
use apbs_vars |
| 723 |
|
| 724 |
IMPLICIT NONE |
| 725 |
|
| 726 |
! passed in variables |
| 727 |
INTEGER, INTENT(in) :: natom |
| 728 |
_REAL_, INTENT(in) :: evdw |
| 729 |
_REAL_, INTENT(in) :: x(3*natom) |
| 730 |
_REAL_ :: f(3*natom) |
| 731 |
_REAL_, INTENT(out) :: eelt, enpol |
| 732 |
|
| 733 |
! local variables |
| 734 |
INTEGER :: i, j, rc, apbsdrv, ncalc(1), iparam12, error |
| 735 |
LOGICAL :: skip, do_apbs_update |
| 736 |
CHARACTER (len=128) :: dxname, dxn, command |
| 737 |
_REAL_ :: cx(natom), cy(natom), cz(natom) |
| 738 |
_REAL_ :: dx(natom), dy(natom), dz(natom) |
| 739 |
_REAL_ :: maxx, minx, maxy, miny, maxz, minz |
| 740 |
_REAL_ :: esenerg(15) |
| 741 |
_REAL_ :: npenerg(15) |
| 742 |
_REAL_ :: sdie, gamma, ionc1, ionc2 |
| 743 |
|
| 744 |
_REAL_ :: enelec, ennp |
| 745 |
_REAL_ :: esenvac, esensolv, npenvac, npensolv |
| 746 |
_REAL_ :: apbsdx(natom), apbsdy(natom), apbsdz(natom) |
| 747 |
_REAL_ :: solvdx(natom), solvdy(natom), solvdz(natom) |
| 748 |
_REAL_ :: vacdx(natom), vacdy(natom), vacdz(natom) |
| 749 |
|
| 750 |
_REAL_ :: apbsqfx(natom), apbsqfy(natom), apbsqfz(natom) |
| 751 |
_REAL_ :: apbsibx(natom), apbsiby(natom), apbsibz(natom) |
| 752 |
_REAL_ :: apbsnpx(natom), apbsnpy(natom), apbsnpz(natom) |
| 753 |
_REAL_ :: apbsdbx(natom), apbsdby(natom), apbsdbz(natom) |
| 754 |
_REAL_ :: solvqfx(natom), solvqfy(natom), solvqfz(natom) |
| 755 |
_REAL_ :: solvibx(natom), solviby(natom), solvibz(natom) |
| 756 |
_REAL_ :: solvnpx(natom), solvnpy(natom), solvnpz(natom) |
| 757 |
_REAL_ :: solvdbx(natom), solvdby(natom), solvdbz(natom) |
| 758 |
_REAL_ :: vacqfx(natom), vacqfy(natom), vacqfz(natom) |
| 759 |
_REAL_ :: vacibx(natom), vaciby(natom), vacibz(natom) |
| 760 |
_REAL_ :: vacnpx(natom), vacnpy(natom), vacnpz(natom) |
| 761 |
_REAL_ :: vacdbx(natom), vacdby(natom), vacdbz(natom) |
| 762 |
|
| 763 |
_REAL_ :: apbsgrid_meta(13), apbsgrid(3*natom) |
| 764 |
|
| 765 |
|
| 766 |
IF ( .NOT. ALLOCATED(solvfrcx) .OR. .NOT. ALLOCATED(solvfrcy) .OR. .NOT. ALLOCATED(solvfrcz)) THEN |
| 767 |
ALLOCATE(solvfrcx(natom), solvfrcy(natom), solvfrcz(natom), stat=error) |
| 768 |
IF (error .NE. 0) THEN |
| 769 |
WRITE(6, '(a)') 'iAPBS: pbradii/pbcg memory allocation failed!' |
| 770 |
WRITE(6, '(a)') 'iAPBS: Exiting ...' |
| 771 |
CALL mexit(6,1) |
| 772 |
ENDIF |
| 773 |
ENDIF |
| 774 |
|
| 775 |
IF ( .NOT. ALLOCATED(savedx) .OR. .NOT. ALLOCATED(savedy) .OR. .NOT. ALLOCATED(savedz)) THEN |
| 776 |
ALLOCATE(savedx(natom), savedy(natom), savedz(natom), stat=error) |
| 777 |
IF (error .NE. 0) THEN |
| 778 |
WRITE(6, '(a)') 'iAPBS: pbradii/pbcg memory allocation failed!' |
| 779 |
WRITE(6, '(a)') 'iAPBS: Exiting ...' |
| 780 |
CALL mexit(6,1) |
| 781 |
ENDIF |
| 782 |
ENDIF |
| 783 |
|
| 784 |
|
| 785 |
! eelt = 0.d0; enpol = 0.d0 rokFIXME?? |
| 786 |
|
| 787 |
! initialization |
| 788 |
DO i = 1, 13 |
| 789 |
apbsgrid_meta(i) = 0.0 |
| 790 |
END DO |
| 791 |
DO i = 1, 3*natom |
| 792 |
apbsgrid(i) = 0.0 |
| 793 |
END DO |
| 794 |
|
| 795 |
! initialize solv forces |
| 796 |
DO i = 1, natom |
| 797 |
solvdx(i)=0.0 |
| 798 |
solvdy(i)=0.0 |
| 799 |
solvdz(i)=0.0 |
| 800 |
vacdx(i)=0.0 |
| 801 |
vacdy(i)=0.0 |
| 802 |
vacdz(i)=0.0 |
| 803 |
solvqfx(i)=0.0 |
| 804 |
solvqfy(i)=0.0 |
| 805 |
solvqfz(i)=0.0 |
| 806 |
solvibx(i)=0.0 |
| 807 |
solviby(i)=0.0 |
| 808 |
solvibz(i)=0.0 |
| 809 |
solvnpx(i)=0.0 |
| 810 |
solvnpy(i)=0.0 |
| 811 |
solvnpz(i)=0.0 |
| 812 |
solvdbx(i)=0.0 |
| 813 |
solvdby(i)=0.0 |
| 814 |
solvdbz(i)=0.0 |
| 815 |
vacqfx(i)=0.0 |
| 816 |
vacqfy(i)=0.0 |
| 817 |
vacqfz(i)=0.0 |
| 818 |
vacibx(i)=0.0 |
| 819 |
vaciby(i)=0.0 |
| 820 |
vacibz(i)=0.0 |
| 821 |
vacnpx(i)=0.0 |
| 822 |
vacnpy(i)=0.0 |
| 823 |
vacnpz(i)=0.0 |
| 824 |
vacdbx(i)=0.0 |
| 825 |
vacdby(i)=0.0 |
| 826 |
vacdbz(i)=0.0 |
| 827 |
END DO |
| 828 |
|
| 829 |
esenerg(1) = 0.0 |
| 830 |
npenerg(1) = 0.0 |
| 831 |
|
| 832 |
|
| 833 |
do_apbs_update = .TRUE. |
| 834 |
|
| 835 |
! unpack coordinates |
| 836 |
DO i = 1, natom |
| 837 |
j = 3*(i-1) |
| 838 |
cx(i) = x(j+1) |
| 839 |
cy(i) = x(j+2) |
| 840 |
cz(i) = x(j+3) |
| 841 |
END DO |
| 842 |
|
| 843 |
IF (apbs_debug > 5) THEN |
| 844 |
WRITE(6, '(a)') 'iAPBS: unpacked coordinates, charge and radius:' |
| 845 |
DO i = 1, natom |
| 846 |
WRITE(6, '(i6, 5f8.3)') i, cx(i), cy(i), cz(i), & |
| 847 |
pbcg(i), pbradii(i) |
| 848 |
END DO |
| 849 |
END IF |
| 850 |
|
| 851 |
! adjust dime parameters if mg-auto and grid is 0 |
| 852 |
! dime_updates == .TRUE. |
| 853 |
IF (dime_updates) THEN |
| 854 |
IF (apbs_print > 1) WRITE(6, '(a)') & |
| 855 |
'iAPBS: Grid dime recalculating on the fly ...' |
| 856 |
maxx = cx(1) |
| 857 |
minx = cx(1) |
| 858 |
maxy = cy(1) |
| 859 |
miny = cy(1) |
| 860 |
maxz = cz(1) |
| 861 |
minz = cz(1) |
| 862 |
DO i = 1, natom |
| 863 |
IF(maxx < cx(i)+pbradii(i)) maxx = cx(i)+pbradii(i) |
| 864 |
IF(minx > cx(i)-pbradii(i)) minx = cx(i)-pbradii(i) |
| 865 |
IF(maxy < cy(i)+pbradii(i)) maxy = cy(i)+pbradii(i) |
| 866 |
IF(miny > cy(i)-pbradii(i)) miny = cy(i)-pbradii(i) |
| 867 |
IF(maxz < cz(i)+pbradii(i)) maxz = cz(i)+pbradii(i) |
| 868 |
IF(minz > cz(i)-pbradii(i)) minz = cz(i)-pbradii(i) |
| 869 |
END DO |
| 870 |
|
| 871 |
IF (apbs_print > 1) THEN |
| 872 |
WRITE(6,'(a, 3f8.3)') 'iAPBS: Molecular dimensions: ', & |
| 873 |
maxx-minx, maxy-miny, maxz-minz |
| 874 |
END IF |
| 875 |
|
| 876 |
cglen(1) = 1.7 * (maxx-minx) |
| 877 |
cglen(2) = 1.7 * (maxy-miny) |
| 878 |
cglen(3) = 1.7 * (maxz-minz) |
| 879 |
fglen(1) = 20.0 + (maxx-minx) |
| 880 |
fglen(2) = 20.0 + (maxy-miny) |
| 881 |
fglen(3) = 20.0 + (maxz-minz) |
| 882 |
|
| 883 |
DO i = 1, 3 |
| 884 |
IF (fglen(i) > cglen(i)) cglen(i) = fglen(i) |
| 885 |
END DO |
| 886 |
|
| 887 |
DO i = 1, 3 |
| 888 |
dime(i) = & |
| 889 |
32*(INT((INT(fglen(i)/grid(i) + 0.5) - 1)/32.0 + 0.5)) + 1 |
| 890 |
IF (dime(i) < 33) dime(i) = 33 |
| 891 |
END DO |
| 892 |
|
| 893 |
IF (apbs_print > 1) THEN |
| 894 |
WRITE(6, '(a)') 'iAPBS: New grid values: ' |
| 895 |
WRITE(6, '(a, 3f8.3)') 'fglen: ', fglen(1), fglen(2), fglen(3) |
| 896 |
WRITE(6, '(a, 3f8.3)') 'cglen: ', cglen(1), cglen(2), cglen(3) |
| 897 |
WRITE(6, '(a, 3i6)') 'dime: ', dime(1), dime(2), dime(3) |
| 898 |
WRITE(6, '(a, 3f8.3)') 'grid: ', grid(1), grid(2), grid(3) |
| 899 |
WRITE(6, '(a, f10.3)') 'Required memory (in MB): ', & |
| 900 |
dime(1)*dime(2)*dime(3)*200.0/1024/1024 |
| 901 |
WRITE(6,'()') |
| 902 |
END IF |
| 903 |
|
| 904 |
END IF |
| 905 |
|
| 906 |
! calcforce parameters should be on! |
| 907 |
IF (apbs_print > 2) THEN |
| 908 |
IF (i_param(11) /= 2 ) THEN |
| 909 |
WRITE(6, *) 'iAPBS: WARNING: calcforce keyword is not set to 2, ', & |
| 910 |
'polar forces will not be calculated.' |
| 911 |
END IF |
| 912 |
IF (i_param(20) /= 2 ) THEN |
| 913 |
WRITE(6, *) 'iAPBS: WARNING: calcnpforce keyword is not set to 2, ', & |
| 914 |
'non-polar forces will not be calculated.' |
| 915 |
END IF |
| 916 |
END IF |
| 917 |
|
| 918 |
napbs = napbs + 1 |
| 919 |
|
| 920 |
! check if the geometry or energy |
| 921 |
! changed enough for PB forces recalculation |
| 922 |
IF (geom_upd_limit > 0.0d0 .OR. evdw_upd_limit > 0.0d0) THEN |
| 923 |
CALL check_apbs_update(cx, cy, cz, natom, evdw, do_apbs_update) |
| 924 |
END IF |
| 925 |
|
| 926 |
! if yes, recalculate PB forces and energies |
| 927 |
IF (do_apbs_update) THEN |
| 928 |
IF (apbs_debug > 1) WRITE(6, '(a)') 'iAPBS: Calling apbsdrv' |
| 929 |
IF (geom_upd_limit > 0.0d0 .OR. evdw_upd_limit > 0.0d0) THEN |
| 930 |
IF (apbs_debug > 0) WRITE(6, '(a)') 'Doing PB forces update' |
| 931 |
END IF |
| 932 |
|
| 933 |
! first calculation - in solvent |
| 934 |
IF (apbs_debug > 1) WRITE(6, '(a)') 'iAPBS: Calling apbsdrv in apbs_force().' |
| 935 |
rc = apbsdrv(natom, cx, cy, cz, pbradii, pbcg, & |
| 936 |
r_param, i_param, & |
| 937 |
grid, dime, pdime, glen, center, & |
| 938 |
cglen, fglen, ccenter, fcenter, & |
| 939 |
ofrac, apbs_debug, & |
| 940 |
ionq, ionc, ionrr, & |
| 941 |
esenerg, npenerg, & |
| 942 |
apbsdx, apbsdy, apbsdz, & |
| 943 |
apbsqfx, apbsqfy, apbsqfz, apbsibx, apbsiby, apbsibz, & |
| 944 |
apbsnpx, apbsnpy, apbsnpz, apbsdbx, apbsdby, apbsdbz, & |
| 945 |
apbsgrid_meta, apbsgrid) |
| 946 |
|
| 947 |
|
| 948 |
IF (apbs_debug > 2) WRITE(6, '(a, i2)') & |
| 949 |
'iAPBS: apbs return code: ', rc |
| 950 |
IF (rc > 0) THEN |
| 951 |
WRITE(6, '(a)') 'iAPBS Bomb: apbs failed' |
| 952 |
CALL mexit(6,1) |
| 953 |
END IF |
| 954 |
|
| 955 |
! total energy in solvent (in kcal/mol) |
| 956 |
esensolv = esenerg(1) / 4.184D0 |
| 957 |
npensolv = npenerg(1) / 4.184D0 |
| 958 |
|
| 959 |
IF (apbs_print > 1) THEN |
| 960 |
WRITE (6, '(a, f10.3, a)') & |
| 961 |
"iAPBS: Electrostatic energy in solvent: ", & |
| 962 |
esensolv, " kcal/mol" |
| 963 |
WRITE (6, '(a, f10.3, a)') & |
| 964 |
"iAPBS: Nonpolar energy in solvent: ", & |
| 965 |
npensolv, " kcal/mol" |
| 966 |
END IF |
| 967 |
|
| 968 |
! get the total forces from the solvent calculation |
| 969 |
IF (i_param(11) == 2) THEN |
| 970 |
DO i = 1, natom |
| 971 |
solvdx(i) = (apbsdx(i) + apbsnpx(i))/ 4.184D0 |
| 972 |
solvdy(i) = (apbsdy(i) + apbsnpy(i))/ 4.184D0 |
| 973 |
solvdz(i) = (apbsdz(i) + apbsnpz(i))/ 4.184D0 |
| 974 |
|
| 975 |
solvqfx(i) = apbsqfx(i) / 4.184D0 |
| 976 |
solvqfy(i) = apbsqfy(i) / 4.184D0 |
| 977 |
solvqfz(i) = apbsqfz(i) / 4.184D0 |
| 978 |
|
| 979 |
solvibx(i) = apbsibx(i) / 4.184D0 |
| 980 |
solviby(i) = apbsiby(i) / 4.184D0 |
| 981 |
solvibz(i) = apbsibz(i) / 4.184D0 |
| 982 |
|
| 983 |
solvdbx(i) = apbsdbx(i) / 4.184D0 |
| 984 |
solvdby(i) = apbsdby(i) / 4.184D0 |
| 985 |
solvdbz(i) = apbsdbz(i) / 4.184D0 |
| 986 |
END DO |
| 987 |
END IF |
| 988 |
IF (i_param(21) > 0) THEN |
| 989 |
DO i = 1, natom |
| 990 |
solvnpx(i) = apbsnpx(i) / 4.184D0 |
| 991 |
solvnpy(i) = apbsnpy(i) / 4.184D0 |
| 992 |
solvnpz(i) = apbsnpz(i) / 4.184D0 |
| 993 |
END DO |
| 994 |
END IF |
| 995 |
|
| 996 |
|
| 997 |
!----------------------------------------------------------------- |
| 998 |
|
| 999 |
! save sdie and ion concentration |
| 1000 |
sdie = r_param(2) |
| 1001 |
ionc1 = ionc(1) |
| 1002 |
ionc2 = ionc(2) |
| 1003 |
! set sdie = 1.0 |
| 1004 |
! salt concentration should be 0.0 |
| 1005 |
r_param(2) = 1.0D0 ! sdie |
| 1006 |
ionc(1) = 0.0D0 |
| 1007 |
ionc(2) = 0.0D0 |
| 1008 |
|
| 1009 |
! if we are generating potential DX file turning it |
| 1010 |
! off for calculation in vacuum |
| 1011 |
iparam12 = 0 |
| 1012 |
IF (i_param(12) == 1) THEN |
| 1013 |
iparam12 = 1 |
| 1014 |
i_param(12) = 0 |
| 1015 |
END IF |
| 1016 |
|
| 1017 |
! redo the calculation in vacuum |
| 1018 |
IF (apbs_debug > 1) WRITE(6, '(a)') 'iAPBS: Calling apbsdrv in apbs_force().' |
| 1019 |
rc = apbsdrv(natom, cx, cy, cz, pbradii, pbcg, & |
| 1020 |
r_param, i_param, & |
| 1021 |
grid, dime, pdime, glen, center, & |
| 1022 |
cglen, fglen, ccenter, fcenter, & |
| 1023 |
ofrac, apbs_debug, & |
| 1024 |
ionq, ionc, ionrr, & |
| 1025 |
esenerg, npenerg, & |
| 1026 |
apbsdx, apbsdy, apbsdz, & |
| 1027 |
apbsqfx, apbsqfy, apbsqfz, apbsibx, apbsiby, apbsibz, & |
| 1028 |
apbsnpx, apbsnpy, apbsnpz, apbsdbx, apbsdby, apbsdbz, & |
| 1029 |
apbsgrid_meta, apbsgrid) |
| 1030 |
|
| 1031 |
IF (apbs_debug > 2) WRITE(6, '(a, i2)') & |
| 1032 |
'iAPBS: apbs return code: ', rc |
| 1033 |
IF (rc > 0) THEN |
| 1034 |
WRITE(6, '(a)') 'iAPBS Bomb: apbs failed' |
| 1035 |
CALL mexit(6,1) |
| 1036 |
END IF |
| 1037 |
|
| 1038 |
r_param(2) = sdie |
| 1039 |
ionc(1) = ionc1 |
| 1040 |
ionc(2) = ionc2 |
| 1041 |
i_param(12) = iparam12 |
| 1042 |
|
| 1043 |
! total energy in vacuum (in kcal/mol) |
| 1044 |
esenvac = esenerg(1) / 4.184D0 |
| 1045 |
! npenvac = npenerg(ncalc(1)) / 4.184D0 |
| 1046 |
! no NP energy in vacuum |
| 1047 |
npenvac = 0.0D0 |
| 1048 |
IF (apbs_print > 1) THEN |
| 1049 |
WRITE(6, '(a, f10.3, a)') & |
| 1050 |
"iAPBS: Electrostatic energy in vacuum: ", & |
| 1051 |
esenvac, " kcal/mol" |
| 1052 |
WRITE(6, '(a, f10.3, a)') & |
| 1053 |
"iAPBS: Nonpolar energy in vacuum: ", & |
| 1054 |
npenvac, " kcal/mol" |
| 1055 |
END IF |
| 1056 |
|
| 1057 |
! get the total forces from the vacuum calculation |
| 1058 |
IF (i_param(11) == 2) THEN |
| 1059 |
DO i = 1, natom |
| 1060 |
vacdx(i) = apbsdx(i) / 4.184D0 |
| 1061 |
vacdy(i) = apbsdy(i) / 4.184D0 |
| 1062 |
vacdz(i) = apbsdz(i) / 4.184D0 |
| 1063 |
|
| 1064 |
vacqfx(i) = apbsqfx(i) / 4.184D0 |
| 1065 |
vacqfy(i) = apbsqfy(i) / 4.184D0 |
| 1066 |
vacqfz(i) = apbsqfz(i) / 4.184D0 |
| 1067 |
|
| 1068 |
vacibx(i) = apbsibx(i) / 4.184D0 |
| 1069 |
vaciby(i) = apbsiby(i) / 4.184D0 |
| 1070 |
vacibz(i) = apbsibz(i) / 4.184D0 |
| 1071 |
|
| 1072 |
! the following are zero in vacuum |
| 1073 |
vacnpx(i) = 0.0D0 |
| 1074 |
vacnpy(i) = 0.0D0 |
| 1075 |
vacnpz(i) = 0.0D0 |
| 1076 |
|
| 1077 |
vacdbx(i) = 0.0D0 |
| 1078 |
vacdby(i) = 0.0D0 |
| 1079 |
vacdbz(i) = 0.0D0 |
| 1080 |
END DO |
| 1081 |
END IF |
| 1082 |
!----------------------------------------------------------------- |
| 1083 |
|
| 1084 |
! add calulated total forces to f in common block |
| 1085 |
DO i = 1, natom |
| 1086 |
j = 3*(i-1) |
| 1087 |
f(j+1) = f(j+1) + (solvdx(i) - vacdx(i)) |
| 1088 |
f(j+2) = f(j+2) + (solvdy(i) - vacdy(i)) |
| 1089 |
f(j+3) = f(j+3) + (solvdz(i) - vacdz(i)) |
| 1090 |
END DO |
| 1091 |
|
| 1092 |
IF (apbs_debug > 6) THEN |
| 1093 |
DO i = 1, natom |
| 1094 |
j = 3*(i-1) |
| 1095 |
WRITE(6, '(a, 4x, i6, 3f8.3)') "iAPBS: TotalForces:", & |
| 1096 |
i, f(j+1), f(j+2), f(j+3) |
| 1097 |
END DO |
| 1098 |
DO i = 1, natom |
| 1099 |
WRITE(6,'(a, 2x, i6, 3f8.3)') "iAPBS: SolventForces:", & |
| 1100 |
i, solvdx(i), solvdy(i) , solvdz(i) |
| 1101 |
END DO |
| 1102 |
DO i = 1, natom |
| 1103 |
WRITE(6,'(a, 3x, i6, 3f8.3)') "iAPBS: VacuumForces:", & |
| 1104 |
i, vacdx(i), vacdy(i), vacdz(i) |
| 1105 |
END DO |
| 1106 |
DO i = 1, natom |
| 1107 |
WRITE(6,'(a, 5x, i6, 3f8.3)') "iAPBS: SolvForces:", & |
| 1108 |
i, solvdx(i) - vacdx(i), solvdy(i) - vacdy(i), & |
| 1109 |
solvdz(i) - vacdz(i) |
| 1110 |
END DO |
| 1111 |
DO i = 1, natom |
| 1112 |
WRITE(6,'(a, 7x, i6, 3f8.3)') "iAPBS: qfForces:", & |
| 1113 |
i, solvqfx(i) - vacqfx(i), & |
| 1114 |
solvqfy(i) - vacqfy(i), solvqfz(i) - vacqfz(i) |
| 1115 |
END DO |
| 1116 |
DO i = 1, natom |
| 1117 |
WRITE(6,'(a, 7x, i6, 3f8.3)') "iAPBS: ibForces:", & |
| 1118 |
i, solvibx(i) - vacibx(i), & |
| 1119 |
solviby(i) - vaciby(i), solvibz(i) - vacibz(i) |
| 1120 |
END DO |
| 1121 |
DO i = 1, natom |
| 1122 |
WRITE(6,'(a, 7x, i6, 3f8.3)') "iAPBS: npForces:", & |
| 1123 |
i, solvnpx(i) - vacnpx(i), & |
| 1124 |
solvnpy(i) - vacnpy(i), solvnpz(i) - vacnpz(i) |
| 1125 |
END DO |
| 1126 |
DO i = 1, natom |
| 1127 |
WRITE(6,'(a, 7x, i6, 3f8.3)') "iAPBS: dbForces:", & |
| 1128 |
i, solvdbx(i) - vacdbx(i), & |
| 1129 |
solvdby(i) - vacdby(i), solvdbz(i) - vacdbz(i) |
| 1130 |
END DO |
| 1131 |
|
| 1132 |
END IF ! if apbs_debug > |
| 1133 |
|
| 1134 |
! total, solvatation energy (in kcal/mol) |
| 1135 |
enelec = esensolv - esenvac |
| 1136 |
IF (apbs_print > 1) THEN |
| 1137 |
WRITE(6, '(a, f10.3, a)') & |
| 1138 |
"iAPBS: Total solvation energy: ", enelec, " kcal/mol" |
| 1139 |
END IF |
| 1140 |
|
| 1141 |
! total, non-polar energy (in kcal/mol) |
| 1142 |
! ennp = npensolv - npenvac |
| 1143 |
ennp = npensolv |
| 1144 |
IF (apbs_print > 1) THEN |
| 1145 |
WRITE(6, '(a, f10.3, a)') & |
| 1146 |
"iAPBS: Total non-polar energy: ", ennp, " kcal/mol" |
| 1147 |
WRITE(6, '(a, f10.3, a)') & |
| 1148 |
"iAPBS: Total non-polar energy (vacuum): ", npenvac, " kcal/mol" |
| 1149 |
END IF |
| 1150 |
|
| 1151 |
! assign calculated energies for export |
| 1152 |
eelt = enelec |
| 1153 |
enpol = ennp |
| 1154 |
|
| 1155 |
|
| 1156 |
! printing options rokFIXME |
| 1157 |
IF (apbs_print > 1) THEN |
| 1158 |
WRITE(6, '(a, f10.3, a)') & |
| 1159 |
'The Free Energy of Charging in Solvent = ', & |
| 1160 |
esensolv,' kcal/mol' |
| 1161 |
WRITE(6, '(a, f10.3, a)') & |
| 1162 |
'The Free Energy of Charging in Vacuum = ', & |
| 1163 |
esenvac,' kcal/mol' |
| 1164 |
WRITE(6, '(a, f10.3, a)') & |
| 1165 |
'The Electrostatic Solvation Free Energy = ', & |
| 1166 |
enelec,' kcal/mol' |
| 1167 |
WRITE(6, '(a, f10.3, a)') & |
| 1168 |
'The Nonpolar Solvation Free Energy = ', & |
| 1169 |
ennp,' kcal/mol' |
| 1170 |
END IF |
| 1171 |
|
| 1172 |
! save solvation forces for different update schemes |
| 1173 |
DO i = 1, natom |
| 1174 |
solvfrcx(i) = solvdx(i) - vacdx(i) |
| 1175 |
solvfrcy(i) = solvdy(i) - vacdy(i) |
| 1176 |
solvfrcz(i) = solvdz(i) - vacdz(i) |
| 1177 |
END DO |
| 1178 |
|
| 1179 |
! save ennp and enelec |
| 1180 |
senelec = enelec |
| 1181 |
sennp = ennp |
| 1182 |
|
| 1183 |
IF (i_param(12) == 1) THEN |
| 1184 |
! if we are generating a potential DX file, rename it |
| 1185 |
! from iapbs-pot.dx to iapbs-pot.#.dx |
| 1186 |
! where # is the MD frame |
| 1187 |
! |
| 1188 |
! this is OS specific (using /bin/mv) |
| 1189 |
WRITE (dxn, '(i6)') napbs |
| 1190 |
dxn = adjustl(dxn) |
| 1191 |
dxname = 'iapbs-pot.'// trim(dxn) //'.dx' |
| 1192 |
dxname = adjustl(dxname) |
| 1193 |
command = '/bin/mv iapbs-pot.dx ' // trim(dxname) |
| 1194 |
CALL system ( command ) |
| 1195 |
END IF |
| 1196 |
|
| 1197 |
ELSE |
| 1198 |
IF (apbs_debug > 0) WRITE(6, '(a)') 'iAPBS: Skipping PB forces update' |
| 1199 |
! we are not updating solv forces in this cycle, so just |
| 1200 |
! return energies and forces calculated during the |
| 1201 |
! previous update |
| 1202 |
eelt = senelec |
| 1203 |
enpol = sennp |
| 1204 |
DO i = 1, natom |
| 1205 |
j = 3*(i-1) |
| 1206 |
f(j+1) = f(j+1) + solvfrcx(i) |
| 1207 |
f(j+2) = f(j+2) + solvfrcy(i) |
| 1208 |
f(j+3) = f(j+3) + solvfrcz(i) |
| 1209 |
END DO |
| 1210 |
END IF ! if (do_apbs_update) |
| 1211 |
|
| 1212 |
RETURN |
| 1213 |
END SUBROUTINE apbs_force |
| 1214 |
|
| 1215 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 1216 |
SUBROUTINE check_apbs_update(cx, cy, cz, natom, evdw, do_apbs_update) |
| 1217 |
! |
| 1218 |
! check if change in geometry warrants new PB energy and forces update |
| 1219 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 1220 |
|
| 1221 |
use apbs_vars |
| 1222 |
|
| 1223 |
IMPLICIT NONE |
| 1224 |
|
| 1225 |
INTEGER :: i, natom |
| 1226 |
LOGICAL :: do_apbs_update |
| 1227 |
_REAL_ :: dx, dy, dz, dis, maxdis, evdw, evdwDelta |
| 1228 |
_REAL_ :: cx(natom), cy(natom), cz(natom) |
| 1229 |
|
| 1230 |
do_apbs_update = .TRUE. |
| 1231 |
|
| 1232 |
IF (napbs > 1) THEN ! do this starting with second apbs call |
| 1233 |
maxdis = 0.d0 |
| 1234 |
DO i = 1, natom |
| 1235 |
dx = cx(i) - savedx(i) |
| 1236 |
dy = cy(i) - savedy(i) |
| 1237 |
dz = cz(i) - savedz(i) |
| 1238 |
dis = dx*dx + dy*dy + dz*dz |
| 1239 |
maxdis = MAX(dis, maxdis) |
| 1240 |
END DO |
| 1241 |
|
| 1242 |
maxdis = SQRT(1.d0/3.d0 * maxdis) |
| 1243 |
! consider vdW energy change |
| 1244 |
evdwDelta = evdw - saveevdw |
| 1245 |
|
| 1246 |
do_apbs_update = (maxdis > geom_upd_limit) .or. & |
| 1247 |
(ABS(evdwDelta) > evdw_upd_limit) |
| 1248 |
|
| 1249 |
IF (apbs_debug > 0) THEN |
| 1250 |
WRITE(6,'()') |
| 1251 |
WRITE(6,'()') |
| 1252 |
WRITE(6, '(a, 2f8.4)') & |
| 1253 |
'iAPBS: Max. change in geometry, maxdis, geom_upd_limit:', & |
| 1254 |
maxdis, geom_upd_limit |
| 1255 |
WRITE(6,'(a, 4f10.4)') & |
| 1256 |
'iAPBS: evdw, saveevdw, evdwDelta, evdw_upd_limit:', & |
| 1257 |
evdw, saveevdw, evdwDelta, evdw_upd_limit |
| 1258 |
END IF |
| 1259 |
END IF |
| 1260 |
|
| 1261 |
! save coords for the next call |
| 1262 |
DO i = 1, natom |
| 1263 |
savedx(i) = cx(i) |
| 1264 |
savedy(i) = cy(i) |
| 1265 |
savedz(i) = cz(i) |
| 1266 |
END DO |
| 1267 |
! save vdW energy for the next call |
| 1268 |
saveevdw = evdw |
| 1269 |
|
| 1270 |
RETURN |
| 1271 |
END SUBROUTINE check_apbs_update |
| 1272 |
|
| 1273 |
#endif /* APBS */ |
| 1274 |
END MODULE apbs |