예제 #1
0
void CoordinationBase::prepare() {
  if(nl->getStride()>0) {
    if(firsttime || (getStep()%nl->getStride()==0)) {
      requestAtoms(nl->getFullAtomList());
      invalidateList=true;
      firsttime=false;
    } else {
      requestAtoms(nl->getReducedAtomList());
      invalidateList=false;
      if(getExchangeStep()) error("Neighbor lists should be updated on exchange steps - choose a NL_STRIDE which divides the exchange stride!");
    }
    if(getExchangeStep()) firsttime=true;
  }
}
예제 #2
0
파일: ActionIMD.cpp 프로젝트: apoma/plumed2
IMD::IMD(const ActionOptions& ao):
  Action(ao),
  ActionAtomistic(ao),
  ActionPilot(ao),
  host("localhost"),
  port(0),
  wait(false),
  wrap(false),
  sock(NULL),
  clientsock(NULL),
  connected(false),
  transferRate(100),
  fscale(1.0)
{
  natoms=plumed.getAtoms().getNatoms();

  std::vector<AtomNumber> index(natoms);
  for(int i=0;i<natoms;i++) index[i].setIndex(i);
  requestAtoms(index);
  coord.resize(natoms*3,float(0.0));
  forces.resize(natoms*3,0.0);

  parseFlag("WAIT",wait);
  bool nowait=false;
  parseFlag("NOWAIT",nowait);
  if(nowait)wait=false;
  parseFlag("WRAP",wrap);
  parse("PORT",port);
  parse("HOST",host);
  parse("FSCALE",fscale);

  checkRead();

  log.printf("  with host %s\n",host.c_str());
  log.printf("  with port %d\n",port);
  if(wait) log.printf("  waiting for a connection\n");
  else     log.printf("  not waiting for a connection\n");
  if(wrap) log.printf("  wrapping atoms\n");
  else     log.printf("  not wrapping atoms\n");
  log.printf("  WMD forces will be scaled by %f\n",fscale);

  if(comm.Get_rank()==0){
    vmdsock_init();
    sock = vmdsock_create();
    vmdsock_bind(sock, port);
    vmdsock_listen(sock);
  }

  connect();
}
예제 #3
0
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() );
  }
}
예제 #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);
  }
}
예제 #5
0
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() );
  }
}