LCOV - code coverage report
Current view: top level - clusters - OutputCluster.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 18 18 100.0 %
Date: 2024-10-18 14:00:25 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2015-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 "core/ActionShortcut.h"
      23             : #include "core/ActionRegister.h"
      24             : 
      25             : //+PLUMEDOC CONCOMP OUTPUT_CLUSTER
      26             : /*
      27             : Output the indices of the atoms in one of the clusters identified by a clustering object
      28             : 
      29             : This action provides one way of getting output from a \ref DFSCLUSTERING calculation.
      30             : The output in question here is either
      31             : 
      32             : - a file that contains a list of the atom indices that form part of one of the clusters that was identified using \ref DFSCLUSTERING
      33             : - an xyz file containing the positions of the atoms in one of the the clusters that was identified using \ref DFSCLUSTERING
      34             : 
      35             : Notice also that if you choose to output an xyz file you can ask PLUMED to try to reconstruct the cluster
      36             : taking the periodic boundary conditions into account by using the MAKE_WHOLE flag.
      37             : 
      38             : \par Examples
      39             : 
      40             : The input shown below identifies those atoms with a coordination number less than 13
      41             : and then constructs a contact matrix that describes the connectivity between the atoms
      42             : that satisfy this criteria.  The DFS algorithm is then used to find the connected components
      43             : in this matrix and the indices of the atoms in the largest connected component are then output
      44             : to a file.
      45             : 
      46             : \plumedfile
      47             : c1: COORDINATIONNUMBER SPECIES=1-1996 SWITCH={CUBIC D_0=0.34 D_MAX=0.38}
      48             : cf: MFILTER_LESS DATA=c1 SWITCH={CUBIC D_0=13 D_MAX=13.5}
      49             : mat: CONTACT_MATRIX ATOMS=cf SWITCH={CUBIC D_0=0.34 D_MAX=0.38}
      50             : dfs: DFSCLUSTERING MATRIX=mat
      51             : OUTPUT_CLUSTER CLUSTERS=dfs CLUSTER=1 FILE=dfs.dat
      52             : \endplumedfile
      53             : 
      54             : */
      55             : //+ENDPLUMEDOC
      56             : 
      57             : namespace PLMD {
      58             : namespace clusters {
      59             : 
      60             : class OutputCluster : public ActionShortcut {
      61             : public:
      62             :   static void registerKeywords( Keywords& keys );
      63             :   explicit OutputCluster(const ActionOptions&);
      64             : };
      65             : 
      66             : PLUMED_REGISTER_ACTION(OutputCluster,"OUTPUT_CLUSTER")
      67             : 
      68           4 : void OutputCluster::registerKeywords( Keywords& keys ) {
      69           4 :   ActionShortcut::registerKeywords( keys );
      70           8 :   keys.add("compulsory","ATOMS","the atoms for which clustering were performed");
      71           8 :   keys.add("compulsory","CLUSTERS","the action that performed the clustering");
      72           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");
      73           8 :   keys.add("compulsory","STRIDE","1","the frequency with which you would like to output the atoms in the cluster");
      74           8 :   keys.add("compulsory","FILE","the name of the file on which to output the details of the cluster");
      75           8 :   keys.remove("HAS_VALUES"); keys.needsAction("PRINT_NDX");
      76           4 : }
      77             : 
      78           2 : OutputCluster::OutputCluster(const ActionOptions& ao):
      79             :   Action(ao),
      80           2 :   ActionShortcut(ao)
      81             : {
      82           4 :   std::string id; parse("CLUSTER",id);
      83           4 :   std::string stride; parse("STRIDE",stride);
      84           4 :   std::string clusters; parse("CLUSTERS",clusters);
      85           4 :   std::string filename; parse("FILE",filename);
      86           2 :   std::string atoms; parse("ATOMS",atoms);
      87           4 :   readInputLine("PRINT_NDX ATOMS=" + atoms + " ARG=" + clusters + " FILE=" + filename + " STRIDE=" + stride + " LESS_THAN_OR_EQUAL=" + id + " GREATER_THAN_OR_EQUAL=" + id );
      88           2 : }
      89             : 
      90             : }
      91             : }
      92             : 
      93             : 

Generated by: LCOV version 1.16