35#include "system/System.hpp"
43#include <boost/mpi/collectives/reduce.hpp>
58 auto const pref = (pid1 < pid2) ? 1.0 : -1.0;
59 return pref * Random::noise_uniform<RNGSalt::SALT_DPD>(
61 (pid1 < pid2) ? pid2 : pid1, (pid1 < pid2) ? pid1 : pid2);
66 for (
int type_a = 0; type_a <= max_type; type_a++) {
67 for (
int type_b = type_a; type_b <= max_type; type_b++) {
70 ia_params.dpd.radial.pref =
71 sqrt(24.0 * kT * ia_params.dpd.radial.gamma / time_step);
72 ia_params.dpd.trans.pref =
73 sqrt(24.0 * kT * ia_params.dpd.trans.gamma / time_step);
85 double dist,
double dist2) {
91 p1_velocity, p2_velocity);
92 auto const noise_vec =
101 auto const P = tensor_product(d / dist2, d);
104 auto const force =
P * (f_r - f_t) + f_t;
109 auto const &box_geo = *system.
box_geo;
115 cell_structure.non_bonded_loop([&stress, &box_geo, &nonbonded_ias](
119 box_geo.velocity_difference(p1.
pos(), p2.
pos(), p1.
v(), p2.
v());
121 auto const &ia_params = nonbonded_ias.get_ia_param(p1.
type(), p2.
type());
122 auto const dist = std::sqrt(d.
dist2);
124 auto const f_r =
dpd_pair_force(ia_params.dpd.radial, v21, dist, {});
125 auto const f_t =
dpd_pair_force(ia_params.dpd.trans, v21, dist, {});
131 auto const f =
P * (f_r - f_t) + f_t;
133 stress += tensor_product(d.
vec21, f);
160 boost::mpi::communicator
const &comm) {
162 std::remove_const_t<
decltype(local_stress)> global_stress{};
164 boost::mpi::reduce(comm, local_stress, global_stress, std::plus<>(), 0);
Vector implementation and trait types for boost qvm interoperability.
This file contains everything related to the global cell structure / cell system.
Utils::Vector3d velocity_difference(Utils::Vector3d const &x, Utils::Vector3d const &y, Utils::Vector3d const &u, Utils::Vector3d const &v) const
Calculate the velocity difference including the Lees-Edwards velocity.
void dpd_init(double kT, double time_step)
auto & get_ia_param(int i, int j)
Get interaction parameters between particle types i and j.
auto get_max_seen_particle_type() const
void on_observable_calc()
called before calculating observables, i.e.
std::shared_ptr< CellStructure > cell_structure
std::shared_ptr< BoxGeometry > box_geo
std::shared_ptr< InteractionsNonBonded > nonbonded_ias
static auto dpd_viscous_stress_local(System::System &system)
Utils::Vector9d dpd_stress(System::System &system, boost::mpi::communicator const &comm)
Viscous stress tensor of the DPD interaction.
Utils::Vector3d dpd_pair_force(Utils::Vector3d const &p1_position, Utils::Vector3d const &p1_velocity, int const &p1_id, Utils::Vector3d const &p2_position, Utils::Vector3d const &p2_velocity, int const &p2_id, DPDThermostat const &dpd, BoxGeometry const &box_geo, IA_parameters const &ia_params, Utils::Vector3d const &d, double dist, double dist2)
Utils::Vector9d dpd_pressure_local(System::System &system)
Local contribution to the pressure tensor.
static Utils::Vector3d dpd_noise(DPDThermostat const &dpd, int pid1, int pid2)
Return a random uniform 3D vector with the Philox thermostat.
Routines to use DPD as thermostat or pair force .
Matrix implementation and trait types for boost qvm interoperability.
void flatten(Range const &v, OutputIterator out)
Flatten a range of ranges.
Various procedures concerning interactions between particles.
Random number generation using Philox.
uint64_t rng_counter() const
Get current value of the RNG.
uint32_t rng_seed() const
Thermostat for dissipative particle dynamics.
Distance vector and length handed to pair kernels.
Parameters for non-bonded interactions.
Struct holding all information for one particle.
auto const & type() const
Matrix representation with static size.