53#include <boost/mpi/collectives.hpp>
75 std::shared_ptr<Integrators::IntegratorHandle>
integrator;
79 std::shared_ptr<Galilei::Galilei>
galilei;
91 auto const add_parameter =
92 [
this, ptr = m_leaves.get()](std::string key,
auto(
Leaves::*member)) {
95 [
this, ptr, member, key](
Variant const &val) {
96 auto &dst = ptr->*member;
98 throw WriteError(key);
100 dst =
get_value<std::remove_reference_t<
decltype(dst)>>(val);
101 dst->bind_system(m_instance);
103 [ptr, member]() {
return ptr->*member; })});
109 context()->parallel_try_catch([&]() {
110 auto const new_value = get_value<Utils::Vector3d>(v);
112 throw std::domain_error(
"Attribute 'box_l' must be > 0");
114 m_instance->veto_boxl_change();
115 m_instance->box_geo->set_length(new_value);
116 m_instance->on_boxl_change();
119 [
this]() {
return m_instance->box_geo->length(); }},
122 auto const periodicity = get_value<Utils::Vector3b>(v);
123 for (
unsigned int i = 0
u; i < 3u; ++i) {
124 m_instance->box_geo->set_periodic(i, periodicity[i]);
126 context()->parallel_try_catch(
127 [&]() { m_instance->on_periodicity_change(); });
131 m_instance->box_geo->periodic(1),
132 m_instance->box_geo->periodic(2)};
136 context()->parallel_try_catch([&]() {
137 auto const new_value = get_value<double>(v);
139 throw std::domain_error(
"Attribute 'min_global_cut' must be >= 0");
141 m_instance->set_min_global_cut(new_value);
144 [
this]() {
return m_instance->get_min_global_cut(); }},
147 add_parameter(
"cell_system", &Leaves::cell_system);
148 add_parameter(
"integrator", &Leaves::integrator);
149 add_parameter(
"thermostat", &Leaves::thermostat);
150 add_parameter(
"analysis", &Leaves::analysis);
151 add_parameter(
"comfixed", &Leaves::comfixed);
152 add_parameter(
"galilei", &Leaves::galilei);
153 add_parameter(
"bond_breakage", &Leaves::bond_breakage);
154 add_parameter(
"lees_edwards", &Leaves::lees_edwards);
156 add_parameter(
"electrostatics", &Leaves::electrostatics);
159 add_parameter(
"magnetostatics", &Leaves::magnetostatics);
178 do_set_parameter(
"box_l",
params.at(
"box_l"));
181 m_instance->lb.bind_system(m_instance);
182 m_instance->ek.bind_system(m_instance);
184 for (
auto const &key : get_parameter_insertion_order()) {
185 if (key !=
"box_l" and
params.count(key) != 0ul) {
186 do_set_parameter(key,
params.at(key));
192 double theta,
double alpha) {
197 double local_mass = 0.0;
199 for (
auto const &p : particles) {
200 if (not p.is_virtual()) {
201 local_com += p.mass() * p.pos();
202 local_mass += p.mass();
206 auto const total_mass =
207 boost::mpi::all_reduce(
comm_cart, local_mass, std::plus<>());
209 boost::mpi::all_reduce(
comm_cart, local_com, std::plus<>()) / total_mass;
213 axis[0] = std::sin(theta) * std::cos(phi);
214 axis[1] = std::sin(theta) * std::sin(phi);
215 axis[2] = std::cos(theta);
218 for (
auto &p : particles) {
240 p.pos()[dir] *= scale;
247Variant System::do_call_method(std::string
const &name,
249 if (name ==
"is_system_created") {
252 if (name ==
"lock_system_creation") {
256 if (name ==
"rescale_boxl") {
257 auto &box_geo = *m_instance->box_geo;
258 auto const coord = get_value<int>(parameters,
"coord");
259 auto const length = get_value<double>(parameters,
"length");
260 assert(coord != 3 or ((box_geo.length()[0] == box_geo.length()[1]) and
261 (box_geo.length()[1] == box_geo.length()[2])));
262 auto const scale = (coord == 3) ? length * box_geo.length_inv()[0]
263 : length * box_geo.length_inv()[coord];
264 context()->parallel_try_catch([&]() {
266 throw std::domain_error(
"Parameter 'd_new' must be > 0");
268 m_instance->veto_boxl_change(
true);
274 new_value = box_geo.length();
275 new_value[coord] = length;
280 m_instance->on_particle_change();
282 m_instance->box_geo->set_length(new_value);
283 m_instance->on_boxl_change();
286 m_instance->on_particle_change();
290 if (name ==
"setup_type_map") {
291 auto const types = get_value<std::vector<int>>(parameters,
"type_list");
292 for (
auto const type : types) {
297 if (name ==
"number_of_particles") {
298 auto const type = get_value<int>(parameters,
"type");
299 return ::number_of_particles_with_type(type);
301 if (name ==
"velocity_difference") {
302 auto const pos1 = get_value<Utils::Vector3d>(parameters,
"pos1");
303 auto const pos2 = get_value<Utils::Vector3d>(parameters,
"pos2");
304 auto const v1 = get_value<Utils::Vector3d>(parameters,
"v1");
305 auto const v2 = get_value<Utils::Vector3d>(parameters,
"v2");
306 return m_instance->box_geo->velocity_difference(pos2, pos1, v2, v1);
308 if (name ==
"distance_vec") {
309 auto const pos1 = get_value<Utils::Vector3d>(parameters,
"pos1");
310 auto const pos2 = get_value<Utils::Vector3d>(parameters,
"pos2");
311 return m_instance->box_geo->get_mi_vector(pos2, pos1);
313 if (name ==
"rotate_system") {
315 get_value<double>(parameters,
"phi"),
316 get_value<double>(parameters,
"theta"),
317 get_value<double>(parameters,
"alpha"));
318 m_instance->on_particle_change();
319 m_instance->update_dependent_particles();
322 if (name ==
"get_propagation_modes_enum") {
325 if (name ==
"session_shutdown") {
330 assert(m_instance.use_count() == 1l);
@ NSQUARE
Atom decomposition (N-square).
@ REGULAR
Regular decomposition.
Vector implementation and trait types for boost qvm interoperability.
This file contains everything related to the global cell structure / cell system.
void add_parameters(std::vector< AutoParameter > &¶ms)
static std::shared_ptr< System > create()
static Vector< T, N > broadcast(T const &s)
Create a vector that has all entries set to one value.
boost::mpi::communicator comm_cart
The communicator.
This file contains the defaults for ESPResSo.
This file contains the asynchronous MPI communication.
@ DATA_PART_PROPERTIES
Particle::p.
@ DATA_PART_POSITION
Particle::r.
static void rotate_system(CellStructure &cell_structure, double phi, double theta, double alpha)
static bool system_created
static void rescale_particles(CellStructure &cell_structure, int dir, double scale)
Rescale all particle positions in direction dir by a factor scale.
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
auto make_unordered_map_of_variants(std::unordered_map< K, V > const &v)
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.
void set_system(std::shared_ptr< System > new_instance)
Vector3d vec_rotate(const Vector3d &axis, double angle, const Vector3d &vector)
Rotate a vector around an axis.
Various procedures concerning interactions between particles.
constexpr double INACTIVE_CUTOFF
Cutoff for deactivated interactions.
Routines to calculate the OIF global forces energy or/and and force for a particle triple (triangle f...
void init_type_map(int type)
Particles creation and deletion.
std::unordered_map< std::string, int > propagation_flags_map()
Convert PropagationMode::PropagationMode to name/value pairs.
This file contains all subroutines required to process rotational motion.
void local_rotate_particle(Particle &p, const Utils::Vector3d &axis_space_frame, const double phi)
Rotate the particle p around the NORMALIZED axis aSpaceFrame by amount phi.
static SteepestDescentParameters params
Currently active steepest descent instance.
Describes a cell structure / cell system.
void update_ghosts_and_resort_particle(unsigned data_parts)
Update ghost particles, with particle resort if needed.
void set_resort_particles(Cells::Resort level)
Increase the local resort level at least to level.
ParticleRange local_particles() const
Description and getter/setter for a parameter.
Container for leaves of the system class.
std::shared_ptr< Thermostat::Thermostat > thermostat
std::shared_ptr< Integrators::IntegratorHandle > integrator
std::shared_ptr< Dipoles::Container > magnetostatics
std::shared_ptr< CellSystem::CellSystem > cell_system
std::shared_ptr< Galilei::Galilei > galilei
std::shared_ptr< Analysis::Analysis > analysis
std::shared_ptr< BondBreakage::BreakageSpecs > bond_breakage
std::shared_ptr< Coulomb::Container > electrostatics
std::shared_ptr< Galilei::ComFixed > comfixed
std::shared_ptr< LeesEdwards::LeesEdwards > lees_edwards