30#include "system/System.hpp"
35#include <boost/mpi/collectives.hpp>
42 boost::mpi::broadcast(
comm_cart, nptiso->p_epsilon, 0);
43 boost::mpi::broadcast(
comm_cart, nptiso->volume, 0);
44 boost::mpi::broadcast(
comm_cart, npt_inst_pressure->p_inst, 0);
50 if (dimension < 3 and not cubic_box and system.coulomb.impl->solver) {
51 throw std::runtime_error(
"If electrostatics is being used you must "
52 "use the cubic box NpT.");
56 if (dimension < 3 and not cubic_box and system.dipoles.impl->solver) {
57 throw std::runtime_error(
"If magnetostatics is being used you must "
58 "use the cubic box NpT.");
66 : piston{piston}, inv_piston{piston}, p_ext{ext_pressure},
67 cubic_box{cubic_box} {
69 if (ext_pressure < 0.0) {
70 throw std::runtime_error(
"The external pressure must be positive");
73 throw std::runtime_error(
"The piston mass must be positive");
77 for (
auto const i : {0u, 1u, 2u}) {
86 throw std::runtime_error(
87 "You must enable at least one of the x y z components "
88 "as fluctuating dimension(s) for box length motion");
99 nptiso->inv_piston = 1. / nptiso->piston;
101 std::pow(box_geo->length()[nptiso->non_const_dim], nptiso->dimension);
108 auto &mass_list = nptiso->mass_list;
110 for (
auto &p : cell_structure->local_particles()) {
111 mass_list.emplace_back(p.mass());
113 mass_list.erase(std::ranges::unique(mass_list).begin(), mass_list.end());
116 mass_list.erase(std::ranges::unique(mass_list).begin(), mass_list.end());
117 std::ranges::sort(mass_list);
124 npt_inst_pressure->p_vir[0] += energy;
131 npt_inst_pressure->p_vir += hadamard_product(force, d);
Vector implementation and trait types for boost qvm interoperability.
void npt_ensemble_init(bool recalc_forces)
Reinitialize the NpT state.
void npt_add_virial_contribution(double energy)
void synchronize_npt_state()
Synchronize NpT state such as instantaneous and average pressure.
boost::mpi::communicator comm_cart
The communicator.
int this_node
The number of this node.
This file contains the defaults for ESPResSo.
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
void gather_buffer(std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
Gather buffer with different size on each node.
Exports for the NpT code.
void coulomb_dipole_sanity_checks(System::System const &system) const
int geometry
geometry information for the NpT integrator.
static constexpr std::array< int, 3 > nptgeom_dir
int non_const_dim
An index to one of the non-constant dimensions.
Utils::Vector< bool, 3 > get_direction() const
NptIsoParameters()=default
int dimension
The number of dimensions in which NpT boxlength motion is coupled to particles.
double piston
mass of a virtual piston representing the shaken box