LCOV - code coverage report
Current view: top level - multicolvar - Density.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 19 26 73.1 %
Date: 2018-12-19 07:49:13 Functions: 12 16 75.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-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 "MultiColvar.h"
      23             : #include "core/ActionRegister.h"
      24             : 
      25             : #include <string>
      26             : #include <cmath>
      27             : 
      28             : using namespace std;
      29             : 
      30             : namespace PLMD {
      31             : namespace multicolvar {
      32             : 
      33             : //+PLUMEDOC MCOLVAR DENSITY
      34             : /*
      35             : Calculate functions of the density of atoms as a function of the box.  This allows one to calculate
      36             : the number of atoms in half the box.
      37             : 
      38             : \par Examples
      39             : 
      40             : The following example calculates the number of atoms in one half of the simulation box.
      41             : 
      42             : \verbatim
      43             : DENSITY SPECIES=1-100 LABEL=d
      44             : AROUND ARG=d XLOWER=0.0 XUPPER=0.5 LABEL=d1
      45             : PRINT ARG=d1.* FILE=colvar1 FMT=%8.4f
      46             : \endverbatim
      47             : 
      48             : */
      49             : //+ENDPLUMEDOC
      50             : 
      51             : 
      52          22 : class Density : public MultiColvar {
      53             : public:
      54             :   static void registerKeywords( Keywords& keys );
      55             :   explicit Density(const ActionOptions&);
      56             : // active methods:
      57             :   virtual double compute( const unsigned& tindex, AtomValuePack& myatoms ) const ;
      58             :   /// Returns the number of coordinates of the field
      59           4 :   bool isPeriodic() { return false; }
      60      196434 :   bool isDensity() const { return true; }
      61           0 :   bool hasDifferentiableOrientation() const { return true; }
      62             : //  void addOrientationDerivativesToBase( const unsigned& iatom, const unsigned& jstore, const unsigned& base_cv_no,
      63             : //                                        const std::vector<double>& weight, MultiColvarFunction* func ){}
      64             :   void getIndexList( const unsigned& ntotal, const unsigned& jstore, const unsigned& maxder, std::vector<unsigned>& indices );
      65             : //  unsigned getNumberOfQuantities();
      66             :   void getValueForTask( const unsigned& iatom, std::vector<double>& vals );
      67             : };
      68             : 
      69        2534 : PLUMED_REGISTER_ACTION(Density,"DENSITY")
      70             : 
      71          12 : void Density::registerKeywords( Keywords& keys ) {
      72          12 :   MultiColvar::registerKeywords( keys );
      73          12 :   keys.use("SPECIES");
      74          12 : }
      75             : 
      76          11 : Density::Density(const ActionOptions&ao):
      77          11 :   PLUMED_MULTICOLVAR_INIT(ao)
      78             : {
      79          11 :   std::vector<AtomNumber> all_atoms; parseMultiColvarAtomList("SPECIES", -1, all_atoms);
      80          11 :   ablocks.resize(1); ablocks[0].resize( atom_lab.size() );
      81          11 :   for(unsigned i=0; i<atom_lab.size(); ++i) { addTaskToList(i); ablocks[0][i]=i; }
      82          11 :   setupMultiColvarBase( all_atoms );
      83             :   // And check everything has been read in correctly
      84          11 :   checkRead();
      85          11 : }
      86             : 
      87       15790 : double Density::compute( const unsigned& tindex, AtomValuePack& myvals ) const {
      88       15790 :   return 1.0;
      89             : }
      90             : 
      91           0 : void Density::getIndexList( const unsigned& ntotal, const unsigned& jstore, const unsigned& maxder, std::vector<unsigned>& indices ) {
      92           0 :   indices[jstore]=0;
      93           0 : }
      94             : 
      95             : // unsigned Density::getNumberOfQuantities(){
      96             : //    return 2;
      97             : // }
      98             : 
      99           0 : void Density::getValueForTask( const unsigned& iatom, std::vector<double>& vals ) {
     100           0 :   plumed_dbg_assert( vals.size()==2 ); vals[0]=vals[1]=1.0;
     101           0 : }
     102             : 
     103             : }
     104        2523 : }
     105             : 

Generated by: LCOV version 1.13