MRMD 0.4.0
Multi Resolution Molecular Dynamics
Loading...
Searching...
No Matches
UpdateSteps.hpp
Go to the documentation of this file.
1// Copyright 2024 Sebastian Eibl
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <Kokkos_Core.hpp>
18
19#include "datatypes.hpp"
20
21namespace mrmd
22{
23namespace action
24{
25KOKKOS_INLINE_FUNCTION
26void updateKick(real_t& vel_x,
27 real_t& vel_y,
28 real_t& vel_z,
29 const real_t& force_x,
30 const real_t& force_y,
31 const real_t& force_z,
32 const real_t& dt,
33 const real_t& mass)
34
35{
36 auto dtfm = dt / mass;
37 vel_x += dtfm * force_x;
38 vel_y += dtfm * force_y;
39 vel_z += dtfm * force_z;
40}
41
42KOKKOS_INLINE_FUNCTION
43void updateDrift(real_t& pos_x,
44 real_t& pos_y,
45 real_t& pos_z,
46 const real_t& vel_x,
47 const real_t& vel_y,
48 const real_t& vel_z,
49 const real_t& dt)
50{
51 pos_x += dt * vel_x;
52 pos_y += dt * vel_y;
53 pos_z += dt * vel_z;
54}
55
56KOKKOS_INLINE_FUNCTION
58 real_t& vel_y,
59 real_t& vel_z,
60 const real_t& dt,
61 const real_t& mass,
62 const real_t& zeta,
63 const real_t& temperature,
64 const real_t& rand_x,
65 const real_t& rand_y,
66 const real_t& rand_z)
67{
68 auto dtm = dt / mass;
69 auto damping = std::exp(-zeta * dtm);
70 auto sigma = std::sqrt(temperature / mass * (1_r - std::exp(-2_r * zeta * dtm)));
71
72 vel_x *= damping;
73 vel_y *= damping;
74 vel_z *= damping;
75
76 vel_x += sigma * rand_x;
77 vel_y += sigma * rand_y;
78 vel_z += sigma * rand_z;
79}
80
81} // namespace action
82} // namespace mrmd
KOKKOS_INLINE_FUNCTION void updateDrift(real_t &pos_x, real_t &pos_y, real_t &pos_z, const real_t &vel_x, const real_t &vel_y, const real_t &vel_z, const real_t &dt)
Definition UpdateSteps.hpp:43
KOKKOS_INLINE_FUNCTION void updateKick(real_t &vel_x, real_t &vel_y, real_t &vel_z, const real_t &force_x, const real_t &force_y, const real_t &force_z, const real_t &dt, const real_t &mass)
Definition UpdateSteps.hpp:26
KOKKOS_INLINE_FUNCTION void updateOrnsteinUhlenbeck(real_t &vel_x, real_t &vel_y, real_t &vel_z, const real_t &dt, const real_t &mass, const real_t &zeta, const real_t &temperature, const real_t &rand_x, const real_t &rand_y, const real_t &rand_z)
Definition UpdateSteps.hpp:57
Definition BerendsenBarostat.cpp:18
double real_t
Definition datatypes.hpp:99