static int dash_mpd_onsegment(void* param, int /*track*/, const void* data, size_t bytes, int64_t /*pts*/, int64_t /*dts*/, int64_t /*duration*/, const char* name)
{
    app_log(LOG_DEBUG, "dash_mpd_onsegment %s\n", name);
	FILE* fp = fopen(name, "wb");
	fwrite(data, 1, bytes, fp);
    fclose(fp);

    dash_playlist_t* dash = (dash_playlist_t*)param;
    if(!strendswith(name, "-init.m4v") && !strendswith(name, "-init.m4a"))
        dash->files.push_back(name);
    while (dash->files.size() > 20)
    {
        app_log(LOG_DEBUG, "Delete %s\n", dash->files.front().c_str());
        path_rmfile(dash->files.front().c_str());
        dash->files.pop_front();
    }

    AutoThreadLocker locker(s_locker);
    dash_mpd_playlist(dash->mpd, dash->playlist, sizeof(dash->playlist));
	return 0;
}
  void SimpleFixedNodeBranch::finalize(MCWalkerConfiguration& w) 
  {

    ostringstream o;
    if(WalkerController)
    {
      o << "====================================================";
      o << "\n  SimpleFixedNodeBranch::finalize after a DMC block" ;
      o << "\n    QMC counter                   = " << iParam[B_COUNTER];
      o << "\n    time step                     = " << vParam[B_TAU];
      o << "\n    effective time step           = " << vParam[B_TAUEFF];
      o << "\n    trial energy                  = " << vParam[B_ETRIAL];
      o << "\n    reference energy              = " << vParam[B_EREF];
      o << "\n    reference variance            = " << vParam[B_SIGMA];
      o << "\n    target walkers                = " << iParam[B_TARGETWALKERS];
      o << "\n    branch cutoff                 = " << vParam[B_BRANCHCUTOFF] << " " << vParam[B_BRANCHMAX];
      o << "\n    Max and mimum walkers per node= " << iParam[B_MAXWALKERS] << " " << iParam[B_MINWALKERS];
      o << "\n    Feedback                      = " << vParam[B_FEEDBACK];
      o << "\n    QMC Status (BranchMode)       = " << BranchMode;
      o << "\n====================================================";
      
    }
    else
    {//running VMC
      RealType e, sigma2;
      //MyEstimator->getEnergyAndWeight(e,w,sigma2);
      MyEstimator->getCurrentStatistics(w,e,sigma2);
      vParam[B_ETRIAL]=vParam[B_EREF]=e;
      vParam[B_SIGMA]=std::sqrt(sigma2);
      //vParam[B_SIGMA]=std::sqrt(iParam[B_TARGETWALKERS]*sigma2);
      
      //vParam[B_ETRIAL]=vParam[B_EREF]=e/w;
      //vParam[B_SIGMA]=std::sqrt(sigma2);

      //this is just to avoid diving by n-1  == 0
      EnergyHist(vParam[B_EREF]);

      //add Eref to the DMCEnergyHistory
      //DMCEnergyHist(vParam[B_EREF]);
      o << "====================================================";
      o << "\n  SimpleFixedNodeBranch::finalize after a VMC block" ;
      o << "\n    QMC counter        = " << iParam[B_COUNTER];
      o << "\n    time step          = " << vParam[B_TAU];
      o << "\n    reference energy   = " << vParam[B_EREF];
      o << "\n    reference variance = " << vParam[B_SIGMA];
      o << "\n====================================================";
    }

    app_log() << o.str() << endl;

    write(RootName,true);
  }
示例#3
0
int main(int argc, char *argv[])
{
    if(!REND_INIT())
        return 1;
    rend_set_log_callback(&log_handler);

    app_log("Beginning tests...");
    testing::InitGoogleTest(&argc, argv);
    int ret = RUN_ALL_TESTS();

    rend_shutdown();
    return ret;
}
示例#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);
  }
示例#5
0
  QMCDriver* DMCFactory::create(MCWalkerConfiguration& w, TrialWaveFunction& psi
      , QMCHamiltonian& h, HamiltonianPool& hpool,WaveFunctionPool& ppool) 
  {
#ifdef QMC_CUDA
    if (GPU)
      return new DMCcuda (w, psi, h,ppool);
#endif
    app_log() << "Creating DMCMP for the qmc driver" << endl;
    QMCDriver*  qmc = new DMCOMP(w,psi,h,hpool,ppool);
    qmc->setUpdateMode(PbyPUpdate);
    qmc->put(myNode);
    return qmc;
  }
