40#include <boost/mpi/collectives/all_reduce.hpp>
59 throw std::domain_error(
"Chain analysis needs at least 1 chain");
62 throw std::domain_error(
"Chain analysis needs at least 1 bead per chain");
70 if (ptr !=
nullptr and not ptr->is_ghost()) {
83 if (ptr !=
nullptr and not ptr->is_ghost()) {
89 std::stringstream error_msg;
90 error_msg <<
"Particle with id " << pid <<
" does not exist; "
91 <<
"cannot perform analysis on the range chain_start="
94 <<
"Please provide a contiguous range of particle ids.";
95 throw std::runtime_error(error_msg.str());
107void Analysis::check_particle_type(
int p_type)
const {
108 auto const &nonbonded_ias =
get_system().nonbonded_ias;
110 std::stringstream error_msg;
111 error_msg <<
"Particle type " <<
p_type <<
" does not exist";
112 throw std::invalid_argument(error_msg.str());
118 if (
name ==
"linear_momentum") {
124 if (
name ==
"particle_energy") {
127 auto const local =
system.particle_short_range_energy_contribution(pid);
130 if (
name ==
"particle_bond_energy") {
135 auto const local =
system.particle_bond_energy(pid, bond_id,
partners);
138 if (
name ==
"particle_neighbor_pids") {
140 system.on_observable_calc();
141 std::unordered_map<int, std::vector<int>>
dict;
145 std::ranges::for_each(neighbor_pids, [&
dict](
auto const &
nbhood) {
152 if (
name ==
"dpd_stress") {
154 return result.as_vector();
157 if (
name ==
"min_dist") {
168 if (
name ==
"center_of_mass") {
174 if (
name ==
"angular_momentum") {
180 if (
name ==
"nbhood") {
186 if (
name ==
"calc_re") {
193 return std::vector<double>(result.begin(), result.end());
195 if (
name ==
"calc_rg") {
204 output =
Variant{std::vector<double>(result.begin(), result.end())};
208 if (
name ==
"calc_rh") {
215 return std::vector<double>(result.begin(), result.end());
217 if (
name ==
"gyration_tensor") {
223 return std::vector<double>(
mat.begin(),
mat.end());
225 if (
name ==
"moment_of_inertia_matrix") {
231 if (
name ==
"structure_factor") {
236 throw std::domain_error(
"order has to be a strictly positive number");
244 if (
name ==
"distribution") {
255 throw std::domain_error(
"Parameter 'r_min' must be > 0");
258 throw std::domain_error(
"Parameter 'r_min' must be >= 0");
261 throw std::domain_error(
"Parameter 'r_max' must be > 'r_min'");
264 throw std::domain_error(
"Parameter 'r_max' must be <= box_l / 2");
267 throw std::domain_error(
"Parameter 'r_bins' must be >= 1");
284 if (
name ==
"calculate_energy") {
285 return m_obs_stat->do_call_method(
"calculate_energy", {});
287 if (
name ==
"calculate_scalar_pressure") {
288 return m_obs_stat->do_call_method(
"calculate_scalar_pressure", {});
290 if (
name ==
"calculate_pressure_tensor") {
291 return m_obs_stat->do_call_method(
"calculate_pressure_tensor", {});
294 if (
name ==
"get_instantaneous_pressure") {
295 return get_system().npt_inst_pressure->p_inst[0];
297 if (
name ==
"get_instantaneous_pressure_virial") {
298 return get_system().npt_inst_pressure->p_inst[1];
Vector implementation and trait types for boost qvm interoperability.
std::vector< NeighborPIDs > get_neighbor_pids(System::System const &system)
Returns pairs of particle ids and neighbor particle id lists.
This file contains everything related to the global cell structure / cell system.
Describes a cell structure / cell system.
Particle * get_local_particle(int id)
Get a local particle by id.
Variant do_call_method(std::string const &name, VariantMap const ¶meters) override
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
Context * context() const
Responsible context.
std::string_view name() const
auto const & get_system() const
boost::mpi::communicator comm_cart
The communicator.
This file contains the asynchronous MPI communication.
Utils::Vector9d dpd_stress(boost::mpi::communicator const &comm)
Viscous stress tensor of the DPD interaction.
Routines to use DPD as thermostat or pair force .
static void check_topology(CellStructure const &cell_structure, int chain_start, int chain_length, int n_chains)
Check if a contiguous range of particle ids exists.
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)
T mpi_reduce_sum(boost::mpi::communicator const &comm, T const &result)
Reduce object by sum on the head node.
auto make_vector_of_variants(std::vector< T > const &v)
void gather_buffer(std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
Gather buffer with different size on each node.
T reduce_optional(boost::mpi::communicator const &comm, std::optional< T > const &result)
Reduce an optional on the head node.
Various procedures concerning interactions between particles.
Exports for the NpT code.
Utils::Vector3d center_of_mass(System::System const &system, int p_type)
Calculate the center of mass of particles of a certain type.
Utils::Vector3d angular_momentum(System::System const &system, int p_type)
Calculate the angular momentum of particles of a certain type.
std::vector< int > nbhood(System::System const &system, Utils::Vector3d const &pos, double dist)
Find all particles within a given radius dist around a position pos.
Utils::Vector9d moment_of_inertia_matrix(System::System const &system, int p_type)
Calculate the moment of inertia of particles of a certain type.
Utils::Vector9d gyration_tensor(System::System const &system, std::vector< int > const &p_types)
Calculate the gyration tensor of particles of certain types.
Utils::Vector3d calc_linear_momentum(System::System const &system, bool include_particles, bool include_lbfluid)
Calculate total momentum of the system (particles & LB fluid).
std::vector< std::vector< double > > structure_factor(System::System const &system, std::vector< int > const &p_types, int order)
Calculate the spherically averaged structure factor.
double mindist(System::System const &system, std::vector< int > const &set1, std::vector< int > const &set2)
Calculate the minimal distance of two particles with types in set1 and set2, respectively.
std::vector< std::vector< double > > calc_part_distribution(System::System const &system, std::vector< int > const &p1_types, std::vector< int > const &p2_types, double r_min, double r_max, int r_bins, bool log_flag, bool int_flag)
Calculate the distribution of particles around others.
Statistical tools to analyze simulations.
std::array< double, 4 > calc_rg(System::System const &system, int chain_start, int chain_length, int n_chains)
Calculate the radius of gyration.
std::array< double, 2 > calc_rh(System::System const &system, int chain_start, int chain_length, int n_chains)
Calculate the hydrodynamic radius (ref.
std::array< double, 4 > calc_re(System::System const &system, int chain_start, int chain_length, int n_chains)
Calculate the end-to-end-distance.
This file contains the code for statistics on chains.
Recursive variant implementation.