ADMPPmeForce
This is a convenient wrapper for multipolar PME calculations It wrapps all the environment parameters of multipolar PME calculation The so called "environment paramters" means parameters that do not need to be differentiable
Source code in dmff/admp/pme.py
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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
__init__(box, axis_type, axis_indices, rc, ethresh, lmax, lpol=False, lpme=True, steps_pol=None)
Initialize the ADMPPmeForce calculator.
Input
box: (3, 3) float, box size in row axis_type: (na,) int, types of local axis (bisector, z-then-x etc.) rc: float: cutoff distance ethresh: float: pme energy threshold lmax: int: max L for multipoles lpol: bool: polarize or not? lpme: bool: do pme or simple cutoff? if False, the kappa will be set to zero and the reciprocal part will not be computed steps: None or int: Whether do fixed number of dipole iteration steps? if None: converge dipoles until convergence threshold is met if int: optimize for this many steps and stop, this is useful if you want to jit the entire function
Output:
Source code in dmff/admp/pme.py
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 |
|
optimize_Uind(positions, box, pairs, Q_local, pol, tholes, mScales, pScales, dScales, U_init=None, steps_pol=None, maxiter=MAX_N_POL, thresh=POL_CONV)
This function converges the induced dipole Note that we cut all the gradient chain passing through this function as we assume Feynman-Hellman theorem Gradients related to Uind should be dropped
Source code in dmff/admp/pme.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
refresh_calculators()
refresh the energy and force calculators according to the current environment
Source code in dmff/admp/pme.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
update_env(attr, val)
Update the environment of the calculator
Source code in dmff/admp/pme.py
139 140 141 142 143 144 |
|
calc_e_ind(dr, thole1, thole2, dmp, pscales, dscales, kappa, lmax=2)
This function calculates the eUindCoefs at once ## compute the Thole damping factors for energies eUindCoefs is basically the interaction tensor between permanent multipole components and induced dipoles Everything should be done in the so called quasi-internal (qi) frame
Inputs
dr: float: distance between one pair of particles dmp float: damping factors between one pair of particles mscales: float: scaling factor between permanent - permanent multipole interactions, for each pair pscales: float: scaling factor between permanent - induced multipole interactions, for each pair au: float: for damping factors kappa: float: \kappa in PME, unit in A^-1 lmax: int: max L
Output
Interaction tensors components
Source code in dmff/admp/pme.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
|
calc_e_perm(dr, mscales, kappa, lmax=2)
This function calculates the ePermCoefs at once ePermCoefs is basically the interaction tensor between permanent multipole components Everything should be done in the so called quasi-internal (qi) frame Energy = \sum_ij qiQI * ePermCoeff_ij * qiQJ
Inputs
dr: float: distance between one pair of particles mscales: float: scaling factor between permanent - permanent multipole interactions, for each pair kappa: float: \kappa in PME, unit in A^-1 lmax: int: max L
Output
cc, cd, dd_m0, dd_m1, cq, dq_m0, dq_m1, qq_m0, qq_m1, qq_m2: n * 1 array: ePermCoefs
Source code in dmff/admp/pme.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
|
energy_pme(positions, box, pairs, Q_local, Uind_global, pol, tholes, mScales, pScales, dScales, construct_local_frame_fn, pme_recip_fn, kappa, K1, K2, K3, lmax, lpol, lpme=True)
This is the top-level wrapper for multipole PME
Input
positions: Na * 3: positions box: 3 * 3: box Q_local: Na * (lmax+1)^2: harmonic multipoles of each site in local frame Uind_global: Na * 3: the induced dipole moment, in GLOBAL CARTESIAN! pol: (Na,) float: the polarizability of each site, unit in A**3 tholes: (Na,) float: the thole damping widths for each atom, it's dimensionless, default is 8 according to MPID paper mScales, pScale, dScale: (Nexcl,): multipole-multipole interaction exclusion scalings: 1-2, 1-3 ... for permanent-permanent, permanent-induced, induced-induced interactions pairs: Np * 3: interacting pair indices and topology distance covalent_map: Na * Na: topological distances between atoms, if i, j are topologically distant, then covalent_map[i, j] == 0 construct_local_frame_fn: function: local frame constructors, from generate_local_frame_constructor pme_recip: function: see recip.py, a reciprocal space calculator kappa: float: kappa in A^-1 K1, K2, K3: int: max K for reciprocal calculations lmax: int: maximum L lpol: bool: if polarizable or not? if yes, 1, otherwise 0 lpme: bool: doing pme? If false, then turn off reciprocal space and set kappa = 0
Output
energy: total pme energy
Source code in dmff/admp/pme.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
|
gen_trim_val_0(thresh)
Trim the value at zero point to avoid singularity
Source code in dmff/admp/pme.py
469 470 471 472 473 474 475 476 477 478 |
|
gen_trim_val_infty(thresh)
Trime the value at infinity to avoid divergence
Source code in dmff/admp/pme.py
483 484 485 486 487 488 489 490 491 492 |
|
pme_real(positions, box, pairs, Q_global, Uind_global, pol, tholes, mScales, pScales, dScales, kappa, lmax, lpol)
This is the real space PME calculate function NOTE: only deals with permanent-permanent multipole interactions It expands the pairwise parameters, and then invoke pme_real_kernel It seems pointless to jit it: 1. the heavy-lifting kernel function is jitted and vmapped 2. len(pairs) keeps changing throughout the simulation, the function would just recompile everytime
Input
positions: Na * 3: positions box: 3 * 3: box, axes arranged in row pairs: Np * 3: interacting pair indices and topology distance Q_global: Na * (l+1)**2: harmonics multipoles of each atom, in global frame Uind_global: Na * 3: harmonic induced dipoles, in global frame pol: (Na,): polarizabilities tholes: (Na,): thole damping parameters mScales: (Nexcl,): permanent multipole-multipole interaction exclusion scalings: 1-2, 1-3 ... covalent_map: Na * Na: topological distances between atoms, if i, j are topologically distant, then covalent_map[i, j] == 0 kappa: float: kappa in A^-1 lmax: int: maximum L lpol: Bool: whether do a polarizable calculation?
Output
ene: pme realspace energy
Source code in dmff/admp/pme.py
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 |
|
pme_real_kernel(dr, qiQI, qiQJ, qiUindI, qiUindJ, thole1, thole2, dmp, mscales, pscales, dscales, kappa, lmax=2, lpol=False)
This is the heavy-lifting kernel function to compute the realspace multipolar PME Vectorized over interacting pairs
Input
dr: float, the interatomic distances, (np) array if vectorized qiQI: [(lmax+1)^2] float array, the harmonic multipoles of site i in quasi-internal frame qiQJ: [(lmax+1)^2] float array, the harmonic multipoles of site j in quasi-internal frame qiUindI (3,) float array, the harmonic dipoles of site i in QI frame qiUindJ (3,) float array, the harmonic dipoles of site j in QI frame thole1 float: thole damping coeff of site i thole2 float: thole damping coeff of site j dmp: float: (pol1 * pol2)**1/6, distance rescaling params used in thole damping mscale: float, scaling factor between interacting sites (permanent-permanent) pscale: float, scaling factor between perm-ind interaction dscale: float, scaling factor between ind-ind interaction kappa: float, kappa in unit A^1 lmax: int, maximum angular momentum lpol: bool, doing polarization?
Output
energy: float, realspace interaction energy between the sites
Source code in dmff/admp/pme.py
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 |
|
pme_self(Q_h, kappa, lmax=2)
This function calculates the PME self energy
Inputs
Q: Na * (lmax+1)^2: harmonic multipoles, local or global does not matter kappa: float: kappa used in PME
Output
ene_self: float: the self energy
Source code in dmff/admp/pme.py
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 |
|
pol_penalty(U_ind, pol)
The energy penalty for polarization of each site, currently only supports isotropic polarization:
Inputs
U_ind: Na * 3 float: induced dipoles, in isotropic polarization case, cartesian or harmonic does not matter pol: (Na,) float: polarizability
Source code in dmff/admp/pme.py
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 |
|
setup_ewald_parameters(rc, ethresh, box=None, spacing=None, method='openmm')
Given the cutoff distance, and the required precision, determine the parameters used in Ewald sum, including: kappa, K1, K2, and K3.
float
The cutoff distance, in nm
float
Required energy precision, in kJ/mol
ndarray, optional
3*3 matrix, box size, a, b, c arranged in rows, used in openmm method
float, optional
fourier spacing to determine K, used in gromacs method
str
Method to determine ewald parameters. Valid values: "openmm" or "gromacs". If openmm, the algorithm can refer to http://docs.openmm.org/latest/userguide/theory.html If gromacs, the algorithm is adapted from gromacs source code
Returns
kappa, K1, K2, K3: (float, int, int, int) float, the attenuation factor K1, K2, K3: integers, sizes of the k-points mesh
Source code in dmff/admp/pme.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
switch_val(x, x0, sigma, y0, y1)
This is a Fermi function switches between y0 and y1, according to the value of x y = y0 when x << x0 y = y1 when x >> x1 sigma control sthe switch width
Source code in dmff/admp/pme.py
455 456 457 458 459 460 461 462 463 464 465 466 |
|