38#include <boost/mpi/collectives/all_reduce.hpp>
57 throw std::domain_error(
"Chain analysis needs at least 1 chain");
60 throw std::domain_error(
"Chain analysis needs at least 1 bead per chain");
68 if (ptr !=
nullptr and not ptr->is_ghost()) {
81 if (ptr !=
nullptr and not ptr->is_ghost()) {
87 std::stringstream error_msg;
88 error_msg <<
"Particle with id " << pid <<
" does not exist; "
89 <<
"cannot perform analysis on the range chain_start="
92 <<
"Please provide a contiguous range of particle ids.";
93 throw std::runtime_error(error_msg.str());
105void Analysis::check_particle_type(
int p_type)
const {
106 auto const &nonbonded_ias =
get_system().nonbonded_ias;
108 std::stringstream error_msg;
109 error_msg <<
"Particle type " <<
p_type <<
" does not exist";
110 throw std::invalid_argument(error_msg.str());
116 if (
name ==
"linear_momentum") {
122 if (
name ==
"particle_energy") {
125 auto const local =
system.particle_short_range_energy_contribution(pid);
128#ifdef DIPOLE_FIELD_TRACKING
129 if (
name ==
"calc_long_range_fields") {
134 if (
name ==
"particle_neighbor_pids") {
136 system.on_observable_calc();
137 std::unordered_map<int, std::vector<int>>
dict;
141 std::for_each(neighbor_pids.begin(), neighbor_pids.end(),
143 dict[neighbor_pid.pid] = neighbor_pid.neighbor_pids;
149 if (
name ==
"dpd_stress") {
151 return result.as_vector();
154 if (
name ==
"min_dist") {
165 if (
name ==
"center_of_mass") {
171 if (
name ==
"angular_momentum") {
177 if (
name ==
"nbhood") {
183 if (
name ==
"calc_re") {
190 return std::vector<double>(result.begin(), result.end());
192 if (
name ==
"calc_rg") {
201 output =
Variant{std::vector<double>(result.begin(), result.end())};
205 if (
name ==
"calc_rh") {
212 return std::vector<double>(result.begin(), result.end());
214 if (
name ==
"gyration_tensor") {
220 return std::vector<double>(
mat.begin(),
mat.end());
222 if (
name ==
"moment_of_inertia_matrix") {
228 if (
name ==
"structure_factor") {
233 throw std::domain_error(
"order has to be a strictly positive number");
241 if (
name ==
"distribution") {
252 throw std::domain_error(
"Parameter 'r_min' must be > 0");
255 throw std::domain_error(
"Parameter 'r_min' must be >= 0");
258 throw std::domain_error(
"Parameter 'r_max' must be > 'r_min'");
261 throw std::domain_error(
"Parameter 'r_max' must be <= box_l / 2");
264 throw std::domain_error(
"Parameter 'r_bins' must be >= 1");
281 if (
name ==
"calculate_energy") {
282 return m_obs_stat->do_call_method(
"calculate_energy", {});
284 if (
name ==
"calculate_scalar_pressure") {
285 return m_obs_stat->do_call_method(
"calculate_scalar_pressure", {});
287 if (
name ==
"calculate_pressure_tensor") {
288 return m_obs_stat->do_call_method(
"calculate_pressure_tensor", {});
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.
Variant do_call_method(std::string const &name, VariantMap const ¶meters) override
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
boost::string_ref name() const
Context * context() const
Responsible context.
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)
boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type Variant
Possible types for parameters.
void gather_buffer(std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
Gather buffer with different size on each node.
Various procedures concerning interactions between particles.
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.
Describes a cell structure / cell system.
Particle * get_local_particle(int id)
Get a local particle by id.