Ejemplo n.º 1
0
/*void StressPBCAA::acceptMove(int active)
{
  if(is_active)
  {
    Return_t* restrict sr_ptr=SR2[active];
    Return_t* restrict pr_ptr=SR2.data()+active;
    for(int iat=0; iat<NumCenters; ++iat, ++sr_ptr,pr_ptr+=NumCenters)
      *pr_ptr = *sr_ptr += dSR[iat];
    Value=NewValue;
  }
}
*/
void StressPBCAA::initBreakup(ParticleSet& P)
{
  //SpeciesSet& tspecies(PtclRef->getSpeciesSet());
  SpeciesSet& tspecies(P.getSpeciesSet());
  //Things that don't change with lattice are done here instead of InitBreakup()
  ChargeAttribIndx = tspecies.addAttribute("charge");
  MemberAttribIndx = tspecies.addAttribute("membersize");
  NumCenters = P.getTotalNum();
  NumSpecies = tspecies.TotalNum;
 // V_const.resize(NumCenters);
  Zat.resize(NumCenters);
  Zspec.resize(NumSpecies);
  NofSpecies.resize(NumSpecies);
  for(int spec=0; spec<NumSpecies; spec++)
  {
    Zspec[spec] = tspecies(ChargeAttribIndx,spec);
    NofSpecies[spec] = static_cast<int>(tspecies(MemberAttribIndx,spec));
  }
  SpeciesID.resize(NumCenters);
  for(int iat=0; iat<NumCenters; iat++)
  {
    SpeciesID[iat]=P.GroupID[iat];
    Zat[iat] = Zspec[P.GroupID[iat]];
  }
  AA = LRCoulombSingleton::getDerivHandler(P);
  //AA->initBreakup(*PtclRef);
  myConst=evalConsts();
  myRcut=AA->get_rc();//Basis.get_rc();
  if(rVs==0)
  {
    rVs = LRCoulombSingleton::createSpline4RbyVs(AA,myRcut,myGrid);
  }
}
Ejemplo n.º 2
0
void ESHDFIonsParser::readESHDF()
{
  int nspecies=0;
  {
    HDFAttribIO<int> a(nspecies);
    a.read(hfile_id,"atoms/number_of_species");
  }
  SpeciesSet& tspecies(ref_.getSpeciesSet());
  int icharge= tspecies.addAttribute("charge");//use charge
  int iatnumber= tspecies.addAttribute(atomic_number_tag);
  int massind= tspecies.addAttribute(mass_tag);
  //add charge
  //atomic_number is optional
  for(int i=0; i<nspecies; ++i)
  {
    ostringstream o;
    o << "atoms/species_"<<i;
    hid_t g=H5Gopen(hfile_id,o.str().c_str());
    string aname;
    HDFAttribIO<string> a(aname);
    a.read(g,"name");
    int ii=tspecies.addSpecies(aname);
    int q=-1;
    HDFAttribIO<int> b(q);
    b.read(g,charge_tag.c_str());
    tspecies(icharge,ii)=q;
    int atnum=0;
    HDFAttribIO<int> c(atnum);
    c.read(g,atomic_number_tag.c_str());
    tspecies(iatnumber,ii)=atnum;
    //close the group
    H5Gclose(g);
  }
  for(int ig=0; ig<nspecies; ++ig)
    tspecies(massind,ig)=1.0;
  //just for checking
  // tspecies(icharge,0)=15.0;
  // tspecies(icharge,1)=6.0;
  {
    //get the unit cell
    Tensor<double,3> alat;
    HDFAttribIO<Tensor<double,3> > a(alat);
    a.read(hfile_id,"supercell/primitive_vectors");
    ref_.Lattice.set(alat);
  }
  {
    //get the unit cell
    int natoms=0;
    HDFAttribIO<int> a(natoms);
    a.read(hfile_id,"atoms/number_of_atoms");
    ref_.create(natoms);
    ref_.R.InUnit=PosUnit::CartesianUnit;
    HDFAttribIO<ParticleSet::ParticlePos_t> b(ref_.R);
    b.read(hfile_id,"atoms/positions");
    HDFAttribIO<ParticleSet::ParticleIndex_t> c(ref_.GroupID);
    c.read(hfile_id,"atoms/species_ids");
  }
  ref_.resetGroups();
}
Ejemplo n.º 3
0
  void VMCcuda::resetRun()
  {
    SpeciesSet tspecies(W.getSpeciesSet());
    int massind=tspecies.addAttribute("mass");
    RealType mass = tspecies(massind,0);
    RealType oneovermass = 1.0/mass;
    RealType oneoversqrtmass = std::sqrt(oneovermass);
    m_oneover2tau = 0.5*mass/Tau;
    m_sqrttau = std::sqrt(Tau/mass);
    m_tauovermass = Tau/mass;

    // Compute the size of data needed for each walker on the GPU card
    PointerPool<Walker_t::cuda_Buffer_t > pool;
    
    Psi.reserve (pool);
    app_log() << "Each walker requires " << pool.getTotalSize() * sizeof(CudaRealType)
	      << " bytes in GPU memory.\n";

    // Now allocate memory on the GPU card for each walker
    // for (int iw=0; iw<W.WalkerList.size(); iw++) {
    //   Walker_t &walker = *(W.WalkerList[iw]);
    //   walker.resizeCuda(pool.getTotalSize());
    //   // pool.allocate(walker.cuda_DataSet);
    // }
    W.allocateGPU(pool.getTotalSize());
    app_log() << "Successfully allocated walkers.\n";
    W.copyWalkersToGPU();
    W.updateLists_GPU();
    vector<RealType> logPsi(W.WalkerList.size(), 0.0);
    //Psi.evaluateLog(W, logPsi);
    Psi.recompute(W, true);
    Estimators->start(nBlocks, true);

    // Compute sample dumping frequency
    if (nTargetSamples) {
      int nnodes = myComm->size();
      int nw = W.WalkerList.size();
      int samples_per_node = (nTargetSamples+nnodes-1)/nnodes; 
      int dumps_per_node   = (samples_per_node+nw-1) / nw;
      myPeriod4WalkerDump = Period4WalkerDump;
      app_log() << "  Dumping walker ensemble every " << myPeriod4WalkerDump
		<< " steps.\n";
    }

    W.clearEnsemble();
    int samples_this_node = nTargetSamples/myComm->size();
    if (nTargetSamples%myComm->size() > myComm->rank()) samples_this_node+=1;
    app_log() << "  Node zero will generate " << samples_this_node << " samples.\n";
    W.setNumSamples(samples_this_node);
  }
