ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
StokesianDynamics.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 "config/config.hpp"
21
22#ifdef STOKESIAN_DYNAMICS
23
24#include "StokesianDynamics.hpp"
25
27
31
32#include <memory>
33#include <stdexcept>
34#include <string>
35
36namespace ScriptInterface {
37namespace Integrators {
38
41 {"viscosity", AutoParameter::read_only,
42 [this]() { return get_instance().viscosity; }},
44 [this]() {
46 }},
47 {"lubrication", AutoParameter::read_only,
48 [this]() {
49 return static_cast<bool>(get_instance().flags &
50 static_cast<int>(sd_flags::LUBRICATION));
51 }},
52 {"self_mobility", AutoParameter::read_only,
53 [this]() {
54 return static_cast<bool>(get_instance().flags &
55 static_cast<int>(sd_flags::SELF_MOBILITY));
56 }},
57 {"pair_mobility", AutoParameter::read_only,
58 [this]() {
59 return static_cast<bool>(get_instance().flags &
60 static_cast<int>(sd_flags::PAIR_MOBILITY));
61 }},
62 {"approximation_method", AutoParameter::read_only,
63 [this]() {
64 return std::string(
65 (get_instance().flags & static_cast<int>(sd_flags::FTS)) ? "fts"
66 : "ft");
67 }},
68 });
69}
70
72 context()->parallel_try_catch([&]() {
73 int bitfield = 0;
74 if (get_value_or<bool>(params, "self_mobility", true)) {
75 bitfield |= static_cast<int>(sd_flags::SELF_MOBILITY);
76 }
77 if (get_value_or<bool>(params, "pair_mobility", true)) {
78 bitfield |= static_cast<int>(sd_flags::PAIR_MOBILITY);
79 }
80 auto const approx =
81 get_value_or<std::string>(params, "approximation_method", "fts");
82 if (approx == "fts") {
83 bitfield |= static_cast<int>(sd_flags::FTS);
84 } else if (approx != "ft") {
85 throw std::invalid_argument("Unknown approximation '" + approx + "'");
86 }
87 m_instance = std::make_shared<::StokesianDynamicsParameters>(
88 get_value<double>(params, "viscosity"),
89 get_value<std::unordered_map<int, double>>(params, "radii"), bitfield);
90 });
91}
92
94 context()->parallel_try_catch([&]() {
96 get_system().propagation->set_integ_switch(INTEG_METHOD_SD);
97 });
98}
99
100} // namespace Integrators
101} // namespace ScriptInterface
102
103#endif // STOKESIAN_DYNAMICS
@ INTEG_METHOD_SD
void add_parameters(std::vector< AutoParameter > &&params)
::StokesianDynamicsParameters const & get_instance() const
void do_construct(VariantMap const &params) override
std::shared_ptr< Propagation > propagation
This file contains the defaults for ESPResSo.
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:82
auto make_unordered_map_of_variants(std::unordered_map< K, V > const &v)
Definition Variant.hpp:93
See for the Stokesian dynamics method used here.
void register_integrator(SteepestDescentParameters const &obj)
static SteepestDescentParameters params
Currently active steepest descent instance.
static constexpr const ReadOnly read_only