本文整理汇总了C++中MultiValue::get方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiValue::get方法的具体用法?C++ MultiValue::get怎么用?C++ MultiValue::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiValue
的用法示例。
在下文中一共展示了MultiValue::get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: completeTask
void MultiColvarFilter::completeTask( const unsigned& curr, MultiValue& invals, MultiValue& outvals ) const {
invals.copyValues( outvals );
if( derivativesAreRequired() ) invals.copyDerivatives( outvals );
// Retrive the value of the multicolvar and apply filter
double val=invals.get(1), df, weight=applyFilter( val, df );
// Now propegate derivatives
if( !getPntrToMultiColvar()->weightHasDerivatives ){
outvals.setValue( 0, weight );
if( derivativesAreRequired() ){
for(unsigned i=0;i<invals.getNumberActive();++i){
unsigned jder=invals.getActiveIndex(i);
outvals.addDerivative( 0, jder, df*invals.getDerivative(1, jder ) );
}
}
} else {
double ww=outvals.get(0); outvals.setValue( 0, ww*weight );
if( derivativesAreRequired() ){
for(unsigned i=0;i<outvals.getNumberActive();++i){
unsigned ider=outvals.getActiveIndex(i);
outvals.setDerivative( 0, ider, weight*outvals.getDerivative(1,ider) + ww*df*outvals.getDerivative(0,ider) );
}
}
}
}
示例2: normalizeVectorDerivatives
void VectorMultiColvar::normalizeVectorDerivatives( MultiValue& myvals ) const {
double v = myvals.get(1), weight = 1.0 / v, wdf = 1.0 / ( v*v*v );
for(unsigned j=0;j<myvals.getNumberActive();++j){
double comp2=0.0; unsigned jder=myvals.getActiveIndex(j);
for(unsigned jcomp=2;jcomp<myvals.getNumberOfValues();++jcomp) comp2 += myvals.get(jcomp)*myvals.getDerivative( jcomp, jder );
for(unsigned jcomp=2;jcomp<myvals.getNumberOfValues();++jcomp){
myvals.setDerivative( jcomp, jder, weight*myvals.getDerivative( jcomp, jder ) - wdf*comp2*myvals.get(jcomp) );
}
}
}
示例3: storeValues
void StoreDataVessel::storeValues( const unsigned& myelem, MultiValue& myvals, std::vector<double>& buffer ) const {
plumed_dbg_assert( vecsize>0 );
unsigned jelem = getAction()->getPositionInCurrentTaskList( myelem ); plumed_dbg_assert( jelem<getNumberOfStoredValues() );
unsigned ibuf = bufstart + jelem * vecsize * nspace;
for(unsigned icomp=0;icomp<vecsize;++icomp){
buffer[ibuf] += myvals.get(icomp); ibuf+=nspace;
}
}
示例4: calculate
void StoreDataVessel::calculate( const unsigned& current, MultiValue& myvals, std::vector<double>& buffer, std::vector<unsigned>& der_list ) const {
if( myvals.get(0)>epsilon ){
storeValues( current, myvals, buffer );
if( !(getAction()->lowmem) && getAction()->derivativesAreRequired() ) storeDerivatives( current, myvals, buffer, der_list );
}
return;
}
示例5: transformBridgedDerivatives
void ManyRestraintsBase::transformBridgedDerivatives( const unsigned& current, MultiValue& invals, MultiValue& outvals ) const {
outvals.setValue( 0, invals.get(0) );
// Get the potential
double dval=0, val=calcPotential( invals.get(1), dval );
outvals.setValue( 1, val );
for(unsigned i=0; i<invals.getNumberActive(); ++i) {
unsigned jder=invals.getActiveIndex(i);
outvals.addDerivative( 1, jder, dval*invals.getDerivative( 1, jder ) );
}
// Now update the outvals derivatives lists
outvals.emptyActiveMembers();
for(unsigned j=0; j<invals.getNumberActive(); ++j) outvals.updateIndex( invals.getActiveIndex(j) );
outvals.completeUpdate();
return;
}
示例6: calculate
void SpathVessel::calculate( const unsigned& current, MultiValue& myvals, std::vector<double>& buffer, std::vector<unsigned>& der_index ) const {
double pp=mymap->getPropertyValue( current, getLabel() ), weight=myvals.get(0);
if( weight<getTolerance() ) return;
unsigned nderivatives=getFinalValue()->getNumberOfDerivatives();
buffer[bufstart] += weight*pp; buffer[bufstart+1+nderivatives] += weight;
if( getAction()->derivativesAreRequired() ) {
myvals.chainRule( 0, 0, 1, 0, pp, bufstart, buffer );
myvals.chainRule( 0, 1, 1, 0, 1.0, bufstart, buffer );
}
}
示例7: calculate
void FunctionVessel::calculate( const unsigned& current, MultiValue& myvals, std::vector<double>& buffer, std::vector<unsigned>& der_list ) const {
unsigned nderivatives=getFinalValue()->getNumberOfDerivatives();
double weight=myvals.get(0);
plumed_dbg_assert( weight>=getTolerance() );
// This deals with the value
double dval, f=calcTransform( myvals.get(mycomp), dval );
if( norm ){
if( usetol && weight<getTolerance() ) return;
buffer[bufstart+1+nderivatives] += weight;
if( diffweight ) myvals.chainRule( 0, 1, 1, 0, 1.0, bufstart, buffer );
}
double contr=weight*f;
if( usetol && contr<getTolerance() ) return;
buffer[bufstart] += contr;
if( diffweight ) myvals.chainRule( 0, 0, 1, 0, f, bufstart, buffer );
if( getAction()->derivativesAreRequired() && fabs(dval)>0.0 ) myvals.chainRule( mycomp, 0, 1, 0, weight*dval, bufstart, buffer );
return;
}
示例8: setNumberInVolume
void VolumeGradientBase::setNumberInVolume( const unsigned& ivol, const unsigned& curr, const double& weight,
const Vector& wdf, const Tensor& virial, const std::vector<Vector>& refders,
MultiValue& outvals ) const {
MultiColvarBase* mcolv=getPntrToMultiColvar();
if( !mcolv->weightHasDerivatives ) {
outvals.setValue(ivol, weight );
if( derivativesAreRequired() ) {
CatomPack catom; mcolv->getCentralAtomPack( 0, curr, catom );
for(unsigned i=0; i<catom.getNumberOfAtomsWithDerivatives(); ++i) {
unsigned jatom=3*catom.getIndex(i);
outvals.addDerivative( ivol, jatom+0, catom.getDerivative(i,0,wdf) );
outvals.addDerivative( ivol, jatom+1, catom.getDerivative(i,1,wdf) );
outvals.addDerivative( ivol, jatom+2, catom.getDerivative(i,2,wdf) );
}
unsigned nmder=getPntrToMultiColvar()->getNumberOfDerivatives();
for(unsigned i=0; i<3; ++i) for(unsigned j=0; j<3; ++j) outvals.addDerivative( ivol, nmder-9+3*i+j, virial(i,j) );
for(unsigned i=0; i<refders.size(); ++i) {
unsigned iatom=nmder+3*i;
outvals.addDerivative( ivol, iatom+0, refders[i][0] );
outvals.addDerivative( ivol, iatom+1, refders[i][1] );
outvals.addDerivative( ivol, iatom+2, refders[i][2] );
}
}
} else if(ivol==0) {
double ww=outvals.get(0); outvals.setValue(ivol,ww*weight);
if( derivativesAreRequired() ) {
plumed_merror("This needs testing");
CatomPack catom; mcolv->getCentralAtomPack( 0, curr, catom );
for(unsigned i=0; i<catom.getNumberOfAtomsWithDerivatives(); ++i) {
unsigned jatom=3*catom.getIndex(i);
outvals.addDerivative( ivol, jatom+0, weight*outvals.getDerivative(ivol,jatom+0) + ww*catom.getDerivative(i,0,wdf) );
outvals.addDerivative( ivol, jatom+1, weight*outvals.getDerivative(ivol,jatom+1) + ww*catom.getDerivative(i,1,wdf) );
outvals.addDerivative( ivol, jatom+2, weight*outvals.getDerivative(ivol,jatom+2) + ww*catom.getDerivative(i,2,wdf) );
}
unsigned nmder=getPntrToMultiColvar()->getNumberOfDerivatives();
for(unsigned i=0; i<3; ++i) for(unsigned j=0; j<3; ++j) outvals.addDerivative( ivol, nmder-9+3*i+j, ww*virial(i,j) );
for(unsigned i=0; i<refders.size(); ++i) {
unsigned iatom=nmder+3*i;
outvals.addDerivative( ivol, iatom+0, ww*refders[i][0] );
outvals.addDerivative( ivol, iatom+1, ww*refders[i][1] );
outvals.addDerivative( ivol, iatom+2, ww*refders[i][2] );
}
}
} else {
double ww=outvals.get(0); outvals.setValue(ivol,ww*weight);
if( derivativesAreRequired() ) {
plumed_merror("This needs testing");
CatomPack catom; mcolv->getCentralAtomPack( 0, curr, catom );
for(unsigned i=0; i<catom.getNumberOfAtomsWithDerivatives(); ++i) {
unsigned jatom=3*catom.getIndex(i);
outvals.addDerivative( ivol, jatom+0, ww*catom.getDerivative(i,0,wdf) );
outvals.addDerivative( ivol, jatom+1, ww*catom.getDerivative(i,1,wdf) );
outvals.addDerivative( ivol, jatom+2, ww*catom.getDerivative(i,2,wdf) );
}
unsigned nmder=getPntrToMultiColvar()->getNumberOfDerivatives();
for(unsigned i=0; i<3; ++i) for(unsigned j=0; j<3; ++j) outvals.addDerivative( ivol, nmder-9+3*i+j, ww*virial(i,j) );
for(unsigned i=0; i<refders.size(); ++i) {
unsigned iatom=nmder+3*i;
outvals.addDerivative( ivol, iatom+0, ww*refders[i][0] );
outvals.addDerivative( ivol, iatom+1, ww*refders[i][1] );
outvals.addDerivative( ivol, iatom+2, ww*refders[i][2] );
}
}
}
}
示例9: calculate
void HistogramOnGrid::calculate( const unsigned& current, MultiValue& myvals, std::vector<double>& buffer, std::vector<unsigned>& der_list ) const {
if( addOneKernelAtATime ) {
plumed_dbg_assert( myvals.getNumberOfValues()==2 && !wasforced );
std::vector<double> der( dimension );
for(unsigned i=0; i<dimension; ++i) der[i]=myvals.getDerivative( 1, i );
accumulate( getAction()->getPositionInCurrentTaskList(current), myvals.get(0), myvals.get(1), der, buffer );
} else {
plumed_dbg_assert( myvals.getNumberOfValues()==dimension+2 );
std::vector<double> point( dimension );
double weight=myvals.get(0)*myvals.get( 1+dimension );
for(unsigned i=0; i<dimension; ++i) point[i]=myvals.get( 1+i );
// Get the kernel
unsigned num_neigh;
std::vector<unsigned> neighbors;
std::vector<double> der( dimension );
KernelFunctions* kernel=getKernelAndNeighbors( point, num_neigh, neighbors );
// If no kernel normalize the vector so von misses distribution is calculated correctly
if( !kernel ) {
double norm=0;
for(unsigned j=0; j<dimension; ++j) norm += point[j]*point[j];
norm=sqrt( norm );
for(unsigned j=0; j<dimension; ++j) point[j] = point[j] / norm;
}
if( !kernel && getType()=="flat" ) {
plumed_dbg_assert( num_neigh==1 );
accumulate( neighbors[0], weight, 1.0, der, buffer );
} else {
double totwforce=0.0;
std::vector<double> intforce( 2*dimension, 0.0 );
std::vector<Value*> vv( getVectorOfValues() );
double newval;
std::vector<double> xx( dimension );
for(unsigned i=0; i<num_neigh; ++i) {
unsigned ineigh=neighbors[i];
if( inactive( ineigh ) ) continue ;
getGridPointCoordinates( ineigh, xx );
for(unsigned j=0; j<dimension; ++j) vv[j]->set(xx[j]);
if( kernel ) {
newval = kernel->evaluate( vv, der, true );
} else {
// Evalulate dot product
double dot=0;
for(unsigned j=0; j<dimension; ++j) {
dot+=xx[j]*point[j];
der[j]=xx[j];
}
// Von misses distribution for concentration parameter
newval = von_misses_norm*exp( von_misses_concentration*dot );
// And final derivatives
for(unsigned j=0; j<dimension; ++j) der[j] *= von_misses_concentration*newval;
}
accumulate( ineigh, weight, newval, der, buffer );
if( wasForced() ) {
accumulateForce( ineigh, weight, der, intforce );
totwforce += myvals.get( 1+dimension )*newval*forces[ineigh];
}
}
if( wasForced() ) {
unsigned nder = getAction()->getNumberOfDerivatives();
unsigned gridbuf = getNumberOfBufferPoints()*getNumberOfQuantities();
for(unsigned j=0; j<dimension; ++j) {
for(unsigned k=0; k<myvals.getNumberActive(); ++k) {
// Minus sign here as we are taking derivative with respect to position of center of kernel NOT derivative wrt to
// grid point
unsigned kder=myvals.getActiveIndex(k);
buffer[ bufstart + gridbuf + kder ] -= intforce[j]*myvals.getDerivative( j+1, kder );
}
}
// Accumulate the sum of all the weights
buffer[ bufstart + gridbuf + nder ] += myvals.get(0);
// Add the derivatives of the weights into the force -- this is separate loop as weights of all parts are considered together
for(unsigned k=0; k<myvals.getNumberActive(); ++k) {
unsigned kder=myvals.getActiveIndex(k);
buffer[ bufstart + gridbuf + kder ] += totwforce*myvals.getDerivative( 0, kder );
buffer[ bufstart + gridbuf + nder + 1 + kder ] += myvals.getDerivative( 0, kder );
}
}
delete kernel;
for(unsigned i=0; i<dimension; ++i) delete vv[i];
}
}
}