Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ performance-*,
-performance-enum-size,

portability-*,
-portability-avoid-pragma-once,

readability-*,
-readability-avoid-const-params-in-decls,
Expand All @@ -35,6 +36,8 @@ readability-*,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-magic-numbers,
-readability-make-member-function-const,
-readability-math-missing-parentheses,
-readability-named-parameter,
-readability-redundant-inline-specifier,
-readability-redundant-string-init,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ jobs:

clang-tidy:
runs-on: ubuntu-latest
container: xzzx/devel:clang-18
container: xzzx/devel:clang-21
steps:
- name: versions
run: |
Expand Down Expand Up @@ -225,7 +225,7 @@ jobs:

- name: run clang-tidy
working-directory: ./source
run: run-clang-tidy-18 -p ../build -header-filter 'source' -j 2 '^(?!.*_deps).*$'
run: run-clang-tidy-21 -p ../build -header-filter 'source' -j 2 '^(?!.*_deps).*$'

clang-format:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion examples/Argon/Argon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <CLI/Config.hpp>
#include <CLI/Formatter.hpp>
#include <Kokkos_Core.hpp>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
Expand Down Expand Up @@ -227,7 +228,7 @@ void LJ(Config& config)
if ((config.temperature > 0_r) && (step > 5000))
{
config.temperature -= 7.8e-3_r;
if (config.temperature < 0_r) config.temperature = 0_r;
config.temperature = std::max(config.temperature, 0_r);
}

langevinThermostat.set(config.gamma, config.temperature * 0.5_r, config.dt);
Expand Down
3 changes: 2 additions & 1 deletion examples/Argon/MultiResArgon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <CLI/Config.hpp>
#include <CLI/Formatter.hpp>
#include <Kokkos_Core.hpp>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
Expand Down Expand Up @@ -243,7 +244,7 @@ void LJ(Config& config)
if ((config.temperature > 0_r) && (step > 5000))
{
config.temperature -= 7.8e-3_r;
if (config.temperature < 0_r) config.temperature = 0_r;
config.temperature = std::max(config.temperature, 0_r);
}

langevinThermostat.set(config.gamma, config.temperature * 0.5_r, config.dt);
Expand Down
4 changes: 3 additions & 1 deletion examples/BinaryLennardJones/NPT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <fmt/format.h>

#include <algorithm>

#include "action/BerendsenBarostat.hpp"
#include "action/BerendsenThermostat.hpp"
#include "action/LennardJones.hpp"
Expand All @@ -34,7 +36,7 @@ void npt(YAML::Node& config, data::Atoms& atoms, data::Subdomain& subdomain)
constexpr real_t cellRatio = 0.5_r;
const real_t skin = config["LJ"]["skin"].as<real_t>();
auto rcVec = config["LJ"]["cutoff"].as<std::vector<real_t>>();
const real_t rc = *std::max_element(rcVec.begin(), rcVec.end());
const real_t rc = std::ranges::max(rcVec);
const real_t neighborCutoff = rc + skin;
auto volume = subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2];

Expand Down
4 changes: 3 additions & 1 deletion examples/BinaryLennardJones/NVT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <fmt/format.h>

#include <algorithm>

#include "action/BerendsenThermostat.hpp"
#include "action/LennardJones.hpp"
#include "action/VelocityVerlet.hpp"
Expand All @@ -33,7 +35,7 @@ void nvt(YAML::Node& config, data::Atoms& atoms, const data::Subdomain& subdomai
constexpr real_t cellRatio = 0.5_r;
const real_t skin = config["LJ"]["skin"].as<real_t>();
auto rcVec = config["LJ"]["cutoff"].as<std::vector<real_t>>();
const real_t rc = *std::max_element(rcVec.begin(), rcVec.end());
const real_t rc = std::ranges::max(rcVec);
const real_t neighborCutoff = rc + skin;
auto volume = subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2];

