28#include "communication.hpp"
30#include "system/System.hpp"
35#include <boost/mpi/collectives.hpp>
51 npt_inst_pressure.
p_inst = {0., 0.};
52 for (
auto i = 0u; i < 3u; ++i) {
54 npt_inst_pressure.
p_inst[0] +=
55 npt_inst_pressure.
p_vir[i] + npt_inst_pressure.
p_vel[i];
56 npt_inst_pressure.
p_inst[1] += npt_inst_pressure.
p_vir[i];
62 std::plus<Utils::Vector2d>(), 0);
68 (npt_inst_pressure.
p_inst[0] - nptiso.
p_ext) * 0.5 * time_step;
74 if (nptiso.volume < 0.) {
76 <<
", time_step=" << time_step
77 <<
", p_epsilon=" << nptiso.p_epsilon
78 <<
" just caused the volume to become negative."
79 <<
" The system is now in an indeterminate state."
80 <<
" Restart the simulation with a smaller time_step.";
81 nptiso.volume = box_geo.volume();
97 auto &box_geo = *system.
box_geo;
100 auto &nptiso = *system.
nptiso;
102 double L_halfdt = 0.0;
116 nptiso.volume += nptiso.inv_piston * nptiso.p_epsilon * 0.5 * time_step;
120 scal[2] =
Utils::sqr(box_geo.length()[nptiso.non_const_dim]) /
121 std::pow(nptiso.volume, 2.0 / nptiso.dimension);
122 L_halfdt = std::pow(nptiso.volume, 1.0 / nptiso.dimension);
125 scal[1] = L_halfdt * box_geo.length_inv()[nptiso.non_const_dim];
127 scal[0] = 1. / scal[1];
135 for (
auto &p : particles) {
136 for (
auto j = 0u; j < 3u; ++j) {
137 if (!p.is_fixed_along(j)) {
140 scal[1] * (p.pos()[j] + scal[2] * p.v()[j] * 0.5 * time_step);
141 p.pos_at_last_verlet_update()[j] *= scal[1];
144 p.pos()[j] += p.v()[j] * 0.5 * time_step;
159 nptiso.volume += nptiso.inv_piston * nptiso.p_epsilon * 0.5 * time_step;
161 L_dt = std::pow(nptiso.volume, 1.0 / nptiso.dimension);
164 scal[1] = L_dt / L_halfdt;
165 scal[0] = 1. / scal[1];
176 for (
auto &p : particles) {
179 for (
auto j = 0u; j < 3u; ++j) {
180 if (!p.is_fixed_along(j)) {
182 p.v()[j] = v_therm[j];
184 scal[1] * (p.pos()[j] + scal[2] * p.v()[j] * 0.5 * time_step);
185 p.pos_at_last_verlet_update()[j] *= scal[1];
188 p.pos()[j] += p.v()[j] * 0.5 * time_step;
201 new_box = box_geo.length();
202 for (
auto i = 0u; i < 3u; ++i) {
203 if (nptiso.cubic_box ||
212 box_geo.set_length(new_box);
221 auto &nptiso = *system.
nptiso;
232 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 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.
double propagate_thermV_nptiso(IsotropicNptThermostat const &npt_iso, double p_epsilon)
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.
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_propagate_vel(NptIsoParameters const &nptiso, InstantaneousPressure &npt_inst_pressure, ParticleRangeNPT const &particles, double time_step)
Propagate the particle's velocity.
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.
static void velocity_verlet_npt_propagate_AVOVA_And(ParticleRangeNPT const &particles, IsotropicNptThermostat const &npt_iso, double time_step, System::System &system)
propagate positions and the volume and add thermal fluctuation.
static void handle_negative_volume(auto &nptiso, auto const &box_geo, double time_step)
void velocity_verlet_npt_Andersen_step_1(ParticleRangeNPT const &particles, IsotropicNptThermostat const &npt_iso, double time_step, System::System &system)
Special propagator for velocity Verlet NpT with the Andersen method.
void velocity_verlet_npt_Andersen_step_2(ParticleRangeNPT const &particles, double time_step, System::System &system)
Final integration step of the velocity Verlet NpT integrator with the Andersen method.