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_secondarystructure_SecondaryStructureRMSD_h 23 : #define __PLUMED_secondarystructure_SecondaryStructureRMSD_h 24 : 25 : #include "core/ActionAtomistic.h" 26 : #include "core/ActionWithValue.h" 27 : #include "vesselbase/ActionWithVessel.h" 28 : #include <vector> 29 : 30 : namespace PLMD { 31 : 32 : class SingleDomainRMSD; 33 : 34 : namespace secondarystructure { 35 : 36 : /// Base action for calculating things like AlphRMSD, AntibetaRMSD, etc 37 : 38 : class SecondaryStructureRMSD : 39 : public ActionAtomistic, 40 : public ActionWithValue, 41 : public vesselbase::ActionWithVessel 42 : { 43 : private: 44 : /// Are we operating without periodic boundary conditions 45 : bool nopbc; 46 : /// The type of rmsd we are calculating 47 : std::string alignType; 48 : /// List of all the atoms we require 49 : std::vector<AtomNumber> all_atoms; 50 : /// The atoms involved in each of the secondary structure segments 51 : std::vector< std::vector<unsigned> > colvar_atoms; 52 : /// The list of reference configurations 53 : std::vector<std::unique_ptr<SingleDomainRMSD>> references; 54 : /// Variables for strands cutoff 55 : bool align_strands; 56 : double s_cutoff2; 57 : unsigned align_atom_1, align_atom_2; 58 : bool verbose_output; 59 : /// Tempory variables for getting positions of atoms and applying forces 60 : std::vector<double> forcesToApply; 61 : /// Get the index of an atom 62 : unsigned getAtomIndex( const unsigned& current, const unsigned& iatom ) const ; 63 : protected: 64 : /// Get the atoms in the backbone 65 : void readBackboneAtoms( const std::string& backnames, std::vector<unsigned>& chain_lengths ); 66 : /// Add a set of atoms to calculat ethe rmsd from 67 : void addColvar( const std::vector<unsigned>& newatoms ); 68 : /// Set a reference configuration 69 : void setSecondaryStructure( std::vector<Vector>& structure, double bondlength, double units ); 70 : /// Setup a pair of atoms to use for strands cutoff 71 : void setAtomsFromStrands( const unsigned& atom1, const unsigned& atom2 ); 72 : public: 73 : static void registerKeywords( Keywords& keys ); 74 : explicit SecondaryStructureRMSD(const ActionOptions&); 75 : virtual ~SecondaryStructureRMSD(); 76 : unsigned getNumberOfFunctionsInAction(); 77 : unsigned getNumberOfDerivatives() override; 78 : unsigned getNumberOfQuantities() const override; 79 : void turnOnDerivatives() override; 80 : void calculate() override; 81 : void performTask( const unsigned&, const unsigned&, MultiValue& ) const override; 82 : void apply() override; 83 25 : bool isPeriodic() override { return false; } 84 : }; 85 : 86 : inline 87 5424 : unsigned SecondaryStructureRMSD::getNumberOfQuantities() const { 88 5424 : return 1 + references.size(); 89 : } 90 : 91 : 92 : inline 93 : unsigned SecondaryStructureRMSD::getNumberOfFunctionsInAction() { 94 : return colvar_atoms.size(); 95 : } 96 : 97 : inline 98 5607 : unsigned SecondaryStructureRMSD::getNumberOfDerivatives() { 99 5607 : return 3*getNumberOfAtoms()+9; 100 : } 101 : 102 : inline 103 : unsigned SecondaryStructureRMSD::getAtomIndex( const unsigned& current, const unsigned& iatom ) const { 104 13174500 : return colvar_atoms[current][iatom]; 105 : } 106 : 107 : } 108 : } 109 : 110 : #endif