ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/thermostat/thermostat.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 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#pragma once
21
24#include "core/thermostat.hpp"
25
29#ifdef WALBERLA
31#endif
32
33#include <cassert>
34#include <limits>
35#include <memory>
36#include <span>
37#include <stdexcept>
38#include <string>
39
40namespace ScriptInterface {
41namespace Thermostat {
42
43template <typename CoreClass>
44class Interface : public AutoParameters<Interface<CoreClass>, System::Leaf> {
46
47public:
48 using CoreThermostat = CoreClass;
52
53protected:
58
59 bool is_active = false;
60 std::shared_ptr<CoreThermostat> m_handle;
61 /** @brief Basic lock mechanism that follows RAII. */
62 std::weak_ptr<bool> m_edit_lock;
63
64 void check_lock() {
65 if (m_edit_lock.expired()) {
67 }
68 }
69
70 void on_bind_system(::System::System &system) override {
73 is_active = true;
74 }
75
76 void on_detach_system(::System::System &system) override {
77 get_member_handle(*system.thermostat).reset();
79 is_active = false;
80 }
81
82 void sanity_checks_positive(double value, std::string const &name) const {
83 if (value < 0.) {
84 throw std::domain_error("Parameter '" + name + "' cannot be negative");
85 }
86 }
87
89 std::string const &name) const {
90 if (not(value >= Utils::Vector3d::broadcast(0.))) {
91 throw std::domain_error("Parameter '" + name + "' cannot be negative");
92 }
93 }
94
95 virtual bool invalid_rng_state(VariantMap const &params) const {
96 return (not params.contains("seed") or is_none(params.at("seed"))) and
98 }
99
100private:
101 virtual std::shared_ptr<CoreThermostat> &
103
104 void set_new_parameters(VariantMap const &params) {
105 context()->parallel_try_catch([&]() {
106 if (params.contains("__check_rng_state") and invalid_rng_state(params)) {
107 throw std::invalid_argument("Parameter 'seed' is needed on first "
108 "activation of the thermostat");
109 }
110 check_required_parameters(params);
111 });
112 for (auto const &key : get_parameter_insertion_order()) {
113 if (params.contains(key)) {
114 auto const &v = params.at(key);
115 if (key == "is_active") {
116 is_active = get_value<bool>(v);
117 } else {
118 do_set_parameter(key.c_str(), v);
119 }
120 }
121 }
122 }
123
124 virtual std::span<std::string_view const> get_required_parameters() const = 0;
125
126 void check_required_parameters(VariantMap const &params) const {
127 for (auto const &required : get_required_parameters()) {
128 auto name = std::string(required);
129 if (not params.contains(name)) {
130 throw std::runtime_error("Parameter '" + name + "' is missing");
131 }
132 }
133 }
134
135protected:
136 template <typename T>
137 auto make_autoparameter(T CoreThermostat::*member, char const *name) {
138 return AutoParameter{
139 name,
140 [this, member, name = std::string(name)](Variant const &v) {
141 check_lock();
142 auto const value = get_value<T>(v);
144 [&]() { sanity_checks_positive(value, name); });
145 m_handle.get()->*member = std::move(value);
146 },
147 [this, member]() { return m_handle.get()->*member; }};
148 }
149
150 template <typename T>
151 auto make_autogamma(T CoreThermostat::*member, char const *name) {
152 return AutoParameter{
153 name,
154 [this, member, name = std::string(name)](Variant const &v) {
155 check_lock();
156 if (is_none(v)) {
157 return;
158 }
159#ifdef PARTICLE_ANISOTROPY
160 static_assert(std::is_same_v<T, Utils::Vector3d>);
161 T gamma{};
162 if (is_type<int>(v) or is_type<double>(v)) {
163 gamma = T::broadcast(get_value<double>(v));
164 } else {
165 gamma = get_value<T>(v);
166 }
167#else
168 auto const gamma = get_value<T>(v);
169#endif // PARTICLE_ANISOTROPY
171 [&]() { sanity_checks_positive(gamma, name); });
172 m_handle.get()->*member = gamma;
173 },
174 [this, member]() {
175 auto constexpr gamma_null = ::Thermostat::gamma_null;
176 auto const gamma = m_handle.get()->*member;
177 return (gamma >= gamma_null) ? Variant{gamma} : Variant{None{}};
178 }};
179 }
180
181 virtual VariantMap extend_parameters(VariantMap const &parameters) const {
182 auto params = parameters;
183 if (not is_seed_required()) {
184 for (auto key : {std::string("seed"), std::string("philox_counter")}) {
185 if (not params.contains(key)) {
186 params[key] = get_parameter(key);
187 }
188 }
189 }
190 return params;
191 }
192
193 Variant do_call_method(std::string const &name,
194 VariantMap const &params) override {
195 if (name == "override_philox_counter") {
196 // only call this method if you know what you are doing
197 set_rng_counter(params.at("counter"));
198 return {};
199 }
200 return {};
201 }
202
203public:
206 {"seed",
207 [this](Variant const &v) {
208 check_lock();
209 context()->parallel_try_catch([&]() {
210 if (not is_none(v))
211 set_rng_seed(v);
212 });
213 },
214 [this]() {
215 return m_handle->is_seed_required() ? Variant{None{}}
217 }},
218 {"philox_counter",
219 [this](Variant const &v) {
220 check_lock();
221 context()->parallel_try_catch([&]() {
222 if (not is_none(v))
224 });
225 },
226 [this]() { return get_rng_counter(); }},
227 {"is_active", AutoParameter::read_only, [this]() { return is_active; }},
228 });
229 }
230
231 virtual std::optional<double> extract_kT(VariantMap const &params) const {
232 if (params.contains("kT")) {
233 auto const value = get_value<double>(params, "kT");
234 sanity_checks_positive(value, "kT");
235 return value;
236 }
237 return {std::nullopt};
238 }
239
241 auto lock = std::make_shared<bool>(false);
242 m_edit_lock = lock;
243 return lock;
244 }
245
246 auto is_activated() const { return is_active; }
247
248 virtual bool is_seed_required() const { return m_handle->is_seed_required(); }
249
250 auto get_rng_seed() const {
251 auto const seed = m_handle->rng_seed();
252 assert(seed <= static_cast<uint32_t>(std::numeric_limits<int>::max()));
253 return static_cast<int>(seed);
254 }
255
256 auto get_rng_counter() const {
257 auto const counter = m_handle->rng_counter();
258 assert(counter <= static_cast<uint64_t>(std::numeric_limits<int>::max()));
259 return static_cast<int>(counter);
260 }
261
262 void set_rng_seed(Variant const &value) {
263 auto const seed = get_value<int>(value);
264 if (seed < 0) {
265 throw std::domain_error("Parameter 'seed' must be a positive integer");
266 }
267 assert(static_cast<uint64_t>(seed) <=
268 static_cast<uint64_t>(std::numeric_limits<uint32_t>::max()));
269 m_handle->rng_initialize(static_cast<uint32_t>(seed));
270 }
271
272 void set_rng_counter(Variant const &value) {
273 auto const counter = get_value<int>(value);
274 assert(counter >= 0);
275 assert(static_cast<uint64_t>(counter) <=
276 std::numeric_limits<uint64_t>::max());
277 m_handle->set_rng_counter(static_cast<uint64_t>(counter));
278 }
279
280 void do_construct(VariantMap const &params) override {
281 m_handle = std::make_shared<CoreThermostat>();
282 if (not params.empty()) {
283 auto const read_write_lock = release_lock();
284 set_new_parameters(params);
285 }
286 }
287
288 void update_and_bind(VariantMap const &params, bool was_active,
289 std::shared_ptr<::System::System> system) {
290 auto const old_handle = m_handle;
291 auto new_params = extend_parameters(params);
292 new_params["__global_kT"] = system->thermostat->kT;
293 new_params["__check_rng_state"] = true;
294 try {
295 m_handle = std::make_shared<CoreThermostat>();
296 set_new_parameters(new_params);
297 bind_system(system);
298 } catch (...) {
299 assert(not is_active);
300 m_handle = old_handle;
301 if (was_active) {
302 bind_system(system);
303 }
304 throw;
305 }
306 }
307
308 virtual ::ThermostatFlags get_thermo_flag() const = 0;
309};
310
311class Langevin : public Interface<::LangevinThermostat> {
312 std::shared_ptr<CoreThermostat> &
314 return thermostat.langevin;
315 }
316
317 std::span<std::string_view const> get_required_parameters() const override {
318 static constexpr std::array names{std::string_view("gamma")};
319 return names;
320 }
321
322public:
326#ifdef ROTATION
328#endif
329 });
330 }
331
333
334protected:
335 VariantMap extend_parameters(VariantMap const &parameters) const override {
336 auto params =
338#ifdef ROTATION
339 // If gamma_rotation is not set explicitly, use the translational one.
340 if (not params.contains("gamma_rotation") and params.contains("gamma")) {
341 params["gamma_rotation"] = params.at("gamma");
342 }
343#endif // ROTATION
344 return params;
345 }
346};
347
348class Brownian : public Interface<::BrownianThermostat> {
349 std::shared_ptr<CoreThermostat> &
351 return thermostat.brownian;
352 }
353
354 std::span<std::string_view const> get_required_parameters() const override {
355 static constexpr std::array names{std::string_view("gamma")};
356 return names;
357 }
358
359public:
363#ifdef ROTATION
365#endif
366 });
367 }
368
370
371protected:
372 VariantMap extend_parameters(VariantMap const &parameters) const override {
373 auto params =
375#ifdef ROTATION
376 // If gamma_rotation is not set explicitly, use the translational one.
377 if (not params.contains("gamma_rotation") and params.contains("gamma")) {
378 params["gamma_rotation"] = params.at("gamma");
379 }
380#endif // ROTATION
381 return params;
382 }
383};
384
385#ifdef NPT
386class IsotropicNpt : public Interface<::IsotropicNptThermostat> {
387 std::shared_ptr<CoreThermostat> &
389 return thermostat.npt_iso;
390 }
391
392 std::span<std::string_view const> get_required_parameters() const override {
393 static constexpr std::array names{std::string_view("gamma0"),
394 std::string_view("gammav")};
395 return names;
396 }
397
398public:
405
407};
408#endif // NPT
409
410#ifdef WALBERLA
411class LBThermostat : public Interface<::LBThermostat> {
412 std::shared_ptr<CoreThermostat> &
414 return thermostat.lb;
415 }
416
417public:
420 {"gamma",
421 [this](Variant const &v) {
422 check_lock();
423 if (is_none(v)) {
424 return;
425 }
426 auto const gamma = get_value<double>(v);
428 [&]() { sanity_checks_positive(gamma, "gamma"); });
429 m_handle->gamma = gamma;
430 },
431 [this]() {
432 auto const gamma = m_handle->gamma;
433 return (gamma >= 0.) ? Variant{gamma} : Variant{None{}};
434 }},
435 });
436 }
437
439
440 std::optional<double> extract_kT(VariantMap const &params) const override {
441 auto const obj =
442 get_value<std::shared_ptr<walberla::LBFluid>>(params, "LB_fluid");
443 auto const value = get_value<double>(obj->get_parameter("kT"));
444 sanity_checks_positive(value, "kT");
445 return value;
446 }
447
448protected:
449 bool invalid_rng_state(VariantMap const &params) const override {
450 return (not params.contains("seed") or is_none(params.at("seed"))) and
451 params.contains("__global_kT") and is_seed_required() and
452 get_value<double>(params, "__global_kT") != 0.;
453 }
454
455 std::span<std::string_view const> get_required_parameters() const override {
456 static constexpr std::array names{std::string_view("gamma")};
457 return names;
458 }
459};
460#endif // WALBERLA
461
462#ifdef DPD
463class DPDThermostat : public Interface<::DPDThermostat> {
464 std::shared_ptr<CoreThermostat> &
466 return thermostat.dpd;
467 }
468
469 std::span<std::string_view const> get_required_parameters() const override {
470 return {};
471 }
472
473public:
475};
476#endif
477
478#ifdef STOKESIAN_DYNAMICS
479class Stokesian : public Interface<::StokesianThermostat> {
480 std::shared_ptr<CoreThermostat> &
482 return thermostat.stokesian;
483 }
484
485 std::span<std::string_view const> get_required_parameters() const override {
486 return {};
487 }
488
489public:
491};
492#endif
493
494class ThermalizedBond : public Interface<::ThermalizedBondThermostat> {
495 std::shared_ptr<CoreThermostat> &
497 return thermostat.thermalized_bond;
498 }
499
500 std::span<std::string_view const> get_required_parameters() const override {
501 return {};
502 }
503
504public:
506};
507
508class Thermostat : public AutoParameters<Thermostat, System::Leaf> {
509 std::shared_ptr<Langevin> langevin;
510 std::shared_ptr<Brownian> brownian;
511#ifdef NPT
512 std::shared_ptr<IsotropicNpt> npt_iso;
513#endif
514#ifdef WALBERLA
515 std::shared_ptr<LBThermostat> lb;
516#endif
517#ifdef DPD
518 std::shared_ptr<DPDThermostat> dpd;
519#endif
520#ifdef STOKESIAN_DYNAMICS
521 std::shared_ptr<Stokesian> stokesian;
522#endif
523 std::shared_ptr<ThermalizedBond> thermalized_bond;
524 std::shared_ptr<::Thermostat::Thermostat> m_handle;
525 std::unique_ptr<VariantMap> m_params;
526
527 template <typename Fun> void apply(Fun fun) {
528 fun(*langevin);
529 fun(*brownian);
530#ifdef NPT
531 fun(*npt_iso);
532#endif
533#ifdef WALBERLA
534 fun(*lb);
535#endif
536#ifdef DPD
537 fun(*dpd);
538#endif
539#ifdef STOKESIAN_DYNAMICS
540 fun(*stokesian);
541#endif
542 fun(*thermalized_bond);
543 }
544
545protected:
546 template <typename T>
547 auto make_autoparameter(T Thermostat::*member, char const *name) {
548 return AutoParameter{
549 name,
550 [this, member, name = std::string(name)](Variant const &v) {
551 auto &thermostat = this->*member;
552 if (thermostat) {
553 throw WriteError{name};
554 }
555 thermostat = get_value<T>(v);
556 },
557 [this, member]() { return this->*member; }};
558 }
559
560 template <typename T>
561 void setup_thermostat(std::shared_ptr<T> &thermostat,
562 VariantMap const &params) {
563 auto const original_kT = m_handle->kT;
564 std::optional<double> new_kT;
566 [&]() { new_kT = thermostat->extract_kT(params); });
567 auto const thermo_flag = thermostat->get_thermo_flag();
568 if (new_kT) {
570 [&]() { update_global_kT(original_kT, *new_kT, thermo_flag); });
571 }
572 auto const was_active = thermostat->is_activated();
573 turn_thermostat_off(*thermostat);
574 auto read_write_lock = thermostat->release_lock();
575 context()->parallel_try_catch([&]() {
576 try {
577 if (new_kT) {
578 m_handle->kT = *new_kT;
579 }
580 thermostat->update_and_bind(params, was_active, m_system.lock());
581 m_handle->thermo_switch |= thermo_flag;
582 } catch (...) {
583 auto success = false;
584 try {
585 m_handle->kT = original_kT;
586 if (was_active) {
587 m_handle->thermo_switch |= thermo_flag;
588 thermostat->bind_system(m_system.lock());
589 }
590 success = true;
591 throw success;
592 } catch (...) {
593 assert(success &&
594 "An exception occurred when setting up the thermostat. "
595 "An exception also occurred when attempting to restore the "
596 "original thermostat. The system is now in an invalid state.");
597 }
598 throw;
599 }
600 });
601 }
602
603 template <typename T> void turn_thermostat_off(T &thermostat) {
604 auto const thermo_flag = thermostat.get_thermo_flag();
605 if (m_handle->thermo_switch & thermo_flag) {
606 thermostat.detach_system();
607 m_handle->thermo_switch &= ~thermo_flag;
608 if (m_handle->thermo_switch == 0) {
609 m_handle->kT = -1.;
610 }
611 }
612 }
613
614 void update_global_kT(double old_kT, double new_kT, int thermo_flag) {
615 if (new_kT >= 0.) {
616 auto const same_kT = ::Thermostat::are_kT_equal(old_kT, new_kT);
617 auto const thermo_switch = m_handle->thermo_switch;
618 if (thermo_switch != THERMO_OFF and thermo_switch != thermo_flag and
619 thermo_switch != THERMO_BOND and not same_kT and old_kT >= 0.) {
620 throw std::runtime_error(
621 "Cannot set parameter 'kT' to " + std::to_string(new_kT) +
622 ": there are currently active thermostats with kT=" +
623 std::to_string(old_kT));
624 }
625 get_system().check_kT(new_kT);
626 if (not same_kT) {
627 m_handle->kT = new_kT;
628 get_system().on_temperature_change();
629 }
630 }
631 }
632
633public:
637 [this]() {
638 return (m_handle->kT >= 0.) ? Variant{m_handle->kT}
639 : Variant{None{}};
640 }},
641 make_autoparameter(&Thermostat::langevin, "langevin"),
642 make_autoparameter(&Thermostat::brownian, "brownian"),
643#ifdef NPT
644 make_autoparameter(&Thermostat::npt_iso, "npt_iso"),
645#endif
646#ifdef WALBERLA
647 make_autoparameter(&Thermostat::lb, "lb"),
648#endif
649#ifdef DPD
650 make_autoparameter(&Thermostat::dpd, "dpd"),
651#endif
652#ifdef STOKESIAN_DYNAMICS
653 make_autoparameter(&Thermostat::stokesian, "stokesian"),
654#endif
655 make_autoparameter(&Thermostat::thermalized_bond, "thermalized_bond"),
656 });
657 }
658
659 Variant do_call_method(std::string const &name,
660 VariantMap const &params) override {
661 if (params.contains("act_on_virtual")) {
662 context()->parallel_try_catch([&]() {
663 throw std::runtime_error(
664 name + "() got an unexpected keyword argument 'act_on_virtual'");
665 });
666 }
667 if (name == "set_langevin") {
668 setup_thermostat(langevin, params);
669 return {};
670 }
671 if (name == "set_brownian") {
672 setup_thermostat(brownian, params);
673 return {};
674 }
675#ifdef NPT
676 if (name == "set_npt") {
677 setup_thermostat(npt_iso, params);
678 return {};
679 }
680#endif // NPT
681#ifdef WALBERLA
682 if (name == "set_lb") {
684 return {};
685 }
686#endif // WALBERLA
687#ifdef DPD
688 if (name == "set_dpd") {
690 return {};
691 }
692#endif // DPD
693#ifdef STOKESIAN_DYNAMICS
694 if (name == "set_stokesian") {
695 setup_thermostat(stokesian, params);
696 return {};
697 }
698#endif // STOKESIAN_DYNAMICS
699 if (name == "set_thermalized_bond") {
700 setup_thermostat(thermalized_bond, params);
701 return {};
702 }
703 if (name == "turn_off") {
704 apply([this](auto &thermostat) { turn_thermostat_off(thermostat); });
705 assert(m_handle->thermo_switch == THERMO_OFF);
706 get_system().on_temperature_change();
707 return {};
708 }
709 return {};
710 }
711
712 void do_construct(VariantMap const &params) override {
713 m_params = std::make_unique<VariantMap>(params);
714 }
715
716 void on_bind_system(::System::System &system) override {
717 assert(m_params != nullptr);
718 m_handle = system.thermostat;
719 auto const &params = *m_params;
720 if (not params.empty()) {
721 reload_checkpointed_thermostats(params);
722 m_params.reset();
723 return;
724 }
725 m_params.reset();
726 if (not context()->is_head_node()) {
727 return;
728 }
729 make_default_constructed_thermostats();
730 }
731
732private:
733 /**
734 * @brief Reload thermostats from checkpointed data.
735 */
736 void reload_checkpointed_thermostats(VariantMap const &params) {
737 for (auto const &key : get_parameter_insertion_order()) {
738 if (key != "kT") {
739 auto const &v = params.at(key);
740 do_set_parameter(key.c_str(), v);
741 }
742 }
743 if (not is_none(params.at("kT"))) {
744 m_handle->kT = get_value<double>(params, "kT");
745 }
746 apply([this](auto &thermostat) {
747 if (get_value<bool>(thermostat.get_parameter("is_active"))) {
748 thermostat.bind_system(m_system.lock());
749 m_handle->thermo_switch |= thermostat.get_thermo_flag();
750 }
751 });
752 get_system().on_thermostat_param_change();
753 }
754
755 /**
756 * @brief Instantiate default-constructed thermostats.
757 * Can only be run on the head node!
758 */
759 void make_default_constructed_thermostats() {
760 assert(context()->is_head_node());
761 auto const make_thermostat = [this](char const *name, char const *so_name) {
762 set_parameter(name, Variant{context()->make_shared(so_name, {})});
763 };
764 make_thermostat("langevin", "Thermostat::Langevin");
765 make_thermostat("brownian", "Thermostat::Brownian");
766#ifdef NPT
767 make_thermostat("npt_iso", "Thermostat::IsotropicNpt");
768#endif
769#ifdef WALBERLA
770 make_thermostat("lb", "Thermostat::LB");
771#endif
772#ifdef DPD
773 make_thermostat("dpd", "Thermostat::DPD");
774#endif
775#ifdef STOKESIAN_DYNAMICS
776 make_thermostat("stokesian", "Thermostat::Stokesian");
777#endif
778 make_thermostat("thermalized_bond", "Thermostat::ThermalizedBond");
779 }
780};
781
782} // namespace Thermostat
783} // namespace ScriptInterface
ScriptInterface::Context decorates ScriptInterface::ObjectHandle objects with a context: a creation p...
ThermostatFlags
Thermostat flags.
@ THERMO_SD
@ THERMO_BROWNIAN
@ THERMO_BOND
@ THERMO_LB
@ THERMO_LANGEVIN
@ THERMO_DPD
@ THERMO_NPT_ISO
@ THERMO_OFF
Data structures for bonded interactions.
Bind parameters in the script interface.
void do_set_parameter(const std::string &name, const Variant &value) final
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
virtual std::shared_ptr< ObjectHandle > make_shared(std::string const &name, const VariantMap &parameters)=0
Get a new reference counted instance of a script interface by name.
Type to indicate no value in Variant.
boost::string_ref name() const
Context * context() const
Responsible context.
void set_parameter(const std::string &name, const Variant &value)
Set single parameter.
Script interface wrapper for a component of the system class.
std::weak_ptr<::System::System > m_system
void bind_system(std::shared_ptr<::System::System > const &system)
VariantMap extend_parameters(VariantMap const &parameters) const override
std::shared_ptr< CoreThermostat > & get_member_handle(::Thermostat::Thermostat &thermostat) override
std::span< std::string_view const > get_required_parameters() const override
std::shared_ptr< CoreThermostat > & get_member_handle(::Thermostat::Thermostat &thermostat) override
std::span< std::string_view const > get_required_parameters() const override
void sanity_checks_positive(double value, std::string const &name) const
void update_and_bind(VariantMap const &params, bool was_active, std::shared_ptr<::System::System > system)
virtual ::ThermostatFlags get_thermo_flag() const =0
virtual std::shared_ptr< CoreThermostat > & get_member_handle(::Thermostat::Thermostat &thermostat)=0
virtual bool invalid_rng_state(VariantMap const &params) const
auto make_autoparameter(T CoreThermostat::*member, char const *name)
Variant do_call_method(std::string const &name, VariantMap const &params) override
virtual std::span< std::string_view const > get_required_parameters() const =0
virtual std::optional< double > extract_kT(VariantMap const &params) const
auto make_autogamma(T CoreThermostat::*member, char const *name)
virtual VariantMap extend_parameters(VariantMap const &parameters) const
std::weak_ptr< bool > m_edit_lock
Basic lock mechanism that follows RAII.
void sanity_checks_positive(Utils::Vector3d const &value, std::string const &name) const
std::span< std::string_view const > get_required_parameters() const override
std::shared_ptr< CoreThermostat > & get_member_handle(::Thermostat::Thermostat &thermostat) override
bool invalid_rng_state(VariantMap const &params) const override
std::shared_ptr< CoreThermostat > & get_member_handle(::Thermostat::Thermostat &thermostat) override
std::optional< double > extract_kT(VariantMap const &params) const override
std::span< std::string_view const > get_required_parameters() const override
std::shared_ptr< CoreThermostat > & get_member_handle(::Thermostat::Thermostat &thermostat) override
std::span< std::string_view const > get_required_parameters() const override
VariantMap extend_parameters(VariantMap const &parameters) const override
std::span< std::string_view const > get_required_parameters() const override
std::shared_ptr< CoreThermostat > & get_member_handle(::Thermostat::Thermostat &thermostat) override
std::span< std::string_view const > get_required_parameters() const override
std::shared_ptr< CoreThermostat > & get_member_handle(::Thermostat::Thermostat &thermostat) override
void update_global_kT(double old_kT, double new_kT, int thermo_flag)
auto make_autoparameter(T Thermostat::*member, char const *name)
void setup_thermostat(std::shared_ptr< T > &thermostat, VariantMap const &params)
Variant do_call_method(std::string const &name, VariantMap const &params) override
Main system class.
std::shared_ptr< Thermostat::Thermostat > thermostat
std::shared_ptr< BrownianThermostat > brownian
std::shared_ptr< ThermalizedBondThermostat > thermalized_bond
std::shared_ptr< LangevinThermostat > langevin
std::shared_ptr< DPDThermostat > dpd
std::shared_ptr< LBThermostat > lb
std::shared_ptr< IsotropicNptThermostat > npt_iso
std::shared_ptr< StokesianThermostat > stokesian
static DEVICE_QUALIFIER constexpr Vector< T, N > broadcast(typename Base::value_type const &value)
Create a vector that has all entries set to the same value.
Definition Vector.hpp:110
Implementation in thermostat.cpp.
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:69
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:67
bool is_none(Variant const &v)
Definition Variant.hpp:115
bool are_kT_equal(double old_kT, double new_kT)
Check that two kT values are close up to a small tolerance.
constexpr GammaType gamma_null
Value for a null friction coefficient.
static SteepestDescentParameters params
Currently active steepest descent instance.
GammaType gamma
Translational friction coefficient .
GammaType gamma_rotation
Rotational friction coefficient .
double gamma0
Friction coefficient of the particles .
double gammav
Friction coefficient for the box .
GammaType gamma_rotation
Rotational friction coefficient .
GammaType gamma
Translational friction coefficient .
Description and getter/setter for a parameter.
static constexpr const ReadOnly read_only