示例#6
0
/** This should be moved to branch engine */
bool EstimatorManager::put(MCWalkerConfiguration& W, QMCHamiltonian& H, xmlNodePtr cur)
{
  vector<string> extra;
  cur = cur->children;
  while(cur != NULL)
  {
    string cname((const char*)(cur->name));
    if(cname == "estimator")
    {
      string est_name(MainEstimatorName);
      string use_hdf5("yes");
      OhmmsAttributeSet hAttrib;
      hAttrib.add(est_name, "name");
      hAttrib.add(use_hdf5, "hdf5");
      hAttrib.put(cur);
      if( (est_name == MainEstimatorName) || (est_name=="elocal") )
      {
        max4ascii=H.sizeOfObservables()+3;
        add(new LocalEnergyEstimator(H,use_hdf5=="yes"),MainEstimatorName);
      }
      else
        extra.push_back(est_name);
    }
    cur = cur->next;
  }
  if(Estimators.empty())
  {
    app_log() << "  Adding a default LocalEnergyEstimator for the MainEstimator " << endl;
    max4ascii=H.sizeOfObservables()+3;
    add(new LocalEnergyEstimator(H,true),MainEstimatorName);
  }
  //Collectables is special and should not be added to Estimators
  if(Collectables == 0 && H.sizeOfCollectables())
  {
    app_log() << "  Using CollectablesEstimator for collectables, e.g. sk, gofr, density " << endl;
    Collectables=new CollectablesEstimator(H);
  }
  return true;
}
示例#7
0
  void QMCAppBase::saveXml() {

    if(!XmlDocStack.empty()) {
      string newxml(myProject.CurrentMainRoot());
      //string newxml(myProject.CurrentRoot());
      //myProject.PreviousRoot(newxml);
      //myProject.rewind();
      newxml.append(".cont.xml");
      app_log() << "\n========================================================="
                << "\n  A new xml input file : " << newxml << endl;
      XmlDocStack.top()->dump(newxml);
    }
  }
示例#8
0
  bool ParticleSetPool::putLattice(xmlNodePtr cur) 
  {
    ReportEngine PRE("ParticleSetPool","putLattice");
    OhmmsAttributeSet pAttrib;
    pAttrib.add(TileMatrix,"tilematrix"); 
    pAttrib.put(cur);

    if(SimulationCell==0)
    {
      app_log() << "  Create Global SuperCell " << endl;
      SimulationCell = new ParticleSet::ParticleLayout_t;
    }
    else
    {
      app_log() << "  Overwrite Global SuperCell " << endl;
    }
    LatticeParser a(*SimulationCell);
    bool success=a.put(cur);

    SimulationCell->print(app_log());
    return success;
  }
示例#9
0
  void CloneManager::makeClones(MCWalkerConfiguration& w, 
      TrialWaveFunction& psi, QMCHamiltonian& ham)
  {

    if(wClones.size()) 
    {
      app_log() << "  Cannot make clones again. Use existing " << NumThreads << " clones" << endl;
      return;
    }

    wClones.resize(NumThreads,0);
    psiClones.resize(NumThreads,0);
    hClones.resize(NumThreads,0);

    wClones[0]=&w;
    psiClones[0]=&psi;
    hClones[0]=&ham;

    if(NumThreads==1) return;

    app_log() << "  CloneManager::makeClones makes " << NumThreads << " clones for W/Psi/H." <<endl;
#if defined(ENABLE_CLONE_PSI_AND_H)
    app_log() << "  Cloning methods for both Psi and H are used" << endl;
    OhmmsInfo::Log->turnoff();
    OhmmsInfo::Warn->turnoff();
    char pname[16];
    for(int ip=1; ip<NumThreads; ++ip) 
    {
      wClones[ip]=new MCWalkerConfiguration(w);
      psiClones[ip]=psi.makeClone(*wClones[ip]);
      hClones[ip]=ham.makeClone(*wClones[ip],*psiClones[ip]);
    }
    OhmmsInfo::Log->reset();
    OhmmsInfo::Warn->reset();
#else
    app_log() << "Old parse method is used." << endl;
    cloneEngine.clone(w,psi,ham,wClones,psiClones,hClones);
#endif
  }
示例#10
0
文件: FWSingle.cpp 项目: jyamu/qmc
bool
FWSingle::put(xmlNodePtr q)
{
  fname<<xmlrootName<<".storeConfig.h5";
  c_file = H5Fopen(fname.str().c_str(),H5F_ACC_RDONLY,H5P_DEFAULT);
  hsize_t numGrps = 0;
  H5Gget_num_objs(c_file, &numGrps);
  numSteps = static_cast<int> (numGrps)-3;
  app_log()<<"  Total number of steps in input file "<<numSteps<<endl;
  if (weightFreq<1)
    weightFreq=1;
  int numberDataPoints = weightLength/weightFreq;
  //     pointsToCalculate.resize(numberDataPoints);
  //     for(int i=0;i<numberDataPoints;i++) pointsToCalculate[i]=i*weightFreq;
  app_log()<<"  "<<numberDataPoints<<" observables will be calculated each "<<weightFreq<<" steps"<<endl;
  app_log()<<"  Config Generations skipped for thermalization: "<<startStep<<endl;//<<" steps. At: ";
  //     for(int i=0;i<numberDataPoints;i++) app_log()<<pointsToCalculate[i]<<" ";
  app_log()<<endl;
  if (H5Fclose(c_file)>-1)
    c_file=-1;
  return true;
}
示例#11
0
  void AGPDeterminant::resize(int nup, int ndown) 
  {
    BasisSize=GeminalBasis->getBasisSetSize();//BasisSize=GeminalBasis->size();
    app_log() << "  AGPDetermiant::resize checking size nup, ndown, basis " 
      << nup << " " << ndown << " " << BasisSize << endl;

    if(NumPtcls == 0) //use Numptcls to ensure resizing only once
    { 
      Lambda.resize(BasisSize,BasisSize);
      if(nup>ndown) LambdaUP.resize(nup-ndown,BasisSize);

      Nup=nup;
      Ndown=ndown;
      NumPtcls=nup+ndown;

      psiM.resize(nup,nup);
      psiM_temp.resize(nup,nup);
      psiU.resize(nup);
      psiD.resize(ndown);
      phiT.resize(NumPtcls,BasisSize);
      phiTv.resize(BasisSize);

      WorkSpace.resize(nup);
      Pivot.resize(nup);

      dY.resize(NumPtcls,BasisSize);
      d2Y.resize(NumPtcls,BasisSize);
      dpsiU.resize(Nup,Nup);
      dpsiD.resize(Ndown,Nup);
      d2psiU.resize(Nup,Nup);
      d2psiD.resize(Ndown,Nup);
      dpsiUv.resize(Nup);
      d2psiUv.resize(Nup);
      dpsiDv.resize(Nup);
      d2psiDv.resize(Nup);

      FirstAddressOfdVU=&(dpsiU(0,0)[0]);
      LastAddressOfdVU=FirstAddressOfdVU+DIM*Nup*Nup;
      FirstAddressOfdVD=&(dpsiD(0,0)[0]);
      LastAddressOfdVD=FirstAddressOfdVD+DIM*Ndown*Nup;
      FirstAddressOfdY=&(dY(0,0)[0]);
      LastAddressOfdY=FirstAddressOfdY+DIM*NumPtcls*BasisSize;

      myG.resize(NumPtcls);
      myL.resize(NumPtcls);
      myG_temp.resize(NumPtcls);
      myL_temp.resize(NumPtcls);
      FirstAddressOfG = &myG[0][0];
      LastAddressOfG = FirstAddressOfG + DIM*NumPtcls;
    }
  }
