37eebc77f887a57f117da1bcdc69de07680b666d
[alexxy/gromacs.git] / src / gromacs / applied_forces / qmmm / qmmmtypes.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 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.
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 /*! \internal \file
36  * \brief
37  * Declares structers and types needed to evaluate forces and energies for QM/MM
38  *
39  * \author Dmitry Morozov <dmitry.morozov@jyu.fi>
40  * \author Christian Blau <blau@kth.se>
41  * \ingroup module_applied_forces
42  */
43 #ifndef GMX_APPLIED_FORCES_QMMMTYPES_H
44 #define GMX_APPLIED_FORCES_QMMMTYPES_H
45
46 #include <memory>
47 #include <string>
48 #include <vector>
49
50 #include "gromacs/math/vectypes.h"
51 #include "gromacs/utility/classhelpers.h"
52 #include "gromacs/utility/enumerationhelpers.h"
53 #include "gromacs/utility/real.h"
54
55 namespace gmx
56 {
57
58 /*! \internal
59  * \brief Helper structure with indexes of broken bonds between QM and MM
60  * Used to determine and store pair of QM and MM atoms between which chemical bond is broken
61  */
62 struct LinkFrontier
63 {
64     //! Global index of QM atom at Frontier
65     index qm;
66     //! Global index of MM atom at Frontier
67     index mm;
68 };
69
70 /*! \brief Enumerator for supported QM methods
71  * Also could be INPUT which means external input file provided
72  * with the name determined by QMMMParameters::qminputfilename_
73  */
74 enum class QMMMQMMethod
75 {
76     PBE,   //!< DFT with PBE functional
77     BLYP,  //!< DFT with BLYP functional
78     INPUT, //!< User provides suitable input file for QM package
79     Count
80 };
81
82 //! The names of the supported QM methods
83 static const EnumerationArray<QMMMQMMethod, const char*> c_qmmmQMMethodNames = {
84     { "PBE", "BLYP", "INPUT" }
85 };
86
87 //! symbols of the elements in periodic table
88 const std::vector<std::string> periodic_system = {
89     "X  ", "H  ", "He ", "Li ", "Be ", "B  ", "C  ", "N  ", "O  ", "F  ", "Ne ", "Na ",
90     "Mg ", "Al ", "Si ", "P  ", "S  ", "Cl ", "Ar ", "K  ", "Ca ", "Sc ", "Ti ", "V  ",
91     "Cr ", "Mn ", "Fe ", "Co ", "Ni ", "Cu ", "Zn ", "Ga ", "Ge ", "As ", "Se ", "Br ",
92     "Kr ", "Rb ", "Sr ", "Y  ", "Zr ", "Nb ", "Mo ", "Tc ", "Ru ", "Rh ", "Pd ", "Ag ",
93     "Cd ", "In ", "Sn ", "Sb ", "Te ", "I  ", "Xe ", "Cs ", "Ba ", "La ", "Ce ", "Pr ",
94     "Nd ", "Pm ", "Sm ", "Eu ", "Gd ", "Tb ", "Dy ", "Ho ", "Er ", "Tm ", "Yb ", "Lu ",
95     "Hf ", "Ta ", "W  ", "Re ", "Os ", "Ir ", "Pt ", "Au ", "Hg ", "Tl ", "Pb ", "Bi ",
96     "Po ", "At ", "Rn ", "Fr ", "Ra ", "Ac ", "Th ", "Pa ", "U  ", "Np ", "Pu ", "Am ",
97     "Cm ", "Bk ", "Cf ", "Es ", "Fm ", "Md ", "No ", "Lr ", "Rf ", "Db ", "Sg ", "Bh ",
98     "Hs ", "Mt ", "Ds ", "Rg ", "Cn ", "Nh ", "Fl ", "Mc ", "Lv ", "Ts ", "Og "
99 };
100
101 /*! \internal
102  * \brief Holding all parameters needed for QM/MM simulation.
103  * Also used for setting all default parameter values.
104  */
105 struct QMMMParameters
106 {
107     //! Indicate if QM/MM is active (default false)
108     bool active_ = false;
109     //! Indices of the atoms that are part of the QM region (default whole System)
110     std::vector<index> qmIndices_;
111     //! Indices of the atoms that are part of the MM region (default no MM atoms)
112     std::vector<index> mmIndices_;
113     //! Vector with pairs of indicies defining broken bonds in QMMM (default determined from topology)
114     std::vector<LinkFrontier> link_;
115     //! Vector with atomic numbers of all atoms in the system (default determined from topology)
116     std::vector<int> atomNumbers_;
117     //! Total charge of QM system (default 0)
118     int qmCharge_ = 0;
119     //! Total multiplicity of QM system (default 1)
120     int qmMult_ = 1;
121     //! Method used for QM calculation (default DFT with PBE functional)
122     QMMMQMMethod qmMethod_ = QMMMQMMethod::PBE;
123     /*! \brief String containing name of the CP2K files (*.inp, *.out, *.pdb)
124      * default value empty, means will be deduced from *.tpr name during mdrun
125      */
126     std::string qmFileNameBase_;
127     //! String containing whole CP2K input which can be stored inside *.tpr
128     std::string qmInput_;
129     //! String containing PDB file for CP2K input which can be stored inside *.tpr
130     std::string qmPdb_;
131     //! Matrix that contains vectors defining QM box
132     matrix qmBox_;
133     //! Translation vector to center QM subsystem inside the QM Box
134     RVec qmTrans_;
135
136     //! Constructor with default initializers for arrays
137     QMMMParameters() :
138         qmBox_{ { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 } }, qmTrans_{ 0.0, 0.0, 0.0 }
139     {
140     }
141
142     GMX_DISALLOW_COPY_AND_ASSIGN(QMMMParameters);
143 };
144
145 } // namespace gmx
146
147 #endif // GMX_APPLIED_FORCES_QMMMTYPES_H