Exemplo n.º 1
0
 bool WalkerControlBase::put(xmlNodePtr cur) 
 {
   ParameterSet params;
   params.add(targetEnergyBound,"energyBound","double");
   params.add(targetSigma,"sigmaBound","double");
   params.add(MaxCopy,"maxCopy","int"); 
   bool success=params.put(cur);
   app_log() << "  WalkerControlBase parameters " << endl;
   //app_log() << "    energyBound = " << targetEnergyBound << endl;
   //app_log() << "    sigmaBound = " << targetSigma << endl;
   app_log() << "    maxCopy = " << MaxCopy << endl;
   return true;
 }
Exemplo n.º 2
0
bool SHEGPotential::put(xmlNodePtr cur)
{
  ParameterSet params;
  params.add(Rs,"rs","double");
  params.add(Zext,"Z","double");
  params.add(Zgauss,"Zgauss","double");
  params.add(Sgauss,"Sgauss","double");
  params.put(cur);
  if(Zext<Ntot)
  {
    XMLReport("Invalid background charge Z=" << Zext << "  Overwriting by " << Ntot);
    Zext=Ntot;
  }
  return true;
}
Exemplo n.º 3
0
 void QMCDriverFactory::putCommunicator(xmlNodePtr cur)
 {
   //BROKEN: myComm is ALWAYS initialized by the constructor
   if(myComm) return;
   ParameterSet params;
   int nparts=1;
   params.add(nparts,"groups","int");
   params.add(nparts,"twistAngles","int");
   params.put(cur);
   if(nparts>1) 
   {
     app_log() << "  Communiator groups = " << nparts << endl;
     myComm = new Communicate(*OHMMS::Controller,nparts);
   }
 }
Exemplo n.º 4
0
 void QMCDriverFactory::putCommunicator(xmlNodePtr cur)
 {
   //this should be done only once
   if(qmcComm) return;
   ParameterSet params;
   int nparts=1;
   params.add(nparts,"groups","int");
   params.add(nparts,"twistAngles","int");
   params.put(cur);
   if(nparts>1) 
   {
     app_log() << "  Communiator groups = " << nparts << endl;
     qmcComm = new Communicate(*OHMMS::Controller,nparts);
   }
 }
  bool singleRPAJastrowBuilder::put(xmlNodePtr cur, int addOrbital)
    {
    MyName="Jep";
    string rpafunc="RPA";
    OhmmsAttributeSet a;
    a.add(MyName,"name");
    a.add(rpafunc,"function");
    a.put(cur);

    ParameterSet params;
    RealType Rs(-1.0);
    RealType Kc(-1.0);
    params.add(Rs,"rs","double");
    params.add(Kc,"kc","double");

    params.put(cur);
        
    if(Rs<0) {
        Rs=tlen;
    }

    if(Kc<0){ 
      Kc = 1e-6 ;
    };


    if (rpafunc=="RPA"){ 
      myHandler= new LRRPAHandlerTemp<EPRPABreakup<RealType>,LPQHIBasis>(targetPtcl,Kc);
      app_log()<<"  using e-p RPA"<<endl;
    }
    else if (rpafunc=="dRPA") {
      myHandler= new LRRPAHandlerTemp<derivEPRPABreakup<RealType>,LPQHIBasis>(targetPtcl,Kc);
      app_log()<<"  using e-p derivRPA"<<endl;
    }
    myHandler->Breakup(targetPtcl,Rs);
    
//     app_log() << "  Maximum K shell " << myHandler->MaxKshell << endl;
//     app_log() << "  Number of k vectors " << myHandler->Fk.size() << endl;
    
    
    //Add short range part
    Rcut = myHandler->get_rc()-0.1;
    GridType* myGrid = new GridType;
    int npts=static_cast<int>(Rcut/0.01)+1;
    myGrid->set(0,Rcut,npts);

      //create the numerical functor
    nfunc = new FuncType;
    SRA = new ShortRangePartAdapter<RealType>(myHandler);
    SRA->setRmax(Rcut);
    nfunc->initialize(SRA, myGrid);
    J1s = new JneType (*sourcePtcl,targetPtcl);
    for(int ig=0; ig<ng; ig++) {
      J1s->addFunc(ig,nfunc);
    }

    app_log()<<" Only Short range part of E-I RPA is implemented"<<endl;
    if (addOrbital) targetPsi.addOrbital(J1s,MyName);
    return true;
  }
