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-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#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())
61}
62
63inline void velocity_verlet_rotator_2(Particle &p, double time_step) {
64 if (p.can_rotate())
66}
67#endif // ESPRESSO_ROTATION
void propagate_omega_quat_particle(Particle &p, double time_step)
See .
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.
Struct holding all information for one particle.
Definition Particle.hpp:450
bool can_rotate() const
Definition Particle.hpp:515
auto const & mass() const
Definition Particle.hpp:507
auto const & v() const
Definition Particle.hpp:488
auto const & pos() const
Definition Particle.hpp:486
bool is_fixed_along(unsigned int const axis) const
Definition Particle.hpp:633
auto const & force() const
Definition Particle.hpp:490
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)