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#ifdef DIPOLE_FIELD_TRACKING
139 if (
name ==
"calc_long_range_fields") {
144 if (
name ==
"particle_neighbor_pids") {
146 system.on_observable_calc();
147 std::unordered_map<int, std::vector<int>>
dict;
151 std::ranges::for_each(neighbor_pids, [&
dict](
auto const &
nbhood) {
158 if (
name ==
"dpd_stress") {
160 return result.as_vector();
163 if (
name ==
"min_dist") {
174 if (
name ==
"center_of_mass") {
180 if (
name ==
"angular_momentum") {
186 if (
name ==
"nbhood") {
192 if (
name ==
"calc_re") {
199 return std::vector<double>(result.begin(), result.end());
201 if (
name ==
"calc_rg") {
210 output =
Variant{std::vector<double>(result.begin(), result.end())};
214 if (
name ==
"calc_rh") {
221 return std::vector<double>(result.begin(), result.end());
223 if (
name ==
"gyration_tensor") {
229 return std::vector<double>(
mat.begin(),
mat.end());
231 if (
name ==
"moment_of_inertia_matrix") {
237 if (
name ==
"structure_factor") {
242 throw std::domain_error(
"order has to be a strictly positive number");
250 if (
name ==
"distribution") {
261 throw std::domain_error(
"Parameter 'r_min' must be > 0");
264 throw std::domain_error(
"Parameter 'r_min' must be >= 0");
267 throw std::domain_error(
"Parameter 'r_max' must be > 'r_min'");
270 throw std::domain_error(
"Parameter 'r_max' must be <= box_l / 2");
273 throw std::domain_error(
"Parameter 'r_bins' must be >= 1");
290 if (
name ==
"calculate_energy") {
291 return m_obs_stat->do_call_method(
"calculate_energy", {});
293 if (
name ==
"calculate_scalar_pressure") {
294 return m_obs_stat->do_call_method(
"calculate_scalar_pressure", {});
296 if (
name ==
"calculate_pressure_tensor") {
297 return m_obs_stat->do_call_method(
"calculate_pressure_tensor", {});
300 if (
name ==
"get_instantaneous_pressure") {
301 return get_system().npt_inst_pressure->p_inst[0];
303 if (
name ==
"get_instantaneous_pressure_virial") {
304 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.
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.
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.
Describes a cell structure / cell system.
Particle * get_local_particle(int id)
Get a local particle by id.