示例#12
0
  bool ReptationMC::run() { 

    Estimators->reportHeader(AppendRun);

    initReptile();

    IndexType block = 0;
    IndexType nAcceptTot = 0;
    IndexType nRejectTot = 0;
    
    PolymerEstimator pe(*Reptile);
    pe.resetReportSettings(RootName);

    //accumulate configuration: probably need to reorder
    HDFWalkerOutput WO(RootName);

    do {

      IndexType step = 0;
      NumTurns = 0;

      Estimators->startBlock();
      do {
        moveReptile();
        step++; CurrentStep++;
        W.copyWalkerRefs(Reptile->front(),Reptile->back());
        Estimators->accumulate(W);
        pe.accumulate();
      } while(step<nSteps);

      Estimators->stopBlock(static_cast<RealType>(nAccept)/static_cast<RealType>(nAccept+nReject));
      
      nAcceptTot += nAccept;
      nRejectTot += nReject;
      
      Estimators->report(CurrentStep);
      pe.report(CurrentStep);
      
      nAccept = 0; nReject = 0;
      block++;

    } while(block<nBlocks);
      
    //Need MPI-IO
    app_log() << "ratio = " 
      << static_cast<double>(nAcceptTot)/static_cast<double>(nAcceptTot+nRejectTot)
      << endl;

    Estimators->finalize();
    return true;
  }
示例#13
0
void PWParameterSet::checkVersion(hid_t h)
{
  if(is_manager())
  {
    hid_t dataset=H5Dopen(h,"version");
    hid_t datatype=H5Dget_type(dataset);
    H5T_class_t classtype = H5Tget_class(datatype);
    H5Tclose(datatype);
    H5Dclose(dataset);
    if(classtype == H5T_INTEGER)
    {
      HDFAttribIO<TinyVector<int,2> > hdfver(version);
      hdfver.read(h,"version");
    }
    else
      if(classtype == H5T_FLOAT)
      {
        TinyVector<double,2> vt;
        HDFAttribIO<TinyVector<double,2> > hdfver(vt);
        hdfver.read(h,"version");
        version[0]=int(vt[0]);
        version[1]=int(vt[1]);
      }
    //else
    //{
    //  APP_ABORT("PWParameterSet::checkVersion  The type of version is not integer or double.");
    //}
  }
  myComm->bcast(version);
  app_log() << "\tWavefunction HDF version: " << version[0] << "." << version[1] << endl;
  if(version[0] == 0)
  {
    if(version[1] == 11)
    {
      hasSpin=false;
      paramTag="parameters_0";
      basisTag="basis_1";
      pwTag="planewaves";
      pwMultTag="multipliers";
      eigTag="eigenstates_3";
      twistTag="twist_";
      bandTag="band_";
    }
    else
      if(version[1] == 10)
      {
        pwMultTag="planewaves";
        pwTag="0";
      }
  }
}
示例#14
0
  /** Add walkers to the end of the ensemble of walkers.  
   * @param nwalkers number of walkers to add
   */
  void 
  QMCDriver::addWalkers(int nwalkers) {

    if(nwalkers>0) {
      //add nwalkers walkers to the end of the ensemble
      int nold = W.getActiveWalkers();

      app_log() << "  Adding " << nwalkers << " walkers to " << nold << " existing sets" << endl;

      W.createWalkers(nwalkers);
      if(nold)
      {
        int iw=nold;
        for(MCWalkerConfiguration::iterator it=W.begin()+nold; it != W.end(); ++it,++iw)
          (*it)->R=W[iw%nold]->R;//assign existing walker configurations when the number of walkers change
      }

    } else if(nwalkers<0) {
      W.destroyWalkers(-nwalkers);
      app_log() << "  Removed " << -nwalkers << " walkers. Current number of walkers =" << W.getActiveWalkers() << endl;
    } else {
      app_log() << "  Using the current " << W.getActiveWalkers() << " walkers." <<  endl;
    }

    //update the global number of walkers
    //int nw=W.getActiveWalkers();
    //myComm->allreduce(nw);
    vector<int> nw(myComm->size(),0),nwoff(myComm->size()+1,0);
    nw[myComm->rank()]=W.getActiveWalkers();
    myComm->allreduce(nw);

    for(int ip=0; ip<myComm->size(); ip++) nwoff[ip+1]=nwoff[ip]+nw[ip];
    W.setGlobalNumWalkers(nwoff[myComm->size()]);
    W.setWalkerOffsets(nwoff);

    app_log() << "  Total number of walkers: " << W.EnsembleProperty.NumSamples  <<  endl;
    app_log() << "  Total weight: " << W.EnsembleProperty.Weight  <<  endl;
  }
