diff --git a/applications/qmc/sse4/model.h b/applications/qmc/sse4/model.h index 3146c0adb..17f8aecc8 100644 --- a/applications/qmc/sse4/model.h +++ b/applications/qmc/sse4/model.h @@ -90,19 +90,6 @@ class Model { _lowering_matrix_elements.resize(lattice.max_site_type() + 1); construct_vertices(); - - if (epsilon <= 0.0 && model.is_signed()) { - epsilon = *std::max_element( - _max_diag_me.begin(), - _max_diag_me.end() - ); - - std::cout - << "Warning: Hamiltonian has a sign problem and EPSILON<=0.\n" - << "Automatically setting EPSILON = " - << epsilon - << " (largest diagonal matrix element).\n"; - } } std::vector const& nbstates() const @@ -289,8 +276,7 @@ class Model { unsigned nneighbors0 = lattice.nneighbors(sites[0]); unsigned nneighbors1 = lattice.nneighbors(sites[1]); - // _max_diag_me[i] = std::numeric_limits::min(); - _max_diag_me[i] = std::numeric_limits::lowest(); + _max_diag_me[i] = std::numeric_limits::lowest(); for (unsigned l = 0; l < nstates[i]; ++l) { vertex_type vertex; @@ -339,9 +325,26 @@ class Model { if (epsilon == 0.0 && !have_diagonal) throw std::runtime_error("Hamiltonian looks purely off-diagonal. " "Parameter EPSILON has to be non zero for SSE to work."); - - if (epsilon <= 0.0) - epsilon = 1e-6; + if (epsilon <= 0.0) { + if (model.is_signed()) { + // A tiny EPSILON can make the diagonal update effectively + // non-ergodic for signed models. Use the largest positive + // diagonal matrix element once those elements are known. + epsilon = 1e-6; + for (std::vector::const_iterator it = _max_diag_me.begin(); + it != _max_diag_me.end(); ++it) + if (*it > epsilon) + epsilon = *it; + + std::cout + << "Warning: Hamiltonian has a sign problem and EPSILON<=0.\n" + << "Automatically setting EPSILON = " << epsilon + << " (largest positive diagonal matrix element, with a " + "1e-6 minimum).\n"; + } else { + epsilon = 1e-6; + } + } std::set::const_iterator sti = site_types.begin(); for (; sti != site_types.end(); ++sti)