LCOV - code coverage report
Current view: top level - colvar - Volume.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 20 20 100.0 %
Date: 2018-12-19 07:49:13 Functions: 10 11 90.9 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2011-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 "Colvar.h"
      23             : #include "ActionRegister.h"
      24             : 
      25             : #include <string>
      26             : #include <cmath>
      27             : 
      28             : using namespace std;
      29             : 
      30             : namespace PLMD {
      31             : namespace colvar {
      32             : 
      33             : //+PLUMEDOC COLVAR VOLUME
      34             : /*
      35             : Calculate the volume of the simulation box.
      36             : 
      37             : \par Examples
      38             : 
      39             : The following input tells plumed to print the volume of the system
      40             : \verbatim
      41             : VOLUME LABEL=vol
      42             : PRINT ARG=vol
      43             : \endverbatim
      44             : (See also \ref PRINT).
      45             : 
      46             : */
      47             : //+ENDPLUMEDOC
      48             : 
      49             : 
      50          18 : class Volume : public Colvar {
      51             : 
      52             : public:
      53             :   explicit Volume(const ActionOptions&);
      54             : // active methods:
      55             :   virtual void calculate();
      56             : /// Register all the keywords for this action
      57             :   static void registerKeywords( Keywords& keys );
      58             : };
      59             : 
      60        2532 : PLUMED_REGISTER_ACTION(Volume,"VOLUME")
      61             : 
      62           9 : Volume::Volume(const ActionOptions&ao):
      63           9 :   PLUMED_COLVAR_INIT(ao)
      64             : {
      65           9 :   std::vector<AtomNumber> atoms;
      66           9 :   checkRead();
      67             : 
      68           9 :   addValueWithDerivatives(); setNotPeriodic();
      69           9 :   requestAtoms(atoms);
      70           9 : }
      71             : 
      72          10 : void Volume::registerKeywords( Keywords& keys ) {
      73          10 :   Action::registerKeywords( keys );
      74          10 :   ActionWithValue::registerKeywords( keys );
      75          10 :   ActionAtomistic::registerKeywords( keys );
      76          10 : }
      77             : 
      78             : 
      79             : // calculator
      80         148 : void Volume::calculate() {
      81             : 
      82         148 :   double v=getBox().determinant();
      83         148 :   setBoxDerivatives(-v*Tensor::identity());
      84         148 :   setValue         (v);
      85         148 : }
      86             : 
      87             : }
      88        2523 : }
      89             : 
      90             : 
      91             : 

Generated by: LCOV version 1.13