ECPComponentBuilder::RadialPotentialType*
ECPComponentBuilder::createVrWithBasisGroup(xmlNodePtr cur, GridType* agrid)
{
  //todo rcut should be reset if necessary
  typedef GaussianTimesRN<RealType> InFuncType;
  InFuncType a;
  a.putBasisGroup(cur);
  bool ignore=true;
  const RealType eps=1e-4;
  RealType rout=agrid->rmax()*2;
  while(ignore&&rout>agrid->rmax())
  {
    ignore=(abs(a.f(rout))<eps);
    rout-=0.01;
  }
  rout += 0.01;
  app_log() << "  cutoff for non-local pseudopotential = " << agrid->rmax() << endl;
  app_log() << "  calculated cutoff for " << eps << " = " << rout << endl;
  int ng = agrid->size();
  if(agrid->GridTag != LINEAR_1DGRID)// || rout > agrid->rmax())
  {
    RealType ri=0.0;
    RealType rf=std::max(rout,agrid->rmax());
    delete agrid;
    agrid = new LinearGrid<RealType>;
    agrid->set(ri,rf,ng);
    app_log() << "  Reset the grid for SemiLocal component to a LinearGrid. " << endl;
  }
  std::vector<RealType> v(ng);
  for(int ig=0; ig<ng; ig++)
  {
    v[ig]=a.f((*agrid)[ig]);
  }
  v[ng-1]=0.0;
  RadialPotentialType *app=new RadialPotentialType(agrid,v);
  app->spline();
  return app;
}
示例#16
0
文件: MPC.cpp 项目: jyamu/qmc
void
MPC::init_gvecs()
{
  TinyVector<int,OHMMS_DIM> maxIndex;
  PosType b[OHMMS_DIM];
  for (int j=0; j < OHMMS_DIM; j++)
  {
    maxIndex[j] = 0;
    b[j] = 2.0*M_PI*PtclRef->Lattice.b(j);
  }
  int numG1 = PtclRef->Density_G.size();
  int numG2 = PtclRef->DensityReducedGvecs.size();
  assert (PtclRef->Density_G.size() == PtclRef->DensityReducedGvecs.size());
  // Loop through all the G-vectors, and find the largest
  // indices in each direction with energy less than the cutoff
  for (int iG=0; iG < PtclRef->DensityReducedGvecs.size(); iG++)
  {
    TinyVector<int,OHMMS_DIM> gint = PtclRef->DensityReducedGvecs[iG];
    PosType G = (double)gint[0] * b[0];
    for (int j=1; j<OHMMS_DIM; j++)
      G += (double)gint[j]*b[j];
    if (0.5*dot(G,G) < Ecut)
    {
      for (int j=0; j<OHMMS_DIM; j++)
        maxIndex[j] = max(maxIndex[j], abs(gint[j]));
      Gvecs.push_back(G);
      Gints.push_back(gint);
      Rho_G.push_back(PtclRef->Density_G[iG]);
    }
  }
  SplineDim = 4 * maxIndex;
  MaxDim = max(maxIndex[0], max(maxIndex[1], maxIndex[2]));
  app_log() << "  Using " << Gvecs.size()
            << " G-vectors for MPC interaction.\n";
  app_log() << "   Using real-space box of size [" << SplineDim[0]
            << "," << SplineDim[1] << "," << SplineDim[2]
            << "] for MPC spline.\n";
}
示例#17
0
  void FWSingleOMP::transferParentsOneGeneration( )
  {

    vector<vector<long> >::reverse_iterator stepIDIterator(IDs.rbegin());
    vector<vector<long> >::reverse_iterator stepPIDIterator(PIDs.rbegin()), nextStepPIDIterator(realPIDs.rbegin());
    stepIDIterator+=gensTransferred;
    nextStepPIDIterator+=gensTransferred;
    int i(0);
    do
    {
      vector<long>::iterator hereID( (*stepIDIterator).begin() ) ;
      vector<long>::iterator nextStepPID( (*nextStepPIDIterator).begin() );
      vector<long>::iterator herePID( (*stepPIDIterator).begin() );
      if (verbose>2) app_log()<<"  calculating Parent IDs for gen:"<<gensTransferred<<" step:"<<i<<"/"<<PIDs.size()-gensTransferred<<endl;
      if (verbose>2) {printIDs((*nextStepPIDIterator));printIDs((*stepIDIterator));printIDs((*stepPIDIterator));}
      do
      {
        if ((*herePID)==(*hereID)) 
        {
          (*herePID)=(*nextStepPID);
          herePID++;
        }
        else
        {
          hereID++; nextStepPID++;
          if (hereID==(*stepIDIterator).end()) 
          {
            hereID=(*stepIDIterator).begin();
            nextStepPID=(*nextStepPIDIterator).begin();
            //             if (verbose>2) app_log()<<"resetting to beginning of parents"<<endl;
          }
        }
      }while(herePID<(*stepPIDIterator).end());
      stepIDIterator++;nextStepPIDIterator++;stepPIDIterator++;i++;
    }while(stepIDIterator<IDs.rend());
    gensTransferred++; //number of gens backward to compare parents
    if (verbose>2) app_log()<<"  Finished generation block"<<endl;
  }
