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

          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          15 :   keys.remove("NN"); keys.remove("MM"); keys.remove("D_0"); keys.remove("R_0"); keys.remove("SWITCH");
      52           6 :   keys.needsAction("DISTANCE_MATRIX"); keys.needsAction("NEIGHBORS");
      53           6 :   keys.needsAction("GSYMFUNC_THREEBODY"); keys.needsAction("CUSTOM");
      54           3 : }
      55             : 
      56           1 : AngularTetra::AngularTetra( const ActionOptions& ao):
      57             :   Action(ao),
      58           1 :   ActionShortcut(ao)
      59             : {
      60           1 :   bool nopbc; parseFlag("NOPBC",nopbc);
      61           1 :   std::string pbcstr=""; if( nopbc ) pbcstr = " NOPBC";
      62             :   // Read species input and create the matrix
      63           3 :   std::string sp_str, rcut; parse("SPECIES",sp_str); parse("CUTOFF",rcut);
      64           1 :   if( sp_str.length()>0 ) {
      65           2 :     readInputLine( getShortcutLabel() + "_mat: DISTANCE_MATRIX COMPONENTS GROUP=" + sp_str + " CUTOFF=" + rcut + pbcstr );
      66             :   } else {
      67           0 :     std::string specA, specB; parse("SPECIESA",specA); parse("SPECIESB",specB);
      68           0 :     if( specA.length()==0 ) error("missing input atoms");
      69           0 :     if( specB.length()==0 ) error("missing SPECIESB keyword");
      70           0 :     readInputLine( getShortcutLabel() + "_mat: DISTANCE_MATRIX COMPONENTS GROUPA=" + specA + " GROUPB=" + specB + " CUTOFF=" + rcut + pbcstr );
      71             :   }
      72             :   // Get the neighbors matrix
      73           2 :   readInputLine( getShortcutLabel() + "_neigh: NEIGHBORS ARG=" + getShortcutLabel() + "_mat.w NLOWEST=4");
      74             :   // Now construct the symmetry function (sum of cos(a) + 1/3)
      75           3 :   readInputLine( getShortcutLabel() + "_g8: GSYMFUNC_THREEBODY WEIGHT=" + getShortcutLabel() + "_neigh " +
      76           3 :                  "ARG=" + getShortcutLabel() + "_mat.x," + getShortcutLabel() + "_mat.y," + getShortcutLabel() + "_mat.z FUNCTION1={FUNC=(cos(ajik)+1/3)^2 LABEL=g8}");
      77             :   // Now evaluate the actual per atom CV
      78           2 :   readInputLine( getShortcutLabel() + ": CUSTOM ARG=" + getShortcutLabel() + "_g8.g8 FUNC=(1-(3*x/8)) PERIODIC=NO");
      79             :   // And get the things to do with the quantities we have computed
      80           1 :   std::map<std::string,std::string> keymap; multicolvar::MultiColvarShortcuts::readShortcutKeywords( keymap, this );
      81           2 :   multicolvar::MultiColvarShortcuts::expandFunctions( getShortcutLabel(), getShortcutLabel(), "", keymap, this );
      82           1 : }
      83             : 
      84             : }
      85             : }

Generated by: LCOV version 1.16