bool MultiColvarBase::setupCurrentAtomList( const unsigned& taskCode, AtomValuePack& myatoms ) const { if( usespecies ){ if( isDensity() ) return true; unsigned natomsper=myatoms.setupAtomsFromLinkCells( taskCode, getPositionOfAtomForLinkCells(taskCode), linkcells ); return natomsper>1; } else if( ablocks.size()<4 ){ std::vector<unsigned> atoms( ablocks.size() ); decodeIndexToAtoms( taskCode, atoms ); myatoms.setNumberOfAtoms( ablocks.size() ); for(unsigned i=0;i<ablocks.size();++i) myatoms.setAtom( i, atoms[i] ); } else { myatoms.setNumberOfAtoms( ablocks.size() ); for(unsigned i=0;i<ablocks.size();++i) myatoms.setAtom( i, ablocks[i][taskCode] ); } return true; }
double NumberOfLinks::compute( const unsigned& tindex, AtomValuePack& myatoms ) const { if( getBaseMultiColvar(0)->getNumberOfQuantities()<3 ) return 1.0; unsigned ncomp=getBaseMultiColvar(0)->getNumberOfQuantities(); std::vector<double> orient0( ncomp ), orient1( ncomp ); getVectorForTask( myatoms.getIndex(0), true, orient0 ); getVectorForTask( myatoms.getIndex(1), true, orient1 ); double dot=0; for(unsigned k=2;k<orient0.size();++k){ dot+=orient0[k]*orient1[k]; } if( !doNotCalculateDerivatives() ){ unsigned nder=myatoms.getNumberOfDerivatives(); //getNumberOfDerivatives(); MultiValue myder0(ncomp,nder), myder1(ncomp,nder); getVectorDerivatives( myatoms.getIndex(0), true, myder0 ); mergeVectorDerivatives( 1, 2, orient1.size(), myatoms.getIndex(0), orient1, myder0, myatoms ); getVectorDerivatives( myatoms.getIndex(1), true, myder1 ); mergeVectorDerivatives( 1, 2, orient0.size(), myatoms.getIndex(1), orient0, myder1, myatoms ); } return dot; }
double DistanceFromContour::compute( const unsigned& tindex, AtomValuePack& myatoms ) const { Vector distance = getSeparation( getPosition(getNumberOfAtoms()-1), myatoms.getPosition(0) ); std::vector<double> pp(3), der(3,0); for(unsigned j=0;j<3;++j) pp[j] = distance[j]; // Now create the kernel and evaluate KernelFunctions kernel( pp, bw, kerneltype, false, 1.0, true ); double newval = kernel.evaluate( pval, der, true ); if( mybasemulticolvars[0]->isDensity() ){ if( !doNotCalculateDerivatives() && derivTime ){ MultiValue& myvals=myatoms.getUnderlyingMultiValue(); Vector vder; unsigned basen=myvals.getNumberOfDerivatives() - 12; for(unsigned i=0;i<3;++i){ vder[i]=der[i]; myvals.addDerivative( 1, basen+i, vder[i] ); } myatoms.setValue( 2, der[dir] ); addAtomDerivatives( 1, 0, -vder, myatoms ); myatoms.addBoxDerivatives( 1, Tensor(vder,distance) ); } myatoms.setValue( 0, 1.0 ); return newval; } // This does the stuff for averaging myatoms.setValue( 0, newval ); // This gets the average if we are using a phase field std::vector<double> cvals( mybasemulticolvars[0]->getNumberOfQuantities() ); mybasedata[0]->retrieveValueWithIndex( tindex, false, cvals ); return newval*cvals[0]*cvals[1]; }
void MultiColvarBase::calculateWeight( AtomValuePack& myatoms ) const { myatoms.setValue( 0, 1.0 ); }