Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2017-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 : #include "OrientationSphere.h" 23 : #include "core/ActionRegister.h" 24 : 25 : //+PLUMEDOC MCOLVARF POLYMER_ANGLES 26 : /* 27 : Calculate a function to investigate the relative orientations of polymer angles 28 : 29 : This CV takes the vectors calculated by a \ref PLANES action as input and computes the following function 30 : of the relative angles, \f$\theta\f$, between the vectors that are normal to the pairs of input vectors: 31 : 32 : \f[ 33 : s = \frac{ 3 \cos^2 \theta - 1 }{ 2 } 34 : \f] 35 : 36 : This average of this quantity over all the vectors in the first coordination sphere around each of the PLANES specified 37 : is then calculated. 38 : 39 : \par Examples 40 : 41 : The example below calculates a set of vectors using the \ref PLANES action. The average number for the function \f$s\f$ 42 : defined above is then computed over the first coordination sphere of each of the centers of mass of the molecules that were 43 : used to define the planes. Finally the average of these quantities is computed an printed to a file. 44 : 45 : \plumedfile 46 : PLANES ... 47 : MOL1=9,10,11 48 : MOL2=89,90,91 49 : MOL3=473,474,475 50 : MOL4=1161,1162,1163 51 : MOL5=1521,1522,1523 52 : MOL6=1593,1594,1595 53 : MOL7=1601,1602,1603 54 : MOL8=2201,2202,2203 55 : LABEL=m3 56 : ... PLANES 57 : 58 : s3: POLYMER_ANGLES SPECIES=m3 LOWMEM SWITCH={RATIONAL R_0=0.6} MEAN 59 : PRINT ARG=s3.mean FILE=colvar 60 : \endplumedfile 61 : 62 : */ 63 : //+ENDPLUMEDOC 64 : 65 : namespace PLMD { 66 : namespace crystallization { 67 : 68 : class PolymerAngles : public OrientationSphere { 69 : public: 70 : static void registerKeywords( Keywords& keys ); 71 : explicit PolymerAngles(const ActionOptions& ao); 72 : double computeVectorFunction( const Vector& conn, const std::vector<double>& vec1, const std::vector<double>& vec2, 73 : Vector& dconn, std::vector<double>& dvec1, std::vector<double>& dvec2 ) const override; 74 : }; 75 : 76 10421 : PLUMED_REGISTER_ACTION(PolymerAngles,"POLYMER_ANGLES") 77 : 78 2 : void PolymerAngles::registerKeywords( Keywords& keys ) { 79 2 : OrientationSphere::registerKeywords(keys); 80 2 : } 81 : 82 1 : PolymerAngles::PolymerAngles(const ActionOptions& ao): 83 : Action(ao), 84 1 : OrientationSphere(ao) 85 : { 86 1 : if( mybasemulticolvars.size()==0 ) error("SMAC must take multicolvar as input"); 87 2 : for(unsigned i=0; i<mybasemulticolvars.size(); ++i) { 88 1 : if( (mybasemulticolvars[i]->getNumberOfQuantities()-2)%3!=0 ) error("POLYMER_ANGLES is only possible with three dimensional vectors"); 89 : } 90 1 : } 91 : 92 616 : double PolymerAngles::computeVectorFunction( const Vector& conn, const std::vector<double>& vec1, const std::vector<double>& vec2, 93 : Vector& dconn, std::vector<double>& dvec1, std::vector<double>& dvec2 ) const { 94 : 95 616 : plumed_assert( (vec1.size()-2)==3 ); 96 2464 : double dot = 0; for(unsigned k=0; k<3; ++k) dot += vec1[2+k]*vec2[2+k]; 97 2464 : double ans = 1.5*dot*dot - 0.5; for(unsigned k=0; k<3; ++k) { dvec1[2+k]=3*dot*vec2[2+k]; dvec2[2+k]=3*dot*vec1[2+k]; } 98 616 : return ans; 99 : } 100 : 101 : } 102 : }