Expand Down
3 changes: 2 additions & 1 deletion examples/BinaryLennardJones/SPARTIAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <fmt/format.h>

#include <algorithm>
#include <fstream>

#include "action/ContributeMoleculeForceToAtoms.hpp"
Expand Down Expand Up @@ -44,7 +45,7 @@ void spartian(YAML::Node& config,
constexpr real_t cellRatio = 0.5_r;
const real_t skin = config["LJ"]["skin"].as<real_t>();
auto rcVec = config["LJ"]["cutoff"].as<std::vector<real_t>>();
const real_t rc = *std::max_element(rcVec.begin(), rcVec.end());
const real_t rc = std::ranges::max(rcVec);
const real_t neighborCutoff = rc + skin;
auto volume = subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2];

Expand Down
4 changes: 3 additions & 1 deletion mrmd/action/LennardJones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "LennardJones.hpp"

#include <algorithm>

namespace mrmd::action
{
void LennardJones::apply(data::Atoms& atoms, HalfVerletList& verletList)
Expand Down Expand Up @@ -46,7 +48,7 @@ LennardJones::LennardJones(const std::vector<real_t>& cappingDistance,
const bool isShifted)
: LJ_(cappingDistance, rc, sigma, epsilon, numTypes, isShifted), numTypes_(1)
{
auto rcMax = *std::max_element(rc.begin(), rc.end());
auto rcMax = std::ranges::max(rc);
rcSqr_ = rcMax * rcMax;
}
} // namespace mrmd::action
4 changes: 3 additions & 1 deletion mrmd/action/VelocityVerlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "VelocityVerlet.hpp"

#include <algorithm>

