Multi Resolution Molecular Dynamics 0.4.0
Multi Resolution Molecular Dynamics
Loading...
Searching...
No Matches
LJ_IdealGas.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 <algorithm>
19
20#include "LennardJones.hpp"
21#include "assert/assert.hpp"
22#include "data/Atoms.hpp"
23#include "data/Molecules.hpp"
25#include "datatypes.hpp"
27
28namespace mrmd::action
29{
30void updateMeanCompensationEnergy(data::MultiHistogram& compensationEnergy,
31 data::MultiHistogram& compensationEnergyCounter,
32 data::MultiHistogram& meanCompensationEnergy,
33 const real_t runningAverageFactor = 10_r);
34
42{
43private:
44 idx_t numTypes_;
45
46 impl::CappedLennardJonesPotential LJ_;
47 real_t rcSqr_ = 0_r;
48
49 data::Molecules::pos_t moleculesPos_;
50 data::Molecules::force_t::atomic_access_slice moleculesForce_;
51 data::Molecules::lambda_t moleculesLambda_;
52 data::Molecules::modulated_lambda_t moleculesModulatedLambda_;
53 data::Molecules::grad_lambda_t moleculesGradLambda_;
54 data::Molecules::atoms_offset_t moleculesAtomsOffset_;
55 data::Molecules::num_atoms_t moleculesNumAtoms_;
56
57 data::Atoms::pos_t atomsPos_;
58 data::Atoms::force_t::atomic_access_slice atomsForce_;
59 data::Atoms::type_t atomsType_;
60
61 static constexpr idx_t COMPENSATION_ENERGY_BINS = 200;
62
63 data::MultiHistogram compensationEnergy_;
64 MultiScatterView compensationEnergyScatter_;
65
66 data::MultiHistogram compensationEnergyCounter_;
67
68 data::MultiHistogram meanCompensationEnergy_;
69
70 bool isDriftCompensationSamplingRun_ = false;
71
72 HalfVerletList verletList_;
73
74 idx_t runCounter_ = 0;
75
76 idx_t compensationEnergySamplingInterval = 200;
77 idx_t compensationEnergyUpdateInveral = 20000;
78
79public:
81 {
82 compensationEnergySamplingInterval = interval;
83 }
85 {
86 compensationEnergyUpdateInveral = interval;
87 }
88 const auto& getMeanCompensationEnergy() const { return meanCompensationEnergy_; }
89
96 KOKKOS_FUNCTION void operator()(const idx_t& alpha, real_t& sumEnergy) const;
97
98 real_t run(data::Molecules& molecules, HalfVerletList& verletList, data::Atoms& atoms);
99
100 LJ_IdealGas(const real_t& cappingDistance,
101 const real_t& rc,
102 const real_t& sigma,
103 const real_t& epsilon,
104 const bool doShift);
105
106 LJ_IdealGas(const std::vector<real_t>& cappingDistance,
107 const std::vector<real_t>& rc,
108 const std::vector<real_t>& sigma,
109 const std::vector<real_t>& epsilon,
110 const idx_t numTypes,
111 const bool doShift);
112};
113
114} // namespace mrmd::action
KOKKOS_FUNCTION void operator()(const idx_t &alpha, real_t &sumEnergy) const
Loop over molecules.
Definition LJ_IdealGas.cpp:52
void setCompensationEnergySamplingInterval(const idx_t &interval)
Definition LJ_IdealGas.hpp:80
real_t run(data::Molecules &molecules, HalfVerletList &verletList, data::Atoms &atoms)
Definition LJ_IdealGas.cpp:227
void setCompensationEnergyUpdateInterval(const idx_t &interval)
Definition LJ_IdealGas.hpp:84
const auto & getMeanCompensationEnergy() const
Definition LJ_IdealGas.hpp:88
LJ_IdealGas(const real_t &cappingDistance, const real_t &rc, const real_t &sigma, const real_t &epsilon, const bool doShift)
Definition LJ_IdealGas.cpp:262
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
typename MoleculesT::template member_slice_type< GRAD_LAMBDA > grad_lambda_t
Definition Molecules.hpp:54
typename MoleculesT::template member_slice_type< MODULATED_LAMBDA > modulated_lambda_t
Definition Molecules.hpp:53
typename MoleculesT::template member_slice_type< LAMBDA > lambda_t
Definition Molecules.hpp:52
typename MoleculesT::template member_slice_type< NUM_ATOMS > num_atoms_t
Definition Molecules.hpp:56
typename MoleculesT::template member_slice_type< ATOMS_OFFSET > atoms_offset_t
Definition Molecules.hpp:55
typename MoleculesT::template member_slice_type< POS > pos_t
Definition Molecules.hpp:50
Everything to evolve the simulation physically.
void updateMeanCompensationEnergy(data::MultiHistogram &compensationEnergy, data::MultiHistogram &compensationEnergyCounter, data::MultiHistogram &meanCompensationEnergy, const real_t runningAverageFactor)
Definition LJ_IdealGas.cpp:21
DeviceMolecules Molecules
Definition Molecules.hpp:176
DeviceAtoms Atoms
Definition Atoms.hpp:177
Kokkos::Experimental::ScatterView< real_t ** > MultiScatterView
Definition datatypes.hpp:162
Cabana::VerletList< Kokkos::DefaultExecutionSpace::memory_space, Cabana::HalfNeighborTag, Cabana::VerletLayout2D, Cabana::TeamOpTag > HalfVerletList
Definition datatypes.hpp:184
int64_t idx_t
Definition datatypes.hpp:91
double real_t
Definition datatypes.hpp:99
Definition MultiHistogram.hpp:30