예제 #1
0
WOSPotential::ValueType
WOSPotential::method5(ParticleSet& P)
{
  static const double V0 = 0;
  /// intialise the particles in WP;
  WP->setP(P);
  Domain domain;   /// create domain;
  double branch = 0.0;
  double tau = 0.01;
  double v0 = -8.709;
  double pe = 0.0;
  double dpe = 0.0;
  for(int irun = 0; irun < m_runs; irun++)
  {
    domain.runner = WP->R0;                /// initialise runner
    domain.in_device = true;               /// runner is inside device
    device->MaximumSphere(domain);         /// calc d_{0}
    //    domain.WalkOnSphere();
    double Gwt = domain.ImportanceWalk();
    double vD0 = device->OC_contrib0(domain.radius,domain.runner,WP);
    double vbare = device->OC_passage(V0,domain,WP);
    WP->calcwt();
    double vol = 0.0;
    while(domain.in_device)
    {
      device->MaximumSphere(domain);
      vol += device->contribk(domain,WP);
      domain.WalkOnSphere();
      vbare += device->OC_passage(V0,domain,WP);
    }
    vol *= WP->qwt;   /// the half has been included
    //    double vrun = vol + vbare + vD0;
    double vrun = 0.25*(vol + vbare)/Gwt + vD0;
    pe += vrun;
    dpe += vrun * vrun;
    //    cout << vrun << '\t' << v0 << '\t' << branch << endl;
  }
  pe *= m_norm;
  branch *= m_norm;
  dpe *= m_norm;
  dpe = sqrt(m_norm * fabs ( dpe - pe * pe ));
  double var = dpe - pe * pe;
  cout << "correlated: " << pe << '\t' << dpe << '\t' << var << '\t'
       << branch << '\t' << branch*exp(-0.5*var*tau*tau) << endl;
  exit(-1);
  return pe;
}
예제 #2
0
/// importance sampling
WOSPotential::ValueType
WOSPotential::method3(ParticleSet& P)
{
  WP->setP(P);
  Domain domain;
  double pe = 0.0;
  double dpe = 0.0;
  for(int irun = 0; irun < m_runs; irun++)
  {
    double vrun = 0.0;
    for(int i = 0; i < WP->m_qpts; i++)
      /// start run
    {
      domain.runner = WP->R[i];
      domain.in_device = true;
      device->MaximumSphere(domain);
      double vi = device->contrib0(i,domain,WP);
      double Gwt = domain.ImportanceWalk();
      double vbare = device->passage(domain);
      double vol = 0.0;
      while(domain.in_device)
      {
        device->MaximumSphere(domain);
        vol += device->contribk(domain,WP);
        domain.WalkOnSphere();
        vbare += device->passage(domain);
      }                                  /// end walk: runner on boundary
      //      vi = 0.0; vol = 0.0;
      vi = WP->Q[i] * (0.25*( 0.5 * vol + vbare )/Gwt + 0.5*vi);
      vrun += vi;
    }                                       /// end run/particle loop
    pe += vrun;
    dpe += vrun * vrun;         /// collect statistics
  }                                         /// end runners-loop
  /// compute estimates
  pe *= m_norm;
  dpe *= m_norm;
  dpe = sqrt(m_norm * fabs ( dpe - pe * pe ));
  double var = dpe - pe * pe;
  cout << "importance: " << pe << '\t' << dpe << '\t' << var << endl;
  exit(-1);
  return pe;
}