void Mapping::prepare(){ if( mymap->mappingNeedsSetup() ){ // Get the arguments and atoms that are required std::vector<AtomNumber> atoms; std::vector<std::string> args; mymap->getAtomAndArgumentRequirements( atoms, args ); requestAtoms( atoms ); std::vector<Value*> req_args; interpretArgumentList( args, req_args ); requestArguments( req_args ); // Duplicate all frames (duplicates are used by sketch-map) mymap->duplicateFrameList(); // Get the number of frames in the path unsigned nfram=getNumberOfReferencePoints(); fframes.resize( 2*nfram, 0.0 ); dfframes.resize( 2*nfram, 0.0 ); plumed_assert( !mymap->mappingNeedsSetup() ); // Resize all derivative arrays mymap->setNumberOfAtomsAndArguments( atoms.size(), args.size() ); // Resize forces array forcesToApply.resize( 3*getNumberOfAtoms() + 9 + getNumberOfArguments() ); } }
ActionWithAveraging::ActionWithAveraging( const ActionOptions& ao ): Action(ao), ActionPilot(ao), ActionAtomistic(ao), ActionWithArguments(ao), ActionWithValue(ao), ActionWithVessel(ao), myaverage(NULL), useRunAllTasks(false), clearstride(0), lweight(0),cweight(0) { if( keywords.exists("CLEAR") ) { parse("CLEAR",clearstride); if( clearstride>0 ) { if( clearstride%getStride()!=0 ) error("CLEAR parameter must be a multiple of STRIDE"); log.printf(" clearing grid every %u steps \n",clearstride); } } if( keywords.exists("LOGWEIGHTS") ) { std::vector<std::string> wwstr; parseVector("LOGWEIGHTS",wwstr); if( wwstr.size()>0 ) log.printf(" reweighting using weights from "); std::vector<Value*> arg( getArguments() ); for(unsigned i=0; i<wwstr.size(); ++i) { ActionWithValue* val = plumed.getActionSet().selectWithLabel<ActionWithValue*>(wwstr[i]); if( !val ) error("could not find value named"); weights.push_back( val->copyOutput(val->getLabel()) ); arg.push_back( val->copyOutput(val->getLabel()) ); log.printf("%s ",wwstr[i].c_str() ); } if( wwstr.size()>0 ) log.printf("\n"); else log.printf(" weights are all equal to one\n"); requestArguments( arg ); } if( keywords.exists("UNORMALIZED") ) parseFlag("UNORMALIZED",unormalised); }
Mapping::Mapping(const ActionOptions&ao): Action(ao), ActionAtomistic(ao), ActionWithArguments(ao), ActionWithValue(ao), ActionWithVessel(ao) { // Read the input std::string mtype; parse("TYPE",mtype); bool skipchecks; parseFlag("DISABLE_CHECKS",skipchecks); // Setup the object that does the mapping mymap = new PointWiseMapping( mtype, skipchecks ); // Read the properties we require if( keywords.exists("PROPERTY") ){ std::vector<std::string> property; parseVector("PROPERTY",property); if(property.size()==0) error("no properties were specified"); mymap->setPropertyNames( property, false ); } else { std::vector<std::string> property(1); property[0]="sss"; mymap->setPropertyNames( property, true ); } // Open reference file std::string reference; parse("REFERENCE",reference); FILE* fp=fopen(reference.c_str(),"r"); if(!fp) error("could not open reference file " + reference ); // Read all reference configurations bool do_read=true; std::vector<double> weights; unsigned nfram=0, wnorm=0., ww; while (do_read){ PDB mypdb; // Read the pdb file do_read=mypdb.readFromFilepointer(fp,plumed.getAtoms().usingNaturalUnits(),0.1/atoms.getUnits().getLength()); // Fix argument names expandArgKeywordInPDB( mypdb ); if(do_read){ mymap->readFrame( mypdb ); ww=mymap->getWeight( nfram ); weights.push_back( ww ); wnorm+=ww; nfram++; } else { break; } } fclose(fp); if(nfram==0 ) error("no reference configurations were specified"); log.printf(" found %d configurations in file %s\n",nfram,reference.c_str() ); for(unsigned i=0;i<weights.size();++i) weights[i] /= wnorm; mymap->setWeights( weights ); // Finish the setup of the mapping object // Get the arguments and atoms that are required std::vector<AtomNumber> atoms; std::vector<std::string> args; mymap->getAtomAndArgumentRequirements( atoms, args ); requestAtoms( atoms ); std::vector<Value*> req_args; interpretArgumentList( args, req_args ); requestArguments( req_args ); // Duplicate all frames (duplicates are used by sketch-map) mymap->duplicateFrameList(); fframes.resize( 2*nfram, 0.0 ); dfframes.resize( 2*nfram, 0.0 ); plumed_assert( !mymap->mappingNeedsSetup() ); // Resize all derivative arrays mymap->setNumberOfAtomsAndArguments( atoms.size(), args.size() ); // Resize forces array if( getNumberOfAtoms()>0 ){ forcesToApply.resize( 3*getNumberOfAtoms() + 9 + getNumberOfArguments() ); } else { forcesToApply.resize( getNumberOfArguments() ); } }