示例#18
0
uint8_t setLight(Light *light)
{
    DictionaryIterator *iter = NULL;

    AppMessageResult result = app_message_outbox_begin(&iter);
    if (result != APP_MSG_OK) {
        app_log(APP_LOG_LEVEL_WARNING, __FILE__, __LINE__, ",unable to send request, status %d", result);
        return false;
    }
    DictionaryResult result2 = dict_write_data(iter, TAG_LIGHT, (uint8_t *)light, sizeof(Light));
    if (result2 != DICT_OK) {
        app_log(APP_LOG_LEVEL_WARNING, __FILE__, __LINE__, ",unable to send data, status %d", result2);
        return false;
    }
    uint16_t r = REQUEST_SET;
    result2 = dict_write_data(iter, TAG_REQUEST_TYPE, (uint8_t *)&r, sizeof(uint16_t));
    if (result2 != DICT_OK) {
        app_log(APP_LOG_LEVEL_WARNING, __FILE__, __LINE__, ",unable to send request, status %d", result2);
        return false;
    }
    app_message_outbox_send();
    return true;
}
示例#19
0
bool
project_in_use (int p_num)
{
    
    if (proj_time[p_num] != 0 || proj_start[p_num] ||
        proj_running[p_num] ||
        (proj_name[p_num] && *proj_name[p_num])) {
        /* This project is being used */
	app_log(APP_LOG_LEVEL_DEBUG, __FILE__, __LINE__,
		"project %d is in use - proj_time=%d,proj_start=%d,proj_running=%d,proj_name=0x%x <%d>",
                p_num,
                (int)proj_time[p_num],
                (int)proj_start[p_num],
                (int)proj_running[p_num],
                (uint)proj_name[p_num],
                (int)*proj_name[p_num]
            );
        return (true);
    }
    app_log(APP_LOG_LEVEL_DEBUG, __FILE__, __LINE__,
            "project %d is not use", p_num);
    return (false);
}
示例#20
0
void destroy_chrono_objects() {
  app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "destroy_chrono_objects");

  if (chrono_digital_window != NULL) {
    window_destroy(chrono_digital_window);
    chrono_digital_window = NULL;
  }

  hand_cache_destroy(&chrono_minute_cache);
  hand_cache_destroy(&chrono_second_cache);
  hand_cache_destroy(&chrono_tenth_cache);

  bwd_destroy(&chrono_dial_white);
}
  /** return the ratio
   * @param P current configuration
   * @param iat particle whose position is moved
   * @param dG differential Gradients
   * @param dL differential Laplacians
   *
   * Data member *_temp contain the data assuming that the move is accepted
   * and are used to evaluate differential Gradients and Laplacians.
   */
  RNDiracDeterminantBaseAlternate::ValueType RNDiracDeterminantBaseAlternate::ratio(ParticleSet& P, int iat,
      ParticleSet::ParticleGradient_t& dG,
      ParticleSet::ParticleLaplacian_t& dL)
  {
    UpdateMode=ORB_PBYP_ALL;
    Phi->evaluate(P, iat, psiV, dpsiV, d2psiV);
    RatioTimer.start();
    WorkingIndex = iat-FirstIndex;

    //psiM_temp = psiM;
    curRatio= DetRatioByRow(psiM_temp, psiV, WorkingIndex);
    RatioTimer.stop();
    if (abs(curRatio)<numeric_limits<RealType>::epsilon())
      {
        app_log()<<"stepped on node"<<endl;
        UpdateMode=ORB_PBYP_RATIO; //singularity! do not update inverse
        return 0.0;
      }
    RealType R = std::abs(curRatio);
    RealType logR = std::log(R);
    RealType bp = 1+std::exp(logepsilon-2.0*LogValue-2.0*logR);
    alternateCurRatio = R*std::sqrt(bp/(1+std::exp(logepsilon-2.0*LogValue)));
    bp = 1.0/bp;

    UpdateTimer.start();
    //update psiM_temp with the row substituted
    InverseUpdateByRow(psiM_temp,psiV,workV1,workV2,WorkingIndex,curRatio);

    //update dpsiM_temp and d2psiM_temp
    std::copy(dpsiV.begin(),dpsiV.end(),dpsiM_temp[WorkingIndex]);
    std::copy(d2psiV.begin(),d2psiV.end(),d2psiM_temp[WorkingIndex]);
    UpdateTimer.stop();
    RatioTimer.start();
    for (int i=0,kat=FirstIndex; i<NumPtcls; i++,kat++)
      {
        //using inline dot functions
        GradType rv=dot(psiM_temp[i],dpsiM_temp[i],NumOrbitals);
        ValueType lap=dot(psiM_temp[i],d2psiM_temp[i],NumOrbitals);
        ValueType rv2 = dot(rv,rv);

        dG[kat] += rv - myG[kat];
        myG_temp[kat]= rv;

        dL[kat] += (lap - rv2) -myL[kat];
        myL_temp[kat]= (lap - rv2) ;
      }
    RatioTimer.stop();

    return curRatio;
  }
  void SimpleFixedNodeBranch::checkParameters(MCWalkerConfiguration& w) 
  {
    if(!BranchMode[B_DMCSTAGE])
    {
      RealType e, sigma2;
      MyEstimator->getCurrentStatistics(w,e,sigma2);
      vParam[B_ETRIAL]=vParam[B_EREF]=e;
      //vParam[B_SIGMA]=std::sqrt(iParam[B_TARGETWALKERS]*sigma2);
      vParam[B_SIGMA]=std::sqrt(sigma2);

      EnergyHist.clear();
      VarianceHist.clear();
      //DMCEnergyHist.clear();

      EnergyHist(vParam[B_EREF]);
      VarianceHist(vParam[B_SIGMA]);
      //DMCEnergyHist(vParam[B_EREF]);

      app_log() << "SimpleFixedNodeBranch::checkParameters " << endl;
      app_log() << "  Average Energy of a population  = " << e << endl;
      app_log() << "  Energy Variance = " << vParam[B_SIGMA] << endl;
    }
  }
