30#include "accumulators/AutoUpdateAccumulators.hpp"
36#include "collision_detection/CollisionDetection.hpp"
37#include "communication.hpp"
48#include "thermostat.hpp"
55#include <boost/mpi/collectives/all_reduce.hpp>
70 auto handle = std::make_shared<System>(Private());
76 box_geo = std::make_shared<BoxGeometry>();
81 gpu = std::make_shared<GpuParticleData>();
84 bonded_ias = std::make_shared<BondedInteractionsMap>();
85 thermostat = std::make_shared<Thermostat::Thermostat>();
87 comfixed = std::make_shared<ComFixed>();
88 galilei = std::make_shared<Galilei>();
91#ifdef ESPRESSO_COLLISION_DETECTION
93 std::make_shared<CollisionDetection::CollisionDetection>();
95 bond_breakage = std::make_shared<BondBreakage::BondBreakage>();
96 lees_edwards = std::make_shared<LeesEdwards::LeesEdwards>();
98 std::make_shared<Accumulators::AutoUpdateAccumulators>();
99 constraints = std::make_shared<Constraints::Constraints>();
101#ifdef ESPRESSO_STOKESIAN_DYNAMICS
105 nptiso = std::make_shared<NptIsoParameters>();
115void System::initialize() {
116 auto handle = shared_from_this();
117 cell_structure->bind_system(handle);
118 lees_edwards->bind_system(handle);
119 bonded_ias->bind_system(handle);
120 thermostat->bind_system(handle);
121 nonbonded_ias->bind_system(handle);
122 oif_global->bind_system(handle);
123 immersed_boundaries->bind_system(handle);
124#ifdef ESPRESSO_COLLISION_DETECTION
125 collision_detection->bind_system(handle);
127 auto_update_accumulators->bind_system(handle);
128 constraints->bind_system(handle);
130 gpu->bind_system(handle);
133 lb.bind_system(handle);
134 ek.bind_system(handle);
146 assert(system !=
nullptr);
152 throw std::domain_error(
"time_step must be > 0.");
153 if (
lb.is_solver_set()) {
154 lb.veto_time_step(value);
156 if (
ek.is_solver_set()) {
157 ek.veto_time_step(value);
164 if (
lb.is_solver_set()) {
167 if (
ek.is_solver_set()) {
186 auto &old_regular_decomposition =
188 std::as_const(*cell_structure).decomposition());
191 old_regular_decomposition.fully_connected_boundary());
201 std::as_const(*cell_structure).decomposition());
203 old_hybrid_decomposition.get_cutoff_regular(),
204 old_hybrid_decomposition.get_n_square_types());
217 if (not skip_method_adaption) {
220#ifdef ESPRESSO_ELECTROSTATICS
223#ifdef ESPRESSO_DIPOLES
231 if (not skip_particle_checks) {
232 auto const n_part = boost::mpi::all_reduce(
235 throw std::runtime_error(
236 "Cannot reset the box length when particles are present");
240 lb.veto_boxl_change();
241 ek.veto_boxl_change();
246 lb.on_node_grid_change();
247 ek.on_node_grid_change();
248#ifdef ESPRESSO_ELECTROSTATICS
251#ifdef ESPRESSO_DIPOLES
258#ifdef ESPRESSO_ELECTROSTATICS
259 coulomb.on_periodicity_change();
262#ifdef ESPRESSO_DIPOLES
263 dipoles.on_periodicity_change();
266#ifdef ESPRESSO_STOKESIAN_DYNAMICS
270 <<
"(False, False, False)\n";
278 lb.on_cell_structure_change();
279 ek.on_cell_structure_change();
280#ifdef ESPRESSO_ELECTROSTATICS
281 coulomb.on_cell_structure_change();
283#ifdef ESPRESSO_DIPOLES
284 dipoles.on_cell_structure_change();
292#ifdef ESPRESSO_ELECTROSTATICS
295#ifdef ESPRESSO_DIPOLES
302 lb.on_temperature_change();
303 ek.on_temperature_change();
307 lb.on_timestep_change();
308 ek.on_timestep_change();
325#ifdef ESPRESSO_ELECTROSTATICS
332#ifdef ESPRESSO_DIPOLES
356#ifdef ESPRESSO_ELECTROSTATICS
359#ifdef ESPRESSO_DIPOLES
371#ifdef ESPRESSO_ELECTROSTATICS
377#ifdef ESPRESSO_VIRTUAL_SITES
381#ifdef ESPRESSO_VIRTUAL_SITES_RELATIVE
388#ifdef ESPRESSO_VIRTUAL_SITES_CENTER_OF_MASS
397#ifdef ESPRESSO_ELECTROSTATICS
416#ifdef ESPRESSO_ELECTROSTATICS
420#ifdef ESPRESSO_DIPOLES
429#ifdef ESPRESSO_COLLISION_DETECTION
449 max_cut = std::max(max_cut,
coulomb.cutoff());
450 max_cut = std::max(max_cut,
dipoles.cutoff());
454 max_cut = std::max(max_cut,
bonded_ias->maximal_cutoff());
456 max_cut = std::max(max_cut,
nonbonded_ias->maximal_cutoff());
458#ifdef ESPRESSO_COLLISION_DETECTION
466#ifdef ESPRESSO_ELECTROSTATICS
469#ifdef ESPRESSO_DIPOLES
472 }
catch (std::runtime_error
const &err) {
493 integrator_sanity_checks();
515#ifdef ESPRESSO_ADDITIONAL_CHECKS
519#ifdef ESPRESSO_ELECTROSTATICS
521 auto const &actor =
coulomb.impl->solver;
527#ifdef ESPRESSO_DIPOLES
529 auto const &actor =
dipoles.impl->solver;
571#ifdef ESPRESSO_ROTATION
575 if (sys.propagation->used_propagations &
584 if (sys.propagation->used_propagations &
590#ifdef ESPRESSO_DIPOLES
593 if (sys.dipoles.impl && sys.dipoles.impl->solver) {
598#ifdef ESPRESSO_GAY_BERNE
606#ifdef ESPRESSO_ENGINE
609 if (sys.lb.is_solver_set()) {
614#ifdef ESPRESSO_THERMAL_STONER_WOHLFARTH
638 if (
lb.is_solver_set())
649#ifdef ESPRESSO_COLLISION_DETECTION
655#ifdef ESPRESSO_ROTATION
666#ifdef ESPRESSO_ROTATION
690#ifdef ESPRESSO_COLLISION_DETECTION
CellStructureType
Cell structure topology.
@ NSQUARE
Atom decomposition (N-square).
@ HYBRID
Hybrid decomposition.
@ REGULAR
Regular decomposition.
@ INTEG_METHOD_NPT_ISO_AND
@ INTEG_METHOD_NPT_ISO_MTK
Vector implementation and trait types for boost qvm interoperability.
Data structures for bonded interactions.
Hybrid decomposition cell system.
static LocalBox make_regular_decomposition(Utils::Vector3d const &box_l, Utils::Vector3i const &node_index, Utils::Vector3i const &node_grid)
void on_periodicity_change()
double get_interaction_range() const
Get the interaction range.
double maximal_cutoff() const
Calculate the maximal cutoff of all interactions.
void on_constraint_change()
Called every time a constraint is changed.
void on_cell_structure_change()
unsigned get_global_ghost_flags() const
Returns the ghost flags required for running pair kernels for the global state, e....
std::shared_ptr< StokesianDynamics > stokesian_dynamics
std::shared_ptr< LeesEdwards::LeesEdwards > lees_edwards
double sim_time
Molecular dynamics integrator simulation time.
void on_boxl_change(bool skip_method_adaption=false)
Called when the box length has changed.
void update_used_propagations()
Update the global propagation bitmask.
void set_box_l(Utils::Vector3d const &box_l)
Change the box dimensions.
std::shared_ptr< LocalBox > local_geo
std::shared_ptr< BondedInteractionsMap > bonded_ias
void on_temperature_change()
double min_global_cut
Minimal global interaction cutoff.
auto get_min_global_cut() const
Get min_global_cut.
void on_thermostat_param_change()
void on_lees_edwards_change()
bool reinit_thermo
Whether the thermostat has to be reinitialized before integration.
void on_integration_start()
std::shared_ptr< ImmersedBoundaries > immersed_boundaries
std::shared_ptr< Accumulators::AutoUpdateAccumulators > auto_update_accumulators
std::shared_ptr< ComFixed > comfixed
void set_force_cap(double value)
Set force_cap.
void on_non_bonded_ia_change()
std::shared_ptr< BondBreakage::BondBreakage > bond_breakage
void on_verlet_skin_change()
void npt_ensemble_init(bool recalc_forces)
Reinitialize the NpT state.
std::shared_ptr< CollisionDetection::CollisionDetection > collision_detection
void update_dependent_particles()
Update particles with properties depending on other particles, namely virtual sites and ICC charges.
std::shared_ptr< InstantaneousPressure > npt_inst_pressure
void on_lb_boundary_conditions_change()
Called when the LB boundary conditions change (geometry, slip velocity, or both).
void veto_boxl_change(bool skip_particle_checks=false) const
void set_time_step(double value)
Set time_step.
std::shared_ptr< OifGlobal > oif_global
void on_particle_change()
Called every time a particle property changes.
bool long_range_interactions_sanity_checks() const
Check electrostatic and magnetostatic methods are properly initialized.
std::shared_ptr< NptIsoParameters > nptiso
void on_node_grid_change()
double force_cap
Molecular dynamics integrator force capping.
void on_particle_charge_change()
Called every time a particle charge changes.
std::shared_ptr< Propagation > propagation
void on_particle_local_change()
Called every time a particle local property changes.
double time_step
Molecular dynamics integrator time step.
void on_observable_calc()
called before calculating observables, i.e.
void update_icc_particles()
std::shared_ptr< SteepestDescent > steepest_descent
std::shared_ptr< GpuParticleData > gpu
void on_timestep_change()
void check_kT(double value) const
Veto temperature change.
std::shared_ptr< Thermostat::Thermostat > thermostat
static std::shared_ptr< System > create()
Utils::Vector3d * get_npt_virial() const
unsigned get_force_reduce_ghost_flags() const
Returns the ghost flags for the force-reduce step.
std::shared_ptr< CellStructure > cell_structure
void set_min_global_cut(double value)
Set min_global_cut.
std::shared_ptr< Constraints::Constraints > constraints
bool has_icc_enabled() const
bool has_npt_enabled() const
void set_cell_structure_topology(CellStructureType topology)
Change cell structure topology.
std::shared_ptr< BoxGeometry > box_geo
void on_short_range_ia_change()
std::shared_ptr< Galilei > galilei
void rebuild_cell_structure()
Rebuild cell lists.
std::shared_ptr< InteractionsNonBonded > nonbonded_ias
bool has_collision_detection_enabled() const
void vs_com_update_particles(CellStructure &cell_structure, BoxGeometry const &box_geo)
std::shared_ptr< KokkosHandle > kokkos_handle
Communicator communicator
boost::mpi::communicator comm_cart
The communicator.
constexpr double inactive_cutoff
Special cutoff value for an inactive interaction.
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
#define runtimeErrorMsg()
Ghost particles and particle exchange.
@ GHOSTTRANS_FORCE
transfer ParticleForce
@ GHOSTTRANS_TORQUE
transfer torque (reduced with force; runtime-conditional)
ICC is a method that allows to take into account the influence of arbitrarily shaped dielectric inter...
@ DATA_PART_MOMENTUM
Particle::m.
@ DATA_PART_PROPERTIES
Particle::p.
@ DATA_PART_BONDS
Particle::bonds.
@ DATA_PART_QUAT
orientation quaternion (pushed with position)
@ DATA_PART_POSITION
Particle::r.
@ TRANS_VS_CENTER_OF_MASS
static std::shared_ptr< System > instance
bool is_same_system(System const *const system)
void set_system(std::shared_ptr< System > new_instance)
static bool orientation_ghosts_needed(System const &sys)
Return true when any active physics requires orientation of ghost particles.
bool all_compare(boost::mpi::communicator const &comm, T const &value)
Compare values on all nodes.
Exports for the NpT code.
void invalidate_fetch_cache()
Invalidate the fetch cache for get_particle_data.
void clear_particle_node()
Invalidate particle_node.
Particles creation and deletion.
void vs_relative_update_particles(CellStructure &cell_structure, BoxGeometry const &box_geo)
See durlofsky87a for the Stokesian dynamics method used here.
void update_verlet_state(System::System const &system, double const collision_cut)
Regular decomposition cell system.
Routines to thermalize the center of mass and distance of a particle pair.