Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2012-2020 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_volumes_ActionVolume_h 23 : #define __PLUMED_volumes_ActionVolume_h 24 : 25 : #include "tools/HistogramBead.h" 26 : #include "core/ActionWithVector.h" 27 : 28 : namespace PLMD { 29 : namespace volumes { 30 : 31 : /** 32 : \ingroup INHERIT 33 : This is the abstract base class to use for implementing a new way of defining a particular region of the simulation 34 : box. You can use this to calculate the number of atoms inside that part or the average value of a quantity like the 35 : coordination number inside that part of the cell. 36 : */ 37 : 38 : class ActionVolume : public ActionWithVector { 39 : private: 40 : /// The value of sigma 41 : double sigma; 42 : /// Are we interested in the area outside the colvar 43 : bool not_in; 44 : /// The kernel type for this histogram 45 : std::string kerneltype; 46 : protected: 47 : double getSigma() const ; 48 : std::string getKernelType() const ; 49 : Vector getPosition( const unsigned& index ) const ; 50 : void requestAtoms( const std::vector<AtomNumber> & a ); 51 : public: 52 : static void registerKeywords( Keywords& keys ); 53 : explicit ActionVolume(const ActionOptions&); 54 : unsigned getNumberOfDerivatives(); 55 : void areAllTasksRequired( std::vector<ActionWithVector*>& task_reducing_actions ) override; 56 : void getNumberOfTasks( unsigned& ntasks ) override ; 57 : int checkTaskStatus( const unsigned& taskno, int& flag ) const override; 58 : void calculate(); 59 : virtual void setupRegions() = 0; 60 : bool isInSubChain( unsigned& nder ) override ; 61 : void performTask( const unsigned&, MultiValue& ) const ; 62 : virtual double calculateNumberInside( const Vector& cpos, Vector& derivatives, Tensor& vir, std::vector<Vector>& refders ) const=0; 63 : }; 64 : 65 : inline 66 1765 : unsigned ActionVolume::getNumberOfDerivatives() { 67 1765 : return 3*getNumberOfAtoms()+9; 68 : } 69 : 70 : inline 71 : double ActionVolume::getSigma() const { 72 194172 : return sigma; 73 : } 74 : 75 : inline 76 : std::string ActionVolume::getKernelType() const { 77 100400 : return kerneltype; 78 : } 79 : 80 : inline 81 547218 : Vector ActionVolume::getPosition( const unsigned& index ) const { 82 547218 : if( getConstPntrToComponent(0)->getRank()==0 ) { 83 12480 : return ActionAtomistic::getPosition( 1 + index ); 84 : } 85 534738 : return ActionAtomistic::getPosition( getConstPntrToComponent(0)->getShape()[0] + index ); 86 : } 87 : 88 : } 89 : } 90 : #endif