Exemplo n.º 6
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool Parameter::attachTo(PublicObject* parent) {
	if ( parent == NULL ) return false;

	// check all possible parents
	ParameterSet* parameterSet = ParameterSet::Cast(parent);
	if ( parameterSet != NULL )
		return parameterSet->add(this);

	SEISCOMP_ERROR("Parameter::attachTo(%s) -> wrong class type", parent->className());
	return false;
}
Exemplo n.º 7
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool Comment::attachTo(PublicObject* parent) {
	if ( parent == NULL ) return false;

	// check all possible parents
	MomentTensor* momentTensor = MomentTensor::Cast(parent);
	if ( momentTensor != NULL )
		return momentTensor->add(this);
	FocalMechanism* focalMechanism = FocalMechanism::Cast(parent);
	if ( focalMechanism != NULL )
		return focalMechanism->add(this);
	Amplitude* amplitude = Amplitude::Cast(parent);
	if ( amplitude != NULL )
		return amplitude->add(this);
	Magnitude* magnitude = Magnitude::Cast(parent);
	if ( magnitude != NULL )
		return magnitude->add(this);
	StationMagnitude* stationMagnitude = StationMagnitude::Cast(parent);
	if ( stationMagnitude != NULL )
		return stationMagnitude->add(this);
	Pick* pick = Pick::Cast(parent);
	if ( pick != NULL )
		return pick->add(this);
	Event* event = Event::Cast(parent);
	if ( event != NULL )
		return event->add(this);
	Origin* origin = Origin::Cast(parent);
	if ( origin != NULL )
		return origin->add(this);
	Parameter* parameter = Parameter::Cast(parent);
	if ( parameter != NULL )
		return parameter->add(this);
	ParameterSet* parameterSet = ParameterSet::Cast(parent);
	if ( parameterSet != NULL )
		return parameterSet->add(this);
	Stream* stream = Stream::Cast(parent);
	if ( stream != NULL )
		return stream->add(this);
	SensorLocation* sensorLocation = SensorLocation::Cast(parent);
	if ( sensorLocation != NULL )
		return sensorLocation->add(this);
	Station* station = Station::Cast(parent);
	if ( station != NULL )
		return station->add(this);
	Network* network = Network::Cast(parent);
	if ( network != NULL )
		return network->add(this);

	SEISCOMP_ERROR("Comment::attachTo(%s) -> wrong class type", parent->className());
	return false;
}
Exemplo n.º 8
0
  bool RPAJastrow::put(xmlNodePtr cur){
    ReportEngine PRE("RPAJastrow","put");
    xmlNodePtr myNode=xmlCopyNode(cur,1);

    //capture attribute jastrow/@name
    MyName="RPA_Jee";
    string useL="yes";
    string useS="yes";
    rpafunc="RPA";
    
    OhmmsAttributeSet a;
    a.add(MyName,"name");
    a.add(useL,"longrange");
    a.add(useS,"shortrange");
    a.add(rpafunc,"function");
    a.put(cur);

    Rs=-1.0;
    Kc=-1.0;
    string ID_Rs="RPA_rs";
    ParameterSet params;
    params.add(Rs,"rs","double");
    params.add(Kc,"kc","double");
    params.put(cur);
    buildOrbital(MyName, useL, useS, rpafunc, Rs, Kc);

//     app_log() <<endl<<"   LongRangeForm is "<<rpafunc<<endl;
// 
//     DropLongRange = (useL == "no");
//     DropShortRange = (useS=="no");
// 
//     app_log() << "    Rs can be optimized using ID=" << ID_Rs << endl;
//     RealType tlen = std::pow(3.0/4.0/M_PI*targetPtcl.Lattice.Volume/ static_cast<RealType>(targetPtcl.getTotalNum()) ,1.0/3.0);
//     
//     if(Rs<0) {
//       if(targetPtcl.Lattice.SuperCellEnum) {
//         Rs=tlen;
//       } else {
//         cout<<"  Error finding rs. Is this an open system?!"<<endl;
//         Rs=100.0;
//       }
//     }
//     
//     //Add Rs to optimizable list
//     myVars.insert(ID_Rs,Rs,true);
//     
//     int indx = targetPtcl.SK->KLists.ksq.size()-1;
//     double Kc_max=std::pow(targetPtcl.SK->KLists.ksq[indx],0.5);
// 
//     if(Kc<0){ 
//       Kc = 2.0*  std::pow(2.25*M_PI,1.0/3.0)/tlen ;
//     }
//     
//     if(Kc>Kc_max){
//       Kc=Kc_max;
//       app_log() << "    Kc set too high. Resetting to the maximum value"<<endl;
//     }
// 
//     app_log() << "    RPAJastrowBuilder::addTwoBodyPart Rs = " << Rs <<  "  Kc= " << Kc << endl;
//     
//     if (rpafunc=="Yukawa" || rpafunc=="breakup"){
//       myHandler= new LRHandlerTemp<YukawaBreakup<RealType>,LPQHIBasis>(targetPtcl,Kc);
//     } else if (rpafunc=="RPA"){
//       myHandler= new LRRPAHandlerTemp<RPABreakup<RealType>,LPQHIBasis>(targetPtcl,Kc);
//     } else if (rpafunc=="dYukawa"){
//       myHandler= new LRHandlerTemp<DerivYukawaBreakup<RealType>,LPQHIBasis >(targetPtcl,Kc);
//     } else if (rpafunc=="dRPA"){
//       myHandler= new LRRPAHandlerTemp<DerivRPABreakup<RealType>,LPQHIBasis >(targetPtcl,Kc);
//     }
//     
//     
//     myHandler->Breakup(targetPtcl,Rs);
//     
//     app_log() << "  Maximum K shell " << myHandler->MaxKshell << endl;
//     app_log() << "  Number of k vectors " << myHandler->Fk.size() << endl;
// 
//     if(!DropLongRange) makeLongRange();
//     if(!DropShortRange) makeShortRange();

    return true;
  }
