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; }
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; }
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; }
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; }