29#include "system/System.hpp"
33#include <boost/mpi/collectives/all_reduce.hpp>
34#include <boost/mpi/collectives/broadcast.hpp>
35#include <boost/range/algorithm/max_element.hpp>
36#include <boost/range/algorithm/min_element.hpp>
44std::string TuningFailed::get_first_error()
const {
47 auto message = std::string(
"tuning failed: an exception was thrown while "
48 "benchmarking the integration loop");
49 for (
auto const &warning : queued_warnings) {
50 if (warning.level() == RuntimeError::ErrorLevel::ERROR) {
51 message +=
" (" + warning.what() +
")";
59 if (acc.
avg() <= 5 * MPI_Wtick()) {
61 <<
"Clock resolution is too low to reliably time integration.";
63 if (acc.
sig() >= 0.1 * acc.
avg()) {
69 auto const error_code = system.
integrate(0, reuse_forces);
82 for (
int i = 0; i < int_steps; i++) {
83 auto const tick = MPI_Wtime();
85 auto const tock = MPI_Wtime();
94 auto retval = 1000. * running_average.
avg();
109 auto const error_code_init =
116 auto const tick = MPI_Wtime();
118 auto const tock = MPI_Wtime();
124 return 1000. * (tock - tick) / int_steps;
129 int int_steps,
bool adjust_max_skin) {
137 auto const max_permissible_skin = std::min(
138 *boost::min_element(cell_structure->max_cutoff()) - maximal_cutoff(),
139 0.5 * *boost::max_element(box_geo->length()));
141 if (adjust_max_skin and max_skin > max_permissible_skin)
142 b = max_permissible_skin;
144 while (fabs(a - b) > tol) {
145 cell_structure->set_verlet_skin(a);
146 auto const time_a =
time_calc(*
this, int_steps);
148 cell_structure->set_verlet_skin(b);
149 auto const time_b =
time_calc(*
this, int_steps);
151 if (time_a > time_b) {
157 cell_structure->set_verlet_skin(0.5 * (a + b));
void tune_verlet_skin(double min_skin, double max_skin, double tol, int int_steps, bool adjust_max_skin)
Tune the Verlet skin.
int integrate(int n_steps, int reuse_forces)
Integrate equations of motion.
Keep running average and variance.
Scalar avg() const
Average of the samples.
Scalar sig() const
Standard deviation of the samples.
void add_sample(Scalar s)
boost::mpi::communicator comm_cart
The communicator.
int this_node
The number of this node.
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
#define runtimeWarningMsg()
Molecular dynamics integrator.
#define INTEG_ERROR_RUNTIME
#define INTEG_REUSE_FORCES_CONDITIONALLY
recalculate forces only if Propagation::recalc_forces is set
#define INTEG_REUSE_FORCES_NEVER
recalculate forces unconditionally (mostly used for timing)
std::vector< RuntimeError > mpi_gather_runtime_errors_all(bool is_head_node)
Gather messages on main rank.
Various procedures concerning interactions between particles.
static void run_full_force_calc(System::System &system, int reuse_forces)
static void check_statistics(Utils::Statistics::RunningAverage< double > &acc)
static double time_calc(System::System &system, int int_steps)
Time the integration.
double benchmark_integration_step(System::System &system, int int_steps)
Benchmark the integration loop.