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 ){
     finishTaskListUpdate();

     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.push_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() );
}
示例#2
0
ManyRestraintsBase::ManyRestraintsBase(const ActionOptions& ao):
    Action(ao),
    ActionWithValue(ao),
    ActionPilot(ao),
    ActionWithVessel(ao),
    ActionWithInputVessel(ao)
{
    // Read in the vessel we are action on
    readArgument("bridge");
    aves=dynamic_cast<ActionWithVessel*>( getDependencies()[0] );

    plumed_assert( getDependencies().size()==1 && aves );
    log.printf("  adding restraints on variables calculated by %s action with label %s\n",
               aves->getName().c_str(),aves->getLabel().c_str());

    // Add a task list in order to avoid problems
    for(unsigned i=0; i<aves->getFullNumberOfTasks(); ++i) addTaskToList( aves->getTaskCode(i) );
    // And turn on the derivatives (note problems here because of ActionWithValue)
    turnOnDerivatives();
    needsDerivatives();

    // Now create the vessel
    std::string fake_input="LABEL=bias";
    addVessel( "SUM", fake_input, 0 );
    readVesselKeywords();
}
示例#3
0
MultiColvarFilter::MultiColvarFilter(const ActionOptions&ao):
Action(ao),
BridgedMultiColvarFunction(ao)
{
  if( getPntrToMultiColvar()->isDensity() ) error("filtering density makes no sense");
  readVesselKeywords(); 
}
示例#4
0
void MultiColvarBase::setupMultiColvarBase(){
  // Setup decoder array
  if( !usespecies && ablocks.size()<4 ){
     decoder.resize( ablocks.size() ); unsigned code=1;
     for(unsigned i=0;i<ablocks.size();++i){ decoder[ablocks.size()-1-i]=code; code *= nblock; } 
  } 
  // Resize stuff here
  resizeLocalArrays();

  // Setup underlying ActionWithVessel
  readVesselKeywords();
}
示例#5
0
MultiColvarFilter::MultiColvarFilter(const ActionOptions&ao):
Action(ao),
BridgedMultiColvarFunction(ao)
{
  if( getPntrToMultiColvar()->isDensity() ) error("filtering/transforming density makes no sense");

  if( getName().find("MFILTER")!=std::string::npos ) filter=true;
  else {
    plumed_assert( getName().find("MTRANSFORM")!=std::string::npos );
    filter=false;
  }

  readVesselKeywords(); 
}
示例#6
0
void MultiColvarBase::setupMultiColvarBase(){
  // Setup decoder array
  if( !usespecies && ablocks.size()<4 ){
     decoder.resize( ablocks.size() ); unsigned code=1;
     for(unsigned i=0;i<ablocks.size();++i){ decoder[ablocks.size()-1-i]=code; code *= nblock; } 
     use_for_central_atom.resize( ablocks.size(), true );
     numberForCentralAtom = 1.0 / static_cast<double>( ablocks.size() );
  } else if( !usespecies ){
     use_for_central_atom.resize( ablocks.size(), true );
     numberForCentralAtom = 1.0 / static_cast<double>( ablocks.size() );
  }

  // Setup underlying ActionWithVessel
  readVesselKeywords();
}
示例#7
0
void VectorMultiColvar::setVectorDimensionality( const unsigned& ncomp, const bool& comp, const int& nat ){
  // Store number of derivatives and if vectors are complex
  ncomponents = ncomp; complexvec=comp; 
  if(complexvec) dervec.resize( 2*ncomponents );
  else dervec.resize( ncomponents );
  // Read in the atoms if we are using multicolvar reading
  int natoms=nat; readAtoms( natoms );
  // Create the store vector object
  std::string param; vesselbase::VesselOptions da("","",0,param,this);
  Keywords keys; StoreVectorsVessel::registerKeywords( keys );
  vesselbase::VesselOptions da2(da,keys);
  vecs = new StoreVectorsVessel(da2);
  // Add the vessel to the base
  addVessel(vecs);
  // Read in any vessels
  readVesselKeywords();
  // Resize a holder for the derivatives of the norm of the vector
}
示例#8
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();
}
示例#9
0
ActionVolume::ActionVolume(const ActionOptions&ao):
  Action(ao),
  VolumeGradientBase(ao)
{
  // Find number of quantities
  if( getPntrToMultiColvar()->isDensity() ) nquantities=2;                           // Value + weight
  else if( getPntrToMultiColvar()->getNumberOfQuantities()==2 ) nquantities=2;       // Value + weight
  else nquantities = 1 + getPntrToMultiColvar()->getNumberOfQuantities()-2 + 1;      // Norm  + vector + weight

  // Output some nice information
  std::string functype=getPntrToMultiColvar()->getName();
  std::transform( functype.begin(), functype.end(), functype.begin(), tolower );
  log.printf("  calculating %s inside region of insterest\n",functype.c_str() );

  parseFlag("OUTSIDE",not_in); sigma=0.0;
  if( keywords.exists("SIGMA") ) parse("SIGMA",sigma);
  if( keywords.exists("KERNEL") ) parse("KERNEL",kerneltype);

  if( getPntrToMultiColvar()->isDensity() ) {
    std::string input;
    addVessel( "SUM", input, -1 );  // -1 here means that this value will be named getLabel()
  }
  readVesselKeywords();
}