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

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2014-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 "Direction.h"
      23             : #include "MetricRegister.h"
      24             : 
      25             : namespace PLMD {
      26             : 
      27        2533 : PLUMED_REGISTER_METRIC(Direction,"DIRECTION")
      28             : 
      29          10 : Direction::Direction( const ReferenceConfigurationOptions& ro ):
      30             :   ReferenceConfiguration(ro),
      31             :   ReferenceAtoms(ro),
      32          10 :   ReferenceArguments(ro)
      33             : {
      34          10 : }
      35             : 
      36           8 : void Direction::read( const PDB& pdb ) {
      37           8 :   readAtomsFromPDB( pdb );
      38           8 :   readArgumentsFromPDB( pdb );
      39           8 : }
      40             : 
      41           4 : void Direction::setDirection( const std::vector<Vector>& conf, const std::vector<double>& args ) {
      42           4 :   std::vector<double> sigma( args.size(), 1.0 ); setReferenceArguments( args, sigma );
      43             : 
      44           4 :   reference_atoms.resize( conf.size() ); align.resize( conf.size() );
      45           4 :   displace.resize( conf.size() ); atom_der_index.resize( conf.size() );
      46           4 :   for(unsigned i=0; i<conf.size(); ++i) { align[i]=1.0; displace[i]=1.0; atom_der_index[i]=i; reference_atoms[i]=conf[i]; }
      47           4 : }
      48             : 
      49           8 : double Direction::calc( const std::vector<Vector>& pos, const Pbc& pbc, const std::vector<Value*>& vals, const std::vector<double>& args,
      50             :                         ReferenceValuePack& myder, const bool& squared ) const {
      51           8 :   plumed_assert( squared );
      52           8 :   for(unsigned i=0; i<getNumberOfReferenceArguments(); ++i) myder.addArgumentDerivatives( i, -2.*getReferenceArgument(i) );
      53           8 :   for(unsigned i=0; i<getNumberOfAtoms(); ++i) myder.getAtomsDisplacementVector()[i]=getReferencePosition(i);
      54             : 
      55           8 :   return 0.0;
      56             : }
      57             : 
      58        2523 : }

Generated by: LCOV version 1.13