34#include "system/System.hpp"
41#include <boost/range/algorithm/copy.hpp>
48 auto obs_pressure_ptr = std::make_shared<Observable_stat>(
50 nonbonded_ias->get_max_seen_particle_type());
52 if (long_range_interactions_sanity_checks()) {
53 return obs_pressure_ptr;
56 auto &obs_pressure = *obs_pressure_ptr;
60 auto const volume = box_geo->volume();
61 auto const local_parts = cell_structure->local_particles();
63 for (
auto const &p : local_parts) {
67 auto const coulomb_force_kernel = coulomb.pair_force_kernel();
68 auto const coulomb_pressure_kernel = coulomb.pair_pressure_kernel();
71 [
this, coulomb_force_kernel_ptr =
get_ptr(coulomb_force_kernel),
72 &obs_pressure](
Particle const &p1,
int bond_id,
76 iaparams, p1, partners, *box_geo, coulomb_force_kernel_ptr);
78 auto const &tensor = result.get();
80 for (
int k = 0; k < 3; k++)
81 for (
int l = 0; l < 3; l++)
82 obs_pressure.bonded_contribution(bond_id)[k * 3 + l] +=
89 [coulomb_force_kernel_ptr =
get_ptr(coulomb_force_kernel),
90 coulomb_pressure_kernel_ptr =
get_ptr(coulomb_pressure_kernel),
this,
93 auto const &ia_params =
94 nonbonded_ias->get_ia_param(p1.
type(), p2.type());
96 coulomb_force_kernel_ptr,
97 coulomb_pressure_kernel_ptr, obs_pressure);
103 auto const coulomb_pressure = coulomb.calc_pressure_long_range(local_parts);
104 boost::copy(coulomb_pressure, obs_pressure.coulomb.begin() + 9);
111#ifdef VIRTUAL_SITES_RELATIVE
112 if (!obs_pressure.virtual_sites.empty()) {
115 obs_pressure.virtual_sites.begin());
119 obs_pressure.rescale(volume);
121 obs_pressure.mpi_reduce();
122 return obs_pressure_ptr;
Vector implementation and trait types for boost qvm interoperability.
double maximal_cutoff_bonded()
Calculate the maximal cutoff of bonded interactions, required to determine the cell size for communic...
BondedInteractionsMap bonded_ia_params
Field containing the parameters of the bonded ia types.
Data structures for bonded interactions.
mapped_type at(key_type const &key) const
std::shared_ptr< Observable_stat > calculate_pressure()
Calculate the pressure from a virial expansion.
A stripped-down version of std::span from C++17.
This file contains the defaults for ESPResSo.
const T * get_ptr(std::optional< T > const &opt)
Solver const & get_dipoles()
void flatten(Range const &v, OutputIterator out)
Flatten a range of ranges.
Various procedures concerning interactions between particles.
void add_kinetic_virials(Particle const &p1, Observable_stat &obs_pressure)
Calculate kinetic pressure (aka energy) for one particle.
void add_non_bonded_pair_virials(Particle const &p1, Particle const &p2, Utils::Vector3d const &d, double dist, IA_parameters const &ia_params, Coulomb::ShortRangeForceKernel::kernel_type const *kernel_forces, Coulomb::ShortRangePressureKernel::kernel_type const *kernel_pressure, Observable_stat &obs_pressure)
Calculate non-bonded energies between a pair of particles.
boost::optional< Utils::Matrix< double, 3, 3 > > calc_bonded_pressure_tensor(Bonded_IA_Parameters const &iaparams, Particle const &p1, Utils::Span< Particle * > partners, BoxGeometry const &box_geo, Coulomb::ShortRangeForceKernel::kernel_type const *kernel)
Utils::Matrix< double, 3, 3 > vs_relative_pressure_tensor(CellStructure const &cell_structure)
void short_range_loop(BondKernel bond_kernel, PairKernel pair_kernel, CellStructure &cell_structure, double pair_cutoff, double bond_cutoff, VerletCriterion const &verlet_criterion={})
void calc_pressure_long_range() const
Distance vector and length handed to pair kernels.
Struct holding all information for one particle.
auto const & type() const