MRMD 0.4.0
Multi Resolution Molecular Dynamics
Loading...
Searching...
No Matches
KineticEnergy.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 "data/Atoms.hpp"
18
19namespace mrmd
20{
21namespace analysis
22{
27{
28 auto vel = atoms.getVel();
29 auto mass = atoms.getMass();
30 real_t velSqr = 0_r;
31 auto policy = Kokkos::RangePolicy<>(0, atoms.numLocalAtoms);
32 auto kernel = KOKKOS_LAMBDA(const idx_t idx, real_t& sum)
33 {
34 sum += mass(idx) *
35 (vel(idx, 0) * vel(idx, 0) + vel(idx, 1) * vel(idx, 1) + vel(idx, 2) * vel(idx, 2));
36 };
37 Kokkos::parallel_reduce("getKineticEnergy", policy, kernel, velSqr);
38 return 0.5_r * velSqr;
39}
40
48} // namespace analysis
49} // namespace mrmd
Data structure for storing information about atoms on the host and the device.
Definition Atoms.hpp:35
KOKKOS_FORCEINLINE_FUNCTION vel_t getVel() const
Definition Atoms.hpp:65
idx_t numLocalAtoms
Definition Atoms.hpp:120
KOKKOS_FORCEINLINE_FUNCTION charge_t getMass() const
Definition Atoms.hpp:68
real_t getKineticEnergy(data::Atoms &atoms)
Definition KineticEnergy.hpp:26
real_t getMeanKineticEnergy(data::Atoms &atoms)
Definition KineticEnergy.hpp:44
Definition BerendsenBarostat.cpp:18
int64_t idx_t
Definition datatypes.hpp:91
double real_t
Definition datatypes.hpp:99
KOKKOS_INLINE_FUNCTION constexpr real_t real_c(T t)
Definition datatypes.hpp:114