Ejemplo n.º 1
0
void VectorMultiColvar::addWeightedValueDerivatives( const unsigned& iatom, const unsigned& base_cv_no, const double& weight, multicolvar::MultiColvarFunction* func ){
  if( usingLowMem() ){
     vecs->recompute( iatom, 1 ); 
     for(unsigned j=0;j<getNumberOfQuantities()-5;++j) vecs->chainRuleForComponent( 1, j, 5+j, base_cv_no, weight, func );
  } else {
     for(unsigned j=0;j<getNumberOfQuantities()-5;++j) vecs->chainRuleForComponent( iatom, j, 5+j, base_cv_no, weight, func );
  }
}
Ejemplo n.º 2
0
void MultiColvarBase::addWeightedValueDerivatives( const unsigned& iatom, const unsigned& base_cv_no, const double& weight, MultiColvarFunction* func ){
  plumed_dbg_assert( myvalues );
  if( usingLowMem() ){
     myvalues->recompute( iatom, 0 );
     myvalues->chainRuleForComponent( 0, 0, base_cv_no, weight, func );
  } else {
     myvalues->chainRuleForComponent( iatom, 0, base_cv_no, weight, func );
  }
}
Ejemplo n.º 3
0
void MultiColvarBase::addCentralAtomDerivativeToFunction( const unsigned& iatom, const unsigned& jout, const unsigned& base_cv_no, const Vector& der, MultiColvarFunction* func ){
  plumed_dbg_assert( mycatoms ); 
  if( usingLowMem() ){
      mycatoms->recompute( iatom, 0 ); ;
      mycatoms->addAtomsDerivatives( 0, jout, base_cv_no, der, func );
  } else{
      mycatoms->addAtomsDerivatives( iatom, jout, base_cv_no, der, func ); 
  }
}
Ejemplo n.º 4
0
void VectorMultiColvar::addOrientationDerivativesToBase( const unsigned& iatom, const unsigned& jstore, const unsigned& base_cv_no, 
                                                         const std::vector<double>& der, multicolvar::MultiColvarFunction* func ){
  if( usingLowMem() ){
      if(jstore==1){
         if(firstcall){ vecs->recompute( iatom, jstore ); firstcall=false; }
         vecs->chainRuleForVector( jstore, 0, base_cv_no, der, func );
      } else {
         vecs->recompute( iatom, jstore );
         vecs->chainRuleForVector( jstore, 0, base_cv_no, der, func );
      }
  } else {
      vecs->chainRuleForVector( iatom, 0, base_cv_no, der, func );
  }
}
Ejemplo n.º 5
0
double VectorMultiColvar::doCalculation(){
  // Now calculate the vector
  calculateVector();
  // Sort out the active derivatives
  updateActiveAtoms();

  // Now calculate the norm of the vector (this is what we return here)
  double norm=0, inorm;
  if(complexvec){
     for(unsigned i=0;i<ncomponents;++i) norm += getComponent(i)*getComponent(i) + getImaginaryComponent(i)*getImaginaryComponent(i); 
     norm=sqrt(norm); inorm = 1.0 / norm;
     for(unsigned i=0;i<ncomponents;++i){ dervec[i] = inorm*getComponent(i); dervec[ncomponents+i] = inorm*getImaginaryComponent(i); } 
  } else {
     for(unsigned i=0;i<ncomponents;++i) norm += getComponent(i)*getComponent(i);
     norm=sqrt(norm); inorm = 1.0 / norm;
     for(unsigned i=0;i<ncomponents;++i) dervec[i] = inorm*getComponent(i); 
  }

  if( usingLowMem() ){
     vecs->storeDerivativesLowMem( 0 );
     vecs->chainRule( 0, dervec );
  } else {
     vecs->storeDerivativesHighMem( getCurrentPositionInTaskList() );
     vecs->chainRule( getCurrentPositionInTaskList(), dervec );
  }

  // Add derivatives to base multicolvars
  Vector tmpd;
  for(unsigned i=0;i<atoms_with_derivatives.getNumberActive();++i){
       unsigned k=atoms_with_derivatives[i];
       tmpd[0]=vecs->getFinalDerivative(3*i+0); 
       tmpd[1]=vecs->getFinalDerivative(3*i+1); 
       tmpd[2]=vecs->getFinalDerivative(3*i+2); 
       MultiColvarBase::addAtomsDerivatives( 0, k, tmpd );
  }   
  unsigned vvbase=3*atoms_with_derivatives.getNumberActive(); Tensor tmpv;
  for(unsigned i=0;i<3;++i){
      for(unsigned j=0;j<3;++j){
          tmpv(i,j) = vecs->getFinalDerivative( vvbase+3*i+j ); 
      }   
  }   
  MultiColvarBase::addBoxDerivatives( 0, tmpv );

  
  return norm;
}