47 auto const get_obs_contribs = [obs_dim,
48 calc_sp](std::span<double>
const &views) {
50 return std::vector<Variant>(views.begin(), views.end());
52 assert(obs_dim == 9ul);
53 assert(views.size() % 9ul == 0ul);
54 std::vector<Variant> out;
55 for (std::size_t i = 0ul; i < views.size() / 9ul; ++i) {
56 auto const view = views.subspan(i * 9ul, 9ul);
58 auto const trace = view[0ul] + view[4ul] + view[8ul];
59 out.emplace_back(trace / 3.);
61 auto const flat_matrix = std::vector<double>(view.begin(), view.end());
62 out.emplace_back(flat_matrix);
68 auto const get_obs_contrib =
69 [&get_obs_contribs](std::span<double>
const &views) ->
Variant {
70 return get_obs_contribs(views)[0ul];
73 std::unordered_map<std::string, Variant> dict;
74 dict[
"kinetic"] = get_obs_contrib(obs.
kinetic);
78 auto values = std::vector<double>(obs_dim);
79 for (std::size_t i = 0ul; i < obs_dim; ++i) {
82 dict[
"total"] = get_obs_contrib({values.data(), obs_dim});
85 auto const n_bonds =
static_cast<int>(system.
bonded_ias->get_next_key());
86 for (
int bond_id = 0; bond_id < n_bonds; ++bond_id) {
87 if (system.
bonded_ias->get_zero_based_type(bond_id) != 0) {
88 dict[
"bonded," + std::to_string(bond_id)] =
93 auto const n_nonbonded =
95 for (
int i = 0; i < n_nonbonded; ++i) {
96 for (
int j = i; j < n_nonbonded; ++j) {
97 auto const indices = std::to_string(i) +
"," + std::to_string(j);
98 dict[
"non_bonded_intra," + indices] =
100 dict[
"non_bonded_inter," + indices] =
107 auto const values = get_obs_contribs(obs.
coulomb);
108 for (std::size_t i = 0ul; i < values.size(); ++i) {
109 dict[
"coulomb," + std::to_string(i)] = values[i];
116 auto const values = get_obs_contribs(obs.
dipolar);
117 for (std::size_t i = 0ul; i < values.size(); ++i) {
118 dict[
"dipolar," + std::to_string(i)] = values[i];
126 for (std::size_t i = 0ul; i < values.size(); ++i) {
127 dict[
"virtual_sites," + std::to_string(i)] = values[i];
138 if (
name ==
"calculate_energy") {
139 auto const obs = system.calculate_energy();
142 if (
name ==
"calculate_scalar_pressure") {
143 auto const obs = system.calculate_pressure();
146 if (
name ==
"calculate_pressure_tensor") {
147 auto const obs = system.calculate_pressure();
Data structures for bonded interactions.
Observable for the pressure and energy.
auto non_bonded_intra_contribution(int type1, int type2) const
Get contribution from a non-bonded intramolecular interaction.
std::span< double > coulomb
Contribution(s) from Coulomb interactions.
auto get_chunk_size() const
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 > dipolar
Contribution(s) from dipolar interactions.
std::span< double > external_fields
Contribution from external fields (accumulated).
Variant do_call_method(std::string const &name, VariantMap const ¶meters) override
boost::string_ref name() const
auto const & get_system() const
std::shared_ptr< BondedInteractionsMap > bonded_ias
std::shared_ptr< InteractionsNonBonded > nonbonded_ias
This file contains the defaults for ESPResSo.
static auto get_summary(::System::System const &system, Observable_stat const &obs, bool const calc_sp)
Generate an observable summary.
std::unordered_map< std::string, Variant > VariantMap
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.
Various procedures concerning interactions between particles.