1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 package ffx.potential.commands;
39
40 import static org.junit.Assert.assertEquals;
41
42 import ffx.potential.utils.PotentialTest;
43 import ffx.potential.commands.test.PhGradient;
44 import java.util.Arrays;
45 import java.util.Collection;
46 import java.util.Random;
47 import org.junit.Test;
48 import org.junit.runner.RunWith;
49 import org.junit.runners.Parameterized;
50 import org.junit.runners.Parameterized.Parameters;
51
52
53
54 @RunWith(Parameterized.class)
55 public class PhGradientTest extends PotentialTest {
56
57 private final String info;
58 private final String filepath;
59 private final String key;
60 private final int nBonds;
61 private final int nAngles;
62 private final int nStretchBends;
63 private final int nUreyBradleys;
64 private final int nOutOfPlaneBends;
65 private final int nTorsions;
66 private final int nImproperTorsions;
67 private final int nPiOrbitalTorsions;
68 private final int nTorsionTorsions;
69 private final int nVanDerWaals;
70 private final int nPermanent;
71 private final int nPolar;
72 private final double bondEnergy;
73 private final double angleEnergy;
74 private final double stretchBendEnergy;
75 private final double ureyBradleyEnergy;
76 private final double outOfPlaneBendEnergy;
77 private final double torsionEnergy;
78 private final double improperTorsionEnergy;
79 private final double piOrbitalTorsionEnergy;
80 private final double torsionTorsionEnergy;
81 private final double vanDerWaalsEnergy;
82 private final double permanentEnergy;
83 private final double polarizationEnergy;
84 private final double extendedSystemBias;
85 private final double totalEnergy;
86 private final double tolerance = 1.0e-2;
87
88 public PhGradientTest(
89 String info,
90 String filename,
91 String key,
92 double bondEnergy,
93 int nBonds,
94 double angleEnergy,
95 int nAngles,
96 double stretchBendEnergy,
97 int nStretchBends,
98 double ureyBradleyEnergy,
99 int nUreyBradleys,
100 double outOfPlaneBendEnergy,
101 int nOutOfPlaneBends,
102 double torsionEnergy,
103 int nTorsions,
104 double improperTorsionEnergy,
105 int nImproperTorsions,
106 double piOrbitalTorsionEnergy,
107 int nPiOrbitalTorsions,
108 double torsionTorsionEnergy,
109 int nTorsionTorsions,
110 double vanDerWaalsEnergy,
111 int nVanDerWaals,
112 double permanentEnergy,
113 int nPermanent,
114 double polarizationEnergy,
115 int nPolar,
116 double discretizerEnergy,
117 double acidostatEnergy) {
118 this.info = info;
119 this.key = key;
120 this.bondEnergy = bondEnergy;
121 this.nBonds = nBonds;
122 this.angleEnergy = angleEnergy;
123 this.nAngles = nAngles;
124 this.stretchBendEnergy = stretchBendEnergy;
125 this.nStretchBends = nStretchBends;
126 this.ureyBradleyEnergy = ureyBradleyEnergy;
127 this.nUreyBradleys = nUreyBradleys;
128 this.outOfPlaneBendEnergy = outOfPlaneBendEnergy;
129 this.nOutOfPlaneBends = nOutOfPlaneBends;
130 this.torsionEnergy = torsionEnergy;
131 this.nTorsions = nTorsions;
132 this.improperTorsionEnergy = improperTorsionEnergy;
133 this.nImproperTorsions = nImproperTorsions;
134 this.piOrbitalTorsionEnergy = piOrbitalTorsionEnergy;
135 this.nPiOrbitalTorsions = nPiOrbitalTorsions;
136 this.torsionTorsionEnergy = torsionTorsionEnergy;
137 this.nTorsionTorsions = nTorsionTorsions;
138 this.vanDerWaalsEnergy = vanDerWaalsEnergy;
139 this.nVanDerWaals = nVanDerWaals;
140 this.permanentEnergy = permanentEnergy;
141 this.nPermanent = nPermanent;
142 this.polarizationEnergy = polarizationEnergy;
143 this.nPolar = nPolar;
144
145 extendedSystemBias = discretizerEnergy + acidostatEnergy;
146 filepath = getResourcePath(filename);
147 totalEnergy = bondEnergy
148 + angleEnergy
149 + stretchBendEnergy
150 + ureyBradleyEnergy
151 + outOfPlaneBendEnergy
152 + torsionEnergy
153 + improperTorsionEnergy
154 + piOrbitalTorsionEnergy
155 + torsionTorsionEnergy
156 + vanDerWaalsEnergy
157 + permanentEnergy
158 + polarizationEnergy
159 + discretizerEnergy
160 + acidostatEnergy;
161 }
162
163 @Parameters
164 public static Collection<Object[]> data() {
165 return Arrays.asList(
166 new Object[][] {
167 {
168 "HDECK peptide",
169 "HDECK.pdb",
170 "\n Titration Lambdas: 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, " +
171 "\n Tautomer Lambdas: 0.0000, 0.0000, 0.0000",
172 28.05522192,
173 134,
174 19.63246647,
175 236,
176 -1.43838685,
177 201,
178 0.0,
179 0,
180 0.00032350,
181 81,
182 33.46613466,
183 335,
184 0.0,
185 0,
186 0.00001133,
187 15,
188 0.0,
189 0,
190 100.22152394,
191 8541,
192 -51.85815355,
193 7648,
194 -42.77517305,
195 7648,
196 -8.00000000,
197 -3.90174646
198 },
199 {
200 "HDECK peptide",
201 "HDECK.pdb",
202 "\n Titration Lambdas: 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, " +
203 "\n Tautomer Lambdas: 0.0000, 0.0000, 0.0000",
204 28.05522192,
205 134,
206 19.63246647,
207 236,
208 -1.43838685,
209 201,
210 0.0,
211 0,
212 0.00032350,
213 81,
214 33.46613466,
215 335,
216 0.0,
217 0,
218 0.00001133,
219 15,
220 0.0,
221 0,
222 101.39983768,
223 8541,
224 -170.80150311,
225 8280,
226 -22.35053436,
227 8280,
228 -8.00000000,
229 -166.24500000
230 }
231 });
232 }
233
234 @Test
235 public void testEndStateEnergyAndGradient() {
236
237 logger.info(" Testing endstate energy for " + info + "at lambdas: " + key);
238
239
240 Random random = new Random();
241 String randomAtom = Integer.toString(random.nextInt(110) + 1);
242
243 String[] args = {"--testEndStateEnergies", "--esvLambda", "0.0", "-d", "0.000001", "--ga", randomAtom, filepath};
244 binding.setVariable("args", args);
245
246 PhGradient pHGradient = new PhGradient(binding).run();
247 potentialScript = pHGradient;
248
249 double[] energyAndInteractionList = pHGradient.endstateEnergyMap.get(key);
250
251 assertEquals(info + " Bond Energy", bondEnergy, energyAndInteractionList[0], tolerance);
252 assertEquals(info + " Bond Count", nBonds, (int) energyAndInteractionList[1]);
253
254 assertEquals(info + " Angle Energy", angleEnergy, energyAndInteractionList[2], tolerance);
255 assertEquals(info + " Angle Count", nAngles, (int) energyAndInteractionList[3]);
256
257 assertEquals(info + " Stretch-Bend Energy", stretchBendEnergy, energyAndInteractionList[4],
258 tolerance);
259 assertEquals(info + " Stretch-Bend Count", nStretchBends, (int) energyAndInteractionList[5]);
260
261 assertEquals(info + " Urey-Bradley Energy", ureyBradleyEnergy, energyAndInteractionList[6],
262 tolerance);
263 assertEquals(info + " Urey-Bradley Count", nUreyBradleys, (int) energyAndInteractionList[7]);
264
265 assertEquals(info + " Out-of-Plane Bend Energy", outOfPlaneBendEnergy,
266 energyAndInteractionList[8], tolerance);
267 assertEquals(info + " Out-of-Plane Bend Count", nOutOfPlaneBends,
268 (int) energyAndInteractionList[9]);
269
270 assertEquals(info + " Torsion Energy", torsionEnergy, energyAndInteractionList[10], tolerance);
271 assertEquals(info + " Torsion Count", nTorsions, (int) energyAndInteractionList[11]);
272
273 assertEquals(info + " Improper Torsion Energy", improperTorsionEnergy,
274 energyAndInteractionList[12], tolerance);
275 assertEquals(info + " Improper Torsion Count", nImproperTorsions,
276 (int) energyAndInteractionList[13]);
277
278 assertEquals(info + " Pi-OrbitalTorsion Energy", piOrbitalTorsionEnergy,
279 energyAndInteractionList[14], tolerance);
280 assertEquals(info + " Pi-OrbitalTorsion Count", nPiOrbitalTorsions,
281 (int) energyAndInteractionList[15]);
282
283 assertEquals(info + " Torsion-Torsion Energy", torsionTorsionEnergy,
284 energyAndInteractionList[16], tolerance);
285 assertEquals(info + " Torsion-Torsion Count", nTorsionTorsions,
286 (int) energyAndInteractionList[17]);
287
288 assertEquals(info + " van Der Waals Energy", vanDerWaalsEnergy, energyAndInteractionList[18],
289 tolerance);
290 assertEquals(info + " van Der Waals Count", nVanDerWaals, (int) energyAndInteractionList[19]);
291
292 assertEquals(info + " Permanent Multipole Energy", permanentEnergy, energyAndInteractionList[20],
293 tolerance);
294 assertEquals(info + " Permanent Multipole Count", nPermanent,
295 (int) energyAndInteractionList[21]);
296
297 assertEquals(info + " Polarization Energy", polarizationEnergy, energyAndInteractionList[22],
298 tolerance);
299 assertEquals(info + " Polarization Count", nPolar, (int) energyAndInteractionList[23]);
300
301 assertEquals(info + " ExtendedSystemBias", extendedSystemBias, energyAndInteractionList[24],
302 tolerance);
303
304 assertEquals(info + " Total Energy", totalEnergy, energyAndInteractionList[25], tolerance);
305
306
307 assertEquals("HDECK gradient failures: ", 0, pHGradient.nFailures);
308 assertEquals("HDECK ESV gradient failures: ", 0, pHGradient.nESVFailures);
309 }
310 }
311