ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
velocity_verlet_inline.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2026 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#include "Particle.hpp"
25#include "rotation.hpp"
26
27/** Propagate the velocities and positions. Integration steps before force
28 * calculation of the Velocity Verlet integrator: <br> \f[ v(t+0.5 \Delta t) =
29 * v(t) + 0.5 \Delta t f(t)/m \f] <br> \f[ p(t+\Delta t) = p(t) + \Delta t
30 * v(t+0.5 \Delta t) \f]
31 */
32inline void velocity_verlet_propagator_1(Particle &p, double time_step) {
33 for (unsigned int j = 0; j < 3; j++) {
34 if (!p.is_fixed_along(j)) {
35 /* Propagate velocities: v(t+0.5*dt) = v(t) + 0.5 * dt * a(t) */
36 p.v()[j] += 0.5 * time_step * p.force()[j] / p.mass();
37
38 /* Propagate positions (only NVT): p(t + dt) = p(t) + dt *
39 * v(t+0.5*dt) */
40 p.pos()[j] += time_step * p.v()[j];
41 }
42 }
43}
44
45/** Final integration step of the Velocity Verlet integrator
46 * \f[ v(t+\Delta t) = v(t+0.5 \Delta t) + 0.5 \Delta t f(t+\Delta t)/m \f]
47 */
48inline void velocity_verlet_propagator_2(Particle &p, double time_step) {
49 for (unsigned int j = 0; j < 3; j++) {
50 if (!p.is_fixed_along(j)) {
51 /* Propagate velocity: v(t+dt) = v(t+0.5*dt) + 0.5*dt * a(t+dt) */
52 p.v()[j] += 0.5 * time_step * p.force()[j] / p.mass();
53 }
54 }
55}
56
57#ifdef ESPRESSO_ROTATION
58inline void velocity_verlet_rotator_1(Particle &p, double time_step) {
59 if (p.can_rotate()) {
60 // p.torque() holds the lab-frame torque at time t: express it in the
61 // body frame of q(t) for the half kick and the quaternion update
62 auto const torque_lab = p.torque();
65 p.torque() = torque_lab;
66 }
67}
68
69inline void velocity_verlet_rotator_2(Particle &p, double time_step) {
70 if (p.can_rotate()) {
71 // half kick with the torque at t+dt in the body frame of q(t+dt);
72 // keep the lab-frame torque for the next call to rotator_1
73 auto const torque_lab = p.torque();
75 p.torque() = torque_lab;
76 }
77}
78#endif // ESPRESSO_ROTATION
void propagate_omega_quat_particle(Particle &p, double time_step)
See omelyan98a.
Definition rotation.cpp:129
void convert_torque_propagate_omega(Particle &p, double time_step)
Definition rotation.cpp:163
This file contains all subroutines required to process rotational motion.
void convert_torque_to_body_frame_apply_fix(Particle &p)
Definition rotation.hpp:65
Struct holding all information for one particle.
Definition Particle.hpp:436
constexpr bool can_rotate() const
Definition Particle.hpp:507
constexpr auto const & pos() const
Definition Particle.hpp:476
constexpr auto const & mass() const
Definition Particle.hpp:500
constexpr auto const & force() const
Definition Particle.hpp:480
constexpr bool is_fixed_along(unsigned int const axis) const
Definition Particle.hpp:634
constexpr auto const & v() const
Definition Particle.hpp:478
constexpr auto const & torque() const
Definition Particle.hpp:529
void velocity_verlet_rotator_1(Particle &p, double time_step)
void velocity_verlet_propagator_2(Particle &p, double time_step)
Final integration step of the Velocity Verlet integrator.
void velocity_verlet_propagator_1(Particle &p, double time_step)
Propagate the velocities and positions.
void velocity_verlet_rotator_2(Particle &p, double time_step)