示例#23
0
文件: MPC.cpp 项目: jyamu/qmc
bool MPC::put(xmlNodePtr cur)
{
  Ecut = -1.0;
  OhmmsAttributeSet attribs;
  attribs.add (Ecut, "cutoff");
  attribs.put (cur);
  if (Ecut < 0.0)
  {
    Ecut = 30.0;
    app_log() << "    MPC cutoff not found.  Set using \"cutoff\" attribute.\n"
              << "    Setting to default value of " << Ecut << endl;
  }
  return true;
}
示例#24
0
  ///initialize polymers
  void ReptationMC::initReptile() {
    
    //overwrite the number of cuts for Bounce algorithm
    if(UseBounce) NumCuts = 1;

    app_log() << "Moving " << NumCuts << " for each reptation step" << endl;

    //Reptile is NOT allocated. Create one.
    if(Reptile == 0) {
      MCWalkerConfiguration::iterator it(W.begin());
      Walker_t* cur(*it);
      cur->Weight=1.0;     
      W.R = cur->R;
      //DistanceTable::update(W);
      W.update();
      RealType logpsi(Psi.evaluateLog(W));
      RealType  eloc_cur = H.evaluate(W);
      cur->resetProperty(logpsi,Psi.getPhase(),eloc_cur);
      H.saveProperty(cur->getPropertyBase());
      cur->Drift = W.G;
      Reptile  = new PolymerChain(cur,PolymerLength,NumCuts);
      Reptile->resizeArrays(1);
    }

    //If ClonePolyer==false, generate configuration using diffusion
    //Not so useful
    if(!ClonePolymer) {
      Walker_t* cur((*Reptile)[0]);
      RealType g = std::sqrt(Tau);
      for(int i=0; i<NumCuts-1; i++ ) {
        //create a 3N-Dimensional Gaussian with variance=1
        makeGaussRandom(deltaR);
        W.R = cur->R + g*deltaR + Tau*cur->Drift;
        
        //update the distance table associated with W
        //DistanceTable::update(W);
        W.update();
        
        //evaluate wave function
        RealType logpsic(Psi.evaluateLog(W));
        RealType e0=H.evaluate(W);
        cur = (*Reptile)[i+1];	  
        cur->resetProperty(logpsic,Psi.getPhase(),e0);
        H.saveProperty(cur->getPropertyBase());

        cur->R = W.R;
        cur->Drift = W.G;
      }
    }
  }
