コード例 #1
0
  mc_weight_type Try() {
#ifdef DEBUG
   std::cout << "I AM IN Try for Insert_Cdag_C_Delta" << std::endl;
   std::cout << "CONFIG BEFORE: " << Config.DT << std::endl;
   // for (int a = 0; a<Config.Na; ++a) print_det(Config.dets[a]);
#endif
   // Pick up the value of alpha and choose the operators
   const Hloc::Operator 
    & Op1(*Config.CdagOps[a_level][Random(Nalpha)]),
    & Op2(*Config.COps[a_level][Random(Nalpha)]);

   // Choice of times.
   double tau1 = Random(Config.Beta), tau2 = Random(Config.Beta);

   // record the length of the kinks
   if (Config.RecordStatisticConfigurations) {
    deltaTau = Config.CyclicOrientedTimeDistance(tau2 - tau1);
    HISTO_Length_Kinks_Proposed<< deltaTau;
   }

   // Insert the operators Op1 and Op2
   Configuration::OP_REF O1, O2;
   tie (no_trivial_reject,O1,O2) = Config.DT.insertTwoOperators(tau1,Op1,tau2,Op2);
   if (!no_trivial_reject) return 0;

   // pick up the determinant 
   // NB ; the det has to be recomputed each time, since global moves will change it
   det = Config.dets[a_level]; 
   int numCdag=1;

   // Find the position for insertion in the determinant
   // NB : the determinant store the C in decreasing order.
   for (Configuration::DET_TYPE::Cdagger_iterator p= det->Cdagger_begin();
     (p != det->Cdagger_end()) && (p->tau > tau1)  ; ++p, ++numCdag) {}
   int numC=1;
   for (Configuration::DET_TYPE::C_iterator p= det->C_begin(); 
     (p != det->C_end()) &&  (p->tau > tau2) ; ++p, ++numC) {}

   // acceptance probability
   mc_weight_type p = Config.DT.ratioNewTrace_OldTrace() * det->try_insert(numCdag,numC,O1,O2);
   double Tratio =power(2*Nalpha* Config.Beta / double(2*(det->NumberOfC()+1)), 2);

#ifdef DEBUG
   std::cout << "Trace Ratio: " << Config.DT.ratioNewTrace_OldTrace() << std::endl;
   std::cout << "p*T: " << p*Tratio << std::endl;
   std::cout << "CONFIG AFTER: " << Config.DT << std::endl;
   //for (int a = 0; a<Config.Na; ++a) print_det(Config.dets[a]);
#endif
   return p*Tratio;
  }
コード例 #2
0
 mc_weight_type Try() {

#ifdef DEBUG
  std::cout << "I AM IN Try for Remove_Cdag_C_Delta" << std::endl;
  std::cout << "CONFIG BEFORE: " << Config.DT << std::endl;
  //for (int a = 0; a<Config.Na; ++a) print_det(Config.dets[a]);
#endif

  // the det has to be recomputed each time, since global moves will change it
  det = Config.dets[a_level]; 

  // Pick up a couple of C, Cdagger to remove at random
  const int Na(det->NumberOfC());
  if (Na==0) return 0;
  int numCdag = 1 + Random(Na);
  int numC = 1 + Random(Na);
  // det is in decreasing order.
  numC    = Na - numC  + 1;
  numCdag = Na - numCdag  + 1;

  // Remove the operators from the traces
  // the -Na +1 is to move backward, to compare with V1 ...
  Config.DT.removeTwoOperators(*det->select_Cdagger( numCdag ),
    *det->select_C( numC ));

  // Acceptance probability
  mc_weight_type p = Config.DT.ratioNewTrace_OldTrace() * det->try_remove(numCdag,numC);
  double Tratio = power(2*Nalpha* Config.Beta / double(2*Na) ,2);

#ifdef DEBUG
  std::cout << "RATIO: " << Config.DT.ratioNewTrace_OldTrace() << std::endl;
  std::cout << "CONFIG AFTER: " << Config.DT << std::endl;
  //for (int a = 0; a<Config.Na; ++a) print_det(Config.dets[a]);
#endif

  return p/Tratio;
 }