From 4a96057e4fef8ca9c02cfcfa7a58707dce008f9b Mon Sep 17 00:00:00 2001 From: Gareth Tribello <gareth.tribello@gmail.com> Date: Fri, 25 May 2018 16:45:04 +0100 Subject: [PATCH] Fixed a bug that can occur when using mappings with virtual atoms --- src/mapping/Mapping.cpp | 30 ++++-------------------------- src/mapping/Mapping.h | 2 -- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/mapping/Mapping.cpp b/src/mapping/Mapping.cpp index 8a05b6ee3..2b063ffb9 100644 --- a/src/mapping/Mapping.cpp +++ b/src/mapping/Mapping.cpp @@ -103,8 +103,10 @@ Mapping::Mapping(const ActionOptions&ao): // Get the arguments and atoms that are required std::vector<AtomNumber> atoms; std::vector<std::string> args; mymap->getAtomAndArgumentRequirements( atoms, args ); - requestAtoms( atoms ); std::vector<Value*> req_args; - interpretArgumentList( args, req_args ); requestArguments( req_args ); + std::vector<Value*> req_args; interpretArgumentList( args, req_args ); + if( req_args.size()>0 && atoms.size()>0 ) error("cannot mix atoms and arguments"); + if( req_args.size()>0 ) requestArguments( req_args ); + if( atoms.size()>0 ) requestAtoms( atoms ); // Duplicate all frames (duplicates are used by sketch-map) // mymap->duplicateFrameList(); // fframes.resize( 2*nfram, 0.0 ); dfframes.resize( 2*nfram, 0.0 ); @@ -124,30 +126,6 @@ void Mapping::turnOnDerivatives() { needsDerivatives(); } -void Mapping::prepare() { - if( mymap->mappingNeedsSetup() ) { - // Get the arguments and atoms that are required - std::vector<AtomNumber> atoms; std::vector<std::string> args; - mymap->getAtomAndArgumentRequirements( atoms, args ); - requestAtoms( atoms ); std::vector<Value*> req_args; - interpretArgumentList( args, req_args ); requestArguments( req_args ); - // Duplicate all frames (duplicates are used by sketch-map) - //mymap->duplicateFrameList(); - // Get the number of frames in the path - // unsigned nfram=getNumberOfReferencePoints(); - // fframes.resize( 2*nfram, 0.0 ); dfframes.resize( 2*nfram, 0.0 ); - // plumed_assert( !mymap->mappingNeedsSetup() ); - // Resize all derivative arrays - // mymap->setNumberOfAtomsAndArguments( atoms.size(), args.size() ); - // Resize forces array - if( getNumberOfAtoms()>0 ) { - forcesToApply.resize( 3*getNumberOfAtoms() + 9 + getNumberOfArguments() ); - } else { - forcesToApply.resize( getNumberOfArguments() ); - } - } -} - unsigned Mapping::getPropertyIndex( const std::string& name ) const { return mymap->getPropertyIndex( name ); } diff --git a/src/mapping/Mapping.h b/src/mapping/Mapping.h index 91d14fcc6..33164ecc1 100644 --- a/src/mapping/Mapping.h +++ b/src/mapping/Mapping.h @@ -95,8 +95,6 @@ public: std::string getArgumentName( unsigned& iarg ); /// Get the value of the ith property for the current frame double getPropertyValue( const unsigned& current, const unsigned& iprop ) const ; -/// Stuff to do before we do the calculation - void prepare(); /// Apply the forces void apply(); }; -- GitLab