Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2013-2023 The plumed team 3 : (see the PEOPLE file at the root of the distribution for a list of names) 4 : 5 : See http://www.plumed.org for more information. 6 : 7 : This file is part of plumed, version 2. 8 : 9 : plumed is free software: you can redistribute it and/or modify 10 : it under the terms of the GNU Lesser General Public License as published by 11 : the Free Software Foundation, either version 3 of the License, or 12 : (at your option) any later version. 13 : 14 : plumed is distributed in the hope that it will be useful, 15 : but WITHOUT ANY WARRANTY; without even the implied warranty of 16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 : GNU Lesser General Public License for more details. 18 : 19 : You should have received a copy of the GNU Lesser General Public License 20 : along with plumed. If not, see <http://www.gnu.org/licenses/>. 21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ 22 : #ifndef __PLUMED_crystallization_VectorMultiColvar_h 23 : #define __PLUMED_crystallization_VectorMultiColvar_h 24 : 25 : #include "tools/Matrix.h" 26 : #include "multicolvar/MultiColvarBase.h" 27 : #include "multicolvar/AtomValuePack.h" 28 : 29 : namespace PLMD { 30 : namespace crystallization { 31 : 32 : class VectorMultiColvar : public multicolvar::MultiColvarBase { 33 : friend class OrientationSphere; 34 : friend class VolumeGradientBase; 35 : private: 36 : /// Are we storing the director of the vector of the vector 37 : bool store_director; 38 : /// How many components does the vector have 39 : unsigned ncomponents; 40 : /// These are tempory vectors that are used to store values and directors 41 : std::vector<double> vv1, vv2; 42 : protected: 43 : /// Set the dimensionality of the vector 44 : void setVectorDimensionality( const unsigned& ); 45 : /// Used in vector average to add forces from vector the the forces from here 46 : void addForcesOnAtoms( const std::vector<double>& inforces ); 47 : public: 48 : static void registerKeywords( Keywords& keys ); 49 : explicit VectorMultiColvar(const ActionOptions&); 50 52 : ~VectorMultiColvar() {} 51 : /// The norm of a vector is not periodic 52 35 : virtual bool isPeriodic() { 53 35 : return false; 54 : } 55 : /// Calculate the multicolvar 56 : // double doCalculation( const unsigned& taskIndex, multicolvar::AtomValuePack& myatoms ) const ; 57 : /// This shouldn't do anything 58 : double compute( const unsigned& tindex, multicolvar::AtomValuePack& myatoms ) const ; 59 : /// Calculate the vector 60 : virtual void calculateVector( multicolvar::AtomValuePack& myatoms ) const=0; 61 : /// Get the number of components in the vector 62 : unsigned getNumberOfComponentsInVector() const ; 63 : /// Get the number of quantities we are calculating per step 64 : unsigned getNumberOfQuantities() const ; 65 : /// Can we differentiate the orientation - yes we can the multicolvar is a vector 66 4 : bool hasDifferentiableOrientation() const { 67 4 : return true; 68 : } 69 : /// This makes sure we are not calculating the director when we do LocalAverage 70 : virtual void doNotCalculateDirector(); 71 : /// This does normalizeing of vectors for storeDataVessel 72 : virtual void normalizeVector( std::vector<double>& vals ) const ; 73 : virtual void normalizeVectorDerivatives( MultiValue& myvals ) const ; 74 : }; 75 : 76 : inline 77 : unsigned VectorMultiColvar::getNumberOfComponentsInVector() const { 78 1929999 : return ncomponents; 79 : } 80 : 81 : inline 82 1255376 : unsigned VectorMultiColvar::getNumberOfQuantities() const { 83 1255376 : return 2 + ncomponents; 84 : } 85 : 86 : } 87 : } 88 : #endif 89 :