LCOV - code coverage report
Current view: top level - clusters - ClusterWithSurface.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 22 22 100.0 %
Date: 2024-10-18 13:59:31 Functions: 2 3 66.7 %

          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           8 :   keys.setValueDescription("vector","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           8 :   keys.needsAction("CLUSTER_WEIGHTS"); keys.needsAction("CONTACT_MATRIX");
      54           8 :   keys.needsAction("OUTER_PRODUCT"); keys.needsAction("CUSTOM");
      55           4 :   keys.needsAction("DFSCLUSTERING");
      56           4 : }
      57             : 
      58           2 : ClusterWithSurface::ClusterWithSurface(const ActionOptions& ao):
      59             :   Action(ao),
      60           2 :   ActionShortcut(ao)
      61             : {
      62             :   // Read atoms for contact matrix
      63           4 :   std::string atdata; parse("ATOMS",atdata);
      64             :   // Read rcut input
      65           2 :   std::string rcut_surf_str; parse("RCUT_SURF",rcut_surf_str);
      66             :   // Create a cluster weights object
      67           4 :   readInputLine( getShortcutLabel() + "_wnosurf: CLUSTER_WEIGHTS " + convertInputLineToString() );
      68             :   // Now create a contact matrix
      69           4 :   readInputLine( getShortcutLabel() + "_cmat: CONTACT_MATRIX GROUP=" + atdata + " SWITCH={" + rcut_surf_str +"}" );
      70             :   // Now create a custom matrix
      71           4 :   readInputLine( getShortcutLabel() + "_cwmat: OUTER_PRODUCT ARG=" + getShortcutLabel() + "_wnosurf," + getShortcutLabel() + "_wnosurf FUNC=max");
      72             :   // Product of matrices
      73           4 :   readInputLine( getShortcutLabel() + "_pmat: CUSTOM ARG=" + getShortcutLabel() + "_cmat," + getShortcutLabel() + "_cwmat FUNC=x*y PERIODIC=NO");
      74             :   // DFS clustering
      75           4 :   readInputLine( getShortcutLabel() + "_clust: DFSCLUSTERING ARG=" + getShortcutLabel() + "_pmat");
      76             :   // And final cluster weights
      77           4 :   readInputLine( getShortcutLabel() + ": CLUSTER_WEIGHTS CLUSTERS=" + getShortcutLabel() + "_clust CLUSTER=1");
      78           2 : }
      79             : 
      80             : }
      81             : }

Generated by: LCOV version 1.16