/src/openbabel/src/forcefields/forcefielduff.h
Line | Count | Source |
1 | | /********************************************************************** |
2 | | forcefielduff.h - UFF force field. |
3 | | |
4 | | Copyright (C) 2007 by Geoffrey Hutchison |
5 | | Some portions Copyright (C) 2006-2007 by Tim Vandermeersch |
6 | | |
7 | | This file is part of the Open Babel project. |
8 | | For more information, see <http://openbabel.org/> |
9 | | |
10 | | This program is free software; you can redistribute it and/or modify |
11 | | it under the terms of the GNU General Public License as published by |
12 | | the Free Software Foundation version 2 of the License. |
13 | | |
14 | | This program 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 |
17 | | GNU General Public License for more details. |
18 | | ***********************************************************************/ |
19 | | |
20 | | #include <vector> |
21 | | #include <string> |
22 | | #include <map> |
23 | | |
24 | | #include <openbabel/forcefield.h> |
25 | | #include <openbabel/base.h> |
26 | | #include <openbabel/mol.h> |
27 | | |
28 | | namespace OpenBabel |
29 | | { |
30 | | class OBFFBondCalculationUFF : public OBFFCalculation2 |
31 | | { |
32 | | public: |
33 | | double bt; // bond order (e.g., 1.41 for amide) |
34 | | double kb, r0, rab, delta; |
35 | | |
36 | | template<bool> void Compute(); |
37 | | }; |
38 | | |
39 | | class OBFFAngleCalculationUFF : public OBFFCalculation3 |
40 | | { |
41 | | public: |
42 | | int at; //angletype (ATIJK) |
43 | | bool linear; |
44 | | double ka, theta0, theta, delta; |
45 | | double c0, c1, c2; |
46 | | double zi, zk, rij, rjk, rik; |
47 | | double cosT0; // cos theta0 |
48 | | int coord, n; |
49 | | |
50 | | template<bool> void Compute(); |
51 | | }; |
52 | | |
53 | | class OBFFTorsionCalculationUFF : public OBFFCalculation4 |
54 | | { |
55 | | public: |
56 | | int n; |
57 | | double tt; //torsiontype (i.e. b-c bond order) |
58 | | double V, tor, cosNPhi0; |
59 | | |
60 | | template<bool> void Compute(); |
61 | | |
62 | | }; |
63 | | |
64 | | class OBFFOOPCalculationUFF : public OBFFCalculation4 |
65 | | { |
66 | | public: |
67 | | double koop, angle; |
68 | | double c0, c1, c2; |
69 | | |
70 | | template<bool> void Compute(); |
71 | | }; |
72 | | |
73 | | class OBFFVDWCalculationUFF : public OBFFCalculation2 |
74 | | { |
75 | | public: |
76 | | bool is14, samering; |
77 | | double ka, kaSquared, Ra, kb, Rb, kab, rab; |
78 | | |
79 | | template<bool> void Compute(); |
80 | | }; |
81 | | |
82 | | class OBFFElectrostaticCalculationUFF : public OBFFCalculation2 |
83 | | { |
84 | | public: |
85 | | double qq, rab; |
86 | | |
87 | | template<bool> void Compute(); |
88 | | }; |
89 | | |
90 | | // Class OBForceFieldUFF |
91 | | // class introduction in forcefieldUFF.cpp |
92 | | class OBForceFieldUFF: public OBForceField |
93 | | { |
94 | | protected: |
95 | | //! Parses the parameter file |
96 | | bool ParseParamFile() override; |
97 | | //! Sets atomtypes to UFF types in _mol |
98 | | bool SetTypes() override; |
99 | | //! Fill OBFFXXXCalculation vectors |
100 | | bool SetupCalculations() override; |
101 | | //! Setup pointers in OBFFXXXCalculation vectors |
102 | | bool SetupPointers() override; |
103 | | bool SetupVDWCalculation(OBAtom *a, OBAtom *b, OBFFVDWCalculationUFF &vdwcalc); |
104 | | //! By default, electrostatic terms are disabled |
105 | | //! This is discouraged, since the parameterization is not designed for it |
106 | | //! But if you want, we give you the option. |
107 | | bool SetupElectrostatics(); |
108 | | //! Same as OBForceField::GetParameter, but simpler |
109 | | OBFFParameter* GetParameterUFF(std::string a, std::vector<OBFFParameter> ¶meter); |
110 | | |
111 | | // OBFFParameter vectors to contain the parameters |
112 | | std::vector<OBFFParameter> _ffparams; |
113 | | |
114 | | // OBFFXXXCalculationYYY vectors to contain the calculations |
115 | | std::vector<OBFFBondCalculationUFF> _bondcalculations; |
116 | | std::vector<OBFFAngleCalculationUFF> _anglecalculations; |
117 | | std::vector<OBFFTorsionCalculationUFF> _torsioncalculations; |
118 | | std::vector<OBFFOOPCalculationUFF> _oopcalculations; |
119 | | std::vector<OBFFVDWCalculationUFF> _vdwcalculations; |
120 | | std::vector<OBFFElectrostaticCalculationUFF> _electrostaticcalculations; |
121 | | |
122 | | public: |
123 | | //! Constructor |
124 | 6 | explicit OBForceFieldUFF(const char* ID, bool IsDefault=true) : OBForceField(ID, IsDefault) |
125 | 6 | { |
126 | 6 | _validSetup = false; |
127 | 6 | _init = false; |
128 | 6 | _rvdw = 7.0; |
129 | 6 | _rele = 15.0; |
130 | 6 | _epsilon = 1.0; // electrostatics not used |
131 | 6 | _pairfreq = 10; |
132 | 6 | _cutoff = false; |
133 | 6 | _linesearch = LineSearchType::Newton2Num; |
134 | 6 | } |
135 | | |
136 | | //! Destructor |
137 | | virtual ~OBForceFieldUFF(); |
138 | | |
139 | | //!Clone the current instance. May be desirable in multithreaded environments |
140 | | OBForceFieldUFF* MakeNewInstance() override |
141 | 0 | { |
142 | 0 | return new OBForceFieldUFF(_id, false); |
143 | 0 | } |
144 | | |
145 | | //! Assignment |
146 | | OBForceFieldUFF &operator = (OBForceFieldUFF &); |
147 | | |
148 | | //! Get the description for this force field |
149 | | const char* Description() override |
150 | 0 | { |
151 | 0 | return "Universal Force Field."; |
152 | 0 | } |
153 | | |
154 | | //! Get the unit in which the energy is expressed |
155 | | std::string GetUnit() override |
156 | 0 | { |
157 | 0 | return std::string("kJ/mol"); // Note that we convert from kcal/mol internally |
158 | 0 | } |
159 | | |
160 | | //! \return that analytical gradients are implemented for UFF |
161 | 0 | bool HasAnalyticalGradients() override { return true; } |
162 | | |
163 | | //! \return total energy |
164 | | double Energy(bool gradients = true) override; |
165 | | //! \return the bond stretching energy |
166 | | template<bool> double E_Bond(); |
167 | | double E_Bond(bool gradients = true) override |
168 | 0 | { |
169 | 0 | return gradients ? E_Bond<true>() : E_Bond<false>(); |
170 | 0 | } |
171 | | //! Returns the angle bending energy |
172 | | template<bool> double E_Angle(); |
173 | | double E_Angle(bool gradients = true) override |
174 | 0 | { |
175 | 0 | return gradients ? E_Angle<true>() : E_Angle<false>(); |
176 | 0 | } |
177 | | //! Returns the torsional energy |
178 | | template<bool> double E_Torsion(); |
179 | | double E_Torsion(bool gradients = true) override |
180 | 0 | { |
181 | 0 | return gradients ? E_Torsion<true>() : E_Torsion<false>(); |
182 | 0 | } |
183 | | //! Returns the out-of-plane bending energy |
184 | | template<bool> double E_OOP(); |
185 | | double E_OOP(bool gradients = true) override |
186 | 0 | { |
187 | 0 | return gradients ? E_OOP<true>() : E_OOP<false>(); |
188 | 0 | } |
189 | | //! Returns the Van der Waals energy (Buckingham potential) |
190 | | template<bool> double E_VDW(); |
191 | | double E_VDW(bool gradients = true) override |
192 | 0 | { |
193 | 0 | return gradients ? E_VDW<true>() : E_VDW<false>(); |
194 | 0 | } |
195 | | //! Returns the dipole-dipole interaction energy |
196 | | template<bool> double E_Electrostatic(); |
197 | | double E_Electrostatic(bool gradients = true) override |
198 | 0 | { |
199 | 0 | return gradients ? E_Electrostatic<true>() : E_Electrostatic<false>(); |
200 | 0 | } |
201 | | |
202 | | //! Compare and print the numerical and analytical gradients |
203 | | bool ValidateGradients() override; |
204 | | |
205 | | }; // class OBForceFieldUFF |
206 | | |
207 | | }// namespace OpenBabel |
208 | | |
209 | | //! \file forcefieldUFF.h |
210 | | //! \brief UFF force field |