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; }
mc_weight_type Try() { det = Config.dets[a_level]; // NB the det pointer has to be recomputed each time, since global moves will change it #ifdef DEBUG std::cout << "I AM IN Try for Insert_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 // Pick up a time to insert the first operator double tau1 = Random(Config.Beta); // Now find the operator A on the same a level at later time, with cyclicity // and compute the maximal *oriented* length between the 2 operators (with cyclicity) Configuration::OP_REF A; if (det->size()>0) { // non empty Configuration::DET_TYPE::Cdagger_iterator itCdag = det->Cdagger_begin(); Configuration::DET_TYPE::C_iterator itC = det->C_begin(); while ( (itCdag != det->Cdagger_end()) && (itCdag->tau > tau1) ) {++itCdag;} while ( (itC != det->C_end()) && (itC->tau > tau1) ) {++itC;} if (itCdag != det->Cdagger_begin()) --itCdag; else itCdag = --det->Cdagger_end(); if (itC != det->C_begin()) --itC; else itC = --det->C_end(); double rC = Config.CyclicOrientedTimeDistance((*itC)->tau - tau1); double rCdag = Config.CyclicOrientedTimeDistance((*itCdag)->tau - tau1); A = ( rC > rCdag ? *itCdag : * itC); try_insert_length_max = min(rC,rCdag); } else { // empty case. try_insert_length_max = Config.Beta; A = Config.DT.OpRef_end(); } // pick up the actual segment length double rr= Random(try_insert_length_max-2*EPSILON) + EPSILON; // deduce the time of the second operator double tau2 = Config.CyclicOrientedTimeDistance(tau1 + rr); // record the length of the kinks if (Config.RecordStatisticConfigurations) { deltaTau = Config.CyclicOrientedTimeDistance(tau2 - tau1); HISTO_Length_Kinks_Proposed<< abs(deltaTau); } // Choose the operators to be inserted const Hloc::Operator & OpCdag(*Config.CdagOps[a_level][0]), & OpC(*Config.COps[a_level][0]); // shall we add C^+ C or C C^+ // we look whether the next operator is a dagger bool Op1_is_dagger = true; if (!A.atEnd()) { const Configuration::BlockInfo & INFO(Config.info[A->Op->Number]); assert(INFO.isFundamental()); Op1_is_dagger = INFO.dagger; } // Insert the operators Op1 and Op2. // O1 will always be the dagger : // Cf doc of insertTwoOperators, order of output OPREF is the same as input operators Configuration::OP_REF O1, O2; tie (no_trivial_reject,O1,O2) = (Op1_is_dagger ? Config.DT.insertTwoOperators(tau1,OpCdag,tau2,OpC) : Config.DT.insertTwoOperators(tau2,OpCdag,tau1,OpC)); if (!no_trivial_reject) return 0; double tauCdag = (Op1_is_dagger ? tau1 : tau2); double tauC = (Op1_is_dagger ? tau2 : tau1); // Find the position for insertion in the determinant // NB : the determinant store the C in decreasing order. int numCdag=1; for (Configuration::DET_TYPE::Cdagger_iterator p= det->Cdagger_begin(); (p != det->Cdagger_end()) && (p->tau > tauCdag) ; ++p, ++numCdag) {} int numC=1; for (Configuration::DET_TYPE::C_iterator p= det->C_begin(); (p != det->C_end()) && (p->tau > tauC) ; ++p, ++numC) {} // acceptance probability mc_weight_type p = Config.DT.ratioNewTrace_OldTrace() * det->try_insert(numCdag-1,numC-1,O1,O2); int Na(det->size()+1); // !!! det not modified until det->complete_operation is called, so I need to compensate by +1 double Tratio = Config.Beta * try_insert_length_max / (Na ==1 ? 1 : 2*Na); // (Na... term : cf remove move... #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; }