From 23e8b9dce5efa1673f5d4b9b5ff4c65d9c884bb1 Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Mon, 29 Jul 2024 21:15:47 +0200 Subject: [PATCH] Add type alias and pointer in arguments --- src/molecules/Comp2Param.cpp | 4 ++-- src/molecules/Comp2Param.h | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/molecules/Comp2Param.cpp b/src/molecules/Comp2Param.cpp index 9071788f5..2030cbc17 100644 --- a/src/molecules/Comp2Param.cpp +++ b/src/molecules/Comp2Param.cpp @@ -8,7 +8,7 @@ void Comp2Param::initialize( - const std::vector& components, std::map> mixcoeff, + const std::vector& components, const MixRulesType & mixcoeff, double epsRF, double rc, double rcLJ) { m_numcomp = components.size(); @@ -41,7 +41,7 @@ void Comp2Param::initialize( for (unsigned int compj = compi + 1; compj < m_numcomp; ++compj) { ParaStrm& pstrmij = m_ssparatbl(compi, compj); unsigned int ncj = components[compj].numLJcenters(); - const auto mixingrule = mixcoeff[compi][compj]; + const auto mixingrule = mixcoeff.at(compi).at(compj); // Generic mixing functions std::function mixingSigma; std::function mixingEpsilon; diff --git a/src/molecules/Comp2Param.h b/src/molecules/Comp2Param.h index 4aca1565b..6ae2e8db4 100644 --- a/src/molecules/Comp2Param.h +++ b/src/molecules/Comp2Param.h @@ -14,6 +14,9 @@ * @author Martin Bernreuther et al. (2010) */ class Comp2Param { + + using MixRulesType = std::map>; + public: /** Create a new empty parameter stream. */ Comp2Param() : m_numcomp(0), m_ssparatbl(0,0) {} @@ -22,7 +25,7 @@ class Comp2Param { * the given components and parameters. */ Comp2Param(const std::vector& components, - std::map> mixcoeff, + const MixRulesType & mixcoeff, double epsRF, double rc, double rcLJ) : m_numcomp(components.size()), m_ssparatbl(m_numcomp,m_numcomp) { @@ -39,7 +42,7 @@ class Comp2Param { * The order of the entries must correspond to the * PotForce() function found in potforce.h reading the stream */ - void initialize(const std::vector& components, std::map> mixcoeff, double epsRF, double rc, double rcLJ); + void initialize(const std::vector& components, const MixRulesType & mixcoeff, double epsRF, double rc, double rcLJ); private: unsigned int m_numcomp; /**< number of components */