RNDiracDeterminantBase::ValueType
RNDiracDeterminantBase::ratioGrad(ParticleSet& P, int iat, GradType& grad_iat)
{
  Phi->evaluate(P, iat, psiV, dpsiV, d2psiV);
  RatioTimer.start();
  WorkingIndex = iat-FirstIndex;
  UpdateMode=ORB_PBYP_PARTIAL;
  alternateCurRatio=simd::dot(psiM[WorkingIndex],psiV.data(),NumOrbitals);
  if (abs(alternateCurRatio)< numeric_limits<RealType>::epsilon())
  {
    app_log()<<"stepped on node: ratioGrad"<<endl;
    RatioTimer.stop();
    return 0.0;
  }
  RealType R = std::abs(alternateCurRatio);
  RealType logR = std::log(R);
  RealType bp = 1+std::exp(logepsilon-2.0*alternateLogValue-2.0*logR) ;
  curRatio=R*std::sqrt(bp/(1.0+std::exp(logepsilon-2.0*alternateLogValue)));
//     bp=std::sqrt(1.0/bp);
  bp = 1.0/bp;
  GradType rv=simd::dot(psiM[WorkingIndex],dpsiV.data(),NumOrbitals);
  grad_iat += (1.0/alternateCurRatio) *bp* rv;
  RatioTimer.stop();
  return curRatio;
  ////////////////////////////////////////
  ////THIS WILL BE REMOVED. ONLY FOR DEBUG DUE TO WAVEFUNCTIONTEST
  //{
  //  int kat=FirstIndex;
  //  for(int j=0; j<NumOrbitals; j++) {
  //    dpsiM_temp(WorkingIndex,j)=dpsiV[j];
  //    d2psiM_temp(WorkingIndex,j)=d2psiV[j];
  //  }
  //  const ValueType* restrict yptr=psiM_temp.data();
  //  const ValueType* restrict d2yptr=d2psiM_temp.data();
  //  const GradType* restrict dyptr=dpsiM_temp.data();
  //  for(int i=0; i<NumPtcls; i++,kat++) {
  //    //This mimics gemm with loop optimization
  //    GradType rv;
  //    ValueType lap=0.0;
  //    for(int j=0; j<NumOrbitals; j++,yptr++) {
  //      rv += *yptr * *dyptr++;
  //      lap += *yptr * *d2yptr++;
  //    }
  //    lap -= dot(rv,rv);
  //    myG_temp[kat]=rv;
  //    myL_temp[kat]=lap;
  //  }
  //}
  ////////////////////////////////////////
}
示例#26
0
///** add a distance table to DistTables list
// * @param d_table pointer to a DistanceTableData to be added
// *
// * DistTables is a list of DistanceTables which are updated by MC moves.
// */
//void ParticleSet::addTable(DistanceTableData* d_table) {
//  int oid=d_table->origin().tag();
//  int i=0;
//  int dsize=DistTables.size();
//  while(i<dsize) {
//    if(oid == DistTables[i]->origin().tag()) //table already exists
//      return;
//    ++i;
//  }
//  DistTables.push_back(d_table);
//}
int ParticleSet::addTable(const ParticleSet& psrc)
{
  if (DistTables.empty())
  {
    DistTables.reserve(4);
    DistTables.push_back(createDistanceTable(*this));
    //add  this-this pair
    myDistTableMap.clear();
    myDistTableMap[ObjectTag]=0;
    app_log() << "  ... ParticleSet::addTable Create Table #0 " << DistTables[0]->Name << endl;
    DistTables[0]->ID=0;
    if (psrc.tag() == ObjectTag)
      return 0;
  }
  if (psrc.tag() == ObjectTag)
  {
    app_log() << "  ... ParticleSet::addTable Reuse Table #" << 0 << " " << DistTables[0]->Name <<endl;
    return 0;
  }
  int tsize=DistTables.size(),tid;
  map<int,int>::iterator tit(myDistTableMap.find(psrc.tag()));
  if (tit == myDistTableMap.end())
  {
    tid=DistTables.size();
    DistTables.push_back(createDistanceTable(psrc,*this));
    myDistTableMap[psrc.tag()]=tid;
    DistTables[tid]->ID=tid;
    app_log() << "  ... ParticleSet::addTable Create Table #" << tid << " " << DistTables[tid]->Name <<endl;
  }
  else
  {
    tid = (*tit).second;
    app_log() << "  ... ParticleSet::addTable Reuse Table #" << tid << " " << DistTables[tid]->Name << endl;
  }
  app_log().flush();
  return tid;
}
示例#27
0
  /** Advance the walkers nblocks*nsteps timesteps. 
   *
   * For each block:
   * <ul>
   *  <li> Advance walkers for nsteps
   *  For each timestep:
   *   <ul>
   *   <li> Move all the particles of a walker.
   *   <li> Calculate the properties for the new walker configuration.
   *   <li> Accept/reject the new configuration.
   *   <li> Accumulate the estimators.
   *   <li> Update the trial energy \f$ E_T \f$
   *   <li> Branch the population of walkers (birth/death algorithm).
   *   </ul>
   * <li> Flush the estimators and print to file.
   * <li> Update the estimate of the local energy.
   * <li> (Optional) Print the ensemble of walker configurations.
   * </ul>
   * Default mode: Print the ensemble of walker configurations 
   * at the end of the run.
   */
  bool DMCMoveAll::run() { 

    bool fixW = (Reconfiguration == "yes");

    branchEngine->initWalkerController(Tau,fixW);
    KillNodeCrossing = (KillWalker == "yes");

    if(Mover ==0) {
      if(NonLocalMove == "yes") {
        app_log() << "  Non-local update is used." << endl;
        DMCNonLocalUpdate* nlocMover= new DMCNonLocalUpdate(W,Psi,H,Random);
        nlocMover->put(qmcNode);
        Mover=nlocMover;
        NonLocalMoveIndex=Estimators->addColumn("NonLocalMove");
      } else {
        if(KillNodeCrossing) {
          app_log() << "  Walkers will be killed if a node crossing is detected." << endl;
          Mover = new DMCUpdateAllWithKill(W,Psi,H,Random);
        } else {
          app_log() << "  Walkers will be kept even if a node crossing is detected." << endl;
          Mover = new DMCUpdateAllWithRejection(W,Psi,H,Random);
        }
      }
    }

    Estimators->reportHeader(AppendRun);

    Mover->resetRun(branchEngine);

    bool success=false;
    if(fixW)  {
      if(BranchInterval<0) {
        BranchInterval=nSteps;
        nSteps=1;
      }
      app_log() << "  DMC all-ptcl update with reconfigurations " << endl;
      app_log() << "    BranchInterval=" << BranchInterval << endl;
      app_log() << "    Steps         =" << nSteps << endl;
      app_log() << "    Blocks        =" << nBlocks << endl;
      success = dmcWithReconfiguration();
    } else {
      app_log() << "  DMC all-ptcl update with a fluctuating population" << endl;
      success = dmcWithBranching();
    }

    return success;
  }