namespace mrmd
{
namespace action
Expand Down Expand Up @@ -42,7 +44,7 @@ real_t VelocityVerlet::preForceIntegrate(data::Atoms& atoms, const real_t dt)
pos(idx, 2) += dz;

auto distSqr = dx * dx + dy * dy + dz * dz;
if (distSqr > maxDistSqr) maxDistSqr = distSqr;
maxDistSqr = std::max(distSqr, maxDistSqr);
};
real_t maxDistSqr = 0_r;
Kokkos::parallel_reduce(
Expand Down
4 changes: 3 additions & 1 deletion mrmd/action/VelocityVerletLangevinThermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "VelocityVerletLangevinThermostat.hpp"

#include <algorithm>

#include "util/math.hpp"

namespace mrmd
Expand Down Expand Up @@ -72,7 +74,7 @@ real_t VelocityVerletLangevinThermostat::preForceIntegrate(data::Atoms& atoms, c
dx[2] -= pos(idx, 2);

auto distSqr = util::dot3(dx, dx);
if (distSqr > maxDistSqr) maxDistSqr = distSqr;
maxDistSqr = std::max(distSqr, maxDistSqr);
};
real_t maxDistSqr = 0_r;
Kokkos::parallel_reduce("VelocityVerletLangevinThermostat::preForceIntegrate",
Expand Down
7 changes: 3 additions & 4 deletions mrmd/communication/PeriodicMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "PeriodicMapping.hpp"

#include <algorithm>

#include "data/Atoms.hpp"
#include "data/Subdomain.hpp"

Expand All @@ -37,10 +39,7 @@ void mapIntoDomain(data::Atoms& atoms, const data::Subdomain& subdomain)
if (subdomain.maxCorner[dim] <= x)
{
x -= subdomain.diameter[dim];
if (x < subdomain.minCorner[dim])
{
x = subdomain.minCorner[dim];
}
x = std::max(x, subdomain.minCorner[dim]);
}
if (x < subdomain.minCorner[dim])
{
Expand Down
4 changes: 2 additions & 2 deletions mrmd/datatypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ using real_t = double;
using Point3D = Kokkos::Array<real_t, 3>;
using Vector3D = Kokkos::Array<real_t, 3>;

KOKKOS_INLINE_FUNCTION constexpr real_t operator"" _r(const long double val)
KOKKOS_INLINE_FUNCTION constexpr real_t operator""_r(const long double val)
{
return static_cast<real_t>(val);
}

KOKKOS_INLINE_FUNCTION constexpr real_t operator"" _r(const unsigned long long val)
KOKKOS_INLINE_FUNCTION constexpr real_t operator""_r(const unsigned long long val)
{
return static_cast<real_t>(val);
}
Expand Down
2 changes: 1 addition & 1 deletion pyMRMD/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
namespace py = pybind11;

template <class SLICE_T>
py::array_t<typename SLICE_T::value_type> getNPArray(const SLICE_T slice)
py::array_t<typename SLICE_T::value_type> getNPArray(const SLICE_T& slice)
{
static_assert(slice.viewRank() == 2 || slice.viewRank() == 3, "Invalid view rank dimension");

Expand Down
19 changes: 6 additions & 13 deletions tests/NPT/NPT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,17 @@ class NPT : public ::testing::TestWithParam<Input>
// void SetUp() override {}
// void TearDown() override {}

data::Subdomain subdomain;
real_t volume;
data::Atoms atoms = data::Atoms(0);
real_t rho;
data::Subdomain subdomain = {{0_r, 0_r, 0_r}, {Config::Lx, Config::Lx, Config::Lx}, Config::neighborCutoff};
real_t volume = {subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2]};
data::Atoms atoms = {fillDomainWithAtomsSC(subdomain, idx_c(Config::rho * volume), 1_r)};
real_t rho = {real_c(atoms.numLocalAtoms) / volume};
communication::GhostLayer ghostLayer;
action::LennardJones LJ = action::LennardJones(0_r, 0_r, 0_r, 0_r);
action::LennardJones LJ = {Config::rc, Config::sigma, Config::epsilon, 0.7_r * Config::sigma};

HalfVerletList verletList;

public:
NPT()
: subdomain({0_r, 0_r, 0_r}, {Config::Lx, Config::Lx, Config::Lx}, Config::neighborCutoff),
volume(subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2]),
atoms(fillDomainWithAtomsSC(subdomain, idx_c(Config::rho * volume), 1_r)),
rho(real_c(atoms.numLocalAtoms) / volume),
LJ(Config::rc, Config::sigma, Config::epsilon, 0.7_r * Config::sigma)
{
}
NPT() = default;
};

TEST_P(NPT, pressure)
Expand Down
19 changes: 6 additions & 13 deletions tests/NVT/NVT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,17 @@ class NVT : public ::testing::TestWithParam<real_t>
// void SetUp() override {}
// void TearDown() override {}

data::Subdomain subdomain;
real_t volume;
data::Atoms atoms;
real_t rho;
data::Subdomain subdomain = { {0_r, 0_r, 0_r}, {Config::Lx, Config::Lx, Config::Lx}, Config::neighborCutoff };
real_t volume = { subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2] };
data::Atoms atoms = { fillDomainWithAtomsSC(subdomain, idx_c(Config::rho * volume), 1_r) };
real_t rho = { real_c(atoms.numLocalAtoms) / volume };
communication::GhostLayer ghostLayer;
action::LennardJones LJ;
action::LennardJones LJ = { Config::rc, Config::sigma, Config::epsilon, 0.7_r * Config::sigma };

HalfVerletList verletList;

public:
NVT()
: subdomain({0_r, 0_r, 0_r}, {Config::Lx, Config::Lx, Config::Lx}, Config::neighborCutoff),
volume(subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2]),
atoms(fillDomainWithAtomsSC(subdomain, idx_c(Config::rho * volume), 1_r)),
rho(real_c(atoms.numLocalAtoms) / volume),
LJ(Config::rc, Config::sigma, Config::epsilon, 0.7_r * Config::sigma)
{
}
NVT() = default;
};

TEST_P(NVT, pressure)
Expand Down
Loading