Debian Codegraph @

include/BALL/MOLMEC/PARAMETER/cosineTorsion.h

raw symbols SCIP
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4
5 #ifndef BALL_MOLMEC_PARAMETER_COSINETORSION_H
6 #define BALL_MOLMEC_PARAMETER_COSINETORSION_H
7
8 #ifndef BALL_FORMAT_PARAMETERSECTION_H
9 # include <BALL/FORMAT/parameterSection.h>
10 #endif
11
12 #ifndef BALL_MOLMEC_PARAMETER_ATOMTYPES_H
13 # include <BALL/MOLMEC/PARAMETER/atomTypes.h>
14 #endif
15
16 namespace BALL
17 {
18 /** Cosine Torsion.
19
20 Molecular Mechanics Parameter: class describing the parameter
21 section required for torsions using a cosine type potential function.
22
23 \ingroup MolmecParameters
24 */
25 class BALL_EXPORT CosineTorsion
26 : public ParameterSection
27 {
28 public:
29
30 enum
31 {
32 UNKNOWN
33 };
34
35 struct SingleValues
36 {
37 float phase;
38 float V;
39 float f;
40 float n;
41
42 SingleValues(const SingleValues& v)
43 : phase(v.phase),
44 V(v.V),
45 f(v.f),
46 n(v.n)
47 {
48 }
49
50 SingleValues()
51 : phase(0),
52 V(0),
53 f(0),
54 n(0)
55 {
56 }
57
58 bool operator == (const SingleValues& rhs) const
59 {
60 return ((phase == rhs.phase) && (V == rhs.V)
61 && (f == rhs.f) && (n == rhs.n));
62 }
63 };
64
65 struct BALL_EXPORT Values
66 {
67 ///
68 Size n;
69 ///
70 SingleValues* values;
71
72 Values()
73 : n(0),
74 values(0)
75 {
76 }
77
78 Values(Size number)
79 : n((unsigned char)number),
80 values(new SingleValues[number])
81 {
82 }
83
84 Values(const Values& v)
85 {
86 n = v.n;
87 values = new SingleValues[n];
88 for (Position i = 0; i < n; i++)
89 {
90 values[i].phase = v.values[i].phase;
91 values[i].V = v.values[i].V;
92 values[i].f = v.values[i].f;
93 values[i].n = v.values[i].n;
94 }
95 }
96
97 void set(const Values& v)
98 {
99 delete [] values;
100
101 n = v.n;
102 values = new SingleValues[n];
103 for (Position i = 0; i < n; i++)
104 {
105 values[i] = v.values[i];
106 }
107 }
108
109 ~Values()
110 {
111 delete [] values;
112 }
113
114 bool operator == (const Values& rhs) const
115 {
116 if (n != rhs.n)
117 {
118 return false;
119 }
120 for (Position i = 0; i < n; ++i)
121 {
122 if (!(values[i] == rhs.values[i]))
123 {
124 return false;
125 }
126 }
127 return true;
128 }
129
130 bool operator != (const Values& rhs) const
131 {
132 return ! operator == (rhs);
133 }
134 };
135
136 struct BALL_EXPORT Data
137 {
138 Atom* atom1;
139 Atom* atom2;
140 Atom* atom3;
141 Atom* atom4;
142
143 Values values;
144 };
145
146 struct BALL_EXPORT SingleData
147 {
148 Atom* atom1;
149 Atom* atom2;
150 Atom* atom3;
151 Atom* atom4;
152
153 SingleValues values;
154 };
155
156 /** @name Constructors and Destructors
157 */
158 //@{
159
160 /** Default constructor.
161 */
162 CosineTorsion();
163
164 /** Copy constructor
165 */
166 CosineTorsion(const CosineTorsion& cosine_torsion);
167
168 /** Destructor.
169 */
170 virtual ~CosineTorsion() ;
171
172 /** Clear method.
173 */
174 virtual void clear() ;
175
176 //@}
177
178 /** @name Accessors
179 */
180 //@{
181
182 /** Reads a parameter section from an INI file.
183 This method reads the section given in section_name from ini_file,
184 interprets (if given) a format line, reads the data from this
185 section according to the format, and builds some datastructures for
186 fast and easy acces this data.
187 */
188 virtual bool extractSection(ForceFieldParameters& parameters, const String& section_name);
189
190 ///
191 virtual bool extractSection(Parameters& parameters, const String& section_name);
192
193 /** Queries whether a parameter set is defined for the given atom types.
194 */
195 bool hasParameters(Atom::Type I, Atom::Type J, Atom::Type K, Atom::Type L) const;
196
197 /** Returns the parameters for a given atom type combination.
198 */
199 CosineTorsion::Values getParameters(Atom::Type I, Atom::Type J, Atom::Type K, Atom::Type L) const;
200
201 /** Assign the parameters for a given atom type combination.
202 If no parameters are defined for this combination, false is
203 returned and nothing is changed.
204 */
205 bool assignParameters(CosineTorsion::Values& parameters, Atom::Type I,
206 Atom::Type J, Atom::Type K, Atom::Type L) const;
207
208 //@}
209 /** @name Assignment
210 */
211 //@{
212
213 /** Assignment operator
214 */
215 CosineTorsion& operator = (const CosineTorsion& cosine_torsion);
216
217 //@}
218
219 /** @name Predicates
220 */
221 //@{
222
223 /** Equality operator
224 */
225 bool operator == (const CosineTorsion& cosine_torsion) const;
226
227 //@}
228
229 protected:
230
231 Size number_of_atom_types_;
232
233 vector<Values> torsions_;
234
235 HashMap<Size, Size> torsion_hash_map_;
236 };
237
238 } // namespace BALL
239
240 #endif // BALL_MOLMEC_PARAMETER_COSINETORSION_H