3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-25 05:43:40 +01:00

mc_tools : add debug print under macro

When TRIQS_MCTOOLS_DEBUG is defined,
the qmc now reports some basic debug info
(when is a move accepted, rejected, ...).
This commit is contained in:
Olivier Parcollet 2013-12-23 23:20:01 +01:00
parent 5f7e0989a3
commit c0993d9db8

View File

@ -26,26 +26,34 @@
#include <boost/mpi.hpp> #include <boost/mpi.hpp>
#include "mc_move_set.hpp" #include "mc_move_set.hpp"
namespace triqs { namespace mc_tools { namespace Step { namespace triqs {
namespace mc_tools {
namespace Step {
// Performs one Metropolis step // Performs one Metropolis step
template<typename MCSignType> template <typename MCSignType> struct Metropolis {
struct Metropolis { static void do_it(move_set<MCSignType>& MoveGroup, random_generator& RNG, MCSignType& signe) {
static void do_it (move_set<MCSignType> & MoveGroup, random_generator & RNG, MCSignType & signe){ double r = MoveGroup.attempt();
double r = MoveGroup.attempt(); if (RNG() < std::min(1.0, r)) {
if (RNG() < std::min(1.0,r)) { #ifdef TRIQS_MCTOOLS_DEBUG
signe *= MoveGroup.accept(); std::cerr << " Move accepted " << std::endl;
#ifdef DEBUG
std::cerr<<" Metropolis sign = "<< signe <<std::endl;
#endif #endif
signe *= MoveGroup.accept();
#ifdef TRIQS_MCTOOLS_DEBUG
std::cerr << " New sign = " << signe << std::endl;
#endif
} else {
#ifdef TRIQS_MCTOOLS_DEBUG
std::cerr << " Move rejected " << std::endl;
#endif
MoveGroup.reject();
} }
else MoveGroup.reject();
} }
}; };
// Put heat Bath here .... // Put heat Bath here ....
}
}}} }
}
#endif #endif