Skip to content
Merged
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ if(Git_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)

if(GIT_SUBMODULE)
if(GIT_SUBMODULE AND NOT EXISTS "${PROJECT_SOURCE_DIR}/external/mstd/include/")
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
Expand Down
10 changes: 8 additions & 2 deletions benchmarks/perf/perfBenchSetup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "matrix.hpp"
#include "molecule.hpp"
#include "simulationBox.hpp"
#include "strongTypes.hpp"

namespace potential
{
Expand Down Expand Up @@ -109,7 +110,7 @@ namespace benchSetup
atom->setShiftForce({0.0, 0.0, 0.0});
atom->setMass(12.0);
atom->setAtomType(i % 2);
atom->setInternalGlobalVDWType(i % 2);
atom->setInternalGlobalVDWType(VdwType{i % 2});
atom->setPartialCharge((i % 2 == 0) ? 0.4 : -0.4);

molecule.addAtom(atom);
Expand All @@ -131,7 +132,12 @@ namespace benchSetup
)
);

auto pair = potential::LennardJonesPair(0UL, 1UL, 12.0, 2.0, 3.0);
auto pair = potential::LennardJonesPair(
ExtVdwType(0),
ExtVdwType(1),
12.0,
LJParams{.c6 = 2.0, .c12 = 3.0}
);
potential.setNonCoulombPairsMatrix(0, 1, pair);
potential.setNonCoulombPairsMatrix(1, 0, pair);

Expand Down
26 changes: 17 additions & 9 deletions benchmarks/perf/perfInterWater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <iostream>
#include <memory>

#include "strongTypes.hpp"

#ifdef PQ_WITH_CALLGRIND
#include <valgrind/callgrind.h>
#else
Expand Down Expand Up @@ -90,7 +92,7 @@ int main()
atom->setAtomicNumber(atomicNumber);
atom->setPosition(pos);
atom->setAtomType(0);
atom->setInternalGlobalVDWType(0);
atom->setInternalGlobalVDWType(VdwType{0});
atom->setPartialCharge(charge);
atom->setForceToZero();
return atom;
Expand Down Expand Up @@ -130,14 +132,20 @@ int main()
}

InterWaterState state;
state._oxygenCharge = -0.82;
state._hydrogenCharge = 0.41;
state._nonCoulombPairOO =
std::make_unique<LennardJonesPair>(CUTOFF, -2.0, 4.0);
state._nonCoulombPairOH =
std::make_unique<LennardJonesPair>(CUTOFF, -0.5, 1.5);
state._nonCoulombPairHH =
std::make_unique<LennardJonesPair>(CUTOFF, -0.2, 0.8);
state._oxygenCharge = -0.82;
state._hydrogenCharge = 0.41;
state._nonCoulombPairOO = std::make_unique<LennardJonesPair>(
CUTOFF,
LJParams{.c6 = 2.0, .c12 = 4.0}
);
state._nonCoulombPairOH = std::make_unique<LennardJonesPair>(
CUTOFF,
LJParams{.c6 = 0.5, .c12 = 1.5}
);
state._nonCoulombPairHH = std::make_unique<LennardJonesPair>(
CUTOFF,
LJParams{.c6 = 0.2, .c12 = 0.8}
);

