1 // A library for defining various atomic quantities 2 3 #ifndef PER_ATOM_QUANTITY_LIBRARY_H 4 #define PER_ATOM_QUANTITY_LIBRARY_H 5 6 #include "PerAtomQuantity.h" 7 #include "FundamentalAtomicQuantity.h" 8 #include <set> 9 #include <map> 10 #include <vector> 11 #include <string> 12 13 namespace ATC { 14 15 // forward declarations 16 class LammpsInterface; 17 class FE_Mesh; 18 class FE_Engine; 19 template <class T> class DenseMatrixTransfer; 20 21 // need to add capability to take in group bit (JAT, 04/02/11) 22 /** 23 * @class AtomNumber 24 * @brief Class for identifying atoms based on a specified group 25 */ 26 27 class AtomNumber : public ProtectedAtomQuantity<double> { 28 29 public: 30 31 // constructor 32 AtomNumber(ATC_Method * atc, AtomType atomType = INTERNAL); 33 34 // destructor ~AtomNumber()35 virtual ~AtomNumber() {}; 36 37 /** reset the quantity */ 38 virtual void reset() const; 39 40 protected: 41 // int groupBit_; 42 ATC_Method * atc_; 43 44 private: 45 46 // do not define 47 AtomNumber(); 48 49 }; 50 51 /** 52 * @class AtomTypeVector 53 * @brief Class for identifying atoms based on a specified group 54 */ 55 56 class AtomTypeVector : public ProtectedAtomQuantity<double> { 57 58 public: 59 60 // constructor 61 AtomTypeVector(ATC_Method * atc, std::vector<int> typeList, 62 AtomType atomType = INTERNAL); 63 AtomTypeVector(ATC_Method * atc, std::vector<int> typeList, std::vector<int> grpList, 64 AtomType atomType = INTERNAL); 65 66 // destructor ~AtomTypeVector()67 virtual ~AtomTypeVector() {}; 68 69 /** reset the quantity */ 70 virtual void reset() const; 71 72 protected: 73 ATC_Method * atc_; 74 int ntypes_; 75 std::vector<int> typeList_,index_; // lammps->atc & atc->lammps 76 std::vector<int> groupList_; 77 78 private: 79 AtomTypeVector(); // do not define 80 81 }; 82 83 84 // inherited classes are used for this task because 85 // lammps changes pointer location so it can only be 86 // accessed by functions 87 /** 88 * @class XrefWrapper 89 * @brief Class for wrapping the xref_ array 90 */ 91 92 class XrefWrapper : public ProtectedClonedAtomQuantity<double> { 93 94 public: 95 96 // constructor 97 XrefWrapper(ATC_Method * atc, AtomType atomType=INTERNAL); 98 99 // destructor ~XrefWrapper()100 virtual ~XrefWrapper() {}; 101 102 protected: 103 104 /** pointer to atc to access raw pointer */ 105 ATC_Method * atc_; 106 107 /** gets appropriate pointer for lammps data */ 108 double ** lammps_vector() const; 109 110 private: 111 112 // do not define 113 XrefWrapper(); 114 115 }; 116 117 /** 118 * @class AtomToElementMap 119 * @brief Class for identifying the element associated with an atom 120 */ 121 122 class AtomToElementMap : public ProtectedAtomQuantity<int> { 123 124 public: 125 126 // constructor 127 AtomToElementMap(ATC_Method * atc, 128 PerAtomQuantity<double> * atomPositions = NULL, 129 AtomType atomType = INTERNAL); 130 131 // destructor 132 virtual ~AtomToElementMap(); 133 134 protected: 135 136 /** resets the data if necessary */ 137 virtual void reset() const; 138 139 /** atomic positions */ 140 PerAtomQuantity<double> * atomPositions_; 141 142 private: 143 144 // do not define 145 AtomToElementMap(); 146 147 }; 148 149 /** 150 * @class AtomToElementMap 151 * @brief Class list of atoms in an element set 152 */ 153 154 class AtomInElementSet : public DependencyManager { 155 156 public: 157 158 // constructor 159 AtomInElementSet(ATC_Method * atc, 160 PerAtomQuantity<int> * map, 161 ESET eset, int type); 162 163 // destructor 164 virtual ~AtomInElementSet(); 165 166 // accessors 167 virtual const ID_LIST & quantity(); set_quantity()168 virtual ID_LIST & set_quantity() {return list_;} size()169 int size() {if (needReset_) reset(); return list_.size(); } item(int i)170 ID_PAIR item(int i) {if (needReset_) reset(); return list_[i]; } 171 protected: 172 173 /** resets the data if necessary */ 174 virtual void reset(); 175 176 PaqAtcUtility atc_; 177 178 /** atom to element map */ 179 PerAtomQuantity<int> * map_; 180 ESET eset_; 181 int type_; 182 const Array<int> & quantityToLammps_; 183 ID_LIST list_; 184 185 private: 186 187 // do not define 188 AtomInElementSet(); 189 190 }; 191 192 /** 193 * @class AtomVolumeUser 194 * @brief Class for defining the volume per atom based on a user specification 195 */ 196 197 class AtomVolumeUser : public ProtectedAtomDiagonalMatrix<double> { 198 199 public: 200 201 // constructor 202 AtomVolumeUser(ATC_Method * atc, 203 std::map<int,double> & atomGroupVolume, 204 AtomType atomType = INTERNAL); 205 206 // destructor ~AtomVolumeUser()207 virtual ~AtomVolumeUser() {}; 208 209 protected: 210 211 /** resets the data if necessary */ 212 virtual void reset() const; 213 214 /** reference to the map of atom group ids to atom volumes */ 215 std::map<int,double> & atomGroupVolume_; 216 217 /** pointer to lammps interface */ 218 const LammpsInterface * lammpsInterface_; 219 220 /** map from atc indices to lammps indices */ 221 const Array<int> & atcToLammps_; 222 223 private: 224 225 // do not define 226 AtomVolumeUser(); 227 228 }; 229 230 /** 231 * @class AtomVolumeGroup 232 * @brief Class for defining the volume per atom based on the atom count in a group and its volume 233 */ 234 235 class AtomVolumeGroup : public AtomVolumeUser { 236 237 public: 238 239 // constructor 240 AtomVolumeGroup(ATC_Method * atc, 241 std::map<int,double> & atomGroupVolume, 242 AtomType atomType = INTERNAL); 243 244 // destructor ~AtomVolumeGroup()245 virtual ~AtomVolumeGroup() {}; 246 247 protected: 248 249 /** map from group to group atom volume */ 250 std::map<int,double> atomGroupVolume_; 251 252 /** pointer to lammps interface */ 253 const LammpsInterface * lammpsInterface_; 254 255 /** reference to array mapping atc indices to lammps indices */ 256 const Array<int> & atcToLammps_; 257 258 private: 259 260 // do not define 261 AtomVolumeGroup(); 262 263 }; 264 265 /** 266 * @class AtomVolumeLattice 267 * @brief Class for defining the volume per atom based on the lattice type and size 268 */ 269 270 class AtomVolumeLattice : public ProtectedAtomDiagonalMatrix<double> { 271 272 public: 273 274 // constructor 275 AtomVolumeLattice(ATC_Method * atc, 276 AtomType atomType = INTERNAL); 277 278 // destructor ~AtomVolumeLattice()279 virtual ~AtomVolumeLattice() {}; 280 281 protected: 282 283 /** resets the data if necessary */ 284 virtual void reset() const; 285 286 /** pointer to lammps interface */ 287 const LammpsInterface * lammpsInterface_; 288 289 private: 290 291 // do not define 292 AtomVolumeLattice(); 293 294 }; 295 296 /** 297 * @class AtomVolumeElement 298 * @brief Class for defining the volume per atom based on the atom count per element and elemental volume 299 */ 300 301 class AtomVolumeElement : public ProtectedAtomDiagonalMatrix<double> { 302 303 public: 304 305 // constructor 306 AtomVolumeElement(ATC_Method * atc, 307 PerAtomQuantity<int> * atomElement = NULL, 308 AtomType atomType = INTERNAL); 309 310 // destructor 311 virtual ~AtomVolumeElement(); 312 313 protected: 314 315 /** resets the data if necessary */ 316 virtual void reset() const; 317 318 /** pointer to the atom to element map */ 319 PerAtomQuantity<int> * atomElement_; 320 321 /** pointer to lammps interface */ 322 const LammpsInterface * lammpsInterface_; 323 324 /** pointer to mesh object */ 325 const FE_Mesh * feMesh_; 326 327 // workspace variables 328 mutable INT_VECTOR _elementAtomCountLocal_; 329 mutable INT_VECTOR _elementAtomCount_; 330 mutable DENS_VEC _elementAtomVolume_; 331 mutable DENS_MAT _nodalCoordinates_; 332 333 private: 334 335 // do not define 336 AtomVolumeElement(); 337 338 }; 339 340 /** 341 * @class AtomVolumeRegion 342 * @brief Class for defining the volume per atom based on the atom count in the MD regions and their volumes. 343 * It will only be meaningful if atoms completely fill all the regions. 344 */ 345 346 class AtomVolumeRegion : public ProtectedAtomDiagonalMatrix<double> { 347 348 public: 349 350 // constructor 351 AtomVolumeRegion(ATC_Method * atc, 352 DENS_MAN * atomCoarseGrainingPositions = NULL, 353 AtomType atomType = INTERNAL); 354 355 // destructor 356 virtual ~AtomVolumeRegion(); 357 358 protected: 359 360 /** resets the data if necessary */ 361 virtual void reset() const; 362 363 /** pointer to atomic coordinates data */ 364 DENS_MAN * atomCoarseGrainingPositions_; 365 366 /** pointer to lammps interface */ 367 const LammpsInterface * lammpsInterface_; 368 369 /** vector from region index to volume */ 370 DENS_VEC regionalAtomVolume_; 371 372 private: 373 374 // do not define 375 AtomVolumeRegion(); 376 377 }; 378 379 /** 380 * @class AtomVolumeFile 381 * @brief Class for defining the volume per atom based on data read in from a file 382 */ 383 384 class AtomVolumeFile : public ProtectedAtomDiagonalMatrix<double> { 385 386 public: 387 388 // constructor 389 AtomVolumeFile(ATC_Method * atc, 390 const std::string & atomVolumeFile, 391 AtomType atomType = INTERNAL); 392 393 // destructor ~AtomVolumeFile()394 virtual ~AtomVolumeFile() {}; 395 396 protected: 397 398 /** resets the data if necessary */ 399 virtual void reset() const; 400 401 /** file name containing the atomic information */ 402 const std::string & atomVolumeFile_; 403 404 /** pointer to lammps interface */ 405 const LammpsInterface * lammpsInterface_; 406 407 private: 408 409 // do not define 410 AtomVolumeFile(); 411 412 }; 413 414 /** 415 * @class AtomicMassWeightedDisplacement 416 * @brief Class for computing the precursor atomic quantity m*(x - x_ref) 417 */ 418 419 class AtomicMassWeightedDisplacement : public ProtectedAtomQuantity<double> { 420 421 public: 422 423 // constructor 424 AtomicMassWeightedDisplacement(ATC_Method * atc, 425 PerAtomQuantity<double> * atomPositions = NULL, 426 PerAtomQuantity<double> * atomMasses = NULL, 427 PerAtomQuantity<double> * atomReferencePositions = NULL, 428 AtomType atomType = INTERNAL); 429 430 // destructor 431 virtual ~AtomicMassWeightedDisplacement(); 432 433 protected: 434 435 /** handles resetting of data */ 436 virtual void reset() const; 437 438 /** atomic positions */ 439 PerAtomQuantity<double> * atomPositions_; 440 441 /** atomic masses */ 442 PerAtomQuantity<double> * atomMasses_; 443 444 /** atomic reference positions */ 445 PerAtomQuantity<double> * atomReferencePositions_; 446 447 private: 448 449 // do not define 450 AtomicMassWeightedDisplacement(); 451 452 }; 453 454 /** 455 * @class FluctuatingVelocity 456 * @brief Class for computing the atomic quantity v - bar{v} 457 */ 458 459 class FluctuatingVelocity : public ProtectedAtomQuantity<double> { 460 461 public: 462 463 // constructor 464 FluctuatingVelocity(ATC_Method * atc, 465 PerAtomQuantity<double> * atomVelocities = NULL, 466 PerAtomQuantity<double> * atomMeanVelocities = NULL, 467 AtomType atomType = INTERNAL); 468 469 // destructor 470 virtual ~FluctuatingVelocity(); 471 472 protected: 473 474 /** handles resetting of data */ 475 virtual void reset() const; 476 477 /** atomic velocities */ 478 PerAtomQuantity<double> * atomVelocities_; 479 480 /** atomic mean velocities */ 481 PerAtomQuantity<double> * atomMeanVelocities_; 482 private: 483 484 // do not define 485 FluctuatingVelocity(); 486 487 }; 488 489 /** 490 * @class ChargeVelcity 491 * @brief Class for computing the atomic quantity q v' 492 */ 493 494 class ChargeVelocity : public ProtectedAtomQuantity<double> { 495 496 public: 497 498 // constructor 499 ChargeVelocity(ATC_Method * atc, 500 PerAtomQuantity<double> * fluctuatingVelocities = NULL, 501 FundamentalAtomQuantity * atomCharges = NULL, 502 AtomType atomType = INTERNAL); 503 504 // destructor 505 virtual ~ChargeVelocity(); 506 507 protected: 508 509 /** handles resetting of data */ 510 virtual void reset() const; 511 512 /** atomic velocities */ 513 PerAtomQuantity<double> * fluctuatingVelocities_; 514 515 /** atomic mean velocities */ 516 FundamentalAtomQuantity * atomCharge_; 517 private: 518 519 // do not define 520 ChargeVelocity(); 521 522 }; 523 524 /** 525 * @class SpeciesVelcity 526 * @brief Class for computing the atomic quantity m^(a) v' 527 */ 528 529 class SpeciesVelocity : public ProtectedAtomQuantity<double> { 530 531 public: 532 533 // constructor 534 SpeciesVelocity(ATC_Method * atc, 535 PerAtomQuantity<double> * fluctuatingVelocities = NULL, 536 PerAtomQuantity<double> * atomTypeVector = NULL, 537 AtomType atomType = INTERNAL); 538 539 // destructor 540 virtual ~SpeciesVelocity(); 541 542 protected: 543 544 /** handles resetting of data */ 545 virtual void reset() const; 546 547 /** atomic velocities */ 548 PerAtomQuantity<double> * fluctuatingVelocities_; 549 550 /** atomic mean velocities */ 551 PerAtomQuantity<double> * atomTypeVector_; 552 private: 553 554 // do not define 555 SpeciesVelocity(); 556 557 }; 558 559 /** 560 * @class AtomicMomentum 561 * @brief Class for computing the precursor atomic quantity m*v 562 */ 563 564 class AtomicMomentum : public ProtectedAtomQuantity<double> { 565 566 public: 567 568 // constructor 569 AtomicMomentum(ATC_Method * atc, 570 PerAtomQuantity<double> * atomVelocities = NULL, 571 PerAtomQuantity<double> * atomMasses = NULL, 572 AtomType atomType = INTERNAL); 573 574 // destructor 575 virtual ~AtomicMomentum(); 576 577 protected: 578 579 /** handles resetting of data */ 580 virtual void reset() const; 581 582 /** atomic velocities */ 583 PerAtomQuantity<double> * atomVelocities_; 584 585 /** atomic masses */ 586 PerAtomQuantity<double> * atomMasses_; 587 588 private: 589 590 // do not define 591 AtomicMomentum(); 592 593 }; 594 595 /** 596 * @class AtomicEnergyForTemperature 597 * @brief Base class for accessing quantities needed for computing temperature 598 */ 599 600 class AtomicEnergyForTemperature : public ProtectedAtomQuantity<double> { 601 602 public: 603 604 // constructor 605 AtomicEnergyForTemperature(ATC_Method * atc, 606 AtomType atomType = INTERNAL) 607 : ProtectedAtomQuantity<double>(atc, 1, atomType) {}; 608 609 // destructor ~AtomicEnergyForTemperature()610 virtual ~AtomicEnergyForTemperature() {}; 611 612 // returns coefficient which multiplies kinetic energy in temperature definition 613 virtual double kinetic_energy_multiplier() const = 0; 614 615 private: 616 617 // do not define 618 AtomicEnergyForTemperature(); 619 620 }; 621 622 /** 623 * @class TwiceKineticEnergy 624 * @brief Class for computing the precursor atomic quantity m*v*v 625 * (used when the kinetic definition of temperature is required) 626 */ 627 628 class TwiceKineticEnergy : public AtomicEnergyForTemperature { 629 630 public: 631 632 // constructor 633 TwiceKineticEnergy(ATC_Method * atc, 634 PerAtomQuantity<double> * atomVelocities = NULL, 635 PerAtomQuantity<double> * atomMasses = NULL, 636 AtomType atomType = INTERNAL); 637 638 // destructor 639 virtual ~TwiceKineticEnergy(); 640 641 // returns coefficient which multiplies kinetic energy in temperature definition kinetic_energy_multiplier()642 virtual double kinetic_energy_multiplier() const {return 2.;}; 643 644 protected: 645 646 /** handles resetting of data */ 647 virtual void reset() const; 648 649 /** atomic velocities */ 650 PerAtomQuantity<double> * atomVelocities_; 651 652 /** atomic masses */ 653 PerAtomQuantity<double> * atomMasses_; 654 655 private: 656 657 // do not define 658 TwiceKineticEnergy(); 659 660 }; 661 662 /** 663 * @class KineticTensor 664 * @brief Class for computing the atomic quantity m v (x) v 665 */ 666 667 class KineticTensor : public ProtectedAtomQuantity<double> { 668 669 public: 670 671 // constructor 672 KineticTensor(ATC_Method * atc, 673 PerAtomQuantity<double> * atomVelocities = NULL, 674 PerAtomQuantity<double> * atomMasses = NULL, 675 AtomType atomType = INTERNAL); 676 677 // destructor 678 virtual ~KineticTensor(); 679 680 protected: 681 682 /** handles resetting of data */ 683 virtual void reset() const; 684 685 /** atomic velocities */ 686 PerAtomQuantity<double> * atomVelocities_; 687 688 /** atomic masses */ 689 PerAtomQuantity<double> * atomMasses_; 690 691 private: 692 693 // do not define 694 KineticTensor(); 695 696 }; 697 698 699 /** 700 * @class FluctuatingKineticTensor 701 * @brief Class for computing the atomic quantity m v (x) v 702 */ 703 704 class FluctuatingKineticTensor : public ProtectedAtomQuantity<double> { 705 706 public: 707 708 // constructor 709 FluctuatingKineticTensor(ATC_Method * atc, 710 PerAtomQuantity<double> * atomVelocities = NULL, 711 PerAtomQuantity<double> * atomMasses = NULL, 712 PerAtomQuantity<double> * atomMeanVelocities = NULL, 713 AtomType atomType = INTERNAL); 714 715 // destructor 716 virtual ~FluctuatingKineticTensor(); 717 718 protected: 719 720 /** handles resetting of data */ 721 virtual void reset() const; 722 723 /** atomic velocities */ 724 PerAtomQuantity<double> * atomVelocities_; 725 726 /** atomic masses */ 727 PerAtomQuantity<double> * atomMasses_; 728 729 /** atomic mean velocities */ 730 PerAtomQuantity<double> * atomMeanVelocities_; 731 private: 732 733 // do not define 734 FluctuatingKineticTensor(); 735 736 }; 737 738 /** 739 * @class TwiceFluctuatingKineticEnergy 740 * @brief Class for computing the precursor atomic quantity m*(v-vr)*(v-vr) 741 * (used when the kinetic definition of temperature is required) 742 */ 743 744 class TwiceFluctuatingKineticEnergy : public AtomicEnergyForTemperature { 745 746 public: 747 748 // constructor 749 TwiceFluctuatingKineticEnergy(ATC_Method * atc, 750 PerAtomQuantity<double> * atomVelocities = NULL, 751 PerAtomQuantity<double> * atomMasses = NULL, 752 PerAtomQuantity<double> * atomMeanVelocities = NULL, 753 AtomType atomType = INTERNAL); 754 755 // destructor 756 virtual ~TwiceFluctuatingKineticEnergy(); 757 758 // returns coefficient which multiplies kinetic energy in temperature definition kinetic_energy_multiplier()759 virtual double kinetic_energy_multiplier() const {return 2.;}; 760 761 protected: 762 763 /** handles resetting of data */ 764 virtual void reset() const; 765 766 /** atomic velocities */ 767 PerAtomQuantity<double> * atomVelocities_; 768 769 /** atomic masses */ 770 PerAtomQuantity<double> * atomMasses_; 771 772 /** atomic mean velocities */ 773 PerAtomQuantity<double> * atomMeanVelocities_; 774 775 private: 776 777 // do not define 778 TwiceFluctuatingKineticEnergy(); 779 780 }; 781 782 /** 783 * @class MixedKePeEnergy 784 * @brief Class for computing the precursor atomic quantity for 785 * a mixed temperature definition involving both KE and PE 786 */ 787 788 class MixedKePeEnergy : public AtomicEnergyForTemperature { 789 790 public: 791 792 // constructor 793 MixedKePeEnergy(ATC_Method * atc, 794 double keMultiplier, 795 double peMultiplier, 796 PerAtomQuantity<double> * twiceKineticEnergy = NULL, 797 PerAtomQuantity<double> * potentialEnergy = NULL, 798 AtomType atomType = INTERNAL); 799 800 // destructor 801 virtual ~MixedKePeEnergy(); 802 803 // returns coefficient which multiplies kinetic energy in temperature definition kinetic_energy_multiplier()804 virtual double kinetic_energy_multiplier() const {return keMultiplier_;}; 805 806 protected: 807 808 /** handles resetting of data */ 809 virtual void reset() const; 810 811 /** factor multiplying kinetic energy */ 812 double keMultiplier_; 813 814 /** factor multiplying potential energy */ 815 double peMultiplier_; 816 817 /** twice the kinetic energy of each atom */ 818 PerAtomQuantity<double> * twiceKineticEnergy_; 819 820 /** potential energy of each atom */ 821 PerAtomQuantity<double> * potentialEnergy_; 822 823 private: 824 825 // do not define 826 MixedKePeEnergy(); 827 828 }; 829 830 /** 831 * @class TotalEnergy 832 * @brief Class for the atomic total energy 833 */ 834 835 class TotalEnergy : public ProtectedAtomQuantity<double> { 836 837 public: 838 839 // constructor 840 TotalEnergy(ATC_Method * atc, 841 PerAtomQuantity<double> * twiceKineticEnergy = NULL, 842 PerAtomQuantity<double> * potentialEnergy = NULL, 843 AtomType atomType = INTERNAL); 844 845 // destructor 846 virtual ~TotalEnergy(); 847 848 protected: 849 /** handles resetting of data */ 850 virtual void reset() const; 851 852 /** twice the kinetic energy of each atom */ 853 PerAtomQuantity<double> * twiceKineticEnergy_; 854 855 /** potential energy of each atom */ 856 PerAtomQuantity<double> * potentialEnergy_; 857 858 private: 859 TotalEnergy(); // do not define 860 }; 861 862 /** 863 * @class FluctuatingPotentialEnergy 864 * @brief Class for computing the precursor atomic quantity for 865 * a configurational (PE-based) temperature 866 */ 867 868 class FluctuatingPotentialEnergy : public AtomicEnergyForTemperature { 869 870 public: 871 872 // constructor 873 FluctuatingPotentialEnergy(ATC_Method * atc, 874 PerAtomQuantity<double> * potentialEnergy = NULL, 875 PerAtomQuantity<double> * referencePotential = NULL, 876 AtomType atomType = INTERNAL); 877 878 // destructor 879 virtual ~FluctuatingPotentialEnergy(); 880 881 // returns coefficient which multiplies kinetic energy in temperature definition kinetic_energy_multiplier()882 virtual double kinetic_energy_multiplier() const {return 0.;;}; 883 884 protected: 885 886 /** handles resetting of data */ 887 virtual void reset() const; 888 889 /** potential energy of each atom */ 890 PerAtomQuantity<double> * potentialEnergy_; 891 892 /** twice the kinetic energy of each atom */ 893 PerAtomQuantity<double> * referencePotential_; 894 895 private: 896 897 // do not define 898 FluctuatingPotentialEnergy(); 899 900 }; 901 902 /** 903 * @class DotTwiceKineticEnergy 904 * @brief Class for computing the precursor atomic power 2*v*f 905 * (used when the kinetic definition of temperature is required) 906 */ 907 908 class DotTwiceKineticEnergy : public ProtectedAtomQuantity<double> { 909 910 public: 911 912 // constructor 913 DotTwiceKineticEnergy(ATC_Method * atc, 914 PerAtomQuantity<double> * atomForces = NULL, 915 PerAtomQuantity<double> * atomVelocities = NULL, 916 AtomType atomType = INTERNAL); 917 918 // destructor 919 virtual ~DotTwiceKineticEnergy(); 920 921 protected: 922 923 /** handles resetting of data */ 924 virtual void reset() const; 925 926 /** atomic forces */ 927 PerAtomQuantity<double> * atomForces_; 928 929 /** atomic velocities */ 930 PerAtomQuantity<double> * atomVelocities_; 931 932 private: 933 934 // do not define 935 DotTwiceKineticEnergy(); 936 937 }; 938 939 /** 940 * @class VelocitySquared 941 * @brief Class for computing the quantity |v|^2 942 * (used for weights in the thermostat) 943 */ 944 945 class VelocitySquared : public ProtectedAtomQuantity<double> { 946 947 public: 948 949 // constructor 950 VelocitySquared(ATC_Method *atc, 951 PerAtomQuantity<double> * atomVelocities = NULL, 952 AtomType atomType = INTERNAL); 953 954 // destructor 955 virtual ~VelocitySquared(); 956 957 protected: 958 959 /** handles resetting of data */ 960 virtual void reset() const; 961 962 /** atomic velocities */ 963 PerAtomQuantity<double> * atomVelocities_; 964 965 private: 966 967 // do not define 968 VelocitySquared(); 969 970 }; 971 972 /** 973 * @class LambdaSquared 974 * @brief Class for computing the 2nd order RHS fractional step 975 * contribution to the equation for lambda, with appropriate weights 976 */ 977 978 class LambdaSquared : public ProtectedAtomQuantity<double> { 979 980 public: 981 982 // constructor 983 LambdaSquared(ATC_Method *atc, 984 PerAtomQuantity<double> * atomMasses = NULL, 985 PerAtomQuantity<double> * atomVelocitiesSquared = NULL, 986 PerAtomQuantity<double> * atomLambdas = NULL, 987 AtomType atomType = INTERNAL); 988 989 // destructor 990 virtual ~LambdaSquared(); 991 992 protected: 993 994 /** handles resetting of data */ 995 virtual void reset() const; 996 997 /** atomic masses */ 998 PerAtomQuantity<double> * atomMasses_; 999 1000 /** atomic velocities squared */ 1001 PerAtomQuantity<double> * atomVelocitiesSquared_; 1002 1003 /** atomic lambdas */ 1004 PerAtomQuantity<double> * atomLambdas_; 1005 1006 private: 1007 1008 // do not define 1009 LambdaSquared(); 1010 1011 }; 1012 1013 /** 1014 * @class LargeToSmallAtomMap 1015 * @brief mapping from a larger set of atoms to a smaller set 1016 * this implementation maximizes storage but reduces execution times, 1017 * including taking advantage of MPI communcation 1018 */ 1019 1020 class LargeToSmallAtomMap : public ProtectedAtomQuantity<int> { 1021 1022 public: 1023 1024 // constructor 1025 LargeToSmallAtomMap(ATC_Method * atc, 1026 AtomType atomType = INTERNAL) 1027 : ProtectedAtomQuantity<int>(atc,1,atomType), size_(0) {}; 1028 1029 // destructor ~LargeToSmallAtomMap()1030 virtual ~LargeToSmallAtomMap() {}; 1031 1032 /** change map when atoms change */ reset_nlocal()1033 virtual void reset_nlocal() {this->set_reset();}; 1034 1035 /** get the number of elements associated with the map */ size()1036 virtual int size() const {this->quantity(); return size_;}; 1037 1038 /** sets quantity to lammps data, if needed, should be called in pre_exchange */ prepare_exchange()1039 virtual void prepare_exchange() {}; 1040 1041 /** sets quantity to lammps data, if needed */ post_exchange()1042 virtual void post_exchange() {this->set_reset();}; 1043 1044 /** returns how much lammps memory is used in this function */ memory_usage()1045 virtual int memory_usage() const {return 0;}; 1046 1047 /** packs up data for parallel transfer when atoms change processors */ pack_exchange(int i,double * buffer)1048 virtual int pack_exchange(int i, double *buffer) {return 0;}; 1049 1050 /** unpacks data after parallel transfer when atoms change processors */ unpack_exchange(int i,double * buffer)1051 virtual int unpack_exchange(int i, double *buffer) {return 0;}; 1052 1053 /** packs up data for parallel transfer to ghost atoms on other processors */ pack_comm(int index,double * buf,int pbc_flag,int * pbc)1054 virtual int pack_comm(int index, double *buf, 1055 int pbc_flag, int *pbc) {return 0;}; 1056 1057 /** unpacks data after parallel transfer to ghost atoms on other processors */ unpack_comm(int index,double * buf)1058 virtual int unpack_comm(int index, double *buf) {return 0;}; 1059 1060 /** returns size of per-atom communication */ size_comm()1061 virtual int size_comm() {return 0;}; 1062 1063 /** changes size of temperary lammps storage data if transfer is being used */ grow_lammps_array(int nmax,const std::string & tag)1064 virtual void grow_lammps_array(int nmax, const std::string & tag) {}; 1065 1066 /** rearrange memory of temporary lammps storage data, called from copy_array */ copy_lammps_array(int i,int j)1067 virtual void copy_lammps_array(int i, int j) {}; 1068 1069 protected: 1070 1071 /** number of nodes in the map */ 1072 mutable int size_; 1073 1074 }; 1075 1076 /** 1077 * @class AtomToType 1078 * @brief mapping from all atoms to the subset of atoms of a specified type 1079 */ 1080 1081 class AtomToType : public LargeToSmallAtomMap { 1082 1083 public: 1084 1085 // constructor 1086 AtomToType(ATC_Method * atc, 1087 int type, 1088 AtomType atomType = INTERNAL); 1089 1090 // destructor ~AtomToType()1091 virtual ~AtomToType() {}; 1092 1093 protected: 1094 1095 /** handles resetting of data */ 1096 virtual void reset() const; 1097 1098 /** tag for type */ 1099 int type_; 1100 1101 private: 1102 1103 // do not define 1104 AtomToType(); 1105 1106 }; 1107 1108 /** 1109 * @class AtomToGroup 1110 * @brief mapping from all atoms to the subset of atoms of a specified group 1111 */ 1112 1113 class AtomToGroup : public LargeToSmallAtomMap { 1114 1115 public: 1116 1117 // constructor 1118 AtomToGroup(ATC_Method * atc, 1119 int group, 1120 AtomType atomType = INTERNAL); 1121 1122 // destructor ~AtomToGroup()1123 virtual ~AtomToGroup() {}; 1124 1125 protected: 1126 1127 /** handles resetting of data */ 1128 virtual void reset() const; 1129 1130 /** tag for group */ 1131 int group_; 1132 1133 private: 1134 1135 // do not define 1136 AtomToGroup(); 1137 1138 }; 1139 1140 /** 1141 * @class AtomToNodeset 1142 * @brief mapping from all atoms to a subset of nodes 1143 */ 1144 1145 class AtomToNodeset : public LargeToSmallAtomMap { 1146 1147 public: 1148 1149 // constructor 1150 AtomToNodeset(ATC_Method * atc, 1151 SetDependencyManager<int> * subsetNodes, 1152 PerAtomQuantity<int> * atomElement = NULL, 1153 AtomType atomType = INTERNAL); 1154 1155 // destructor ~AtomToNodeset()1156 virtual ~AtomToNodeset() { 1157 atomElement_->remove_dependence(this); 1158 subsetNodes_->remove_dependence(this); 1159 }; 1160 1161 protected: 1162 1163 /** handles resetting of data */ 1164 virtual void reset() const; 1165 1166 /** set of nodes which are being regulated */ 1167 SetDependencyManager<int> * subsetNodes_; 1168 1169 /** map from atom to element in which it resides */ 1170 PerAtomQuantity<int> * atomElement_; 1171 1172 /** pointer to the finite element engine */ 1173 const FE_Mesh * feMesh_; 1174 1175 // workspace 1176 mutable Array<int> _nodes_; // nodes associated with an element 1177 1178 private: 1179 1180 // do not define 1181 AtomToNodeset(); 1182 1183 }; 1184 1185 /** 1186 * @class AtomToElementset 1187 * @brief mapping from all atoms to a subset of elements 1188 */ 1189 1190 class AtomToElementset : public LargeToSmallAtomMap { 1191 1192 public: 1193 1194 // constructor 1195 AtomToElementset(ATC_Method * atc, 1196 MatrixDependencyManager<DenseMatrix, bool> * elementMask, 1197 PerAtomQuantity<int> * atomElement = NULL, 1198 AtomType atomType = INTERNAL); 1199 1200 // destructor 1201 virtual ~AtomToElementset(); 1202 1203 protected: 1204 1205 /** handles resetting of data */ 1206 virtual void reset() const; 1207 1208 /** set of nodes which are being regulated */ 1209 MatrixDependencyManager<DenseMatrix, bool> * elementMask_; 1210 1211 /** map from atom to element in which it resides */ 1212 PerAtomQuantity<int> * atomElement_; 1213 1214 /** pointer to the finite element engine */ 1215 const FE_Mesh * feMesh_; 1216 1217 private: 1218 1219 // do not define 1220 AtomToElementset(); 1221 1222 }; 1223 1224 /** 1225 * @class MappedAtomQuantity 1226 * @brief generic reduced mapping 1227 */ 1228 1229 class MappedAtomQuantity : public ProtectedMappedAtomQuantity<double> { 1230 1231 public: 1232 1233 // constructor 1234 MappedAtomQuantity(ATC_Method * atc, 1235 PerAtomQuantity<double> * source, 1236 LargeToSmallAtomMap * map, 1237 AtomType atomType = INTERNAL); 1238 1239 // destructor ~MappedAtomQuantity()1240 virtual ~MappedAtomQuantity() { 1241 source_->remove_dependence(this); 1242 map_->remove_dependence(this); 1243 }; 1244 1245 protected: 1246 1247 /** handles resetting of data */ 1248 virtual void reset() const; 1249 1250 /** original quantity */ 1251 PerAtomQuantity<double> * source_; 1252 1253 /** mapping transfer */ 1254 LargeToSmallAtomMap * map_; 1255 1256 private: 1257 1258 // do not define 1259 MappedAtomQuantity(); 1260 1261 }; 1262 1263 /** 1264 * @class VelocitySquaredMapped 1265 * @brief Class for computing the quantity |v|^2 on a subset of atoms 1266 * (used for weights in the thermostat) 1267 */ 1268 1269 class VelocitySquaredMapped : public ProtectedMappedAtomQuantity<double> { 1270 1271 public: 1272 1273 // constructor 1274 VelocitySquaredMapped(ATC_Method *atc, 1275 MatrixDependencyManager<DenseMatrix, int> * atomMap, 1276 PerAtomQuantity<double> * atomVelocities = NULL, 1277 AtomType atomType = INTERNAL); 1278 1279 // destructor 1280 virtual ~VelocitySquaredMapped(); 1281 1282 protected: 1283 1284 /** handles resetting of data */ 1285 virtual void reset() const; 1286 1287 /** atomic velocities */ 1288 PerAtomQuantity<double> * atomVelocities_; 1289 1290 private: 1291 1292 // do not define 1293 VelocitySquaredMapped(); 1294 1295 }; 1296 1297 /** 1298 * @class LambdaSquaredMapped 1299 * @brief Class for computing the 2nd order RHS fractional step 1300 * contribution to the equation for lambda, with appropriate weights 1301 */ 1302 1303 class LambdaSquaredMapped : public ProtectedMappedAtomQuantity<double> { 1304 1305 public: 1306 1307 // constructor 1308 LambdaSquaredMapped(ATC_Method *atc, 1309 MatrixDependencyManager<DenseMatrix, int> * atomMap, 1310 PerAtomQuantity<double> * atomMasses = NULL, 1311 PerAtomQuantity<double> * atomVelocitiesSquared = NULL, 1312 PerAtomQuantity<double> * atomLambdas = NULL, 1313 AtomType atomType = INTERNAL); 1314 1315 // destructor 1316 virtual ~LambdaSquaredMapped(); 1317 1318 protected: 1319 1320 /** handles resetting of data */ 1321 virtual void reset() const; 1322 1323 /** atomic masses */ 1324 PerAtomQuantity<double> * atomMasses_; 1325 1326 /** atomic velocities squared */ 1327 PerAtomQuantity<double> * atomVelocitiesSquared_; 1328 1329 /** atomic lambdas */ 1330 PerAtomQuantity<double> * atomLambdas_; 1331 1332 private: 1333 1334 // do not define 1335 LambdaSquaredMapped(); 1336 1337 }; 1338 1339 /** 1340 * @class HeatCapacity 1341 * @brief Class for the classical atomic heat capacity 1342 */ 1343 1344 class HeatCapacity : public ConstantQuantity<double> { 1345 1346 public: 1347 1348 // constructor 1349 HeatCapacity(ATC_Method * atc, AtomType atomType = INTERNAL); 1350 1351 // destructor ~HeatCapacity()1352 virtual ~HeatCapacity() {}; 1353 1354 protected: 1355 1356 private: 1357 1358 // do not define 1359 HeatCapacity(); 1360 1361 }; 1362 1363 /** 1364 * @class AtomicVelocityRescaleFactor 1365 * @brief Class for computing the atomic rescaling induced by the rescaling thermostat 1366 */ 1367 1368 class AtomicVelocityRescaleFactor : public ProtectedAtomQuantity<double> { 1369 1370 public: 1371 1372 // constructor 1373 AtomicVelocityRescaleFactor(ATC_Method * atc, 1374 PerAtomQuantity<double> * atomLambdas = NULL, 1375 AtomType atomType = INTERNAL); 1376 1377 // destructor 1378 virtual ~AtomicVelocityRescaleFactor(); 1379 1380 protected: 1381 1382 /** handles resetting of data */ 1383 virtual void reset() const; 1384 1385 /** atomic masses */ 1386 FundamentalAtomQuantity * atomMasses_; 1387 1388 /** atomic lambdas */ 1389 PerAtomQuantity<double> * atomLambdas_; 1390 1391 private: 1392 1393 // do not define 1394 AtomicVelocityRescaleFactor(); 1395 1396 }; 1397 1398 /** 1399 * @class AtomicThermostatForce 1400 * @brief Class for computing the atomic force induced by the GLC-based thermostats 1401 */ 1402 1403 class AtomicThermostatForce : public ProtectedAtomQuantity<double> { 1404 1405 public: 1406 1407 // constructor 1408 AtomicThermostatForce(ATC_Method * atc, 1409 PerAtomQuantity<double> * atomLambdas = NULL, 1410 PerAtomQuantity<double> * atomVelocities = NULL, 1411 AtomType atomType = INTERNAL); 1412 1413 // destructor 1414 virtual ~AtomicThermostatForce(); 1415 1416 protected: 1417 1418 /** handles resetting of data */ 1419 virtual void reset() const; 1420 1421 /** atomic lambdas */ 1422 PerAtomQuantity<double> * atomLambdas_; 1423 1424 /** atomic velocities */ 1425 PerAtomQuantity<double> * atomVelocities_; 1426 1427 private: 1428 1429 // do not define 1430 AtomicThermostatForce(); 1431 1432 }; 1433 1434 /** 1435 * @class AtomicKinetostatForceDisplacement 1436 * @brief Class for computing the atomic force induced by the GLC-based kinetostats 1437 */ 1438 1439 class AtomicKinetostatForceDisplacement : public ProtectedAtomQuantity<double> { 1440 1441 public: 1442 1443 // constructor 1444 AtomicKinetostatForceDisplacement(ATC_Method * atc, 1445 PerAtomQuantity<double> * atomLambda = NULL, 1446 PerAtomQuantity<double> * atomMass = NULL, 1447 AtomType atomType = INTERNAL); 1448 1449 // destructor 1450 virtual ~AtomicKinetostatForceDisplacement(); 1451 1452 protected: 1453 1454 /** handles resetting of data */ 1455 virtual void reset() const; 1456 1457 /** computes the multiplication factor assocaited with the controlled quantity being an integral of the degrees of freedom */ time_step_factor(double dt)1458 virtual double time_step_factor(double dt) const {return 1./dt/dt;}; 1459 1460 /** atomic lambdas */ 1461 PerAtomQuantity<double> * atomLambda_; 1462 1463 /** atomic velocities */ 1464 PerAtomQuantity<double> * atomMass_; 1465 1466 private: 1467 1468 // do not define 1469 AtomicKinetostatForceDisplacement(); 1470 1471 }; 1472 1473 /** 1474 * @class AtomicKinetostatForceVelocity 1475 * @brief Class for computing the atomic force induced by the GLC-based kinetostats 1476 */ 1477 1478 class AtomicKinetostatForceVelocity : public AtomicKinetostatForceDisplacement { 1479 1480 public: 1481 1482 // constructor 1483 AtomicKinetostatForceVelocity(ATC_Method * atc, 1484 PerAtomQuantity<double> * atomLambda = NULL, 1485 PerAtomQuantity<double> * atomMass = NULL, 1486 AtomType atomType = INTERNAL) : AtomicKinetostatForceDisplacement(atc,atomLambda,atomMass,atomType)1487 AtomicKinetostatForceDisplacement(atc,atomLambda,atomMass,atomType) {}; 1488 1489 // destructor ~AtomicKinetostatForceVelocity()1490 virtual ~AtomicKinetostatForceVelocity() {}; 1491 1492 protected: 1493 1494 /** computes the multiplication factor assocaited with the controlled quantity being an integral of the degrees of freedom */ time_step_factor(double dt)1495 virtual double time_step_factor(double dt) const {return 1./dt;}; 1496 1497 private: 1498 1499 // do not define 1500 AtomicKinetostatForceVelocity(); 1501 1502 }; 1503 1504 /** 1505 * @class AtomicKinetostatForceStress 1506 * @brief Class for computing the atomic force induced by the stress-based kinetostats 1507 */ 1508 1509 class AtomicKinetostatForceStress : public ProtectedAtomQuantity<double> { 1510 1511 public: 1512 1513 // constructor 1514 AtomicKinetostatForceStress(ATC_Method * atc, 1515 PerAtomQuantity<double> * atomLambda = NULL, 1516 AtomType atomType = INTERNAL); 1517 1518 // destructor 1519 virtual ~AtomicKinetostatForceStress(); 1520 1521 protected: 1522 1523 /** handles resetting of data */ 1524 virtual void reset() const; 1525 1526 /** atomic lambdas */ 1527 PerAtomQuantity<double> * atomLambda_; 1528 1529 private: 1530 1531 // do not define 1532 AtomicKinetostatForceStress(); 1533 1534 }; 1535 1536 /** 1537 * @class PerAtomKernelFunction 1538 * @brief Class for computing the kernel function at each atom location 1539 */ 1540 1541 class PerAtomKernelFunction : public ProtectedAtomSparseMatrix<double> { 1542 1543 public: 1544 1545 // constructor 1546 PerAtomKernelFunction(ATC_Method * atc, 1547 PerAtomQuantity<double> * atomPositions = NULL, 1548 AtomType atomType = INTERNAL); 1549 1550 // destructor 1551 virtual ~PerAtomKernelFunction(); 1552 1553 protected: 1554 1555 /** handles resetting of data */ 1556 virtual void reset() const; 1557 1558 /** atomic coarse-graining positions */ 1559 PerAtomQuantity<double> * atomPositions_; 1560 1561 /** finite element engine */ 1562 const FE_Engine * feEngine_; 1563 1564 private: 1565 1566 // do not define 1567 PerAtomKernelFunction(); 1568 1569 }; 1570 1571 /** 1572 * @class PerAtomShapeFunction 1573 * @brief Class for computing the shape function at each atom location 1574 */ 1575 1576 class PerAtomShapeFunction : public ProtectedAtomSparseMatrix<double> { 1577 1578 public: 1579 1580 // constructor 1581 PerAtomShapeFunction(ATC_Method * atc, 1582 PerAtomQuantity<double> * atomPositions = NULL, 1583 PerAtomQuantity<int> * atomElements = NULL, 1584 AtomType atomType = INTERNAL); 1585 1586 // destructor 1587 virtual ~PerAtomShapeFunction(); 1588 1589 protected: 1590 1591 /** handles resetting of data */ 1592 virtual void reset() const; 1593 1594 /** atomic coarse-graining positions */ 1595 PerAtomQuantity<double> * atomPositions_; 1596 1597 /** atom to element map */ 1598 PerAtomQuantity<int> * atomElements_; 1599 1600 /** finite element engine */ 1601 const FE_Engine * feEngine_; 1602 1603 private: 1604 1605 // do not define 1606 PerAtomShapeFunction(); 1607 1608 }; 1609 1610 /** 1611 * @class LambdaCouplingMatrix 1612 * @brief constructs the coupling matrix needed to solve for lambda, i.e. N in N^T w N L = b 1613 */ 1614 1615 class LambdaCouplingMatrix : public ProtectedMappedAtomSparseMatrix<double> { 1616 1617 public: 1618 1619 // constructor 1620 LambdaCouplingMatrix(ATC_Method * atc, 1621 MatrixDependencyManager<DenseMatrix, int> * nodeToOverlapMap = NULL, 1622 SPAR_MAN * shapeFunction = NULL); 1623 1624 // destructor ~LambdaCouplingMatrix()1625 virtual ~LambdaCouplingMatrix() { 1626 shapeFunction_->remove_dependence(this); 1627 nodeToOverlapMap_->remove_dependence(this); 1628 }; 1629 1630 protected: 1631 1632 /** does the actual computation of the quantity */ 1633 virtual void reset() const; 1634 1635 /** base shape function */ 1636 SPAR_MAN * shapeFunction_; 1637 1638 /** map from all nodes to regulated ones */ 1639 MatrixDependencyManager<DenseMatrix, int> * nodeToOverlapMap_; 1640 1641 private: 1642 1643 // do not define 1644 LambdaCouplingMatrix(); 1645 1646 }; 1647 1648 /** 1649 * @class LocalLambdaCouplingMatrix 1650 * @brief constructs the coupling matrix needed to solve for lambda, i.e. N in N^T w N L = b 1651 * when localization is being used for the constraint 1652 */ 1653 1654 class LocalLambdaCouplingMatrix : public LambdaCouplingMatrix { 1655 1656 public: 1657 1658 // constructor 1659 LocalLambdaCouplingMatrix(ATC_Method * atc, 1660 MatrixDependencyManager<DenseMatrix, int> * lambdaAtomMap = NULL, 1661 MatrixDependencyManager<DenseMatrix, int> * nodeToOverlapMap = NULL, 1662 SPAR_MAN * shapeFunction = NULL); 1663 1664 // destructor ~LocalLambdaCouplingMatrix()1665 virtual ~LocalLambdaCouplingMatrix() { 1666 lambdaAtomMap_->remove_dependence(this); 1667 }; 1668 1669 protected: 1670 1671 /** does the actual computation of the quantity */ 1672 virtual void reset() const; 1673 1674 /** map from all atoms to regulated ones */ 1675 MatrixDependencyManager<DenseMatrix, int> * lambdaAtomMap_; 1676 1677 private: 1678 1679 // do not define 1680 LocalLambdaCouplingMatrix(); 1681 1682 }; 1683 1684 /** 1685 * @class GhostCouplingMatrix 1686 * @brief constructs the modified shape functions used to compute the total forces between ghost and internal atoms 1687 */ 1688 1689 class GhostCouplingMatrix : public LambdaCouplingMatrix { 1690 1691 public: 1692 1693 // constructor 1694 GhostCouplingMatrix(ATC_Method * atc, 1695 SPAR_MAN * shapeFunction, 1696 SetDependencyManager<int> * subsetNodes, 1697 MatrixDependencyManager<DenseMatrix, int> * nodeToOverlapMap = NULL); 1698 1699 // destructor ~GhostCouplingMatrix()1700 virtual ~GhostCouplingMatrix() { 1701 subsetNodes_->remove_dependence(this); 1702 }; 1703 1704 protected: 1705 1706 /** does the actual computation of the quantity */ 1707 virtual void reset() const; 1708 1709 /** set of nodes which are being regulated */ 1710 SetDependencyManager<int> * subsetNodes_; 1711 1712 // workspace 1713 mutable DENS_VEC _activeNodes_; // nodes which are being regulated are 1, otherwise 0 1714 mutable DENS_VEC _weights_; // required weighting for each shape function row to enforce partition of unity 1715 mutable DIAG_MAT _weightMatrix_; // diagonal with necessary scaling for partition of unity 1716 1717 private: 1718 1719 // do not define 1720 GhostCouplingMatrix(); 1721 1722 }; 1723 1724 1725 } 1726 1727 #endif 1728