void VectorMultiColvar::addForcesOnAtoms( const std::vector<double>& inforces ){ plumed_dbg_assert( inforces.size()==getNumberOfDerivatives() ); std::vector<double> oldforces( getNumberOfDerivatives() ); getForcesFromVessels( oldforces ); for(unsigned i=0;i<getNumberOfDerivatives();++i) oldforces[i]+=inforces[i]; setForcesOnAtoms( oldforces ); }
void Histogram::apply() { if( !myhist->wasForced() ) return ; in_apply=true; // Run the loop to calculate the forces runAllTasks(); finishAveraging(); // We now need to retrieve the buffer and set the forces on the atoms myhist->applyForce( forcesToApply ); // Now make the forces make sense for the virial unsigned fbase=0, tbase=0, vbase = getNumberOfDerivatives() - myvessels.size()*9; for(unsigned i=vbase; i<vbase+9; ++i) finalForces[i]=0.0; for(unsigned i=0; i<myvessels.size(); ++i) { for(unsigned j=0; j<myvessels[i]->getNumberOfDerivatives()-9; ++j) { finalForces[fbase + j] = forcesToApply[tbase + j]; } unsigned k=0; for(unsigned j=myvessels[i]->getNumberOfDerivatives()-9; j<myvessels[i]->getNumberOfDerivatives(); ++j) { finalForces[vbase + k] += forcesToApply[tbase + j]; k++; } fbase += myvessels[i]->getNumberOfDerivatives() - 9; tbase += myvessels[i]->getNumberOfDerivatives(); } // And set the final forces on the atoms setForcesOnAtoms( finalForces ); // Reset everything for next regular loop in_apply=false; }
void VolumeGradientBase::addBridgeForces( const std::vector<double>& bb ) { plumed_dbg_assert( bb.size()==tmpforces.size()-9 ); // Forces on local atoms for(unsigned i=0; i<bb.size(); ++i) tmpforces[i]=bb[i]; // Virial contribution is zero for(unsigned i=bb.size(); i<bb.size()+9; ++i) tmpforces[i]=0.0; setForcesOnAtoms( tmpforces, 0 ); }
void SecondaryStructureRMSD::apply(){ if( getForcesFromVessels( forcesToApply ) ) setForcesOnAtoms( forcesToApply ); }
void MultiColvarBase::apply(){ if( getForcesFromVessels( forcesToApply ) ) setForcesOnAtoms( forcesToApply ); }
void DistanceFromContour::apply(){ if( getPntrToComponent("dist")->applyForce( forces ) ) setForcesOnAtoms( forces ); }
void Mapping::apply(){ if( getForcesFromVessels( forcesToApply ) ){ addForcesOnArguments( forcesToApply ); if( getNumberOfAtoms()>0 ) setForcesOnAtoms( forcesToApply, getNumberOfArguments() ); } }