19#ifndef OBSERVABLES_BONDANGLES_HPP
20#define OBSERVABLES_BONDANGLES_HPP
24#include "system/System.hpp"
46 if (this->
ids().size() < 3)
47 throw std::runtime_error(
"At least 3 particles are required");
54 auto const positions_sorted = detail::get_all_particle_positions(
55 comm, local_particles,
ids(),
traits,
false);
57 if (comm.rank() != 0) {
63 auto v1 = box_geo.get_mi_vector(positions_sorted[1], positions_sorted[0]);
65 for (std::size_t i = 0, end =
n_values(); i < end; i++) {
66 auto v2 = box_geo.get_mi_vector(positions_sorted[i + 2],
67 positions_sorted[i + 1]);
68 auto const n2 = v2.norm();
76 res[i] = acos(-cosine);
82 std::vector<std::size_t>
shape()
const override {
83 assert(
ids().size() >= 2);
84 return {
ids().size() - 2};
Vector implementation and trait types for boost qvm interoperability.
Calculate bond angles between particles in a polymer.
std::vector< std::size_t > shape() const override
BondAngles(std::vector< int > ids)
std::vector< double > evaluate(boost::mpi::communicator const &comm, ParticleReferenceRange const &local_particles, const ParticleObservables::traits< Particle > &traits) const override
std::size_t n_values() const
Size of the flat array returned by the observable.
Particle-based observable.
PidObservable(std::vector< int > ids)
std::vector< int > const & ids() const
std::shared_ptr< BoxGeometry > box_geo
#define TINY_COS_VALUE
Tiny angle cutoff for cosine calculations.
std::vector< std::reference_wrapper< Particle const > > ParticleReferenceRange