1 // ENG1_MM.H : molecular mechanics "engine" base classes.
2 
3 // Copyright (C) 1998 Tommi Hassinen.
4 
5 // This package is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 
10 // This package is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 
15 // You should have received a copy of the GNU General Public License
16 // along with this package; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 /*################################################################################################*/
20 
21 #ifndef ENG1_MM_H
22 #define ENG1_MM_H
23 
24 class setup1_mm;
25 
26 struct mm_bt1_data;	// saved distance results.
27 struct mm_bt2_data;	// saved angle results.
28 
29 struct mm_c_dst;	// dst-constraint
30 
31 class eng1_mm;
32 
33 /*################################################################################################*/
34 
35 #include "atom.h"
36 #include "bond.h"
37 
38 #include "model.h"
39 #include "engine.h"
40 
41 #include <vector>
42 using namespace std;
43 
44 /*################################################################################################*/
45 
46 // THE ID NUMBERS SHOULD NOT CHANGE!!! the numbering logic is the following:
47 // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48 // for periodic ones, set the bit 0x0100. use bits 0x00FF as ID numbers.
49 
50 #define ENG1_MM_DEFAULT		0x0001		// eng1_mm_default
51 #define ENG1_MM_TRIPOS52	0x0050		// eng1_mm_tripos52
52 #define ENG1_MM_PERIODIC	0x0101		// eng1_mm_default_mim
53 
54 #define ENG1_MM_EXPERIMENTAL	0x00F1		// eng1_mm_prmfit ; ALWAYS THE LAST ONE (disable in standard setup???)
55 
56 /// A setup class for MM submodels; should always pass the atoms/bonds of MM submodel to eng.
57 
58 class setup1_mm : virtual public setup
59 {
60 	protected:
61 
62 	static const i32u eng_id_tab[];
63 	static const char * eng_name_tab[];
64 
65 	bool exceptions;
66 
67 	friend class default_tables;
68 
69 	public:
70 
71 	setup1_mm(model *);
72 	~setup1_mm(void);
73 
GetExceptions(void)74 	bool GetExceptions(void) { return exceptions; }
SetExceptions(bool e)75 	void SetExceptions(bool e) { exceptions = e; }
76 
77 	void UpdateAtomFlags(void);		// virtual
78 
79 	static i32u static_GetEngineCount(void);
80 	static i32u static_GetEngineIDNumber(i32u);
81 	static const char * static_GetEngineName(i32u);
82 	static const char * static_GetClassName(void);
83 
84 	i32u GetEngineCount(void);		// virtual
85 	i32u GetEngineIDNumber(i32u);		// virtual
86 	const char * GetEngineName(i32u);	// virtual
87 	const char * GetClassName_lg(void);	// virtual
88 
89 	engine * CreateEngineByIndex(i32u);	// virtual
90 };
91 
92 /*################################################################################################*/
93 
94 struct mm_bt1_data		// saved distance results.
95 {
96 	f64 len;
97 	f64 dlen[2][3];
98 };
99 
100 struct mm_bt2_data		// saved angle results.
101 {
102 	f64 csa;
103 	f64 dcsa[3][3];
104 };
105 
106 struct mm_c_dst			// dst-constraint
107 {
108 	i32s atmi[2];
109 
110 	f64 mindist; f64 minFC;
111 	f64 maxdist; f64 maxFC;
112 
113 	int bt1index;
114 	bool skipNB;
115 };
116 
117 /*################################################################################################*/
118 
119 /// A base engine class for molecular mechanics.
120 
121 #define NEAR_LINEAR_LIMIT (165.0*M_PI/180.0)
122 
123 class eng1_mm : virtual public engine
124 {
125 	protected:
126 
127 	i32u * l2g_mm;		// the local-to-global lookup table.
128 
129 	vector<atom *> cr1; i32s * range_cr1;	// connectivity records...
130 	vector<atom *> cr2; i32s * range_cr2;	// connectivity records...
131 
132 	vector<mm_c_dst> c_dst_vector;
133 
134 	bool do_virial;
135 
136 	public:
137 
138 	static const f64 fudgeLJ;	// how the 1-4 nonbonded interactions are modified...
139 	static const f64 fudgeQQ;	// how the 1-4 nonbonded interactions are modified...
140 
141 	f64 energy_bt1;
142 	f64 energy_bt2;
143 	f64 energy_bt3;
144 	f64 energy_bt4;
145 
146 	f64 energy_nbt1a;	// dispersion
147 	f64 energy_nbt1b;	// electrostatic
148 	f64 energy_nbt1c;
149 	f64 energy_nbt1d;
150 
151 	public:
152 
153 	eng1_mm(setup *, i32u);
154 	virtual ~eng1_mm(void);
155 
156 	void Compute(i32u, bool = false);	// virtual
157 
GetOrbitalCount(void)158 	virtual i32s GetOrbitalCount(void) { return 0; }	// virtual
GetOrbitalEnergy(i32s)159 	virtual f64 GetOrbitalEnergy(i32s) { return 0.0; }	// virtual
160 
GetElectronCount(void)161 	virtual i32s GetElectronCount(void) { return 0; }	// virtual
162 
SetupPlotting(void)163 	virtual void SetupPlotting(void) { }		// virtual
164 
165 	virtual fGL GetVDWSurf(fGL *, fGL *);		// virtual
166 
167 	virtual fGL GetESP(fGL *, fGL *);		// virtual
168 
GetElDens(fGL *,fGL *)169 	virtual fGL GetElDens(fGL *, fGL *) { return 0.0; }	// virtual
170 
GetOrbital(fGL *,fGL *)171 	virtual fGL GetOrbital(fGL *, fGL *) { return 0.0; }	// virtual
GetOrbDens(fGL *,fGL *)172 	virtual fGL GetOrbDens(fGL *, fGL *) { return 0.0; }	// virtual
173 
174 	private:
175 
176 	void SearchCR1a(atom *);
177 	void SearchCR1b(atom *, bond *);
178 	void SearchCR2(atom *, bond *, bond *);
179 
180 	protected:
181 
182 	virtual void ComputeBT1(i32u) = 0;	// bond streching
183 	virtual void ComputeBT2(i32u) = 0;	// angle bending
184 	virtual void ComputeBT3(i32u) = 0;	// torsion
185 	virtual void ComputeBT4(i32u) = 0;	// out of plane
186 
187 	virtual void ComputeNBT1(i32u) = 0;	// nonbonded
188 };
189 
190 /*################################################################################################*/
191 
192 #endif	// ENG1_MM_H
193 
194 // eof
195