示例#1
0
bool Mean::calculate(){
  double weight=getAction()->getElementValue(wnum);
  plumed_dbg_assert( weight>=getTolerance() );
  addValueIgnoringTolerance( 1, weight );
  double colvar=getAction()->getElementValue(0);
  addValueIgnoringTolerance( 0, weight*colvar  );
  getAction()->chainRuleForElementDerivatives( 0, 0, weight, this );
  if(diffweight){
     getAction()->chainRuleForElementDerivatives( 0, wnum, colvar, this );
     getAction()->chainRuleForElementDerivatives( 1, wnum, 1.0, this );
  }
  return true;
}
示例#2
0
文件: Max.cpp 项目: apoma/plumed2
bool Max::calculate(){
  double val=getAction()->getElementValue(0);
  double dval, f = exp(val/beta); dval=f/beta;
  addValueIgnoringTolerance(0,f);
  getAction()->chainRuleForElementDerivatives( 0, 0, dval, this );
  return true;
}
示例#3
0
bool GradientVessel::calculate(){
  for(unsigned iw=0;iw<nweights;++iw){
      unsigned xx = (ncomponents+1)*iw;
      double weight=getAction()->getElementValue(ncomponents + iw);
      addValueIgnoringTolerance( xx, weight ); 
      getAction()->chainRuleForElementDerivatives( xx , ncomponents + iw, 1.0, this );
      for(unsigned jc=0;jc<ncomponents;++jc){
          double colvar=getAction()->getElementValue( jc );
          addValueIgnoringTolerance( xx + 1 + jc, weight*colvar );
          getAction()->chainRuleForElementDerivatives( xx + 1 + jc, jc, weight, this );
          getAction()->chainRuleForElementDerivatives( xx + 1 + jc, ncomponents + iw, colvar, this );   
      }
  }

  return true;
}
示例#4
0
bool DHEnergy::calculate(){
  if( mycolv->getAbsoluteIndex(0)==mycolv->getAbsoluteIndex(1) ) return false;

  double val=getAction()->getElementValue(0);
  double invdistance = 1.0 / val;
  double f=exp(-k*val)*invdistance*constant*mycolv->getCharge(0)*mycolv->getCharge(1)/epsilon;
  double dval=-(k+invdistance)*f; 
  addValueIgnoringTolerance(0,f);
  getAction()->chainRuleForElementDerivatives( 0, 0, dval, this ); 
  return true;
}