LCOV - code coverage report
Current view: top level - crystallization - LocalSteinhardt.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 15 21 71.4 %
Date: 2026-03-30 13:16:06 Functions: 5 9 55.6 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2013-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             : #ifndef __PLUMED_crystallization_LocalSteinhardt_h
      23             : #define __PLUMED_crystallization_LocalSteinhardt_h
      24             : #include "OrientationSphere.h"
      25             : 
      26             : namespace PLMD {
      27             : namespace crystallization {
      28             : 
      29             : template<class T>
      30             : class LocalSteinhardt : public OrientationSphere {
      31             : public:
      32          17 :   static void registerKeywords( Keywords& keys ) {
      33          17 :     OrientationSphere::registerKeywords(keys);
      34          17 :   }
      35           5 :   explicit LocalSteinhardt(const ActionOptions& ao): Action(ao), OrientationSphere(ao) {
      36          12 :     for(unsigned i=0; i<getNumberOfBaseMultiColvars(); ++i) {
      37           7 :       T* mc=dynamic_cast<T*>( getBaseMultiColvar(i) );
      38           7 :       if(!mc) {
      39           0 :         if( getBaseMultiColvar(i)->getNumberOfBaseMultiColvars()==0 ) {
      40           0 :           error("input action is not calculating the correct vectors");
      41             :         }
      42           0 :         for(unsigned j=0; j<getBaseMultiColvar(i)->getNumberOfBaseMultiColvars(); ++j) {
      43           0 :           T* mmc=dynamic_cast<T*>( getBaseMultiColvar(i)->getBaseMultiColvar(j) );
      44           0 :           if( !mmc ) {
      45           0 :             error("input action is not calculating the correct vectors");
      46             :           }
      47             :         }
      48             :       }
      49             :     }
      50           5 :   }
      51       43186 :   double computeVectorFunction( const Vector& conn, const std::vector<double>& vec1, const std::vector<double>& vec2,
      52             :                                 Vector& dconn, std::vector<double>& dvec1, std::vector<double>& dvec2 ) const override {
      53             :     double dot=0;
      54       43186 :     dconn.zero();
      55     1166022 :     for(unsigned k=2; k<vec1.size(); ++k) {
      56     1122836 :       dot+=vec1[k]*vec2[k];
      57     1122836 :       dvec1[k]=vec2[k];
      58     1122836 :       dvec2[k]=vec1[k];
      59             :     }
      60       43186 :     return dot;
      61             :   }
      62             : };
      63             : 
      64             : }
      65             : }
      66             : #endif

Generated by: LCOV version 1.16