5180f4e3534a85d68ad51d9d23b67799ec364aba
[alexxy/gromacs.git] / src / gromacs / mdtypes / enerdata.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2018,2019, 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.
8  *
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.
13  *
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.
18  *
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.
23  *
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.
31  *
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.
34  */
35 #ifndef GMX_MDTYPES_TYPES_ENERDATA_H
36 #define GMX_MDTYPES_TYPES_ENERDATA_H
37
38 #include <array>
39 #include <vector>
40
41 #include "gromacs/mdtypes/md_enums.h"
42 #include "gromacs/topology/idef.h"
43 #include "gromacs/utility/real.h"
44
45 enum
46 {
47     egCOULSR,
48     egLJSR,
49     egBHAMSR,
50     egCOUL14,
51     egLJ14,
52     egNR
53 };
54
55 struct gmx_grppairener_t
56 {
57     gmx_grppairener_t(int numEnergyGroups) : nener(numEnergyGroups * numEnergyGroups)
58     {
59         for (auto& elem : ener)
60         {
61             elem.resize(nener);
62         }
63     }
64
65     int                                 nener; /* The number of energy group pairs */
66     std::array<std::vector<real>, egNR> ener;  /* Energy terms for each pair of groups */
67 };
68
69 struct gmx_enerdata_t
70 {
71     gmx_enerdata_t(int numEnergyGroups, int numFepLambdas);
72
73     real term[F_NRE] = { 0 }; /* The energies for all different interaction types */
74     struct gmx_grppairener_t grpp;
75     double dvdl_lin[efptNR]    = { 0 }; /* Contributions to dvdl with linear lam-dependence */
76     double dvdl_nonlin[efptNR] = { 0 }; /* Idem, but non-linear dependence                  */
77     /* The idea is that dvdl terms with linear lambda dependence will be added
78      * automatically to enerpart_lambda. Terms with non-linear lambda dependence
79      * should explicitly determine the energies at foreign lambda points
80      * when n_lambda > 0. */
81
82     int                 fep_state = 0; /*current fep state -- just for printing */
83     std::vector<double> enerpart_lambda; /* Partial Hamiltonian for lambda and flambda[], includes at least all perturbed terms */
84     real foreign_term[F_NRE] = { 0 };      /* alternate array for storing foreign lambda energies */
85     struct gmx_grppairener_t foreign_grpp; /* alternate array for storing foreign lambda energies */
86 };
87
88 #endif