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 "ParticleRange.hpp"
27#include "PropagationMode.hpp"
29#include "npt.hpp"
30#include "system/System.hpp"
31#include "thermostat.hpp"
32
33#include <utils/math/sqr.hpp>
34
36 int modes;
43
44 bool operator()(int prop) const { return (prop & modes); }
45};
46
48
49namespace System {
50class System;
51}
52
53/** Special propagator for NpT isotropic for Andersen method.
54 * Propagate the velocities and positions. Integration steps before force
55 * calculation of the Velocity Verlet integrator:
56 * \f[ v(t+0.5 \Delta t) = v(t) + 0.5 \Delta t \cdot F(t)/m \f]
57 * \f[ x(t+\Delta t) = x(t) + \Delta t \cdot v(t+0.5 \Delta t) \f]
58 *
59 * Propagate pressure, box_length (2 times) and positions, rescale
60 * positions and velocities and check Verlet list criterion (only NpT).
61 */
63 IsotropicNptThermostat const &npt_iso,
64 double time_step,
66/** Special propagator for NpT isotropic for MTK approach. */
68 IsotropicNptThermostat const &npt_iso,
69 double time_step, System::System &system);
70
71/** Final integration step of the Velocity Verlet+NpT integrator for Andersen
72 * method. 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,
79/** Final integration step of the Velocity Verlet+NpT integrator for Andersen
80 * method. */
82 double time_step, System::System &system);
83
84/**
85 * @brief Propagate the particle's velocity.
86 * @f$ v(t+dt) = v(t+0.5*dt) + 0.5*dt * a(t+dt) @f$
87 */
89 NptIsoParameters const &nptiso, InstantaneousPressure &npt_inst_pressure,
90 ParticleRangeNPT const &particles, double time_step) {
91
92 npt_inst_pressure.p_vel = {};
93 for (auto &p : particles) {
94 for (auto j = 0u; j < 3u; ++j) {
95 if (!p.is_fixed_along(j)) {
97 npt_inst_pressure.p_vel[j] += Utils::sqr(p.v()[j]) * p.mass();
98 }
99 p.v()[j] += p.force()[j] * time_step / (2. * p.mass());
100 }
101 }
102 }
103}
104
105/**
106 * @brief Propagate the particle's velocity.
107 * @f$ v(t+0.5*dt) = v(t) + 0.5*dt * a(t) @f$
108 */
110 NptIsoParameters const &nptiso, InstantaneousPressure &npt_inst_pressure,
111 ParticleRangeNPT const &particles, double time_step) {
112 npt_inst_pressure.p_vel = {};
113
114 for (auto &p : particles) {
115 for (auto j = 0u; j < 3u; ++j) {
116 if (!p.is_fixed_along(j)) {
117 p.v()[j] += p.force()[j] * time_step / (2. * p.mass());
119 npt_inst_pressure.p_vel[j] += Utils::sqr(p.v()[j]) * p.mass();
120 }
121 }
122 }
123 }
124}
125
126#endif // ESPRESSO_NPT
Main system class.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
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 NpT isotropic for MTK approach.
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 for Andersen method.
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.