LCOV - code coverage report
Current view: top level - reference - Direction.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 39 43 90.7 %
Date: 2026-03-30 13:16:06 Functions: 10 12 83.3 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2014-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 "Direction.h"
      23             : #include "MetricRegister.h"
      24             : 
      25             : namespace PLMD {
      26             : 
      27       13805 : PLUMED_REGISTER_METRIC(Direction,"DIRECTION")
      28             : 
      29         219 : Direction::Direction( const ReferenceConfigurationOptions& ro ):
      30             :   ReferenceConfiguration(ro),
      31             :   ReferenceAtoms(ro),
      32             :   ReferenceArguments(ro),
      33         219 :   normalized(false) {
      34         219 : }
      35             : 
      36         219 : void Direction::read( const PDB& pdb ) {
      37         219 :   readAtomsFromPDB( pdb, true );
      38         219 :   readArgumentsFromPDB( pdb );
      39         219 : }
      40             : 
      41         494 : void Direction::setDirection( const std::vector<Vector>& conf, const std::vector<double>& args ) {
      42         494 :   std::vector<double> sigma( args.size(), 1.0 );
      43         494 :   setReferenceArguments( args, sigma );
      44             : 
      45         494 :   reference_atoms.resize( conf.size() );
      46         494 :   align.resize( conf.size() );
      47         494 :   displace.resize( conf.size() );
      48         494 :   atom_der_index.resize( conf.size() );
      49         715 :   for(unsigned i=0; i<conf.size(); ++i) {
      50         221 :     align[i]=1.0;
      51         221 :     displace[i]=1.0;
      52         221 :     atom_der_index[i]=i;
      53         221 :     reference_atoms[i]=conf[i];
      54             :   }
      55         494 : }
      56             : 
      57         303 : void Direction::addDirection( const double& weight, const Direction& dir ) {
      58             :   plumed_dbg_assert( dir.getNumberOfReferenceArguments()==getNumberOfReferenceArguments() && dir.reference_atoms.size()==reference_atoms.size() );
      59         909 :   for(unsigned i=0; i<reference_args.size(); ++i) {
      60         606 :     reference_args[i] += weight*dir.reference_args[i];
      61             :   }
      62         303 :   for(unsigned i=0; i<reference_atoms.size(); ++i) {
      63           0 :     reference_atoms[i] += weight*reference_atoms.size()*dir.reference_atoms[i];
      64             :   }
      65         303 : }
      66             : 
      67          12 : void Direction::zeroDirection() {
      68          32 :   for(unsigned i=0; i<reference_args.size(); ++i) {
      69          20 :     reference_args[i] = 0.;
      70             :   }
      71          38 :   for(unsigned i=0; i<reference_atoms.size(); ++i) {
      72          26 :     reference_atoms[i].zero();
      73             :   }
      74          12 : }
      75             : 
      76           0 : double Direction::calc( const std::vector<Vector>& pos, const Pbc& pbc, const std::vector<Value*>& vals, const std::vector<double>& args,
      77             :                         ReferenceValuePack& myder, const bool& squared ) const {
      78           0 :   plumed_merror("You should never be calling calc for a direction");
      79             : }
      80             : 
      81          10 : void Direction::extractArgumentDisplacement( const std::vector<Value*>& vals, const std::vector<double>& arg, std::vector<double>& dirout ) const {
      82          10 :   for(unsigned i=0; i<getNumberOfReferenceArguments(); ++i) {
      83           0 :     dirout[i]=getReferenceArgument(i);
      84             :   }
      85          10 : }
      86             : 
      87          10 : void Direction::extractAtomicDisplacement( const std::vector<Vector>& pos, std::vector<Vector>& dirout ) const {
      88          80 :   for(unsigned i=0; i<getNumberOfAtoms(); ++i) {
      89          70 :     dirout[i]=getReferencePosition(i);
      90             :   }
      91          10 : }
      92             : 
      93             : }

Generated by: LCOV version 1.16