ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
velocity_verlet_npt.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <config/config.hpp>
23
24#ifdef ESPRESSO_NPT
25
26#include "PropagationMode.hpp"
28#include "npt.hpp"
29#include "system/System.hpp"
30#include "thermostat.hpp"
31
32#include <utils/math/sqr.hpp>
33
35 int modes;
42
43 bool operator()(int prop) const { return (prop & modes); }
44};
45
47
48/**
49 * @brief Special propagator for velocity Verlet NpT with the Andersen method.
50 * Propagate the velocities and positions. Integration steps before force
51 * calculation of the Velocity Verlet integrator:
52 * \f[ v(t+0.5 \Delta t) = v(t) + 0.5 \Delta t \cdot F(t)/m \f]
53 * \f[ x(t+\Delta t) = x(t) + \Delta t \cdot v(t+0.5 \Delta t) \f]
54 *
55 * Propagate pressure, box_length (2 times) and positions, rescale
56 * positions and velocities and check Verlet list criterion (only NpT).
57 */
59 IsotropicNptThermostat const &npt_iso,
60 double time_step,
61 System::System &system);
62/**
63 * @brief Special propagator for velocity Verlet NpT with the Andersen method.
64 */
66 IsotropicNptThermostat const &npt_iso,
67 double time_step, System::System &system);
68
69/**
70 * @brief Final integration step of the velocity Verlet NpT integrator
71 * with the Andersen method.
72 * Finalize instantaneous pressure calculation:
73 * \f[ v(t+\Delta t) = v(t+0.5 \Delta t)
74 * + 0.5 \Delta t \cdot F(t+\Delta t)/m \f]
75 */
77 double time_step,
78 System::System &system);
79/**
80 * @brief Final integration step of the velocity Verlet NpT integrator
81 * with the MTK method.
82 */
84 double time_step, System::System &system);
85
86/**
87 * @brief Propagate the particle's velocity.
88 * @f$ v(t+dt) = v(t+0.5*dt) + 0.5*dt * a(t+dt) @f$
89 */
91 NptIsoParameters const &nptiso, InstantaneousPressure &npt_inst_pressure,
92 ParticleRangeNPT const &particles, double time_step) {
93
94 npt_inst_pressure.p_vel = {};
95 for (auto &p : particles) {
96 for (auto j = 0u; j < 3u; ++j) {
97 if (!p.is_fixed_along(j)) {
99 npt_inst_pressure.p_vel[j] += Utils::sqr(p.v()[j]) * p.mass();
100 }
101 p.v()[j] += p.force()[j] * time_step / (2. * p.mass());
102 }
103 }
104 }
105}
106
107/**
108 * @brief Propagate the particle's velocity.
109 * @f$ v(t+0.5*dt) = v(t) + 0.5*dt * a(t) @f$
110 */
112 NptIsoParameters const &nptiso, InstantaneousPressure &npt_inst_pressure,
113 ParticleRangeNPT const &particles, double time_step) {
114 npt_inst_pressure.p_vel = {};
115
116 for (auto &p : particles) {
117 for (auto j = 0u; j < 3u; ++j) {
118 if (!p.is_fixed_along(j)) {
119 p.v()[j] += p.force()[j] * time_step / (2. * p.mass());
120 if (nptiso.geometry & NptIsoParameters::nptgeom_dir[j]) {
121 npt_inst_pressure.p_vel[j] += Utils::sqr(p.v()[j]) * p.mass();
122 }
123 }
124 }
125 }
126}
127
128#endif // ESPRESSO_NPT
Main system class.
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Definition sqr.hpp:28
Exports for the NpT code.
Instantaneous pressure during force calculation for NPT integration.
Definition npt.hpp:92
Utils::Vector3d p_vel
ideal gas components of p_inst, derived from the velocities
Definition npt.hpp:99
Thermostat for isotropic NPT dynamics.
Parameters of the isotropic NpT-integration scheme.
Definition npt.hpp:42
int geometry
geometry information for the NpT integrator.
Definition npt.hpp:72
static constexpr std::array< int, 3 > nptgeom_dir
Definition npt.hpp:88
PropagationPredicateNPT(int default_propagation)
bool operator()(int prop) const
void velocity_verlet_npt_MTK_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_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.
void velocity_verlet_npt_MTK_step_2(ParticleRangeNPT const &particles, double time_step, System::System &system)
Final integration step of the velocity Verlet NpT integrator with the MTK method.
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.