From e7353221ec845578f6723b7686bc03b9b34ecc0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Grad?= Date: Tue, 23 Jun 2020 16:03:09 +0200 Subject: [PATCH] core: Rename obs_pressure_tensor to obs_pressure --- src/core/Observable_stat.hpp | 2 +- src/core/pressure.cpp | 23 +++++++++++------------ src/core/pressure_inline.hpp | 15 ++++++--------- src/python/espressomd/analyze.pxd | 2 +- src/python/espressomd/analyze.pyx | 4 ++-- 5 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/core/Observable_stat.hpp b/src/core/Observable_stat.hpp index 39935ce9820..8b9228d43a8 100644 --- a/src/core/Observable_stat.hpp +++ b/src/core/Observable_stat.hpp @@ -29,7 +29,7 @@ #include #include -/** Observable for the scalar pressure, pressure tensor and energy. */ +/** Observable for the pressure and energy. */ class Observable_stat { /** Array for observables on each node. */ std::vector m_data; diff --git a/src/core/pressure.cpp b/src/core/pressure.cpp index 518560d344a..72c0c95de83 100644 --- a/src/core/pressure.cpp +++ b/src/core/pressure.cpp @@ -38,7 +38,7 @@ #include "electrostatics_magnetostatics/dipole.hpp" /** Pressure tensor of the system */ -Observable_stat obs_pressure_tensor{9}; +Observable_stat obs_pressure{9}; nptiso_struct nptiso = {0.0, 0.0, @@ -58,7 +58,7 @@ nptiso_struct nptiso = {0.0, void calc_long_range_virials(const ParticleRange &particles) { #ifdef ELECTROSTATICS /* calculate k-space part of electrostatic interaction. */ - Coulomb::calc_pressure_long_range(obs_pressure_tensor, particles); + Coulomb::calc_pressure_long_range(obs_pressure, particles); #endif #ifdef DIPOLES /* calculate k-space part of magnetostatic interaction. */ @@ -76,7 +76,7 @@ void pressure_calc() { if (!interactions_sanity_checks()) return; - obs_pressure_tensor = Observable_stat{9}; + obs_pressure = Observable_stat{9}; on_observable_calc(); @@ -93,19 +93,18 @@ void pressure_calc() { calc_long_range_virials(cell_structure.local_particles()); #ifdef VIRTUAL_SITES - if (!obs_pressure_tensor.virtual_sites.empty()) { - auto const vs_pressure_tensor = virtual_sites()->pressure_tensor(); - boost::copy(flatten(vs_pressure_tensor), - obs_pressure_tensor.virtual_sites.begin()); + if (!obs_pressure.virtual_sites.empty()) { + auto const vs_pressure = virtual_sites()->pressure_tensor(); + boost::copy(flatten(vs_pressure), obs_pressure.virtual_sites.begin()); } #endif - obs_pressure_tensor.rescale(volume); + obs_pressure.rescale(volume); /* gather data */ - auto obs_pressure_tensor_res = reduce(comm_cart, obs_pressure_tensor); - if (obs_pressure_tensor_res) { - std::swap(obs_pressure_tensor, *obs_pressure_tensor_res); + auto obs_pressure_res = reduce(comm_cart, obs_pressure); + if (obs_pressure_res) { + std::swap(obs_pressure, *obs_pressure_res); } } @@ -115,7 +114,7 @@ Utils::Vector9d observable_compute_pressure_tensor() { update_pressure(); Utils::Vector9d pressure_tensor{}; for (size_t j = 0; j < 9; j++) { - pressure_tensor[j] = obs_pressure_tensor.accumulate(0, j); + pressure_tensor[j] = obs_pressure.accumulate(0, j); } return pressure_tensor; } diff --git a/src/core/pressure_inline.hpp b/src/core/pressure_inline.hpp index 39ea96bce25..bb7db4e6817 100644 --- a/src/core/pressure_inline.hpp +++ b/src/core/pressure_inline.hpp @@ -32,7 +32,7 @@ #include -extern Observable_stat obs_pressure_tensor; +extern Observable_stat obs_pressure; /** Calculate non bonded energies between a pair of particles. * @param p1 pointer to particle 1. @@ -51,18 +51,17 @@ inline void add_non_bonded_pair_virials(Particle const &p1, Particle const &p2, auto const type1 = p1.p.mol_id; auto const type2 = p2.p.mol_id; - obs_pressure_tensor.add_non_bonded_contribution(type1, type2, - flatten(stress)); + obs_pressure.add_non_bonded_contribution(type1, type2, flatten(stress)); } #ifdef ELECTROSTATICS - if (!obs_pressure_tensor.coulomb.empty()) { + if (!obs_pressure.coulomb.empty()) { /* real space Coulomb */ auto const p_coulomb = Coulomb::pair_pressure(p1, p2, d, dist); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - obs_pressure_tensor.coulomb[i * 3 + j] += p_coulomb[i][j]; + obs_pressure.coulomb[i * 3 + j] += p_coulomb[i][j]; } } } @@ -148,8 +147,7 @@ inline bool add_bonded_pressure_tensor(Particle &p1, int bond_id, /* pressure tensor part */ for (int k = 0; k < 3; k++) for (int l = 0; l < 3; l++) - obs_pressure_tensor.bonded_contribution(bond_id)[k * 3 + l] += - tensor[k][l]; + obs_pressure.bonded_contribution(bond_id)[k * 3 + l] += tensor[k][l]; return false; } @@ -167,8 +165,7 @@ inline void add_kinetic_virials(Particle const &p1) { /* kinetic pressure */ for (int k = 0; k < 3; k++) for (int l = 0; l < 3; l++) - obs_pressure_tensor.kinetic[k * 3 + l] += - (p1.m.v[k]) * (p1.m.v[l]) * p1.p.mass; + obs_pressure.kinetic[k * 3 + l] += p1.m.v[k] * p1.m.v[l] * p1.p.mass; } #endif diff --git a/src/python/espressomd/analyze.pxd b/src/python/espressomd/analyze.pxd index bc8c4821dfa..f7b79a9c3d6 100644 --- a/src/python/espressomd/analyze.pxd +++ b/src/python/espressomd/analyze.pxd @@ -82,7 +82,7 @@ cdef extern from "statistics_chain.hpp": array2 calc_rh(int, int, int) cdef extern from "pressure_inline.hpp": - cdef Observable_stat obs_pressure_tensor + cdef Observable_stat obs_pressure cdef extern from "pressure.hpp": cdef void update_pressure() diff --git a/src/python/espressomd/analyze.pyx b/src/python/espressomd/analyze.pyx index fdf1b2a31a2..3f9581be06e 100644 --- a/src/python/espressomd/analyze.pyx +++ b/src/python/espressomd/analyze.pyx @@ -332,7 +332,7 @@ class Analysis: # Update in ESPResSo core analyze.update_pressure() - return _Observable_stat_to_dict(analyze.obs_pressure_tensor, 9, True) + return _Observable_stat_to_dict(analyze.obs_pressure, 9, True) def pressure_tensor(self): """Calculate the instantaneous pressure_tensor (in parallel). This is @@ -366,7 +366,7 @@ class Analysis: # Update in ESPResSo core analyze.update_pressure() - return _Observable_stat_to_dict(analyze.obs_pressure_tensor, 9, False) + return _Observable_stat_to_dict(analyze.obs_pressure, 9, False) IF DPD == 1: def dpd_stress(self):