Esempio n. 1
0
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();
}
Esempio n. 2
0
void Histogram::prepareForAveraging() {
  if( myvessels.size()>0 ) {
    deactivateAllTasks(); double norm=0;
    for(unsigned i=0; i<stashes[0]->getNumberOfStoredValues(); ++i) {
      std::vector<double> cvals( myvessels[0]->getNumberOfQuantities() );
      stashes[0]->retrieveSequentialValue( i, false, cvals );
      unsigned itask=myvessels[0]->getActiveTask(i); double tnorm = cvals[0];
      for(unsigned j=1; j<myvessels.size(); ++j) {
        if( myvessels[j]->getActiveTask(i)!=itask ) error("mismatched task identities in histogram suggests histogram is meaningless");
        if( cvals.size()!=myvessels[j]->getNumberOfQuantities() ) cvals.resize( myvessels[j]->getNumberOfQuantities() );
        stashes[j]->retrieveSequentialValue( i, false, cvals ); tnorm *= cvals[0];
      }
      norm += tnorm; taskFlags[i]=1;
    }
    lockContributors();
    // Sort out normalization of histogram
    if( !noNormalization() ) ww = cweight / norm;
    else ww = cweight;
  } else {
    // Now fetch the kernel and the active points
    std::vector<double> point( getNumberOfArguments() );
    for(unsigned i=0; i<point.size(); ++i) point[i]=getArgument(i);
    unsigned num_neigh; std::vector<unsigned> neighbors(1);
    kernel = myhist->getKernelAndNeighbors( point, num_neigh, neighbors );

    if( num_neigh>1 ) {
      // Activate relevant tasks
      deactivateAllTasks();
      for(unsigned i=0; i<num_neigh; ++i) taskFlags[neighbors[i]]=1;
      lockContributors();
    } else {
      // This is used when we are not doing kernel density evaluation
      mygrid->addToGridElement( neighbors[0], 0, cweight );
    }
  }
}
Esempio n. 3
0
ActionWithIntegral::ActionWithIntegral(const ActionOptions&ao):
Action(ao),
ActionWithInputGrid(ao)
{
  plumed_assert( ingrid->getNumberOfComponents()==1 ); 
  // Retrieve the volume of the grid (for integration)
  volume = ingrid->getCellVolume();
  // Create something that is going to calculate the sum of all the values 
  // at the various grid points - this is going to be the integral
  std::string fake_input; addVessel( "SUM", fake_input, -1 ); readVesselKeywords();
  // Now create task list - number of tasks is equal to the number of grid points
  // as we have to evaluate the function at each grid points
  for(unsigned i=0;i<ingrid->getNumberOfPoints();++i) addTaskToList(i);
  // And activate all tasks
  deactivateAllTasks(); 
  for(unsigned i=0;i<ingrid->getNumberOfPoints();++i) taskFlags[i]=1;
  lockContributors();
}
void FindContourSurface::prepareForAveraging() {
  // Create a task list if first time
  if( firsttime ) {
    std::vector<unsigned> find( ingrid->getDimension() );
    std::vector<unsigned> ind( mygrid->getDimension() );
    for(unsigned i=0; i<mygrid->getNumberOfPoints(); ++i) {
      find.assign( find.size(), 0 ); mygrid->getIndices( i, ind );
      for(unsigned j=0; j<gdirs.size(); ++j) find[gdirs[j]]=ind[j];
      // Current will be set equal to the start point for this grid index
      addTaskToList( ingrid->getIndex(find) );
    }
    // And prepare the task list
    deactivateAllTasks();
    for(unsigned i=0; i<getFullNumberOfTasks(); ++i) taskFlags[i]=1;
    lockContributors();
    // Set the direction in which to look for the contour
    direction.resize( ingrid->getDimension(), 0 );
    direction[dir_n] = 0.999999999*ingrid->getGridSpacing()[dir_n];
  }
}
void SecondaryStructureRMSD::setSecondaryStructure( std::vector<Vector>& structure, double bondlength, double units ) {
  // If we are in natural units get conversion factor from nm into natural length units
  if( plumed.getAtoms().usingNaturalUnits() ) {
    error("cannot use this collective variable when using natural units");
  }
  plumed_massert( !(align_strands && align_atom_1==0 && align_atom_2==0), "you must use setAtomsFromStrands with strands cutoff");

  // Convert into correct units
  for(unsigned i=0; i<structure.size(); ++i) {
    structure[i][0]*=units; structure[i][1]*=units; structure[i][2]*=units;
  }

  if( references.size()==0 ) {
    readVesselKeywords();
    if( getNumberOfVessels()==0 ) {
      double r0; parse("R_0",r0); double d0; parse("D_0",d0);
      int nn; parse("NN",nn); int mm; parse("MM",mm);
      std::ostringstream ostr;
      ostr<<"RATIONAL R_0="<<r0<<" D_0="<<d0<<" NN="<<nn<<" MM="<<mm;
      std::string input=ostr.str(); addVessel( "LESS_THAN", input, -1 ); // -1 here means that this value will be named getLabel()
      readVesselKeywords();  // This makes sure resizing is done
    }
  }

  // Set the reference structure
  references.emplace_back( metricRegister().create<SingleDomainRMSD>( alignType ) );
  unsigned nn=references.size()-1;
  std::vector<double> align( structure.size(), 1.0 ), displace( structure.size(), 1.0 );
  references[nn]->setBoundsOnDistances( true, bondlength );   // We always use pbc
  references[nn]->setReferenceAtoms( structure, align, displace );
//  references[nn]->setNumberOfAtoms( structure.size() );

  // And prepare the task list
  deactivateAllTasks();
  for(unsigned i=0; i<getFullNumberOfTasks(); ++i) taskFlags[i]=1;
  lockContributors();
}
void SecondaryStructureRMSD::prepare(){
  if( contributorsAreUnlocked ) lockContributors();
  if( updateFreq>0 ){
      if( firsttime || getStep()%updateFreq==0 ){ firsttime=false; unlockContributors(); }
  }
}