2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2020,2021, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
35 /*! \inpublicapi \file
37 * Definitions for supported nblib listed interaction data, such as bonds, angles, dihedrals, etc
39 * \author Victor Holanda <victor.holanda@cscs.ch>
40 * \author Joe Jordan <ejjordan@kth.se>
41 * \author Prashanth Kanduri <kanduri@cscs.ch>
42 * \author Sebastian Keller <keller@cscs.ch>
43 * \author Artem Zhmurov <zhmurov@gmail.com>
45 #ifndef NBLIB_LISTEDFORCES_DEFINITIONS_H
46 #define NBLIB_LISTEDFORCES_DEFINITIONS_H
50 #include "nblib/util/traits.hpp"
51 #include "bondtypes.h"
56 //***********************************************************************************
58 /*! \brief These type lists define what interaction types are supported in
61 * -ListedForceCalculator
63 * To enable force calculation for your new interaction type that you've added to bondtypes.h,
64 * list your new type here under the appropriate category and make sure that you've added
65 * a kernel in kernels.hpp
68 using SupportedTwoCenterTypes =
69 TypeList<HarmonicBondType, G96BondType, CubicBondType, FENEBondType, HalfAttractiveQuarticBondType>;
70 using SupportedThreeCenterTypes = TypeList<HarmonicAngle>;
71 using SupportedFourCenterTypes = TypeList<ProperDihedral, ImproperDihedral, RyckaertBellemanDihedral>;
72 using SupportedFiveCenterTypes = TypeList<Default5Center>;
74 //***********************************************************************************
76 using SupportedListedTypes =
77 Fuse<SupportedTwoCenterTypes, SupportedThreeCenterTypes, SupportedFourCenterTypes, SupportedFiveCenterTypes>;
79 //! \brief meta function to map from an Interaction type to the number of interaction centers
80 template<class Interaction, class = void>
85 //! \brief meta function return value for two-center interactions
86 template<class Interaction>
87 struct NCenter<Interaction, std::enable_if_t<Contains<Interaction, SupportedTwoCenterTypes>{}>> :
88 std::integral_constant<std::size_t, 2>
92 //! \brief meta function return value for three-center interactions
93 template<class Interaction>
94 struct NCenter<Interaction, std::enable_if_t<Contains<Interaction, SupportedThreeCenterTypes>{}>> :
95 std::integral_constant<std::size_t, 3>
99 //! \brief meta function return value for four-center interactions
100 template<class Interaction>
101 struct NCenter<Interaction, std::enable_if_t<Contains<Interaction, SupportedFourCenterTypes>{}>> :
102 std::integral_constant<std::size_t, 4>
106 //! \brief meta function return value for five-center interactions
107 template<class Interaction>
108 struct NCenter<Interaction, std::enable_if_t<Contains<Interaction, SupportedFiveCenterTypes>{}>> :
109 std::integral_constant<std::size_t, 5>
114 using IndexArray = std::array<int, N>;
116 /*! \brief encodes the number of integers needed to represent N-center interactions
118 * number of indices to store is the the number of interaction center
119 * plus 1 index for the interaction parameter lookup
121 template<class Interaction>
122 using InteractionIndex = IndexArray<NCenter<Interaction>{} + 1>;
124 // same as InteractionIndex, but just the coordinate indices
125 template<class Interaction>
126 using CoordinateIndex = IndexArray<NCenter<Interaction>{}>;
128 //! \brief container data type for listed interactions
129 template<class InteractionType>
130 struct ListedTypeData
132 using type = InteractionType;
134 // tuple format: <particleID i, particleID j, ..., InteractionInstanceIndex>
135 std::vector<InteractionIndex<InteractionType>> indices;
136 // vector of unique TwoCenterType instances
137 std::vector<InteractionType> parameters;
140 using TwoCenterInteraction = Reduce<std::variant, SupportedTwoCenterTypes>;
141 using ThreeCenterInteraction = Reduce<std::variant, SupportedThreeCenterTypes>;
142 using FourCenterInteraction = Reduce<std::variant, SupportedFourCenterTypes>;
143 using FiveCenterInteraction = Reduce<std::variant, SupportedFiveCenterTypes>;
145 //! This is the complete type that holds all listed interaction data
146 // result: std::tuple<ListedTypeData<SupportedListedType1>, ...>
147 using ListedInteractionData = Reduce<std::tuple, Map<ListedTypeData, SupportedListedTypes>>;
151 #endif // NBLIB_LISTEDFORCES_DEFINITIONS_H