コード例 #1
0
ファイル: Maximize_method.cpp プロジェクト: nliko/mainline
void Maximize_method::run(Program_options & options, ostream & output) {
    Wavefunction * wf=NULL;
    Sample_point * sample=NULL;
    sys->generateSample(sample);
    wfdata->generateWavefunction(wf);
    sample->attachObserver(wf);

    int nconfig=100;
    Array1 <Config_save_point> config_pos(nconfig);
    Array1 <doublevar> epos(3);

    Primary guidewf;
    generate_sample(sample,wf,wfdata,&guidewf,nconfig,config_pos);
    int nelectrons=sample->electronSize();
    Properties_gather mygather;

    string tablename=options.runid+".table";
    ofstream tableout(tablename.c_str());

    for(int e=0; e< nelectrons; e++) {
        sample->getElectronPos(e,epos);
        for(int d=0; d< 3; d++) {
            tableout << "e" << e << "_"<< d << " ";
        }
    }
    tableout << "elocal" << endl;

    for(int i=0; i < nconfig; i++) {
        maximize(sample,wf,config_pos(i));
        for(int e=0; e< nelectrons; e++) {
            sample->getElectronPos(e,epos);
            for(int d=0; d< 3; d++) {
                tableout << epos(d) << " ";
            }
        }
        Properties_point pt;
        mygather.gatherData(pt, pseudo, sys, wfdata, wf,
                            sample, &guidewf);

        tableout << pt.energy(0) << endl;

        config_pos(i).write(cout);
    }

    delete wf;
    delete sample;
}
コード例 #2
0
ファイル: Postprocess_method.cpp プロジェクト: nliko/mainline
//----------------------------------------------------------------------
int Postprocess_method::gen_point(Wavefunction * wf, Sample_point * sample,
    Config_save_point & configpos, doublevar weight, Properties_point & pt) { 
  Primary guide;
  Properties_gather gather;
  
  configpos.restorePos(sample);
  
  pseudo->randomize();
  if(evaluate_energy) 
    gather.gatherData(pt,pseudo,sys,wfdata,wf,sample,&guide);
  pt.avgrets.Resize(1,average_var.GetDim(0));
  //cout << mpi_info.node << " generating a point with " << average_var.GetDim(0) << " avgrets " << endl;
  for(int i=0; i< average_var.GetDim(0); i++) { 
    average_var(i)->randomize(wfdata,wf,sys,sample);
    average_var(i)->evaluate(wfdata, wf, sys, pseudo,sample,pt, pt.avgrets(0,i));
  }
  for(int i=0; i< densplt.GetDim(0); i++) densplt(i)->accumulate(sample,weight);
  pt.weight(0)=weight;
  
}
コード例 #3
0
doublevar Reptation_method::slither(int direction,
                                    deque <Reptile_point> & reptile,
                                    Properties_gather & mygather, 
                                    Reptile_point & pt, 
                                    doublevar & main_diffusion) {
  
  Dynamics_info dinfo;
  int nelectrons=sample->electronSize();
  
  for(int e=0; e<nelectrons; e++) {
    sampler->sample(e,sample, wf, 
                    mywfdata, guidewf, dinfo, timestep);

  }
  //Update all the quantities we want
  mygather.gatherData(pt.prop, pseudo, sys, mywfdata, wf, sample, guidewf);


  pt.savePos(sample);

  
  doublevar nen=pt.prop.energy(0);
  doublevar olden=0.0;
  deque<Reptile_point>::iterator last_point;
  if(reptile.size() >0) {
    if(direction==1 ) 
      last_point=(reptile.end()-1);
    else 
      last_point=reptile.begin();
      olden=last_point->prop.energy(0);
  }

  //Cutting off the energy
  doublevar fbet=max(eref-nen,eref-olden);
  doublevar cutoff=1;
  if(fbet > 1.5*energy_cutoff) 
    cutoff=0;
  else if(fbet > energy_cutoff) 
    cutoff*=(1.-(fbet-energy_cutoff)/(.5*energy_cutoff));

  pt.branching=-0.5*timestep*cutoff*(olden+nen);

  
  
  //Acceptance..
  doublevar lost_branching=0;
  if(reptile.size()>0) { 
    if(direction==1 )
      lost_branching=(reptile.begin()+1)->branching;
    else
      lost_branching=(reptile.end()-1)->branching;
  }
  doublevar accept=exp(pt.branching-lost_branching);

  if(pt.prop.wf_val.amp(0,0) < -1e12 ) {
    cout  << "rejecting based on wf value" << endl;
    accept=0;
  }
  
  pt.prop.avgrets.Resize(1,average_var.GetDim(0));
  for(int i=0; i< average_var.GetDim(0); i++) { 
    average_var(i)->evaluate(mywfdata, wf, sys, sample, pt.prop.avgrets(0,i));
  }
  
  return accept;
}