/src/openbabel/src/forcefields/forcefieldghemical.h
Line | Count | Source |
1 | | /********************************************************************** |
2 | | forcefieldghemical.h - Ghemical force field. |
3 | | |
4 | | Copyright (C) 2006 by Tim Vandermeersch <tim.vandermeersch@gmail.com> |
5 | | |
6 | | This file is part of the Open Babel project. |
7 | | For more information, see <http://openbabel.org/> |
8 | | |
9 | | This program is free software; you can redistribute it and/or modify |
10 | | it under the terms of the GNU General Public License as published by |
11 | | the Free Software Foundation version 2 of the License. |
12 | | |
13 | | This program is distributed in the hope that it will be useful, |
14 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | GNU General Public License for more details. |
17 | | ***********************************************************************/ |
18 | | |
19 | | #include <vector> |
20 | | #include <string> |
21 | | #include <map> |
22 | | |
23 | | #include <openbabel/forcefield.h> |
24 | | #include <openbabel/base.h> |
25 | | #include <openbabel/mol.h> |
26 | | |
27 | | namespace OpenBabel |
28 | | { |
29 | | class OBFFBondCalculationGhemical : public OBFFCalculation2 |
30 | | { |
31 | | public: |
32 | | int bt; // bondtype (BTIJ) |
33 | | double kb, r0, rab, delta; |
34 | | |
35 | | template<bool> void Compute(); |
36 | | }; |
37 | | |
38 | | class OBFFAngleCalculationGhemical : public OBFFCalculation3 |
39 | | { |
40 | | public: |
41 | | double ka, theta, theta0, delta; |
42 | | |
43 | | template<bool> void Compute(); |
44 | | }; |
45 | | |
46 | | class OBFFTorsionCalculationGhemical : public OBFFCalculation4 |
47 | | { |
48 | | public: |
49 | | int tt; //torsiontype (TTIJKL) |
50 | | double V, s, n, tor; |
51 | | double k1, k2, k3; |
52 | | |
53 | | template<bool> void Compute(); |
54 | | }; |
55 | | |
56 | | class OBFFVDWCalculationGhemical : public OBFFCalculation2 |
57 | | { |
58 | | public: |
59 | | bool is14, samering; |
60 | | double Ra, Rb, kab, rab; |
61 | | union { |
62 | | double ka, sigma12; |
63 | | }; |
64 | | union { |
65 | | double kb, sigma6; |
66 | | }; |
67 | | |
68 | | template<bool> void Compute(); |
69 | | }; |
70 | | |
71 | | class OBFFElectrostaticCalculationGhemical : public OBFFCalculation2 |
72 | | { |
73 | | public: |
74 | | double qq, rab; |
75 | | |
76 | | template<bool> void Compute(); |
77 | | }; |
78 | | |
79 | | // Class OBForceFieldGhemical |
80 | | // class introduction in forcefieldghemical.cpp |
81 | | class OBForceFieldGhemical: public OBForceField |
82 | | { |
83 | | protected: |
84 | | //! Parses the parameter file |
85 | | bool ParseParamFile() override; |
86 | | //! Sets atomtypes to Ghemical types in _mol |
87 | | bool SetTypes() override; |
88 | | //! Sets partial charges to Ghemical charges in _mol |
89 | | bool SetPartialCharges() override; |
90 | | //! fill OBFFXXXCalculation vectors |
91 | | bool SetupCalculations() override; |
92 | | //! Setup pointers in OBFFXXXCalculation vectors |
93 | | bool SetupPointers() override; |
94 | | //! Same as OBForceField::GetParameter, but takes (bond/angle/torsion) type in account. |
95 | | OBFFParameter* GetParameterGhemical(int type, const char* a, const char* b, |
96 | | const char* c, const char* d, std::vector<OBFFParameter> ¶meter); |
97 | | |
98 | | // OBFFParameter vectors to contain the parameters |
99 | | std::vector<OBFFParameter> _ffbondparams; |
100 | | std::vector<OBFFParameter> _ffangleparams; |
101 | | std::vector<OBFFParameter> _fftorsionparams; |
102 | | std::vector<OBFFParameter> _ffvdwparams; |
103 | | std::vector<OBFFParameter> _ffchargeparams; |
104 | | |
105 | | // OBFFXXXCalculationYYY vectors to contain the calculations |
106 | | std::vector<OBFFBondCalculationGhemical> _bondcalculations; |
107 | | std::vector<OBFFAngleCalculationGhemical> _anglecalculations; |
108 | | std::vector<OBFFTorsionCalculationGhemical> _torsioncalculations; |
109 | | std::vector<OBFFVDWCalculationGhemical> _vdwcalculations; |
110 | | std::vector<OBFFElectrostaticCalculationGhemical> _electrostaticcalculations; |
111 | | |
112 | | public: |
113 | | //! Constructor |
114 | 6 | explicit OBForceFieldGhemical(const char* ID, bool IsDefault=true) : OBForceField(ID, IsDefault) |
115 | 6 | { |
116 | 6 | _validSetup = false; |
117 | 6 | _init = false; |
118 | 6 | _rvdw = 7.0; |
119 | 6 | _rele = 15.0; |
120 | 6 | _epsilon = 1.0; |
121 | 6 | _pairfreq = 10; |
122 | 6 | _cutoff = false; |
123 | 6 | _linesearch = LineSearchType::Newton2Num; |
124 | 6 | } |
125 | | |
126 | | //! Destructor |
127 | | virtual ~OBForceFieldGhemical(); |
128 | | |
129 | | //! Assignment |
130 | | OBForceFieldGhemical &operator = (OBForceFieldGhemical &); |
131 | | |
132 | | //! Get the description for this force field |
133 | | const char* Description() override |
134 | 0 | { |
135 | 0 | return "Ghemical force field."; |
136 | 0 | } |
137 | | |
138 | | //!Clone the current instance. May be desirable in multithreaded environments |
139 | | OBForceFieldGhemical* MakeNewInstance() override |
140 | 0 | { |
141 | 0 | return new OBForceFieldGhemical(_id, false); |
142 | 0 | } |
143 | | |
144 | | //! Get the unit in which the energy is expressed |
145 | | std::string GetUnit() override |
146 | 0 | { |
147 | 0 | return std::string("kJ/mol"); |
148 | 0 | } |
149 | | |
150 | | //! \return that analytical gradients are implemented for Ghemical |
151 | 0 | bool HasAnalyticalGradients() override { return true; } |
152 | | |
153 | | //! Setup |
154 | | bool Setup(OBMol &mol); |
155 | | |
156 | | //! \return total energy |
157 | | double Energy(bool gradients = true) override; |
158 | | //! Returns the bond stretching energy |
159 | | template<bool> double E_Bond(); |
160 | | double E_Bond(bool gradients = true) override |
161 | 0 | { |
162 | 0 | return gradients ? E_Bond<true>() : E_Bond<false>(); |
163 | 0 | } |
164 | | //! Returns the angle bending energy |
165 | | template<bool> double E_Angle(); |
166 | | double E_Angle(bool gradients = true) override |
167 | 0 | { |
168 | 0 | return gradients ? E_Angle<true>() : E_Angle<false>(); |
169 | 0 | } |
170 | | //! Returns the torsional energy |
171 | | template<bool> double E_Torsion(); |
172 | | double E_Torsion(bool gradients = true) override |
173 | 0 | { |
174 | 0 | return gradients ? E_Torsion<true>() : E_Torsion<false>(); |
175 | 0 | } |
176 | | //! Returns the Van der Waals energy (Buckingham potential) |
177 | | template<bool> double E_VDW(); |
178 | | double E_VDW(bool gradients = true) override |
179 | 0 | { |
180 | 0 | return gradients ? E_VDW<true>() : E_VDW<false>(); |
181 | 0 | } |
182 | | //! Returns the dipole-dipole interaction energy |
183 | | template<bool> double E_Electrostatic(); |
184 | | double E_Electrostatic(bool gradients = true) override |
185 | 0 | { |
186 | 0 | return gradients ? E_Electrostatic<true>() : E_Electrostatic<false>(); |
187 | 0 | } |
188 | | |
189 | | //! Compare and print the numerical and analytical gradients |
190 | | bool ValidateGradients() override; |
191 | | |
192 | | }; // class OBForceFieldGhemical |
193 | | |
194 | | }// namespace OpenBabel |
195 | | |
196 | | //! \file forcefieldghemical.h |
197 | | //! \brief Ghemical force field |