Ejemplo n.º 4
0
  void DMCcuda::resetRun()
  {
    resetUpdateEngine();
    SpeciesSet tspecies(W.getSpeciesSet());
    int massind=tspecies.addAttribute("mass");
    RealType mass = tspecies(massind,0);
    RealType oneovermass = 1.0/mass;
    RealType oneoversqrtmass = std::sqrt(oneovermass);
    m_oneover2tau = 0.5/Tau;
    m_sqrttau = std::sqrt(Tau/mass);
    m_tauovermass = Tau/mass;

    if (!myComm->rank())
      gpu::cuda_memory_manager.report();

    // Compute the size of data needed for each walker on the GPU card
    PointerPool<Walker_t::cuda_Buffer_t > pool;
    Psi.reserve (pool);
    app_log() << "Each walker requires " 
	      << pool.getTotalSize() * sizeof(CudaRealType)
	      << " bytes in GPU memory.\n";
    app_log() << "Preparing to allocate " << W.WalkerList.size() 
	      << " walkers.\n";

    // Now allocate memory on the GPU card for each walker
    int cudaSize = pool.getTotalSize();
    for (int iw=0; iw<W.WalkerList.size(); iw++) {
      Walker_t &walker = *(W.WalkerList[iw]);
      walker.resizeCuda(cudaSize);
      //pool.allocate(walker.cuda_DataSet);
    }
    app_log() << "Successfully allocated walkers.\n";
    W.copyWalkersToGPU();
    W.updateLists_GPU();
    vector<RealType> logPsi(W.WalkerList.size(), 0.0);
    //Psi.evaluateLog(W, logPsi);
    Psi.recompute(W, true);
    Estimators->start(nBlocks, true);
  }
Ejemplo n.º 5
0
bool ESHDFIonsParser::put(xmlNodePtr cur)
{
  //add basic attributes of the speciesset
  SpeciesSet& tspecies(ref_.getSpeciesSet());
  int icharge= tspecies.addAttribute("charge");//charge_tag);
  int iatnumber= tspecies.addAttribute(atomic_number_tag);
  int membersize= tspecies.addAttribute("membersize");
  int massind= tspecies.addAttribute(mass_tag);
  if(myComm->rank()==0 && hfile_id>=-1)
    readESHDF();
  if(myComm->size()==1)
    return true;
  int nspecies=tspecies.getTotalNum();
  int natoms=ref_.getTotalNum();
  ostringstream o;
  if(myComm->rank()==0)
  {
    int i=0;
    for(; i<nspecies-1; ++i)
      o<<tspecies.speciesName[i]<<",";
    o<<tspecies.speciesName[i];
  }
  TinyVector<int,3> bsizes(nspecies,natoms,o.str().size()+1);
  myComm->bcast(bsizes);
  //send the names: UGLY!!!!
  nspecies=bsizes[0];
  char *species_names=new char[bsizes[2]];
  if(myComm->rank()==0)
    snprintf(species_names, bsizes[2], "%s",o.str().c_str());
  myComm->bcast(species_names,bsizes[2]);
  if(myComm->rank())
  {
    vector<string> vlist;
    parsewords(species_names,vlist);
    for(int i=0; i<vlist.size(); ++i)
      tspecies.addSpecies(vlist[i]);
    //create natoms particles
    ref_.create(bsizes[1]);
  }
  delete [] species_names;
  ParticleSet::Tensor_t lat(ref_.Lattice.R);
  ParticleSet::Buffer_t pbuffer;
  for(int i=0; i<tspecies.numAttributes(); ++i)
    pbuffer.add(tspecies.d_attrib[i]->begin(),tspecies.d_attrib[i]->end());
  pbuffer.add(lat.begin(),lat.end());
  pbuffer.add(get_first_address(ref_.R),get_last_address(ref_.R));
  pbuffer.add(ref_.GroupID.begin(),ref_.GroupID.end());
  myComm->bcast(pbuffer);
  ref_.R.InUnit=PosUnit::CartesianUnit;
  if(myComm->rank())
  {
    pbuffer.rewind();
    for(int i=0; i<tspecies.numAttributes(); ++i)
      pbuffer.get(tspecies.d_attrib[i]->begin(),tspecies.d_attrib[i]->end());
    pbuffer.get(lat.begin(),lat.end());
    pbuffer.get(get_first_address(ref_.R),get_last_address(ref_.R));
    pbuffer.get(ref_.GroupID.begin(),ref_.GroupID.end());
    ref_.Lattice.set(lat);
  }
  return true;
}