Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2016-2018 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 "core/ActionRegister.h" 23 : #include "core/ActionShortcut.h" 24 : #include "CoordinationNumbers.h" 25 : #include "multicolvar/MultiColvarShortcuts.h" 26 : 27 : //+PLUMEDOC MCOLVAR TETRA_ANGULAR 28 : /* 29 : Calculate the angular tetra CV 30 : 31 : \par Examples 32 : 33 : */ 34 : //+ENDPLUMEDOC 35 : 36 : namespace PLMD { 37 : namespace symfunc { 38 : 39 : class AngularTetra : public ActionShortcut { 40 : public: 41 : static void registerKeywords( Keywords& keys ); 42 : explicit AngularTetra(const ActionOptions&ao); 43 : }; 44 : 45 : PLUMED_REGISTER_ACTION(AngularTetra,"TETRA_ANGULAR") 46 : 47 3 : void AngularTetra::registerKeywords( Keywords& keys ) { 48 3 : CoordinationNumbers::shortcutKeywords( keys ); 49 6 : keys.addFlag("NOPBC",false,"ignore the periodic boundary conditions when calculating distances"); 50 6 : keys.add("compulsory","CUTOFF","-1","ignore distances that have a value larger than this cutoff"); 51 6 : keys.setValueDescription("vector","the value of the angular tetehedrality parameter for each of the input atoms"); 52 15 : keys.remove("NN"); keys.remove("MM"); keys.remove("D_0"); keys.remove("R_0"); keys.remove("SWITCH"); 53 6 : keys.needsAction("DISTANCE_MATRIX"); keys.needsAction("NEIGHBORS"); 54 6 : keys.needsAction("GSYMFUNC_THREEBODY"); keys.needsAction("CUSTOM"); 55 3 : } 56 : 57 1 : AngularTetra::AngularTetra( const ActionOptions& ao): 58 : Action(ao), 59 1 : ActionShortcut(ao) 60 : { 61 1 : bool nopbc; parseFlag("NOPBC",nopbc); 62 1 : std::string pbcstr=""; if( nopbc ) pbcstr = " NOPBC"; 63 : // Read species input and create the matrix 64 3 : std::string sp_str, rcut; parse("SPECIES",sp_str); parse("CUTOFF",rcut); 65 1 : if( sp_str.length()>0 ) { 66 2 : readInputLine( getShortcutLabel() + "_mat: DISTANCE_MATRIX COMPONENTS GROUP=" + sp_str + " CUTOFF=" + rcut + pbcstr ); 67 : } else { 68 0 : std::string specA, specB; parse("SPECIESA",specA); parse("SPECIESB",specB); 69 0 : if( specA.length()==0 ) error("missing input atoms"); 70 0 : if( specB.length()==0 ) error("missing SPECIESB keyword"); 71 0 : readInputLine( getShortcutLabel() + "_mat: DISTANCE_MATRIX COMPONENTS GROUPA=" + specA + " GROUPB=" + specB + " CUTOFF=" + rcut + pbcstr ); 72 : } 73 : // Get the neighbors matrix 74 2 : readInputLine( getShortcutLabel() + "_neigh: NEIGHBORS ARG=" + getShortcutLabel() + "_mat.w NLOWEST=4"); 75 : // Now construct the symmetry function (sum of cos(a) + 1/3) 76 3 : readInputLine( getShortcutLabel() + "_g8: GSYMFUNC_THREEBODY WEIGHT=" + getShortcutLabel() + "_neigh " + 77 3 : "ARG=" + getShortcutLabel() + "_mat.x," + getShortcutLabel() + "_mat.y," + getShortcutLabel() + "_mat.z FUNCTION1={FUNC=(cos(ajik)+1/3)^2 LABEL=g8}"); 78 : // Now evaluate the actual per atom CV 79 2 : readInputLine( getShortcutLabel() + ": CUSTOM ARG=" + getShortcutLabel() + "_g8.g8 FUNC=(1-(3*x/8)) PERIODIC=NO"); 80 : // And get the things to do with the quantities we have computed 81 1 : std::map<std::string,std::string> keymap; multicolvar::MultiColvarShortcuts::readShortcutKeywords( keymap, this ); 82 2 : multicolvar::MultiColvarShortcuts::expandFunctions( getShortcutLabel(), getShortcutLabel(), "", keymap, this ); 83 1 : } 84 : 85 : } 86 : }