void ActionWithAveraging::update() { if( (clearstride!=1 && getStep()==0) || !onStep() ) return; // Clear if it is time to reset if( myaverage ) { if( myaverage->wasreset() ) clearAverage(); } // Calculate the weight for all reweighting if ( weights.size()>0 ) { double sum=0; for(unsigned i=0; i<weights.size(); ++i) sum+=weights[i]->get(); lweight=sum; cweight = exp( sum ); } else { lweight=0; cweight=1.0; } // Prepare to do the averaging prepareForAveraging(); // Run all the tasks (if required if( useRunAllTasks ) runAllTasks(); // This the averaging if it is not done using task list else performOperations( true ); // Update the norm if( myaverage ) myaverage->setNorm( cweight + myaverage->getNorm() ); // Finish the averaging finishAveraging(); // By resetting here we are ensuring that the grid will be cleared at the start of the next step if( myaverage ) { if( getStride()==0 || (clearstride>0 && getStep()%clearstride==0) ) myaverage->reset(); } }
void Histogram::apply() { if( !myhist->wasForced() ) return ; in_apply=true; // Run the loop to calculate the forces runAllTasks(); finishAveraging(); // We now need to retrieve the buffer and set the forces on the atoms myhist->applyForce( forcesToApply ); // Now make the forces make sense for the virial unsigned fbase=0, tbase=0, vbase = getNumberOfDerivatives() - myvessels.size()*9; for(unsigned i=vbase; i<vbase+9; ++i) finalForces[i]=0.0; for(unsigned i=0; i<myvessels.size(); ++i) { for(unsigned j=0; j<myvessels[i]->getNumberOfDerivatives()-9; ++j) { finalForces[fbase + j] = forcesToApply[tbase + j]; } unsigned k=0; for(unsigned j=myvessels[i]->getNumberOfDerivatives()-9; j<myvessels[i]->getNumberOfDerivatives(); ++j) { finalForces[vbase + k] += forcesToApply[tbase + j]; k++; } fbase += myvessels[i]->getNumberOfDerivatives() - 9; tbase += myvessels[i]->getNumberOfDerivatives(); } // And set the final forces on the atoms setForcesOnAtoms( finalForces ); // Reset everything for next regular loop in_apply=false; }
void ClusterDiameter::calculate(){ // Retrieve the atoms in the largest cluster std::vector<unsigned> myatoms; retrieveAtomsInCluster( clustr, myatoms ); // Activate the relevant tasks deactivateAllTasks(); for(unsigned i=1;i<myatoms.size();++i){ for(unsigned j=0;j<i;++j) taskFlags[ myatoms[i]*getNumberOfNodes() + myatoms[j] ] = 1; } lockContributors(); // Now do the calculation runAllTasks(); }
void DFSClusterDiameter::calculate(){ // Do the clustring performClustering(); // Retrieve the atoms in the largest cluster std::vector<unsigned> myatoms; retrieveAtomsInCluster( clustr, myatoms ); // Activate the relevant tasks deactivateAllTasks(); std::vector<unsigned> active_tasks( getFullNumberOfTasks(), 0 ); for(unsigned i=1;i<myatoms.size();++i){ for(unsigned j=0;j<i;++j) active_tasks[ myatoms[i]*getNumberOfNodes() + myatoms[j] ] = 1; } activateTheseTasks( active_tasks ); // Now do the calculation runAllTasks(); }
void ActionWithGrid::calculate(){ // Do nothing if derivatives are not required if( doNotCalculateDerivatives() ) return; // Clear on every step if( mygrid ) clearAverage(); // Should not be any reweighting so just set these accordingly lweight=0; cweight=1.0; // Prepare to do the averaging prepareForAveraging(); // Run all the tasks (if required if( useRunAllTasks ) runAllTasks(); // This the averaging if it is not done using task list else performOperations( true ); // Update the norm if( mygrid ) mygrid->setNorm( cweight ); // Finish the averaging finishAveraging(); // And reset for next step if( mygrid ) mygrid->reset(); }
void SecondaryStructureRMSD::calculate(){ runAllTasks(); }
void PathBase::calculate(){ // Loop over all frames is now performed by ActionWithVessel runAllTasks(); }