35#include "constraints/Constraints.hpp"
36#include "constraints/ShapeBasedConstraint.hpp"
38#include "system/System.hpp"
43#include <boost/mpi/collectives/all_reduce.hpp>
57 for (
auto i = 0
u; i < 3u; ++i)
65 double const theta = 2. * std::numbers::pi *
rng();
87 std::vector<std::vector<Utils::Vector3d>>
const &positions,
92 auto operator()(
double const a,
double const b)
const {
93 return std::min(a, b);
101 for (
auto &c : *
system.constraints) {
103 std::dynamic_pointer_cast<const Constraints::ShapeBasedConstraint>(c);
120 for (
auto const &p :
system.cell_structure->local_particles()) {
131 for (
auto const &p : positions) {
132 for (
auto const &m : p) {
142std::vector<std::vector<Utils::Vector3d>>
150 auto const &box_geo = *
system.box_geo;
152 dist = std::uniform_real_distribution<double>(
153 0.0, 1.0)]()
mutable {
return dist(
mt); };
155 std::vector<std::vector<Utils::Vector3d>> positions(
n_polymers);
156 for (
auto &p : positions) {
169 throw std::runtime_error(
"Invalid start positions.");
185 auto const last_vec = positions[p][m - 1] - positions[p][m - 2];
186 return positions[p][m - 1] +
193 [&](
int p,
int m) -> std::optional<Utils::Vector3d> {
210 p,
static_cast<int>(positions[p].size()));
214 positions[p].push_back(*pos);
215 }
else if (
not positions[p].empty()) {
217 positions[p].pop_back();
239 throw std::runtime_error(
"Failed to create polymer positions.");
Vector implementation and trait types for boost qvm interoperability.
ESPRESSO_ATTR_ALWAYS_INLINE Utils::Vector3< T > get_mi_vector(Utils::Vector3< T > const &a, Utils::Vector3< T > const &b) const
Get the minimum-image vector between two coordinates.
auto folded_position(Utils::Vector3d const &pos) const
Calculate coordinates folded to primary simulation box.
Utils::Vector3d const & length() const
Box length.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
boost::mpi::communicator comm_cart
The communicator.
__device__ void vector_product(float const *a, float const *b, float *out)
std::mt19937 mt19937(T &&seed)
Mersenne Twister with warmup.
Vector3d vec_rotate(const Vector3d &axis, double angle, const Vector3d &vector)
Rotate a vector around an axis.
static Utils::Vector3d random_position(BoxGeometry const &box_geo, RNG &rng)
static Utils::Vector3d random_unit_vector(RNG &rng)
std::vector< std::vector< Utils::Vector3d > > draw_polymer_positions(System::System const &system, int const n_polymers, int const beads_per_chain, double const bond_length, std::vector< Utils::Vector3d > const &start_positions, double const min_distance, int const max_tries, int const use_bond_angle, double const bond_angle, int const respect_constraints, int const seed)
Determines valid polymer positions and returns them.
static bool is_valid_position(System::System const &system, Utils::Vector3d const &pos, std::vector< std::vector< Utils::Vector3d > > const &positions, BoxGeometry const &box_geo, double const min_distance, int const respect_constraints)
Determines whether a given position pos is valid, i.e., it doesn't collide with existing or buffered ...
This file contains everything needed to create a start-up configuration of polymer chains which may r...
Random number generation using Philox.