void ActionWithVessel::readVesselKeywords(){ // Set maxderivatives if it is too big if( maxderivatives>getNumberOfDerivatives() ) maxderivatives=getNumberOfDerivatives(); // Loop over all keywords find the vessels and create appropriate functions for(unsigned i=0;i<keywords.size();++i){ std::string thiskey,input; thiskey=keywords.getKeyword(i); // Check if this is a key for a vessel if( vesselRegister().check(thiskey) ){ plumed_assert( keywords.style(thiskey,"vessel") ); bool dothis=false; parseFlag(thiskey,dothis); if(dothis) addVessel( thiskey, input ); parse(thiskey,input); if(input.size()!=0){ addVessel( thiskey, input ); } else { for(unsigned i=1;;++i){ if( !parseNumbered(thiskey,i,input) ) break; std::string ss; Tools::convert(i,ss); addVessel( thiskey, input, i ); input.clear(); } } } } // Make sure all vessels have had been resized at start if( functions.size()>0 ) resizeFunctions(); }
vesselbase::StoreDataVessel* MultiColvarBase::buildDataStashes( const bool& allow_wcutoff, const double& wtol ){ // Check if vessels have already been setup for(unsigned i=0;i<getNumberOfVessels();++i){ StoreColvarVessel* ssc=dynamic_cast<StoreColvarVessel*>( getPntrToVessel(i) ); if(ssc){ if( allow_wcutoff && !ssc->weightCutoffIsOn() ) error("Cannot have more than one data stash with different properties"); if( !allow_wcutoff && ssc->weightCutoffIsOn() ) error("Cannot have more than one data stash with different properties"); return ssc; } } // Setup central atoms vesselbase::VesselOptions da("","",0,"",this); mycatoms=new StoreCentralAtomsVessel(da); if( allow_wcutoff ) mycatoms->setHardCutoffOnWeight( wtol ); addVessel(mycatoms); // Setup store values vessel vesselbase::VesselOptions ta("","",0,"",this); myvalues=new StoreColvarVessel(ta); if( allow_wcutoff ) myvalues->setHardCutoffOnWeight( wtol ); addVessel(myvalues); // Make sure resizing of vessels is done resizeFunctions(); return myvalues; }
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() ); }
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(); }
Histogram::Histogram( const VesselOptions& da ): ShortcutVessel(da) { bool norm; parseFlag("NORM",norm); std::string normstr=""; if(norm) normstr=" NORM"; std::vector<std::string> bins; HistogramBead::generateBins( getAllInput(), "", bins ); for(unsigned i=0;i<bins.size();++i) addVessel("BETWEEN",bins[i] + normstr); }
void ActionWithVessel::addVessel( const std::string& name, const std::string& input, const int numlab ){ VesselOptions da(name,"",numlab,input,this); Vessel* vv=vesselRegister().create(name,da); FunctionVessel* fv=dynamic_cast<FunctionVessel*>(vv); if( fv ){ std::string mylabel=Vessel::transformName( name ); plumed_massert( keywords.outputComponentExists(mylabel,false), "a description of the value calculated by vessel " + name + " has not been added to the manual"); } addVessel(vv); }
StoreDataVessel* ActionWithVessel::buildDataStashes( const bool& allow_wcutoff, const double& wtol ){ if(mydata) return mydata; VesselOptions da("","",0,"",this); StoreDataVessel* mm=new StoreDataVessel(da); if( allow_wcutoff ) mm->setHardCutoffOnWeight( wtol ); addVessel(mm); // Make sure resizing of vessels is done resizeFunctions(); return mydata; }
PathBase::PathBase(const ActionOptions& ao): Action(ao), Mapping(ao) { bool noz; parseFlag("NOZPATH",noz); parse("LAMBDA",lambda); // Create the list of tasks for(unsigned i=0;i<getNumberOfReferencePoints();++i) addTaskToList( i ); std::string empty="LABEL=zpath"; if(!noz) addVessel("ZPATH",empty,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 }
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(); }
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(); }
void ActionWithAveraging::setAveragingAction( AveragingVessel* av_vessel, const bool& usetasks ) { myaverage=av_vessel; addVessel( myaverage ); useRunAllTasks=usetasks; resizeFunctions(); }
void ActionWithVessel::addVessel( const std::string& name, const std::string& input, const int numlab, const std::string thislab ){ VesselOptions da(name,thislab,numlab,input,this); Vessel* vv=vesselRegister().create(name,da); vv->checkRead(); addVessel(vv); }