ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
Integrator.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022-2026 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "Integrator.hpp"
21
22#include "core/integrate.hpp"
24
26
27#include <stdexcept>
28#include <string>
29
30namespace ScriptInterface {
31namespace Integrators {
32
34 auto const steps = get_value<int>(params, "steps");
35 auto const recalc_forces_flag = get_value<bool>(params, "recalc_forces");
36 auto const reuse_forces_flag = get_value<bool>(params, "reuse_forces");
37
39 if (steps < 0) {
40 throw std::domain_error("Parameter 'steps' must be positive");
41 }
43 throw std::invalid_argument(
44 "cannot reuse old forces and recalculate forces");
45 }
46 });
47
48 auto constexpr update_accumulators = true;
49 // The mutual-exclusion check above guarantees that at most one of the two
50 // flags is set, so the order of these cases is irrelevant. recalc_forces
51 // must map to NEVER so that forces are recomputed unconditionally, even
52 // when propagation.recalc_forces is already false after a prior run.
57 return get_system().integrate_with_signal_handler(steps, reuse_forces,
59}
60
61Variant Integrator::do_call_method(std::string const &name,
62 VariantMap const &params) {
63 if (name == "integrate") {
64 return integrate(params);
65 }
66 return none;
67}
68
69} // namespace Integrators
70} // namespace ScriptInterface
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
virtual Variant integrate(VariantMap const &params)
Variant do_call_method(std::string const &name, VariantMap const &params) override
Context * context() const
Responsible context.
std::string_view name() const
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Molecular dynamics integrator.
#define INTEG_REUSE_FORCES_CONDITIONALLY
recalculate forces only if Propagation::recalc_forces is set
Definition integrate.hpp:51
#define INTEG_REUSE_FORCES_NEVER
recalculate forces unconditionally (mostly used for timing)
Definition integrate.hpp:49
#define INTEG_REUSE_FORCES_ALWAYS
do not recalculate forces (mostly when reading checkpoints with forces)
Definition integrate.hpp:53
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:133
constexpr const None none
None-"literal".
Definition Variant.hpp:126
Recursive variant implementation.
Definition Variant.hpp:84