ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
SteepestDescent.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 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 "SteepestDescent.hpp"
21
23
25#include "core/integrate.hpp"
28
29#include <utils/Vector.hpp>
30
31#include <memory>
32#include <string>
33
34namespace ScriptInterface {
35namespace Integrators {
36
38 auto constexpr reuse_forces = INTEG_REUSE_FORCES_NEVER;
39 auto constexpr update_accumulators = false;
40 auto const steps = get_value<int>(params, "steps");
41 context()->parallel_try_catch([&]() {
42 if (steps < 0) {
43 throw std::domain_error("Parameter 'steps' must be positive");
44 }
45 });
46 return get_system().integrate_with_signal_handler(steps, reuse_forces,
47 update_accumulators);
48}
49
53 [this]() { return get_instance().f_max; }},
55 [this]() { return get_instance().gamma; }},
56 {"max_displacement", AutoParameter::read_only,
57 [this]() { return get_instance().max_displacement; }},
58 });
59}
60
62 auto const f_max = get_value<double>(params, "f_max");
63 auto const gamma = get_value<double>(params, "gamma");
64 auto const max_d = get_value<double>(params, "max_displacement");
65
66 context()->parallel_try_catch([&]() {
67 m_instance =
68 std::make_shared<::SteepestDescentParameters>(f_max, gamma, max_d);
69 });
70}
71
76
77} // namespace Integrators
78} // namespace ScriptInterface
@ INTEG_METHOD_STEEPEST_DESCENT
Vector implementation and trait types for boost qvm interoperability.
void add_parameters(std::vector< AutoParameter > &&params)
void do_construct(VariantMap const &params) override
::SteepestDescentParameters const & get_instance() const
Variant integrate(VariantMap const &params) override
int integrate_with_signal_handler(int n_steps, int reuse_forces, bool update_accumulators)
std::shared_ptr< Propagation > propagation
Molecular dynamics integrator.
#define INTEG_REUSE_FORCES_NEVER
recalculate forces unconditionally (mostly used for timing)
Definition integrate.hpp:49
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
void register_integrator(SteepestDescentParameters const &obj)
static SteepestDescentParameters params
Currently active steepest descent instance.
static constexpr const ReadOnly read_only
double gamma
Dampening constant.
double max_displacement
Maximal particle displacement.
double f_max
Maximal particle force.