Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2015-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 : 25 : //+PLUMEDOC CONCOMP CLUSTER_WITHSURFACE 26 : /* 27 : Determine the atoms that are within a certain cutoff of the atoms in a cluster 28 : 29 : \par Examples 30 : 31 : 32 : */ 33 : //+ENDPLUMEDOC 34 : 35 : namespace PLMD { 36 : namespace clusters { 37 : 38 : class ClusterWithSurface : public ActionShortcut { 39 : public: 40 : static void registerKeywords(Keywords& keys); 41 : explicit ClusterWithSurface(const ActionOptions&); 42 : }; 43 : 44 : PLUMED_REGISTER_ACTION(ClusterWithSurface,"CLUSTER_WITHSURFACE") 45 : 46 4 : void ClusterWithSurface::registerKeywords(Keywords& keys) { 47 4 : ActionShortcut::registerKeywords(keys); 48 8 : keys.add("optional","RCUT_SURF",""); 49 8 : keys.add("compulsory","ATOMS","the atoms that were used to calculate the matrix that was clustered"); 50 8 : keys.add("compulsory","CLUSTERS","the label of the action that does the clustering"); 51 8 : 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."); 52 4 : keys.setValueDescription("a vector that is one for those atoms that are within the cluster or that are within a cetain cutoff of one of the atoms in the cluster and zero otherwise"); 53 4 : keys.needsAction("CLUSTER_WEIGHTS"); 54 4 : keys.needsAction("CONTACT_MATRIX"); 55 4 : keys.needsAction("OUTER_PRODUCT"); 56 4 : keys.needsAction("CUSTOM"); 57 4 : keys.needsAction("DFSCLUSTERING"); 58 4 : } 59 : 60 2 : ClusterWithSurface::ClusterWithSurface(const ActionOptions& ao): 61 : Action(ao), 62 2 : ActionShortcut(ao) { 63 : // Read atoms for contact matrix 64 : std::string atdata; 65 4 : parse("ATOMS",atdata); 66 : // Read rcut input 67 : std::string rcut_surf_str; 68 2 : parse("RCUT_SURF",rcut_surf_str); 69 : // Create a cluster weights object 70 4 : readInputLine( getShortcutLabel() + "_wnosurf: CLUSTER_WEIGHTS " + convertInputLineToString() ); 71 : // Now create a contact matrix 72 4 : readInputLine( getShortcutLabel() + "_cmat: CONTACT_MATRIX GROUP=" + atdata + " SWITCH={" + rcut_surf_str +"}" ); 73 : // Now create a custom matrix 74 4 : readInputLine( getShortcutLabel() + "_cwmat: OUTER_PRODUCT ARG=" + getShortcutLabel() + "_wnosurf," + getShortcutLabel() + "_wnosurf FUNC=max"); 75 : // Product of matrices 76 4 : readInputLine( getShortcutLabel() + "_pmat: CUSTOM ARG=" + getShortcutLabel() + "_cmat," + getShortcutLabel() + "_cwmat FUNC=x*y PERIODIC=NO"); 77 : // DFS clustering 78 4 : readInputLine( getShortcutLabel() + "_clust: DFSCLUSTERING ARG=" + getShortcutLabel() + "_pmat"); 79 : // And final cluster weights 80 4 : readInputLine( getShortcutLabel() + ": CLUSTER_WEIGHTS CLUSTERS=" + getShortcutLabel() + "_clust CLUSTER=1"); 81 2 : } 82 : 83 : } 84 : }