33 std::vector<double> m_data;
35 std::size_t m_chunk_size;
37 std::size_t get_non_bonded_offset(
int type1,
int type2)
const;
40 auto get_non_bonded_contribution(std::span<double> view,
int type1,
42 auto const offset = get_non_bonded_offset(type1, type2);
43 return view.subspan(offset * m_chunk_size, m_chunk_size);
47 Observable_stat(std::size_t chunk_size, std::size_t n_bonded,
int max_type);
56 double accumulate(
double acc = 0.0, std::size_t column = 0ul)
const {
57 assert(column < m_chunk_size);
58 if (m_chunk_size == 1ul)
59 return std::accumulate(m_data.begin(), m_data.end(), acc);
61 for (
auto it = m_data.begin() +
static_cast<std::ptrdiff_t
>(column);
62 it < m_data.end(); it +=
static_cast<std::ptrdiff_t
>(m_chunk_size))
69 std::ranges::transform(m_data, m_data.begin(),
70 std::bind_front(std::multiplies{}, 1. / volume));
92 auto const offset = m_chunk_size *
static_cast<std::size_t
>(bond_id);
93 return {
bonded.data() + offset, m_chunk_size};
97 std::span<const double> data) {
98 assert(data.size() == m_chunk_size);
100 auto const dest = get_non_bonded_contribution(view, type1, type2);
102 std::ranges::transform(dest, data, dest.begin(), std::plus{});
Observable for the pressure and energy.
auto non_bonded_intra_contribution(int type1, int type2) const
Get contribution from a non-bonded intramolecular interaction.
void add_non_bonded_contribution(int type1, int type2, int molid1, int molid2, double data)
std::span< double > coulomb
Contribution(s) from Coulomb interactions.
std::span< double > non_bonded_inter
Contribution(s) from non-bonded intermolecular interactions.
auto get_chunk_size() const
void add_non_bonded_contribution(int type1, int type2, int molid1, int molid2, std::span< const double > data)
void rescale(double volume)
Rescale values.
auto non_bonded_inter_contribution(int type1, int type2) const
Get contribution from a non-bonded intermolecular interaction.
std::span< double > virtual_sites
Contribution from virtual sites (accumulated).
std::span< double > kinetic
Contribution from linear and angular kinetic energy (accumulated).
std::span< double > bonded_contribution(int bond_id) const
Get contribution from a bonded interaction.
double accumulate(double acc=0.0, std::size_t column=0ul) const
Accumulate values.
std::span< double > non_bonded_intra
Contribution(s) from non-bonded intramolecular interactions.
void mpi_reduce()
MPI reduction.
std::span< double > dipolar
Contribution(s) from dipolar interactions.
std::span< double > external_fields
Contribution from external fields (accumulated).
std::span< double > bonded
Contribution(s) from bonded interactions.