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.algorithms.groovy;
39
40 import static org.junit.Assert.assertEquals;
41
42 import ffx.algorithms.dynamics.MolecularDynamics;
43 import ffx.algorithms.misc.AlgorithmsTest;
44 import java.util.Arrays;
45 import java.util.Collection;
46 import org.junit.Test;
47 import org.junit.runner.RunWith;
48 import org.junit.runners.Parameterized;
49 import org.junit.runners.Parameterized.Parameters;
50
51
52 @RunWith(Parameterized.class)
53 public class DynamicsStochasticTest extends AlgorithmsTest {
54
55 private String info;
56 private String filename;
57 private double endKineticEnergy;
58 private double endPotentialEnergy;
59 private double endTotalEnergy;
60 private boolean testSeed;
61 private boolean testFriction00;
62 private boolean testFriction01;
63 private double tolerance = 0.1;
64
65 public DynamicsStochasticTest(
66 String info,
67 String filename,
68 double endKineticEnergy,
69 double endPotentialEnergy,
70 double endTotalEnergy,
71 boolean testSeed,
72 boolean testFriction00,
73 boolean testFriction01) {
74
75 this.info = info;
76 this.filename = filename;
77 this.endKineticEnergy = endKineticEnergy;
78 this.endPotentialEnergy = endPotentialEnergy;
79 this.endTotalEnergy = endTotalEnergy;
80 this.testSeed = testSeed;
81 this.testFriction00 = testFriction00;
82 this.testFriction01 = testFriction01;
83 }
84
85 @Parameters
86 public static Collection<Object[]> data() {
87 return Arrays.asList(
88 new Object[][] {
89 {
90 "Acetamide Peptide Restart and Stochastic Random Seed",
91 "acetamide_res_stoch.xyz",
92 6.8546,
93 -26.9921,
94 -20.1375,
95 true,
96 false,
97 false,
98 },
99 {
100 "Acetamide Peptide Restart, Stochastic Random Seed and Friction 0.0",
101 "acetamide_res_stoch.xyz",
102 4.5625,
103 -29.8043,
104 -25.2418,
105 false,
106 true,
107 false
108 },
109 {
110 "Acetamide Peptide Restart, Stochastic Random Seed and Friction 0.1",
111 "acetamide_res_stoch.xyz",
112 4.5743,
113 -29.7373,
114 -25.1630,
115 false,
116 false,
117 true
118 }
119 });
120 }
121
122 @Test
123 public void testDynamicsStochasticRandomSeed() {
124 if (!testSeed) {
125 return;
126 }
127
128
129 String[] args = {
130 "-n", "10",
131 "-t", "298.15",
132 "-i", "Stochastic",
133 "-b", "Adiabatic",
134 "-r", "0.001",
135 getResourcePath(filename)
136 };
137 binding.setVariable("args", args);
138
139
140 Dynamics dynamics = new Dynamics(binding).run();
141 algorithmsScript = dynamics;
142
143 MolecularDynamics molDyn = dynamics.getMolecularDynamics();
144
145
146
147 assertEquals(
148 info + " Final kinetic energy", endKineticEnergy, molDyn.getKineticEnergy(), tolerance);
149 assertEquals(
150 info + " Final potential energy",
151 endPotentialEnergy,
152 molDyn.getPotentialEnergy(),
153 tolerance);
154 assertEquals(info + " Final total energy", endTotalEnergy, molDyn.getTotalEnergy(), tolerance);
155
156 }
157
158 @Test
159 public void testDynamicsStochasticRandomSeedFriction0() {
160
161 if (!testFriction00) {
162 return;
163 }
164
165
166 String[] args = {
167 "-n", "10",
168 "-t", "298.15",
169 "-i", "Stochastic",
170 "-b", "Adiabatic",
171 "-r", "0.001",
172 getResourcePath(filename)
173 };
174 binding.setVariable("args", args);
175
176 System.setProperty("friction", "0.0");
177
178
179 Dynamics dynamics = new Dynamics(binding).run();
180 algorithmsScript = dynamics;
181
182 MolecularDynamics molDyn = dynamics.getMolecularDynamics();
183
184
185
186 assertEquals(
187 info + " Final kinetic energy", endKineticEnergy, molDyn.getKineticEnergy(), tolerance);
188 assertEquals(
189 info + " Final potential energy",
190 endPotentialEnergy,
191 molDyn.getPotentialEnergy(),
192 tolerance);
193 assertEquals(info + " Final total energy", endTotalEnergy, molDyn.getTotalEnergy(), tolerance);
194 }
195
196 @Test
197 public void testDynamicsStochasticRandomSeedFriction01() {
198
199 if (!testFriction01) {
200 return;
201 }
202
203
204 String[] args = {
205 "-n", "10",
206 "-t", "298.15",
207 "-i", "Stochastic",
208 "-b", "Adiabatic",
209 "-r", "0.001",
210 getResourcePath(filename)
211 };
212 binding.setVariable("args", args);
213
214 System.setProperty("friction", "0.1");
215
216
217 Dynamics dynamics = new Dynamics(binding).run();
218 algorithmsScript = dynamics;
219
220 MolecularDynamics molDyn = dynamics.getMolecularDynamics();
221
222
223
224 assertEquals(
225 info + " Final kinetic energy", endKineticEnergy, molDyn.getKineticEnergy(), tolerance);
226 assertEquals(
227 info + " Final potential energy",
228 endPotentialEnergy,
229 molDyn.getPotentialEnergy(),
230 tolerance);
231 assertEquals(info + " Final total energy", endTotalEnergy, molDyn.getTotalEnergy(), tolerance);
232 }
233 }