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-2023 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 }
42 if (recalc_forces_flag and reuse_forces_flag) {
43 throw std::invalid_argument(
44 "cannot reuse old forces and recalculate forces");
45 }
46 });
47
48 auto constexpr update_accumulators = true;
49 auto const reuse_forces = reuse_forces_flag
52 return get_system().integrate_with_signal_handler(steps, reuse_forces,
53 update_accumulators);
54}
55
56Variant Integrator::do_call_method(std::string const &name,
57 VariantMap const &params) {
58 if (name == "integrate") {
59 return integrate(params);
60 }
61 return none;
62}
63
64} // namespace Integrators
65} // 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
boost::string_ref name() const
Context * context() const
Responsible context.
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_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:82
boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type Variant
Possible types for parameters.
Definition Variant.hpp:80
constexpr const None none
None-"literal".
Definition Variant.hpp:63
static SteepestDescentParameters params
Currently active steepest descent instance.