mc_weight_type Try() { #ifdef DEBUG std::cout << "I AM IN Try for Remove_Cdag_C_Delta_SegmentPicture" << 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 pointer 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->size()); if (Na==0) return 0; // I am selecting the n th C or Cdag operator, starting from small time. // Because the det orders the tau in decreasing order (cf insert) // I need to iterate over the C, Cdag in reverse. int n = Random(2*Na); // pick up n // the Cs will look like 0 : c1 c2 c1 c2 c1 c2 c1 c2 : beta // where c1, c2 are C,Cdag or Cdag,C // from n, I now compute the number of the c1,c2 operator (between 0 and N-1) // if n = 2p, n1 = p , n2 = p // if n = 2p+1, n1 = p +1 , n2 = p // e.g. c1[0] c2[0] c1[1] c2[1] c1[2] c2[2] c1[3] c2[3] // n= 0 1 2 3 4 5 6 7 //eg n=2,p=1 { } //eg n=3,p=1 { } //eg n=7,p=3 } { // be careful of the cyclic condition int n1 = 1+ (n+1)/2, n2 = 1 + n/2; const bool use_cyclicity (n1 > Na); if (use_cyclicity) n1 = 1; // cyclic condition // decide whether C1 is C or Cdag bool Cisfirst = (det->Cdagger_rbegin()->tau > det->C_rbegin()->tau ); int numC = (Cisfirst ? n1: n2); int numCdag = (Cisfirst ? n2: n1); #ifdef DEBUG cout<<" Cfirst n n1 n2 "<< Cisfirst<< " "<<n<< " "<< n1 << " "<< n2 <<endl; cout<<numC<< " "<<numCdag <<endl; #endif // take an iterator on the couple C,Cdag Configuration::DET_TYPE::Cdagger_reverse_iterator itCdag = det->select_reverse_Cdagger( numCdag ); Configuration::DET_TYPE::C_reverse_iterator itC = det->select_reverse_C( numC ); // Remove the operators from the traces Config.DT.removeTwoOperators(*itCdag,*itC); // first_point is the first of the couple, next_point is the op on a_level *after* the second // with cyclicity // if cyclicity was not used, the first point is simply the lowest tau // otherwise it is the *highest* tau ! Configuration::OP_REF first_point, next_point; const bool C_before_Cdag(((*itC)->tau < (*itCdag)->tau)); if ((!use_cyclicity && C_before_Cdag) || (use_cyclicity && !C_before_Cdag)) { first_point = *itC; ++itC; next_point = (itC == det->C_rend() ? *det->C_rbegin() : *itC); // cyclicity check } else { first_point = *itCdag; ++itCdag; next_point = (itCdag == det->Cdagger_rend() ? *det->Cdagger_rbegin() : *itCdag); // cyclicity check } double length_max = ( first_point == next_point ? Config.Beta : Config.CyclicOrientedTimeDistance(next_point->tau- first_point->tau) ); // Acceptance probability mc_weight_type p = Config.DT.ratioNewTrace_OldTrace() * det->try_remove(Na-numCdag, Na-numC); double Tratio = (Na ==1 ? 1 : 2*Na) / (Config.Beta * length_max); // (Na term : because if we have only 1 couple of C Cdagger, n = 0 and 1 will lead to the same couple // and this is the only case like this. #ifdef DEBUG cout<< " length_max "<<length_max<<endl; std::cout << "RATIO: " << Config.DT.ratioNewTrace_OldTrace() << std::endl; std::cout << "CONFIG AFTER: " << Config.DT << std::endl; #endif return p*Tratio; }