Exemplo n.º 9
0
 bool VMCUpdatePbyP::put(xmlNodePtr cur)
 {
   ParameterSet params;
   params.add(nSubSteps,"subSteps","int"); params.add(nSubSteps,"substeps","int");
   return params.put(cur);
 }
Exemplo n.º 10
0
int SimpleFixedNodeBranch::resetRun(xmlNodePtr cur)
{
  //estimator is always reset
  MyEstimator->reset();
  MyEstimator->setCollectionMode(true);
  bitset<B_MODE_MAX> bmode(BranchMode);
  IParamType iparam_old(iParam);
  VParamType vparam_old(vParam);
  myNode=cur;
  //store old target
  int nw_target=iParam[B_TARGETWALKERS];
  m_param.put(cur);

  int target_min=-1;
  ParameterSet p;
  p.add(target_min,"minimumtargetwalkers","int"); //p.add(target_min,"minimumTargetWalkers","int"); 
  p.add(target_min,"minimumsamples","int"); //p.add(target_min,"minimumSamples","int");
  p.put(cur);

  if (iParam[B_TARGETWALKERS] < target_min) {
    iParam[B_TARGETWALKERS] = target_min;
  }


  bool same_wc=true;
  if(BranchMode[B_DMC] && WalkerController)
  {
    string reconfig("no");
    if(WalkerController->MyMethod) reconfig="yes";
    string reconfig_prev(reconfig);
    ParameterSet p;
    p.add(reconfig,"reconfiguration","string");
    p.put(cur);
    same_wc=(reconfig==reconfig_prev);
  }

  //everything is the same, do nothing
  if(same_wc && bmode==BranchMode
      && std::equal(iParam.begin(),iParam.end(),iparam_old.begin())
      && std::equal(vParam.begin(),vParam.end(),vparam_old.begin())
    )
  {
    app_log() << "  Continue with the same input as the previous block." << endl;
    app_log().flush();
    return 1;
  }
  app_log() << " SimpleFixedNodeBranch::resetRun detected changes in <parameter>'s " << endl;
  app_log() << " BranchMode : " << bmode << " " << BranchMode << endl;

  //vmc does not need to do anything with WalkerController
  if(!BranchMode[B_DMC])
  {
    app_log() << " iParam (old): "  <<iparam_old << endl;
    app_log() << " iParam (new): "  <<iParam << endl;
    app_log() << " vParam (old): "  <<vparam_old << endl;
    app_log() << " vParam (new): "  <<vParam << endl;
    app_log().flush();
    return 1;
  }
  if(WalkerController==0)
  {
    APP_ABORT("SimpleFixedNodeBranch::resetRun cannot initialize WalkerController");
  }

  if(!same_wc)
  {
    app_log() << "Destroy WalkerController. Existing method " << WalkerController->MyMethod << endl;;
    delete WalkerController;
    WalkerController = createWalkerController(iParam[B_TARGETWALKERS], MyEstimator->getCommunicator(), myNode);
    app_log().flush();

    BranchMode[B_POPCONTROL]= (WalkerController->MyMethod == 0);
    if(BranchMode[B_POPCONTROL])
    {
      vParam[B_ETRIAL]=vParam[B_EREF];
      vParam[B_FEEDBACK]=1.0;
    }
  }

  //always add a warmup step using default 10 steps
  R2Accepted.clear();
  R2Proposed.clear();
  //R2Accepted(1.0e-12);
  //R2Proposed(1.0e-12);
  BranchMode[B_DMCSTAGE]=0;
  ToDoSteps=iParam[B_WARMUPSTEPS]=(iParam[B_WARMUPSTEPS])?iParam[B_WARMUPSTEPS]:10;
  BranchMode.set(B_USETAUEFF,sParam[USETAUOPT]=="no");
  if(BranchMode[B_POPCONTROL])
    logN = std::log(static_cast<RealType>(iParam[B_TARGETWALKERS]));
  else
  {
    //vParam[B_ETRIAL]=0.0;
    vParam[B_ETRIAL]=vParam[B_EREF];
    vParam[B_FEEDBACK]=0.0;
    logN=0.0;
  }
  WalkerController->put(myNode);
  WalkerController->setEnergyAndVariance(vParam[B_EREF],vParam[B_SIGMA]);
  WalkerController->reset();
  if(BackupWalkerController)
    BackupWalkerController->reset();

  iParam[B_MAXWALKERS]=WalkerController->Nmax;
  iParam[B_MINWALKERS]=WalkerController->Nmin;

  app_log() << " iParam (old): "  <<iparam_old << endl;
  app_log() << " iParam (new): "  <<iParam << endl;
  app_log() << " vParam (old): "  <<vparam_old << endl;
  app_log() << " vParam (new): "  <<vParam << endl;
  app_log().flush();
  //  return static_cast<int>(iParam[B_TARGETWALKERS]*1.01/static_cast<double>(nw_target));
  return static_cast<int>(round(static_cast<double>(iParam[B_TARGETWALKERS]/static_cast<double>(nw_target))));
}
Exemplo n.º 11
0
bool
VMCSingleOMP::put(xmlNodePtr q)
{
  //grep minimumTargetWalker
  int target_min=-1;
  ParameterSet p;
  p.add(target_min,"minimumtargetwalkers","int"); //p.add(target_min,"minimumTargetWalkers","int"); 
  p.add(target_min,"minimumsamples","int"); //p.add(target_min,"minimumSamples","int");
  p.put(q);

  app_log() << "\n<vmc function=\"put\">"
    << "\n  qmc_counter=" << qmc_common.qmc_counter << "  my_counter=" << MyCounter<< endl;
  if(qmc_common.qmc_counter && MyCounter)
  {
    nSteps=prevSteps;
    nStepsBetweenSamples=prevStepsBetweenSamples;
  }
  else
  {
    int nw=W.getActiveWalkers();
    //compute samples and overwrite steps for the given samples
    int Nthreads = omp_get_max_threads();
    int Nprocs=myComm->size();
    //target samples set by samples or samplesperthread/dmcwalkersperthread
    nTargetPopulation=std::max(nTargetPopulation,nSamplesPerThread*Nprocs*Nthreads);
    nTargetSamples=static_cast<int>(std::ceil(nTargetPopulation));

    if(nTargetSamples)
    {
      int nwtot=nw*Nprocs;  //total number of walkers used by this qmcsection
      nTargetSamples=std::max(nwtot,nTargetSamples);
      if(target_min>0) 
      { 
        nTargetSamples=std::max(nTargetSamples,target_min);
        nTargetPopulation=std::max(nTargetPopulation,static_cast<double>(target_min));
      }
      nTargetSamples=((nTargetSamples+nwtot-1)/nwtot)*nwtot; // nTargetSamples are always multiples of total number of walkers
      nSamplesPerThread=nTargetSamples/Nprocs/Nthreads;
      int ns_target=nTargetSamples*nStepsBetweenSamples; //total samples to generate
      int ns_per_step=Nprocs*nw;  //total samples per step
      nSteps=std::max(nSteps,(ns_target/ns_per_step+nBlocks-1)/nBlocks);
      Period4WalkerDump=nStepsBetweenSamples=(ns_per_step*nSteps*nBlocks)/nTargetSamples;
    }
    else
    {
      Period4WalkerDump = nStepsBetweenSamples=(nBlocks+1)*nSteps; //some positive number, not used
      nSamplesPerThread=0;
    }
  }
  prevSteps=nSteps;
  prevStepsBetweenSamples=nStepsBetweenSamples;

  app_log() << "  time step      = " << Tau << endl;
  app_log() << "  blocks         = " << nBlocks << endl;
  app_log() << "  steps          = " << nSteps << endl;
  app_log() << "  substeps       = " << nSubSteps << endl;
  app_log() << "  current        = " << CurrentStep << endl;
  app_log() << "  target samples = " << nTargetPopulation << endl;
  app_log() << "  walkers/mpi    = " << W.getActiveWalkers() << endl << endl;
  app_log() << "  stepsbetweensamples = " << nStepsBetweenSamples << endl;

  m_param.get(app_log());

  if(DumpConfig)
  {
    app_log() << "  DumpConfig==true Configurations are dumped to config.h5 with a period of " << Period4CheckPoint << " blocks" << endl;
  }
  else
  {
    app_log() << "  DumpConfig==false Nothing (configurations, state) will be saved." << endl;
  }

  if (Period4WalkerDump>0)
    app_log() << "  Walker Samples are dumped every " << Period4WalkerDump << " steps." << endl;

  app_log() << "</vmc>" << endl;
  app_log().flush();

  return true;
}