ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
EKSpecies.hpp
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#pragma once
21
22#include "config/config.hpp"
23
24#ifdef WALBERLA
25
26#include "LatticeModel.hpp"
27#include "LatticeWalberla.hpp"
28#include "VTKHandle.hpp"
29
33
35
37
38#include <memory>
39#include <string>
40
42
43class EKVTKHandle;
44
45class EKSpecies : public LatticeModel<::EKinWalberlaBase, EKVTKHandle> {
46protected:
53 double m_tau;
54 double m_density;
55
56 void make_instance(VariantMap const &params) override;
57
58public:
61 {"lattice", AutoParameter::read_only, [this]() { return m_lattice; }},
62 {"diffusion",
63 [this](Variant const &v) {
64 m_instance->set_diffusion(get_value<double>(v) * m_conv_diffusion);
65 },
66 [this]() { return m_instance->get_diffusion() / m_conv_diffusion; }},
67 {"kT",
68 [this](Variant const &v) {
69 m_instance->set_kT(get_value<double>(v) * m_conv_energy);
70 },
71 [this]() { return m_instance->get_kT() / m_conv_energy; }},
72 {"valency",
73 [this](Variant const &v) {
74 m_instance->set_valency(get_value<double>(v));
75 },
76 [this]() { return m_instance->get_valency(); }},
77 {"ext_efield",
78 [this](Variant const &v) {
79 m_instance->set_ext_efield(get_value<Utils::Vector3d>(v) *
81 },
82 [this]() { return m_instance->get_ext_efield() / m_conv_ext_efield; }},
83 {"advection",
84 [this](Variant const &v) {
85 m_instance->set_advection(get_value<bool>(v));
86 },
87 [this]() { return m_instance->get_advection(); }},
88 {"friction_coupling",
89 [this](Variant const &v) {
90 m_instance->set_friction_coupling(get_value<bool>(v));
91 },
92 [this]() { return m_instance->get_friction_coupling(); }},
93 {"single_precision", AutoParameter::read_only,
94 [this]() { return not m_instance->is_double_precision(); }},
95 {"tau", AutoParameter::read_only, [this]() { return m_tau; }},
96 {"density", AutoParameter::read_only,
97 [this]() { return m_density / m_conv_density; }},
99 [this]() { return m_instance->get_lattice().get_grid_dimensions(); }},
100 {"vtk_writers", AutoParameter::read_only,
101 [this]() { return serialize_vtk_writers(); }},
102 });
103 }
104
105 void do_construct(VariantMap const &params) override;
106
107 [[nodiscard]] auto get_ekinstance() const { return m_instance; }
108 [[nodiscard]] auto get_lattice() const { return m_lattice; }
109
110 Variant do_call_method(std::string const &method,
111 VariantMap const &parameters) override;
112
113 [[nodiscard]] auto get_conversion_factor_density() const noexcept {
114 return m_conv_density;
115 }
116 [[nodiscard]] auto get_conversion_factor_flux() const noexcept {
117 return m_conv_flux;
118 }
119
121 return {
122 {"density", 1. / m_conv_density},
123 {"flux", 1. / m_conv_flux},
124 };
125 }
126
127private:
128 void load_checkpoint(std::string const &filename, int mode);
129 void save_checkpoint(std::string const &filename, int mode);
130};
131
132class EKVTKHandle : public VTKHandleBase<::EKinWalberlaBase> {
133 static std::unordered_map<std::string, int> const obs_map;
134
135 std::unordered_map<std::string, int> const &get_obs_map() const override {
136 return obs_map;
137 }
138};
139
140} // namespace ScriptInterface::walberla
141
142#endif // WALBERLA
std::unordered_map< std::string, double > units_map
void add_parameters(std::vector< AutoParameter > &&params)
auto get_conversion_factor_flux() const noexcept
auto get_conversion_factor_density() const noexcept
void make_instance(VariantMap const &params) override
Definition EKSpecies.cpp:91
Variant do_call_method(std::string const &method, VariantMap const &parameters) override
Definition EKSpecies.cpp:49
::LatticeModel::units_map get_latice_to_md_units_conversion() const override
void do_construct(VariantMap const &params) override
std::unordered_map< std::string, int > const & get_obs_map() const override
This file contains the defaults for ESPResSo.
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
static SteepestDescentParameters params
Currently active steepest descent instance.
static constexpr const ReadOnly read_only