Multi Resolution Molecular Dynamics 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::action::impl
22{
23KOKKOS_INLINE_FUNCTION
24void updateKick(real_t& vel_x,
25 real_t& vel_y,
26 real_t& vel_z,
27 const real_t& force_x,
28 const real_t& force_y,
29 const real_t& force_z,
30 const real_t& dt,
31 const real_t& mass)
32
33{
34 auto dtfm = dt / mass;
35 vel_x += dtfm * force_x;
36 vel_y += dtfm * force_y;
37 vel_z += dtfm * force_z;
38}
39
40KOKKOS_INLINE_FUNCTION
41void updateDrift(real_t& pos_x,
42 real_t& pos_y,
43 real_t& pos_z,
44 const real_t& vel_x,
45 const real_t& vel_y,
46 const real_t& vel_z,
47 const real_t& dt)
48{
49 pos_x += dt * vel_x;
50 pos_y += dt * vel_y;
51 pos_z += dt * vel_z;
52}
53
54KOKKOS_INLINE_FUNCTION
55void updateOrnsteinUhlenbeck(real_t& vel_x,
56 real_t& vel_y,
57 real_t& vel_z,
58 const real_t& dt,
59 const real_t& mass,
60 const real_t& zeta,
61 const real_t& temperature,
62 const real_t& rand_x,
63 const real_t& rand_y,
64 const real_t& rand_z)
65{
66 auto dtm = dt / mass;
67 auto damping = std::exp(-zeta * dtm);
68 auto sigma = std::sqrt(temperature / mass * (1_r - std::exp(-2_r * zeta * dtm)));
69
70 vel_x *= damping;
71 vel_y *= damping;
72 vel_z *= damping;
73
74 vel_x += sigma * rand_x;
75 vel_y += sigma * rand_y;
76 vel_z += sigma * rand_z;
77}
78} // namespace mrmd::action::impl
double real_t
Definition datatypes.hpp:99