Multi Resolution Molecular Dynamics 0.4.0
Multi Resolution Molecular Dynamics
Loading...
Searching...
No Matches
NoForce.hpp
Go to the documentation of this file.
1// Copyright 2024 Sebastian Eibl
2// Copyright 2026 Julian Friedrich Hille
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// https://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#pragma once
17
18#include "data/Atoms.hpp"
19#include "datatypes.hpp"
20
21namespace mrmd::action
22{
28{
29private:
31 data::Atoms::force_t::atomic_access_slice force_;
33
34 HalfVerletList verletList_;
35
36public:
37 KOKKOS_INLINE_FUNCTION
38 real_t computeForce(const real_t& /*distSqr*/) const { /* TO BE IMPLEMENTED */ return 0_r; }
39
40 KOKKOS_INLINE_FUNCTION
41 void operator()(const idx_t& idx) const
42 {
43 real_t posTmp[3];
44 posTmp[0] = pos_(idx, 0);
45 posTmp[1] = pos_(idx, 1);
46 posTmp[2] = pos_(idx, 2);
47
48 real_t forceTmp[3] = {0_r, 0_r, 0_r};
49
50 const auto numNeighbors = idx_c(HalfNeighborList::numNeighbor(verletList_, idx));
51 for (idx_t n = 0; n < numNeighbors; ++n)
52 {
53 idx_t jdx = idx_c(HalfNeighborList::getNeighbor(verletList_, idx, n));
54 assert(0 <= jdx);
55
56 auto dx = posTmp[0] - pos_(jdx, 0);
57 auto dy = posTmp[1] - pos_(jdx, 1);
58 auto dz = posTmp[2] - pos_(jdx, 2);
59
60 auto distSqr = dx * dx + dy * dy + dz * dz;
61
62 auto force = computeForce(distSqr);
63
64 forceTmp[0] += dx * force;
65 forceTmp[1] += dy * force;
66 forceTmp[2] += dz * force;
67
68 force_(jdx, 0) -= dx * force;
69 force_(jdx, 1) -= dy * force;
70 force_(jdx, 2) -= dz * force;
71 }
72
73 force_(idx, 0) += forceTmp[0];
74 force_(idx, 1) += forceTmp[1];
75 force_(idx, 2) += forceTmp[2];
76 }
77
78 void apply(data::Atoms& atoms, HalfVerletList& verletList);
79
80 NoForce() = default;
81};
82} // namespace mrmd::action
KOKKOS_INLINE_FUNCTION real_t computeForce(const real_t &) const
Definition NoForce.hpp:38
KOKKOS_INLINE_FUNCTION void operator()(const idx_t &idx) const
Definition NoForce.hpp:41
void apply(data::Atoms &atoms, HalfVerletList &verletList)
Definition NoForce.cpp:19
typename AtomsT::template member_slice_type< TYPE > type_t
Definition Atoms.hpp:59
typename AtomsT::template member_slice_type< POS > pos_t
Definition Atoms.hpp:56
Everything to evolve the simulation physically.
DeviceAtoms Atoms
Definition Atoms.hpp:177
Cabana::VerletList< Kokkos::DefaultExecutionSpace::memory_space, Cabana::HalfNeighborTag, Cabana::VerletLayout2D, Cabana::TeamOpTag > HalfVerletList
Definition datatypes.hpp:184
KOKKOS_INLINE_FUNCTION constexpr idx_t idx_c(const T &val)
Definition datatypes.hpp:93
int64_t idx_t
Definition datatypes.hpp:91
double real_t
Definition datatypes.hpp:99