29#include "system/System.hpp"
33#include <boost/mpi/collectives/all_reduce.hpp>
34#include <boost/mpi/collectives/broadcast.hpp>
42std::string TuningFailed::get_first_error()
const {
45 auto message = std::string(
"tuning failed: an exception was thrown while "
46 "benchmarking the integration loop");
47 for (
auto const &warning : queued_warnings) {
48 if (warning.level() == RuntimeError::ErrorLevel::ERROR) {
49 message +=
" (" + warning.what() +
")";
57 if (acc.
avg() <= 5 * MPI_Wtick()) {
59 <<
"Clock resolution is too low to reliably time integration.";
61 if (acc.
sig() >= 0.1 * acc.
avg()) {
67 auto const error_code = system.
integrate(0, reuse_forces);
80 for (
int i = 0; i < int_steps; i++) {
81 auto const tick = MPI_Wtime();
83 auto const tock = MPI_Wtime();
92 auto retval = 1000. * running_average.
avg();
107 auto const error_code_init =
114 auto const tick = MPI_Wtime();
116 auto const tock = MPI_Wtime();
122 return 1000. * (tock - tick) / int_steps;
127 int int_steps,
bool adjust_max_skin) {
135 auto const max_permissible_skin = std::min(
136 std::ranges::min(cell_structure->max_cutoff()) - maximal_cutoff(),
137 0.5 * std::ranges::max(box_geo->length()));
139 if (adjust_max_skin and max_skin > max_permissible_skin)
140 b = max_permissible_skin;
142 while (fabs(a - b) > tol) {
143 cell_structure->set_verlet_skin(a);
144 auto const time_a =
time_calc(*
this, int_steps);
146 cell_structure->set_verlet_skin(b);
147 auto const time_b =
time_calc(*
this, int_steps);
149 if (time_a > time_b) {
155 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.