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
"
23
#include "
core/system/System.hpp
"
24
25
#include "
script_interface/ScriptInterface.hpp
"
26
27
#include <stdexcept>
28
#include <string>
29
30
namespace
ScriptInterface
{
31
namespace
Integrators {
32
33
Variant
Integrator::integrate
(
VariantMap
const
&
params
) {
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
38
context
()->
parallel_try_catch
([&]() {
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
50
?
INTEG_REUSE_FORCES_ALWAYS
51
:
INTEG_REUSE_FORCES_CONDITIONALLY
;
52
return
get_system
().integrate_with_signal_handler(
steps
,
reuse_forces
,
53
update_accumulators
);
54
}
55
56
Variant
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
Integrator.hpp
ScriptInterface.hpp
ScriptInterface::Context::parallel_try_catch
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
ScriptInterface::Integrators::Integrator::integrate
virtual Variant integrate(VariantMap const ¶ms)
Definition
Integrator.cpp:33
ScriptInterface::Integrators::Integrator::do_call_method
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
Definition
Integrator.cpp:56
ScriptInterface::ObjectHandle::context
Context * context() const
Responsible context.
Definition
ObjectHandle.hpp:57
ScriptInterface::ObjectHandle::name
std::string_view name() const
Definition
ObjectHandle.cpp:117
ScriptInterface::System::Leaf::get_system
auto const & get_system() const
Definition
script_interface/system/Leaf.hpp:53
stream
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Definition
common_cuda.cu:34
System.hpp
integrate.hpp
Molecular dynamics integrator.
INTEG_REUSE_FORCES_CONDITIONALLY
#define INTEG_REUSE_FORCES_CONDITIONALLY
recalculate forces only if Propagation::recalc_forces is set
Definition
integrate.hpp:51
INTEG_REUSE_FORCES_ALWAYS
#define INTEG_REUSE_FORCES_ALWAYS
do not recalculate forces (mostly when reading checkpoints with forces)
Definition
integrate.hpp:53
ScriptInterface
Definition
script_interface/accumulators/AccumulatorBase.hpp:33
ScriptInterface::VariantMap
std::unordered_map< std::string, Variant > VariantMap
Definition
Variant.hpp:133
ScriptInterface::none
constexpr const None none
None-"literal".
Definition
Variant.hpp:126
params
static SteepestDescentParameters params
Currently active steepest descent instance.
Definition
steepest_descent.cpp:44
ScriptInterface::impl::recursive_variant
Recursive variant implementation.
Definition
Variant.hpp:84
src
script_interface
integrators
Integrator.cpp
Generated on Mon Dec 8 2025 02:32:29 for ESPResSo by
1.9.8