InterWater interWater(
std::move(state),
Expand Down
16 changes: 13 additions & 3 deletions benchmarks/perf/perfNonCoulombPairs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,19 @@ static constexpr std::uint64_t ITERATIONS = 20000;

int main()
{
auto lj = potential::LennardJonesPair(9.0, 2.0, 3.0);
auto buck = potential::BuckinghamPair(9.0, 1.0, 0.3, 2.0);
auto morse = potential::MorsePair(9.0, 1.0, 2.0, 1.5);
auto lj = potential::LennardJonesPair(9.0, LJParams{.c6 = 2.0, .c12 = 3.0});
auto buck = potential::BuckinghamPair(
9.0,
BuckinghamParams{.scaling = 1.0, .dRho = 0.3, .c6 = 2.0}
);
auto morse = potential::MorsePair(
9.0,
MorseParams{
.dissociationEnergy = 1.0,
.wellWidth = 2.0,
.equilibriumDistance = 1.5
}
);

CALLGRIND_ZERO_STATS;

Expand Down
3 changes: 2 additions & 1 deletion benchmarks/src/benchmarkSetup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "atom.hpp"
#include "molecule.hpp"
#include "simulationBox.hpp"
#include "strongTypes.hpp"
#include "vector3d.hpp"

namespace benchmarkSetup
Expand Down Expand Up @@ -68,7 +69,7 @@ namespace benchmarkSetup
atom->setForce({0.1, -0.2, 0.05});
atom->setMass(12.0);
atom->setAtomType(0);
atom->setInternalGlobalVDWType(0);
atom->setInternalGlobalVDWType(VdwType{0});
atom->setPartialCharge(atomIndex++ % 2 == 0 ? 0.4 : -0.4);
atom->setShiftForce({0.0, 0.0, 0.0});

Expand Down
3 changes: 1 addition & 2 deletions benchmarks/src/potential/benchmarkForceCalculation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ namespace

const auto pair = std::make_shared<potential::LennardJonesPair>(
benchmarkSetup::cutOff,
1.0,
1.0
LJParams{.c6 = 1.0, .c12 = 1.0}
);
nonCoulomb->setGuffNonCoulPair({1, 1, 0, 0}, pair);

Expand Down
19 changes: 16 additions & 3 deletions benchmarks/src/potential/benchmarkPairPotentials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,32 @@ namespace

void BM_LennardJones(benchmark::State& state)
{
potential::LennardJonesPair potential(9.0, 2.0, 3.0);
potential::LennardJonesPair potential(
9.0,
LJParams{.c6 = 2.0, .c12 = 3.0}
);
runNonCoulombBenchmark(state, potential);
}

void BM_Buckingham(benchmark::State& state)
{
potential::BuckinghamPair potential(9.0, 1.0, 0.3, 2.0);
potential::BuckinghamPair potential(
9.0,
BuckinghamParams{.scaling = 1.0, .dRho = 0.3, .c6 = 2.0}
);
runNonCoulombBenchmark(state, potential);
}

void BM_Morse(benchmark::State& state)
{
potential::MorsePair potential(9.0, 1.0, 2.0, 1.5);
potential::MorsePair potential(
9.0,
MorseParams{
.dissociationEnergy = 1.0,
.wellWidth = 2.0,
.equilibriumDistance = 1.5
}
);
runNonCoulombBenchmark(state, potential);
}

Expand Down
5 changes: 5 additions & 0 deletions changes/developer/enhancement.strong-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
- add strong type for `BondId`
- add strong type for `AngleId`
- add strong type for `DihedralId`
- add strong types for `ExtVdwType` and `VdwType`
- add strong type for morse params aka `MorseParams`
- add strong type for lennard jones params aka `LJParams`
- add strong type for bukcingham params aka `BuckinghamParams`
- make guff pari used `std::array` instead of `std::vector`
2 changes: 1 addition & 1 deletion external/mstd
2 changes: 2 additions & 0 deletions include/config/defaults.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ namespace defaults
static constexpr double ABS_ENERGY_CONV_DEFAULT = 1.0e-6;
static constexpr double MAX_FORCE_CONV_DEFAULT = 1.0e-6;
static constexpr double RMS_FORCE_CONV_DEFAULT = 1.0e-6;

static constexpr auto NUM_GUFF_COEFFICIENTS = 22;
// clang-format on

} // namespace defaults
Expand Down
12 changes: 12 additions & 0 deletions include/config/guffCoefficients.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,51 @@

#define _GUFF_COEFFICIENTS_HPP_

#include "strongTypes.hpp"

namespace constants
{
// clang-format off
// values calculated from the original SPC publication
static constexpr double SPC_LJ_C6_OO = -625.455653639347; // A^6 kcal mol^-1
static constexpr double SPC_LJ_C12_OO = 629358.472583307; // A^12 kcal mol^-1
static constexpr LJParams SPC_LJ_PARAMS_OO{.c6 = SPC_LJ_C6_OO, .c12 = SPC_LJ_C12_OO};

static constexpr double SPC_E_LJ_C6_OO = SPC_LJ_C6_OO; // A^6 kcal mol^-1
static constexpr double SPC_E_LJ_C12_OO = SPC_LJ_C12_OO; // A^12 kcal mol^-1
static constexpr LJParams SPC_E_LJ_PARAMS_OO{.c6 = SPC_E_LJ_C6_OO, .c12 = SPC_E_LJ_C12_OO};

static constexpr double SPC_FW_LJ_C6_OO = -625.5024676571352; // A^6 kcal mol^-1
static constexpr double SPC_FW_LJ_C12_OO = 629326.9774051674; // A^12 kcal mol^-1
static constexpr LJParams SPC_FW_LJ_PARAMS_OO{.c6 = SPC_FW_LJ_C6_OO, .c12 = SPC_FW_LJ_C12_OO};

static constexpr double QSPC_FW_LJ_C6_OO = -625.5020652114152; // A^6 kcal mol^-1
static constexpr double QSPC_FW_LJ_C12_OO = 629326.5724987736; // A^12 kcal mol^-1
static constexpr LJParams QSPC_FW_LJ_PARAMS_OO{.c6 = QSPC_FW_LJ_C6_OO, .c12 = QSPC_FW_LJ_C12_OO};

static constexpr double SPC_DC_LJ_C6_OO = -779.8414665600154; // A^6 kcal mol^-1
static constexpr double SPC_DC_LJ_C12_OO = 773048.5510230307; // A^12 kcal mol^-1
static constexpr LJParams SPC_DC_LJ_PARAMS_OO{.c6 = SPC_DC_LJ_C6_OO, .c12 = SPC_DC_LJ_C12_OO};

static constexpr double H2O_DC_LJ_C6_OO = -590.6923729027751; // A^6 kcal mol^-1
static constexpr double H2O_DC_LJ_C12_OO = 615459.8371975797; // A^12 kcal mol^-1
static constexpr LJParams H2O_DC_LJ_PARAMS_OO{.c6 = H2O_DC_LJ_C6_OO, .c12 = H2O_DC_LJ_C12_OO};

static constexpr double TIP3P_LJ_C6_OO = -595.067688427684; // A^6 kcal mol^-1
static constexpr double TIP3P_LJ_C12_OO = 582015.099443679; // A^12 kcal mol^-1
static constexpr LJParams TIP3P_LJ_PARAMS_OO{.c6 = TIP3P_LJ_C6_OO, .c12 = TIP3P_LJ_C12_OO};

static constexpr double OPC3_LJ_C6_OO = -668.637501352773; // A^6 kcal mol^-1
static constexpr double OPC3_LJ_C12_OO = 683996.561589584; // A^12 kcal mol^-1
static constexpr LJParams OPC3_LJ_PARAMS_OO{.c6 = OPC3_LJ_C6_OO, .c12 = OPC3_LJ_C12_OO};

static constexpr double SPC_MTR_LJ_C6_OO = -613.527724665392; // A^6 kcal mol^-1
static constexpr double SPC_MTR_LJ_C12_OO = 629302.103250478; // A^12 kcal mol^-1
static constexpr LJParams SPC_MTR_LJ_PARAMS_OO{.c6 = SPC_MTR_LJ_C6_OO, .c12 = SPC_MTR_LJ_C12_OO};

static constexpr double TIP3P_MTR_LJ_C6_OO = -454.1108986615679; // A^6 kcal mol^-1
static constexpr double TIP3P_MTR_LJ_C12_OO = 513862.3326959847; // A^12 kcal mol^-1
static constexpr LJParams TIP3P_MTR_LJ_PARAMS_OO{.c6 = TIP3P_MTR_LJ_C6_OO, .c12 = TIP3P_MTR_LJ_C12_OO};
// clang-format on

} // namespace constants
Expand Down
6 changes: 3 additions & 3 deletions include/forceField/forcefield.tpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ namespace forceField
const auto vdwType1 = molecule1->getInternalGlobalVDWType(atomIndex1);
const auto vdwType2 = molecule2->getInternalGlobalVDWType(atomIndex2);

const auto indices =
{molType1, molType2, atomType1, atomType2, vdwType1, vdwType2};
const auto indices = {molType1, molType2, atomType1, atomType2};

const auto nonCoulombPair = nonCoulPot.getNonCoulPair(indices);
const auto nonCoulombPair =
nonCoulPot.getNonCoulPair(indices, {vdwType1, vdwType2});

if (distance < nonCoulombPair->getRadialCutOff())
{
Expand Down
13 changes: 7 additions & 6 deletions include/input/guffDatReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ namespace input::guffdat
const double rncCutOff
);
void addGuffPair(
const size_t molType1,
const size_t molType2,
const size_t atomType1,
const size_t atomType2,
const std::vector<double> &coefficients,
const double rncCutOff
const size_t molType1,
const size_t molType2,
const size_t atomType1,
const size_t atomType2,
const std::array<double, defaults::NUM_GUFF_COEFFICIENTS>
&coefficients,
const double rncCutOff
);

/********************
Expand Down
12 changes: 6 additions & 6 deletions include/molsys/atom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ namespace molsys
std::string _name;
std::string _atomTypeName;

size_t _externalGlobalVDWType;
size_t _internalGlobalVDWType;
ExtVdwType _externalGlobalVDWType;
VdwType _internalGlobalVDWType;

size_t _externalAtomType;
size_t _atomType;
Expand Down Expand Up @@ -125,8 +125,8 @@ namespace molsys
[[nodiscard]] size_t getExternalAtomType() const;
[[nodiscard]] size_t getAtomType() const;

[[nodiscard]] size_t getExternalGlobalVDWType() const;
[[nodiscard]] size_t getInternalGlobalVDWType() const;
[[nodiscard]] ExtVdwType getExternalGlobalVDWType() const;
[[nodiscard]] VdwType getInternalGlobalVDWType() const;

[[nodiscard]]
AtomNumber getAtomicNumber() const
Expand Down Expand Up @@ -166,8 +166,8 @@ namespace molsys

void setAtomType(const size_t atomType);
void setExternalAtomType(const size_t externalAtomType);
void setExternalGlobalVDWType(const size_t externalGlobalVDWType);
void setInternalGlobalVDWType(const size_t internalGlobalVDWType);
void setExternalGlobalVDWType(const ExtVdwType externalGlobalVDWType);
void setInternalGlobalVDWType(const VdwType internalGlobalVDWType);

void setPosition(const linearAlgebra::Vec3D &position);
void setVelocity(const linearAlgebra::Vec3D &velocity);
Expand Down
16 changes: 9 additions & 7 deletions include/molsys/molecule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <vector> // for vector

#include "atom.hpp" // for Atom
#include "strongTypes.hpp"

namespace molsys
{
Expand Down Expand Up @@ -109,8 +110,8 @@ namespace molsys
void scale(const linearAlgebra::tensor3D &, const Box &);
void scaleVelocity(const linearAlgebra::tensor3D &, const Box &);

[[nodiscard]] size_t getNumberOfAtomTypes();
[[nodiscard]] std::vector<size_t> getExternalGlobalVDWTypes() const;
[[nodiscard]] size_t getNumberOfAtomTypes();
[[nodiscard]] std::vector<ExtVdwType> getExternalGlobalVDWTypes() const;

[[nodiscard]] std::vector<double> getAtomMasses() const;
[[nodiscard]] std::vector<double> getPartialCharges() const;
Expand Down Expand Up @@ -184,12 +185,13 @@ namespace molsys
const size_t index
) const;

[[nodiscard]] AtomNumber getAtomicNumber(const size_t index) const;
[[nodiscard]] double getAtomMass(const size_t index) const;
[[nodiscard]] double getPartialCharge(const size_t index) const;
[[nodiscard]] size_t getAtomType(const size_t index) const;
[[nodiscard]] size_t getInternalGlobalVDWType(const size_t index) const;
[[nodiscard]] AtomNumber getAtomicNumber(const size_t index) const;
[[nodiscard]] double getAtomMass(const size_t index) const;
[[nodiscard]] double getPartialCharge(const size_t index) const;
[[nodiscard]] size_t getAtomType(const size_t index) const;
[[nodiscard]] std::string getAtomName(const size_t index) const;
[[nodiscard]]
VdwType getInternalGlobalVDWType(const size_t index) const;

/***************************
* standard getter methods *
Expand Down
8 changes: 5 additions & 3 deletions include/molsys/moleculeType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <string_view> // for string_view
#include <vector> // for vector

#include "strongTypes.hpp"

namespace molsys
{
/**
Expand All @@ -49,7 +51,7 @@ namespace molsys
std::vector<std::string> _atomNames;
std::vector<size_t> _atomTypes;
std::vector<size_t> _externalAtomTypes;
std::vector<size_t> _externalGlobalVDWTypes;
std::vector<ExtVdwType> _externalGlobalVDWTypes;
std::vector<double> _partialCharges;

std::map<size_t, size_t> _externalToInternalAtomTypes;
Expand All @@ -68,7 +70,7 @@ namespace molsys
void addAtomName(const std::string &atomName);
void addExternalAtomType(const size_t externalAtomType);
void addPartialCharge(const double partialCharge);
void addExternalGlobalVDWType(const size_t externalGlobalVDWType);
void addExternalGlobalVDWType(const ExtVdwType externalGlobalVDWType);

void addExternalToInternalAtomTypeElement(const size_t, const size_t);
void addAtomType(const size_t atomType);
Expand Down Expand Up @@ -104,7 +106,7 @@ namespace molsys

[[nodiscard]] std::vector<std::string> getAtomNames() const;
[[nodiscard]] std::vector<size_t> &getExternalAtomTypes();
[[nodiscard]] std::vector<size_t> &getExternalGlobalVDWTypes();
[[nodiscard]] std::vector<ExtVdwType> &getExternalGlobalVDWTypes();
[[nodiscard]] std::vector<double> &getPartialCharges();

[[nodiscard]] std::map<size_t, size_t> getExternalToInternalAtomTypes(
Expand Down
Loading
Loading