29#include "system/System.hpp"
33#include <boost/mpi/collectives/all_reduce.hpp>
34#include <boost/mpi/collectives/broadcast.hpp>
41std::string TuningFailed::get_first_error() {
44 auto message = std::string(
"tuning failed: an exception was thrown while "
45 "benchmarking the integration loop");
46 for (
auto const &warning : queued_warnings) {
47 if (warning.level() == RuntimeError::ErrorLevel::ERROR) {
48 message +=
" (" + warning.what() +
")";
56 if (acc.
avg() <= 5 * MPI_Wtick()) {
58 <<
"Clock resolution is too low to reliably time integration.";
60 if (acc.
sig() >= 0.1 * acc.
avg()) {
66 auto const error_code = system.
integrate(0, reuse_forces);
79 for (
int i = 0; i < int_steps; i++) {
80 auto const tick = MPI_Wtime();
82 auto const tock = MPI_Wtime();
91 auto retval = 1000. * running_average.
avg();
106 auto const error_code_init =
113 auto const tick = MPI_Wtime();
115 auto const tock = MPI_Wtime();
121 return 1000. * (tock - tick) / int_steps;
126 int int_steps,
bool adjust_max_skin) {
134 auto const max_permissible_skin = std::min(
135 std::ranges::min(cell_structure->max_cutoff()) - maximal_cutoff(),
136 0.5 * std::ranges::max(box_geo->length()));
138 if (adjust_max_skin and max_skin > max_permissible_skin)
139 b = max_permissible_skin;
141 while (fabs(a - b) > tol) {
142 cell_structure->set_verlet_skin(a);
143 auto const time_a =
time_calc(*
this, int_steps);
145 cell_structure->set_verlet_skin(b);
146 auto const time_b =
time_calc(*
this, int_steps);
148 if (time_a > time_b) {
154 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.