Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2014-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 : #include "core/ActionShortcut.h" 23 : #include "core/ActionRegister.h" 24 : #include "multicolvar/MultiColvarShortcuts.h" 25 : 26 : //+PLUMEDOC CONCOMP CLUSTER_PROPERTIES 27 : /* 28 : Calculate properties of the distribution of some quantities that are part of a connected component 29 : 30 : This collective variable was developed for looking at nucleation phenomena, where you are 31 : interested in using studying the behavior of atoms in small aggregates or nuclei. In these sorts of 32 : problems you might be interested in the degree the atoms in a nucleus have adopted their crystalline 33 : structure or (in the case of heterogeneous nucleation of a solute from a solvent) you might be 34 : interested in how many atoms are present in the largest cluster \cite tribello-clustering. 35 : 36 : \par Examples 37 : 38 : The input below calculates the coordination numbers of atoms 1-100 and then computes the an adjacency 39 : matrix whose elements measures whether atoms \f$i\f$ and \f$j\f$ are within 0.55 nm of each other. The action 40 : labelled dfs then treats the elements of this matrix as zero or ones and thus thinks of the matrix as defining 41 : a graph. This dfs action then finds the largest connected component in this graph. The sum of the coordination 42 : numbers for the atoms in this largest connected component are then computed and this quantity is output to a colvar 43 : file. The way this input can be used is described in detail in \cite tribello-clustering. 44 : 45 : \plumedfile 46 : lq: COORDINATIONNUMBER SPECIES=1-100 SWITCH={CUBIC D_0=0.45 D_MAX=0.55} LOWMEM 47 : cm: CONTACT_MATRIX ATOMS=lq SWITCH={CUBIC D_0=0.45 D_MAX=0.55} 48 : dfs: DFSCLUSTERING MATRIX=cm 49 : clust1: CLUSTER_PROPERTIES CLUSTERS=dfs CLUSTER=1 SUM 50 : PRINT ARG=clust1.* FILE=colvar 51 : \endplumedfile 52 : 53 : */ 54 : //+ENDPLUMEDOC 55 : 56 : namespace PLMD { 57 : namespace clusters { 58 : 59 : class ClusterProperties : public ActionShortcut { 60 : public: 61 : static void registerKeywords(Keywords& keys); 62 : explicit ClusterProperties(const ActionOptions&); 63 : }; 64 : 65 : PLUMED_REGISTER_ACTION(ClusterProperties,"CLUSTER_PROPERTIES") 66 : 67 54 : void ClusterProperties::registerKeywords(Keywords& keys) { 68 54 : ActionShortcut::registerKeywords( keys ); 69 108 : keys.add("compulsory","ARG","calculate the sum of the arguments calculated by this action for the cluster"); 70 108 : keys.add("compulsory","CLUSTERS","the label of the action that does the clustering"); 71 108 : keys.add("compulsory","CLUSTER","1","which cluster would you like to look at 1 is the largest cluster, 2 is the second largest, 3 is the the third largest and so on."); 72 108 : keys.setValueDescription("vector","a vector that is one if the atom is part of the cluster or interest and zero otherwise"); 73 54 : multicolvar::MultiColvarShortcuts::shortcutKeywords( keys ); 74 54 : keys.needsAction("CLUSTER_WEIGHTS"); 75 54 : } 76 : 77 20 : ClusterProperties::ClusterProperties(const ActionOptions& ao): 78 : Action(ao), 79 20 : ActionShortcut(ao) 80 : { 81 : // Read the property we are interested in 82 40 : std::string argstr; parse("ARG",argstr); 83 : // Read in the shortcut keywords 84 20 : std::map<std::string,std::string> keymap; multicolvar::MultiColvarShortcuts::readShortcutKeywords( keymap, this ); 85 : // Create a cluster weights object 86 40 : readInputLine( getShortcutLabel() + ": CLUSTER_WEIGHTS " + convertInputLineToString() ); 87 : // Now do the multicolvar bit 88 20 : multicolvar::MultiColvarShortcuts::expandFunctions( getShortcutLabel(), argstr, getShortcutLabel(), keymap, this ); 89 20 : } 90 : 91 : } 92 : }