29#include "communication.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;
84 auto &box_geo = *system.
box_geo;
87 auto &nptiso = *system.
nptiso;
89 double L_halfdt = 0.0;
103 nptiso.volume += nptiso.inv_piston * nptiso.p_epsilon * 0.5 * time_step;
106 scal[2] =
Utils::sqr(box_geo.length()[nptiso.non_const_dim]) /
107 pow(nptiso.volume, 2.0 / nptiso.dimension);
108 if (nptiso.volume < 0.0) {
110 <<
"your choice of piston= " << nptiso.piston <<
", dt= " << time_step
111 <<
", p_epsilon= " << nptiso.p_epsilon
112 <<
" just caused the volume to become negative, decrease dt";
113 nptiso.volume = box_geo.volume();
117 L_halfdt = pow(nptiso.volume, 1.0 / nptiso.dimension);
120 scal[1] = L_halfdt * box_geo.length_inv()[nptiso.non_const_dim];
122 scal[0] = 1. / scal[1];
130 for (
auto &p : particles) {
131 for (
auto j = 0u; j < 3u; ++j) {
132 if (!p.is_fixed_along(j)) {
135 scal[1] * (p.pos()[j] + scal[2] * p.v()[j] * 0.5 * time_step);
136 p.pos_at_last_verlet_update()[j] *= scal[1];
139 p.pos()[j] += p.v()[j] * 0.5 * time_step;
154 nptiso.volume += nptiso.inv_piston * nptiso.p_epsilon * 0.5 * time_step;
155 L_dt = pow(nptiso.volume, 1.0 / nptiso.dimension);
158 scal[1] = L_dt / L_halfdt;
159 scal[0] = 1. / scal[1];
170 for (
auto &p : particles) {
173 for (
auto j = 0u; j < 3u; ++j) {
174 if (!p.is_fixed_along(j)) {
176 p.v()[j] = v_therm[j];
178 scal[1] * (p.pos()[j] + scal[2] * p.v()[j] * 0.5 * time_step);
179 p.pos_at_last_verlet_update()[j] *= scal[1];
182 p.pos()[j] += p.v()[j] * 0.5 * time_step;
195 new_box = box_geo.length();
196 for (
auto i = 0u; i < 3u; ++i) {
197 if (nptiso.cubic_box ||
206 box_geo.set_length(new_box);
215 auto &nptiso = *system.
nptiso;
226 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)
propagete positions and the volume and add thermal fluctuation.
void velocity_verlet_npt_Andersen_step_1(ParticleRangeNPT const &particles, IsotropicNptThermostat const &npt_iso, double time_step, System::System &system)
Special propagator for NpT isotropic for 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 for Andersen method.