32#include <boost/container/vector.hpp>
33#include <boost/serialization/is_bitwise_serializable.hpp>
34#include <boost/serialization/level.hpp>
35#include <boost/serialization/vector.hpp>
43constexpr inline bool get_nth_bit(uint8_t
const bitfield,
44 unsigned int const bit_idx) {
45 return bitfield & (1u << bit_idx);
59 template <
class Archive>
void serialize(Archive &ar,
long int ) {
65#ifdef ESPRESSO_THERMAL_STONER_WOHLFARTH
95 template <
class Archive>
void serialize(Archive &ar,
long int ) {
118#ifdef ESPRESSO_ROTATION
130 static constexpr uint8_t
rotation =
static_cast<uint8_t
>(0b000u);
133#ifdef ESPRESSO_EXTERNAL_FORCES
144 static constexpr uint8_t
ext_flag =
static_cast<uint8_t
>(0b000u);
151 constexpr static double mass{1.0};
155#ifdef ESPRESSO_ROTATIONAL_INERTIA
162#ifdef ESPRESSO_ELECTROSTATICS
165 constexpr static double q{0.0};
168#ifdef ESPRESSO_LB_ELECTROHYDRODYNAMICS
173#ifdef ESPRESSO_DIPOLES
178#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
183#ifdef ESPRESSO_VIRTUAL_SITES_RELATIVE
199 template <
class Archive>
void serialize(Archive &ar,
long int) {
208#ifdef ESPRESSO_THERMOSTAT_PER_PARTICLE
210#ifndef ESPRESSO_PARTICLE_ANISOTROPY
215#ifdef ESPRESSO_ROTATION
217#ifndef ESPRESSO_PARTICLE_ANISOTROPY
225#ifdef ESPRESSO_EXTERNAL_FORCES
228#ifdef ESPRESSO_ROTATION
234#ifdef ESPRESSO_ENGINE
238#ifdef ESPRESSO_THERMAL_STONER_WOHLFARTH
242 template <
class Archive>
void serialize(Archive &ar,
long int ) {
250#ifdef ESPRESSO_ROTATIONAL_INERTIA
253#ifdef ESPRESSO_ROTATION
256#ifdef ESPRESSO_ELECTROSTATICS
259#ifdef ESPRESSO_LB_ELECTROHYDRODYNAMICS
262#ifdef ESPRESSO_DIPOLES
265#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
268#ifdef ESPRESSO_VIRTUAL_SITES_RELATIVE
271#ifdef ESPRESSO_THERMOSTAT_PER_PARTICLE
273#ifdef ESPRESSO_ROTATION
277#ifdef ESPRESSO_EXTERNAL_FORCES
280#ifdef ESPRESSO_ROTATION
284#ifdef ESPRESSO_ENGINE
287#ifdef ESPRESSO_THERMAL_STONER_WOHLFARTH
302#ifdef ESPRESSO_ROTATION
311#ifdef ESPRESSO_BOND_CONSTRAINT
316 template <
class Archive>
void serialize(Archive &ar,
long int ) {
319#ifdef ESPRESSO_ROTATION
322#ifdef ESPRESSO_BOND_CONSTRAINT
336#ifdef ESPRESSO_ROTATION
350#ifdef ESPRESSO_ROTATION
359#ifdef ESPRESSO_ROTATION
364 template <
class Archive>
void serialize(Archive &ar,
long int ) {
366#ifdef ESPRESSO_ROTATION
380#ifdef ESPRESSO_ROTATION
387 template <
class Archive>
void serialize(Archive &ar,
long int ) {
389#ifdef ESPRESSO_ROTATION
407 template <
class Archive>
void serialize(Archive &ar,
long int ) {
415#ifdef ESPRESSO_BOND_CONSTRAINT
426 return *
this = *
this + rhs;
429 template <
class Archive>
void serialize(Archive &ar,
long int ) {
443#ifdef ESPRESSO_BOND_CONSTRAINT
447#ifdef ESPRESSO_EXCLUSIONS
455 constexpr auto const &
id()
const {
return p.identity; }
456 constexpr auto &
id() {
return p.identity; }
457 constexpr auto const &
mol_id()
const {
return p.mol_id; }
458 constexpr auto &
mol_id() {
return p.mol_id; }
459 constexpr auto const &
type()
const {
return p.type; }
460 constexpr auto &
type() {
return p.type; }
462 constexpr auto const &
propagation()
const {
return p.propagation; }
466 return id() == rhs.
id();
470 return id() != rhs.
id();
473 constexpr auto const &
bonds()
const {
return bl; }
474 constexpr auto &
bonds() {
return bl; }
476 constexpr auto const &
pos()
const {
return r.p; }
477 constexpr auto &
pos() {
return r.p; }
478 constexpr auto const &
v()
const {
return m.v; }
479 constexpr auto &
v() {
return m.v; }
480 constexpr auto const &
force()
const {
return f.f; }
481 constexpr auto &
force() {
return f.f; }
485 constexpr bool is_ghost()
const {
return l.ghost; }
486 constexpr void set_ghost(
bool const ghost_flag) { l.ghost = ghost_flag; }
492 return l.lees_edwards_offset;
496 return l.lees_edwards_flag;
500 constexpr auto const &
mass()
const {
return p.mass; }
502 constexpr auto &
mass() {
return p.mass; }
504#ifdef ESPRESSO_ROTATION
505 constexpr auto const &
rotation()
const {
return p.rotation; }
507 constexpr bool can_rotate()
const {
return static_cast<bool>(p.rotation); }
510 return detail::get_nth_bit(p.rotation, axis);
513 bool const rot_flag) {
516 p.rotation |=
static_cast<uint8_t
>(1u << axis);
518 p.rotation &=
static_cast<uint8_t
>(~(1u << axis));
522 p.rotation =
static_cast<uint8_t
>(0b111u);
525 p.rotation =
static_cast<uint8_t
>(0b000u);
527 constexpr auto const &
quat()
const {
return r.quat; }
528 constexpr auto &
quat() {
return r.quat; }
529 constexpr auto const &
torque()
const {
return f.torque; }
530 constexpr auto &
torque() {
return f.torque; }
531 constexpr auto const &
omega()
const {
return m.omega; }
532 constexpr auto &
omega() {
return m.omega; }
533#ifdef ESPRESSO_EXTERNAL_FORCES
534 constexpr auto const &
ext_torque()
const {
return p.ext_torque; }
539 constexpr auto can_rotate()
const {
return false; }
542#ifdef ESPRESSO_DIPOLES
543 constexpr auto const &
dipm()
const {
return p.dipm; }
544 constexpr auto &
dipm() {
return p.dipm; }
547#ifdef ESPRESSO_THERMAL_STONER_WOHLFARTH
549 return p.magnetodynamics.is_enabled;
552 return p.magnetodynamics.is_enabled;
555 return p.magnetodynamics.phi0;
559 return p.magnetodynamics.sat_mag;
562 return p.magnetodynamics.sat_mag;
565 return p.magnetodynamics.ani_fld_inv;
568 return p.magnetodynamics.ani_fld_inv;
571 return p.magnetodynamics.ani_energy;
574 return p.magnetodynamics.ani_energy;
577 return p.magnetodynamics.tau0_inv;
580 return p.magnetodynamics.tau0_inv;
583 return p.magnetodynamics.dt_incr;
586 return p.magnetodynamics.dt_incr;
589#ifdef ESPRESSO_DIPOLE_FIELD_TRACKING
590 constexpr auto const &
dip_fld()
const {
return p.dip_fld; }
591 constexpr auto &
dip_fld() {
return p.dip_fld; }
593 constexpr auto const &
rinertia()
const {
return p.rinertia; }
594#ifdef ESPRESSO_ROTATIONAL_INERTIA
597 constexpr auto const &
q()
const {
return p.q; }
598#ifdef ESPRESSO_ELECTROSTATICS
599 constexpr auto &
q() {
return p.q; }
601#ifdef ESPRESSO_LB_ELECTROHYDRODYNAMICS
602 constexpr auto const &
mu_E()
const {
return p.mu_E; }
603 constexpr auto &
mu_E() {
return p.mu_E; }
605#ifdef ESPRESSO_VIRTUAL_SITES
614 constexpr auto is_virtual()
const {
return false; }
616#ifdef ESPRESSO_VIRTUAL_SITES_RELATIVE
617 constexpr auto const &
vs_relative()
const {
return p.vs_relative; }
620#ifdef ESPRESSO_THERMOSTAT_PER_PARTICLE
621 constexpr auto const &
gamma()
const {
return p.gamma; }
622 constexpr auto &
gamma() {
return p.gamma; }
623#ifdef ESPRESSO_ROTATION
624 constexpr auto const &
gamma_rot()
const {
return p.gamma_rot; }
628#ifdef ESPRESSO_EXTERNAL_FORCES
629 constexpr auto const &
fixed()
const {
return p.ext_flag; }
630 constexpr auto &
fixed() {
return p.ext_flag; }
632 return static_cast<bool>(p.ext_flag);
636 return detail::get_nth_bit(p.ext_flag, axis);
639 bool const fixed_flag) {
642 p.ext_flag |=
static_cast<uint8_t
>(1u << axis);
644 p.ext_flag &=
static_cast<uint8_t
>(~(1u << axis));
647 constexpr auto const &
ext_force()
const {
return p.ext_force; }
651 constexpr bool is_fixed_along(
unsigned int const)
const {
return false; }
653#ifdef ESPRESSO_ENGINE
654 constexpr auto const &
swimming()
const {
return p.swim; }
657#ifdef ESPRESSO_BOND_CONSTRAINT
666#ifdef ESPRESSO_EXCLUSIONS
670 return std::ranges::find(el, pid) != el.end();
675 friend boost::serialization::access;
676 template <
class Archive>
void serialize(Archive &ar,
long int ) {
683#ifdef ESPRESSO_EXCLUSIONS
689BOOST_CLASS_IMPLEMENTATION(
Particle, object_serializable)
690#ifdef ESPRESSO_ENGINE
693#ifdef ESPRESSO_THERMAL_STONER_WOHLFARTH
700BOOST_CLASS_IMPLEMENTATION(
ParticleForce, object_serializable)
701BOOST_CLASS_IMPLEMENTATION(
ParticleLocal, object_serializable)
702#ifdef ESPRESSO_BOND_CONSTRAINT
705#ifdef ESPRESSO_VIRTUAL_SITES_RELATIVE
710#ifdef ESPRESSO_ENGINE
713#ifdef ESPRESSO_THERMAL_STONER_WOHLFARTH
721#ifdef ESPRESSO_BOND_CONSTRAINT
724#ifdef ESPRESSO_VIRTUAL_SITES_RELATIVE
Vector implementation and trait types for boost qvm interoperability.
Custom vector container optimized for size.
@ TRANS_VS_CENTER_OF_MASS
constexpr Vector< T, 3 > convert_quaternion_to_director(Quaternion< T > const &quat)
Convert quaternion to director.
Quaternion implementation and trait types for boost qvm interoperability.
Force information on a particle.
Utils::Vector3d torque
torque in lab frame.
ParticleForce(const Utils::Vector3d &f, const Utils::Vector3d &torque)
void serialize(Archive &ar, long int)
friend ParticleForce operator+(ParticleForce const &lhs, ParticleForce const &rhs)
ParticleForce(const Utils::Vector3d &f)
ParticleForce(ParticleForce const &)=default
ParticleForce & operator+=(ParticleForce const &rhs)
ParticleForce & operator=(ParticleForce const &)=default
Information on a particle that is needed only on the node the particle belongs to.
bool ghost
is particle a ghost particle.
short int lees_edwards_flag
void serialize(Archive &ar, long int)
double lees_edwards_offset
Accumulated applied Lees-Edwards offset.
Utils::Vector3d p_old
position from the last Verlet list update.
Momentum information on a particle.
Utils::Vector3d v
velocity.
Utils::Vector3d omega
angular velocity.
void serialize(Archive &ar, long int)
Properties of a self-propelled particle.
void serialize(Archive &ar, long int)
bool swimming
Is the particle a swimmer.
bool is_engine_force_on_fluid
Whether f_swim is applied to the particle or to the fluid.
double f_swim
Imposed constant force.
Positional information on a particle.
Utils::Quaternion< double > quat
quaternion to define particle orientation
Utils::Vector3i i
index of the simulation box image where the particle really sits.
constexpr Utils::Vector3d calc_director() const
unit director calculated from the quaternion
Utils::Vector3d p_last_timestep
particle position at the previous time step (RATTLE algorithm)
void serialize(Archive &ar, long int)
Utils::Vector3d p
periodically folded position.
The following properties define, with respect to which real particle a virtual site is placed and at ...
void serialize(Archive &ar, long int)
Utils::Quaternion< double > rel_orientation
Relative position of the virtual site.
Utils::Quaternion< double > quat
Orientation of the virtual particle in the body fixed frame.
Properties of a particle which are not supposed to change during the integration, but have to be know...
Utils::Vector3d gamma_rot
Friction coefficient for rotation.
double dipm
dipole moment (absolute value)
Utils::Vector3d rinertia
rotational inertia
ParticleParametersSwimming swim
int identity
unique identifier for the particle.
Utils::Vector3d ext_torque
External torque in lab frame.
void serialize(Archive &ar, long int)
Utils::Vector3d ext_force
External force.
Utils::Vector3d mu_E
electrophoretic mobility times E-field: mu_0 * E
int mol_id
Molecule identifier.
Utils::Vector3d dip_fld
total dipole field
ThermalStonerWohlfarthParameters magnetodynamics
uint8_t ext_flag
Flag for fixed particle coordinates.
int propagation
which propagation schemes should be applied to the particle
struct ParticleProperties::VirtualSitesRelativeParameters vs_relative
Utils::Vector3d gamma
Friction coefficient for translation.
uint8_t rotation
Bitfield for the particle axes of rotation.
int type
particle type, used for non-bonded interactions.
friend ParticleRattle operator+(ParticleRattle const &lhs, ParticleRattle const &rhs)
Utils::Vector3d correction
position/velocity correction
ParticleRattle & operator+=(ParticleRattle const &rhs)
void serialize(Archive &ar, long int)
Struct holding all information for one particle.
constexpr auto const & dip_fld() const
constexpr auto & stoner_wohlfarth_tau0_inv()
constexpr auto & torque()
constexpr auto calc_director() const
bool has_exclusion(int pid) const
constexpr void set_cannot_rotate_all_axes()
constexpr auto const & bonds() const
constexpr auto & stoner_wohlfarth_is_enabled()
constexpr auto const & magnetic_anisotropy_field_inv() const
constexpr auto const & stoner_wohlfarth_is_enabled() const
constexpr auto & force_and_torque()
constexpr auto & vs_relative()
constexpr auto & propagation()
constexpr auto const & quat() const
constexpr auto calc_dip() const
constexpr bool can_rotate() const
constexpr auto const & pos() const
constexpr auto const & swimming() const
Utils::compact_vector< int > const & exclusions() const
constexpr auto const & rattle_correction() const
constexpr auto & rinertia()
constexpr auto & stoner_wohlfarth_dt_incr()
constexpr auto const & rinertia() const
constexpr auto const & mass() const
constexpr auto const & dipm() const
Utils::compact_vector< int > & exclusions()
constexpr auto & rotation()
constexpr auto const & type() const
constexpr auto const & omega() const
constexpr auto & stoner_wohlfarth_phi_0()
constexpr auto & pos_last_time_step()
constexpr auto & magnetic_anisotropy_energy()
constexpr auto & ext_force()
constexpr auto const & saturation_magnetization() const
constexpr auto const & stoner_wohlfarth_dt_incr() const
constexpr auto & magnetic_anisotropy_field_inv()
constexpr auto & dip_fld()
constexpr auto const & magnetic_anisotropy_energy() const
constexpr auto const & ext_force() const
constexpr void set_can_rotate_all_axes()
constexpr auto const & propagation() const
constexpr bool operator==(Particle const &rhs) const
constexpr auto & ext_torque()
constexpr auto const & ext_torque() const
constexpr auto & pos_at_last_verlet_update()
constexpr bool operator!=(Particle const &rhs) const
constexpr auto const & rotation() const
constexpr void set_can_rotate_around(unsigned int const axis, bool const rot_flag)
constexpr auto const & force() const
constexpr auto is_virtual() const
constexpr auto const & vs_relative() const
constexpr auto const & fixed() const
constexpr auto const & gamma() const
constexpr auto & rattle_params()
constexpr bool has_fixed_coordinates() const
constexpr void set_fixed_along(unsigned int const axis, bool const fixed_flag)
constexpr auto const & gamma_rot() const
constexpr auto const & image_box() const
constexpr auto & lees_edwards_flag()
constexpr bool is_fixed_along(unsigned int const axis) const
constexpr auto const & mu_E() const
constexpr auto & image_box()
constexpr auto const & stoner_wohlfarth_tau0_inv() const
constexpr auto const & id() const
constexpr auto const & mol_id() const
constexpr auto const & q() const
constexpr bool can_rotate_around(unsigned int const axis) const
constexpr auto const & stoner_wohlfarth_phi_0() const
constexpr auto const & force_and_torque() const
constexpr auto const & rattle_params() const
constexpr auto & lees_edwards_offset()
constexpr auto const & pos_at_last_verlet_update() const
constexpr void set_ghost(bool const ghost_flag)
constexpr auto const & pos_last_time_step() const
constexpr auto & swimming()
constexpr auto & mol_id()
constexpr bool is_ghost() const
constexpr auto & gamma_rot()
constexpr auto const & v() const
constexpr auto const & torque() const
constexpr auto const & lees_edwards_flag() const
constexpr auto const & lees_edwards_offset() const
constexpr auto & rattle_correction()
constexpr auto & saturation_magnetization()
Properties for thermal Stoner-Wohlfarth magnetodynamics.
bool is_enabled
Flag to distinguish virtual particles carrying the dipole moment in the thermal Stoner-Wohlfarth mode...
double tau0_inv
Browns attempt frequency.
double ani_energy
Magnetic anisotropy energy (K1 * V) in units of energy.
void serialize(Archive &ar, long int)
double dt_incr
time units parameter for the kinetic Monte Carlo step
double ani_fld_inv
Inverse anisotropy field in reduced units.
double sat_mag
saturation magnetisation of a polarizable particle
double phi0
angle between the director and dipole moment of a Stoner-Wohlfarth particle
Quaternion representation.
static Quaternion< T > identity()
Construct an identity quaternion.