29#include "communication.hpp"
32#include "system/System.hpp"
33#include "thermostat.hpp"
39#include <boost/mpi/collectives.hpp>
52 npt_inst_pressure.
p_vel = {};
53 for (
auto &p : particles) {
54 for (
unsigned int j = 0; j < 3; j++) {
55 if (!p.is_fixed_along(j)) {
59 p.v()[j] += p.force()[j] * time_step / 2.0 / p.mass();
76 npt_inst_pressure.
p_inst = {0., 0.};
77 for (
unsigned int i = 0; i < 3; i++) {
79 npt_inst_pressure.
p_inst[0] +=
80 npt_inst_pressure.
p_vir[i] + npt_inst_pressure.
p_vel[i];
81 npt_inst_pressure.
p_inst[1] += npt_inst_pressure.
p_vir[i];
87 std::plus<Utils::Vector2d>(), 0);
93 (npt_inst_pressure.
p_inst[0] - nptiso.
p_ext) * 0.5 * time_step;
102 auto &box_geo = *system.
box_geo;
105 auto &nptiso = *system.
nptiso;
107 double L_halfdt = 0.0;
121 nptiso.volume += nptiso.inv_piston * nptiso.p_epsilon * 0.5 * time_step;
124 scal[2] =
Utils::sqr(box_geo.length()[nptiso.non_const_dim]) /
125 pow(nptiso.volume, 2.0 / nptiso.dimension);
126 if (nptiso.volume < 0.0) {
128 <<
"your choice of piston= " << nptiso.piston <<
", dt= " << time_step
129 <<
", p_epsilon= " << nptiso.p_epsilon
130 <<
" just caused the volume to become negative, decrease dt";
131 nptiso.volume = box_geo.volume();
135 L_halfdt = pow(nptiso.volume, 1.0 / nptiso.dimension);
138 scal[1] = L_halfdt * box_geo.length_inv()[nptiso.non_const_dim];
140 scal[0] = 1. / scal[1];
142 boost::mpi::broadcast(
comm_cart, scal, 0);
148 for (
auto &p : particles) {
149 for (
unsigned int j = 0; j < 3; j++) {
150 if (!p.is_fixed_along(j)) {
153 scal[1] * (p.pos()[j] + scal[2] * p.v()[j] * 0.5 * time_step);
154 p.pos_at_last_verlet_update()[j] *= scal[1];
157 p.pos()[j] += p.v()[j] * 0.5 * time_step;
173 nptiso.volume += nptiso.inv_piston * nptiso.p_epsilon * 0.5 * time_step;
174 L_dt = pow(nptiso.volume, 1.0 / nptiso.dimension);
177 scal[1] = L_dt / L_halfdt;
178 scal[0] = 1. / scal[1];
180 boost::mpi::broadcast(
comm_cart, scal, 0);
189 for (
auto &p : particles) {
192 for (
unsigned int j = 0; j < 3; j++) {
193 if (!p.is_fixed_along(j)) {
195 p.v()[j] = v_therm[j];
197 scal[1] * (p.pos()[j] + scal[2] * p.v()[j] * 0.5 * time_step);
198 p.pos_at_last_verlet_update()[j] *= scal[1];
201 p.pos()[j] += p.v()[j] * 0.5 * time_step;
214 new_box = box_geo.length();
216 for (
unsigned int i = 0; i < 3; i++) {
217 if (nptiso.cubic_box ||
224 boost::mpi::broadcast(
comm_cart, new_box, 0);
226 box_geo.set_length(new_box);
239 npt_inst_pressure.p_vel = {};
241 for (
auto &p : particles) {
242 for (
unsigned int j = 0; j < 3; j++) {
243 if (!p.is_fixed_along(j)) {
244 p.v()[j] += p.force()[j] * time_step / 2.0 / p.mass();
246 npt_inst_pressure.p_vel[j] +=
Utils::sqr(p.v()[j]) * p.mass();
262 auto &nptiso = *system.
nptiso;
Vector implementation and trait types for boost qvm interoperability.
void on_boxl_change(bool skip_method_adaption=false)
Called when the box length has changed.
std::shared_ptr< InstantaneousPressure > npt_inst_pressure
std::shared_ptr< NptIsoParameters > nptiso
std::shared_ptr< CellStructure > cell_structure
std::shared_ptr< BoxGeometry > box_geo
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 ...
#define runtimeErrorMsg()
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Exports for the NpT code.
double propagate_thermV_nptiso(IsotropicNptThermostat const &npt_iso, double p_epsilon, double piston)
Added noise and friction for NpT-sims to NptIsoParameters::p_epsilon; .
Utils::Vector3d propagate_therm0_nptiso(IsotropicNptThermostat const &npt_iso, Utils::Vector3d const &vel, double mass, int p_identity)
Add velocity-dependent noise and friction for NpT-sims to the particle's velocity; .
Instantaneous pressure during force calculation for NPT integration.
Utils::Vector3d p_vel
ideal gas components of p_inst, derived from the velocities
Utils::Vector3d p_vir
virial (short-range) components of p_inst
Utils::Vector2d p_inst
instantaneous pressure for p_inst[0] and virial pressure for p_inst[1] the system currently has
Thermostat for isotropic NPT dynamics.
Parameters of the isotropic NpT-integration scheme.
int geometry
geometry information for the NpT integrator.
static constexpr std::array< int, 3 > nptgeom_dir
double p_ext
desired pressure to which the algorithm strives to
int dimension
The number of dimensions in which NpT boxlength motion is coupled to particles.
double p_epsilon
conjugate momentum of volume
double volume
isotropic volume.
static void velocity_verlet_npt_propagate_vel(ParticleRangeNPT const &particles, double time_step)
Propagate the particle's velocity.
static void velocity_verlet_npt_propagate_vel_final(NptIsoParameters const &nptiso, InstantaneousPressure &npt_inst_pressure, ParticleRangeNPT const &particles, double time_step)
Propagate the particle's velocity.
void velocity_verlet_npt_step_1(ParticleRangeNPT const &particles, IsotropicNptThermostat const &npt_iso, double time_step, System::System &system)
Special propagator for NpT isotropic.
void velocity_verlet_npt_step_2(ParticleRangeNPT const &particles, double time_step, System::System &system)
Final integration step of the Velocity Verlet+NpT integrator.
static void velocity_verlet_npt_propagate_pos(ParticleRangeNPT const &particles, IsotropicNptThermostat const &npt_iso, double time_step, System::System &system)
static void velocity_verlet_npt_finalize_p_inst(NptIsoParameters &nptiso, InstantaneousPressure &npt_inst_pressure, double time_step)
Scale and communicate instantaneous NpT pressure and propagate the conjugate momentum for volume.