예제 #1
0
파일: Parser.cpp 프로젝트: aappleby/Tuplit
ParseStatus Parser::parseCall() {
  assert(lex[0].isIdentifier());
  assert(lex[1].isDelimiter(DL_LPAREN));

  Atom func = resolve(lex[0].text);
  if (func.isNil()) {
    // Couldn't resolve function call name.
    return PARSE_ERROR;
  }
  lex++;

  // Save the stack top.
  Atom* args = stack.empty() ? NULL : &stack.back();

  // Parse argument list, push arguments onto the stack.
  ParseStatus error = parseAtomList();
  if (error) return error;

  if (args == NULL && !stack.empty()) args = &stack[0];

  // Invoke function
  if (func.isHook()) {
    // Should emit code, but interpreting for now...
    stack.push(Atom::nil);
    func.getHook()(args);
  }

  // Done.
  return PARSE_OK;
}
예제 #2
0
SetupMolInfo::SetupMolInfo( const ActionOptions&ao ):
Action(ao),
ActionSetup(ao),
ActionAtomistic(ao),
pdb(*new(PDB))
{
  // Read what is contained in the pdb file
  parse("MOLTYPE",mytype);

  std::vector<SetupMolInfo*> moldat=plumed.getActionSet().select<SetupMolInfo*>();
  if( moldat.size()!=0 ) error("cannot use more than one MOLINFO action in input");

  std::vector<AtomNumber> backbone;
  parseAtomList("CHAIN",backbone);
  if( read_backbone.size()==0 ){
      for(unsigned i=1;;++i){
          parseAtomList("CHAIN",i,backbone);
          if( backbone.size()==0 ) break;
          read_backbone.push_back(backbone);
          backbone.resize(0);
      }
  } else {
      read_backbone.push_back(backbone);
  }
  if( read_backbone.size()==0 ){
    std::string reference; parse("STRUCTURE",reference);

    if( ! pdb.read(reference,plumed.getAtoms().usingNaturalUnits(),0.1/plumed.getAtoms().getUnits().getLength()))plumed_merror("missing input file " + reference );

    std::vector<std::string> chains; pdb.getChainNames( chains );
    log.printf("  pdb file named %s contains %u chains \n",reference.c_str(), static_cast<unsigned>(chains.size()));
    for(unsigned i=0;i<chains.size();++i){
       unsigned start,end; std::string errmsg;
       pdb.getResidueRange( chains[i], start, end, errmsg );
       if( errmsg.length()!=0 ) error( errmsg );
       AtomNumber astart,aend; 
       pdb.getAtomRange( chains[i], astart, aend, errmsg );
       if( errmsg.length()!=0 ) error( errmsg );
       log.printf("  chain named %s contains residues %u to %u and atoms %u to %u \n",chains[i].c_str(),start,end,astart.serial(),aend.serial());
    }
  }
}
예제 #3
0
void ActionAtomistic::parseAtomList(const std::string&key, std::vector<AtomNumber> &t){
  parseAtomList(key,-1,t);
}
예제 #4
0
CoordinationBase::CoordinationBase(const ActionOptions&ao):
  PLUMED_COLVAR_INIT(ao),
  pbc(true),
  serial(false),
  invalidateList(true),
  firsttime(true)
{

  parseFlag("SERIAL",serial);

  vector<AtomNumber> ga_lista,gb_lista;
  parseAtomList("GROUPA",ga_lista);
  parseAtomList("GROUPB",gb_lista);

  bool nopbc=!pbc;
  parseFlag("NOPBC",nopbc);
  pbc=!nopbc;

// pair stuff
  bool dopair=false;
  parseFlag("PAIR",dopair);

// neighbor list stuff
  bool doneigh=false;
  double nl_cut=0.0;
  int nl_st=0;
  parseFlag("NLIST",doneigh);
  if(doneigh) {
    parse("NL_CUTOFF",nl_cut);
    if(nl_cut<=0.0) error("NL_CUTOFF should be explicitly specified and positive");
    parse("NL_STRIDE",nl_st);
    if(nl_st<=0) error("NL_STRIDE should be explicitly specified and positive");
  }

  addValueWithDerivatives(); setNotPeriodic();
  if(gb_lista.size()>0) {
    if(doneigh)  nl= new NeighborList(ga_lista,gb_lista,dopair,pbc,getPbc(),nl_cut,nl_st);
    else         nl= new NeighborList(ga_lista,gb_lista,dopair,pbc,getPbc());
  } else {
    if(doneigh)  nl= new NeighborList(ga_lista,pbc,getPbc(),nl_cut,nl_st);
    else         nl= new NeighborList(ga_lista,pbc,getPbc());
  }

  requestAtoms(nl->getFullAtomList());

  log.printf("  between two groups of %u and %u atoms\n",static_cast<unsigned>(ga_lista.size()),static_cast<unsigned>(gb_lista.size()));
  log.printf("  first group:\n");
  for(unsigned int i=0; i<ga_lista.size(); ++i) {
    if ( (i+1) % 25 == 0 ) log.printf("  \n");
    log.printf("  %d", ga_lista[i].serial());
  }
  log.printf("  \n  second group:\n");
  for(unsigned int i=0; i<gb_lista.size(); ++i) {
    if ( (i+1) % 25 == 0 ) log.printf("  \n");
    log.printf("  %d", gb_lista[i].serial());
  }
  log.printf("  \n");
  if(pbc) log.printf("  using periodic boundary conditions\n");
  else    log.printf("  without periodic boundary conditions\n");
  if(dopair) log.printf("  with PAIR option\n");
  if(doneigh) {
    log.printf("  using neighbor lists with\n");
    log.printf("  update every %d steps and cutoff %f\n",nl_st,nl_cut);
  }
}