示例#28
0
  bool eeI_JastrowBuilder::putkids (xmlNodePtr kids, J3type &J3) 
  {
    SpeciesSet &iSet = sourcePtcl->getSpeciesSet();
    SpeciesSet &eSet = targetPtcl.getSpeciesSet();
    int numiSpecies = iSet.getTotalNum();
    
    bool success=false;
    while (kids != NULL) {
      std::string kidsname = (char*)kids->name;	 
      if (kidsname == "correlation") {
	RealType ee_cusp=0.0;
	RealType eI_cusp=0.0;
	string iSpecies, eSpecies1("u"), eSpecies2("u");
	OhmmsAttributeSet rAttrib;
	rAttrib.add(iSpecies,"ispecies");
	rAttrib.add(eSpecies1,"especies1");
	rAttrib.add(eSpecies2,"especies2");
	rAttrib.add(ee_cusp,"ecusp");
	rAttrib.add(eI_cusp,"icusp");
	rAttrib.put(kids);
	
	typedef typename J3type::FuncType FT;
	FT *functor = new FT(ee_cusp, eI_cusp);
	
	functor->iSpecies = iSpecies;
	functor->eSpecies1 = eSpecies1;
	functor->eSpecies2 = eSpecies2;
	int iNum = iSet.findSpecies (iSpecies);
	int eNum1 = eSet.findSpecies (eSpecies1);
	int eNum2 = eSet.findSpecies (eSpecies2);
	
	functor->put (kids);
	if (functor->cutoff_radius < 1.0e-6) {
	  app_log()  << "  eeI functor rcut is currently zero.\n"
		     << "  Setting to Wigner-Seitz radius = " 
		     << sourcePtcl->Lattice.WignerSeitzRadius << endl;
	  functor->cutoff_radius = sourcePtcl->Lattice.WignerSeitzRadius;
	  functor->reset();
	}
	strstream aname;
	aname << iSpecies << "_" << eSpecies1 << "_" << eSpecies2;
	J3.addFunc(aname.str(), iNum, eNum1, eNum2, functor);
      }
      kids = kids->next;
    }
    targetPsi.addOrbital(&J3,"eeI");
    J3.setOptimizable(true);
    return true;
  }
示例#29
0
  bool DMCMoveAll::dmcWithReconfiguration() {
    Mover->MaxAge=0;
    IndexType block = 0;
    IndexType nAcceptTot = 0;
    IndexType nRejectTot = 0;
    bool checkNonLocalMove=(NonLocalMoveIndex>0);
    //Mover->resetRun(branchEngine);
    do {
      IndexType step = 0;
      Mover->startBlock();
      Estimators->startBlock();
      do {
        int interval=0; 
        Mover->NonLocalMoveAccepted=0;
        do {
          Mover->advanceWalkers(W.begin(), W.end());
          ++interval;
          ++step; ++CurrentStep; 
        } while(interval<BranchInterval);

        if(checkNonLocalMove) {
          Estimators->setColumn(NonLocalMoveIndex, 
              static_cast<RealType>(Mover->NonLocalMoveAccepted)/
              static_cast<RealType>(W.getActiveWalkers()*BranchInterval));
        }

        Estimators->accumulate(W);
        branchEngine->branch(CurrentStep,W);
      } while(step<nSteps);

      nAccept = Mover->nAccept;
      nReject = Mover->nReject;

      Estimators->stopBlock(static_cast<RealType>(nAccept)/static_cast<RealType>(nAccept+nReject));

      nAcceptTot += nAccept;
      nRejectTot += nReject;
      
      nAccept = 0; nReject = 0;
      block++;
      recordBlock(block);
      W.reset();
    } while(block<nBlocks);
    
    //Need MPI-IO
    app_log() << "\t ratio = " << static_cast<double>(nAcceptTot)/static_cast<double>(nAcceptTot+nRejectTot) << endl;

    return finalize(block);
  }
 /** process xml node for each element
  * @param cur xmlnode <element name="string" alpha="double" rb="double"/> 
  */
 bool LocalCorePolPotential::CPP_Param::put(xmlNodePtr cur) 
 {
   OhmmsAttributeSet att;
   att.add(alpha,"alpha");
   att.add(r_b,"rb");
   att.put(cur);
   //const xmlChar* a_ptr = xmlGetProp(cur,(const xmlChar *)"alpha");
   //const xmlChar* b_ptr = xmlGetProp(cur,(const xmlChar *)"rb");
   //if(a_ptr) alpha = atof((const char*)a_ptr);
   //if(b_ptr) r_b = atof((const char*)b_ptr);
   C = -0.5*alpha;
   one_over_rr = 1.0/r_b/r_b;
   app_log() << "\talpha = " << alpha << " rb = " << r_b <<endl;
   return true;
 }