|
| 1 | +#include "ff/amoebamod.h" |
| 2 | + |
| 3 | +#include "test.h" |
| 4 | +#include "testrt.h" |
| 5 | + |
| 6 | +using namespace tinker; |
| 7 | + |
| 8 | +TEST_CASE("ExchangePolarization-1", "[ff][hippo][expol]") |
| 9 | +{ |
| 10 | + TestFile fx1(TINKER9_DIRSTR "/test/file/expol/NaCl.xyz"); |
| 11 | + TestFile fk1(TINKER9_DIRSTR "/test/file/expol/expol.key"); |
| 12 | + TestFile fp1(TINKER9_DIRSTR "/test/file/expol/expol.prm"); |
| 13 | + |
| 14 | + const char* xn = "NaCl.xyz"; |
| 15 | + const char* kn = "expol.key"; |
| 16 | + const char* argv[] = {"dummy", xn, "-k", kn}; |
| 17 | + int argc = 4; |
| 18 | + |
| 19 | + const double eps_e = testGetEps(0.0001, 0.0001); |
| 20 | + const double eps_g = testGetEps(0.0001, 0.0001); |
| 21 | + const double eps_v = testGetEps(0.001, 0.001); |
| 22 | + |
| 23 | + TestReference r(TINKER9_DIRSTR "/test/ref/expol.1.txt"); |
| 24 | + auto ref_c = r.getCount(); |
| 25 | + auto ref_e = r.getEnergy(); |
| 26 | + auto ref_v = r.getVirial(); |
| 27 | + auto ref_g = r.getGradient(); |
| 28 | + |
| 29 | + rc_flag = calc::xyz | calc::vmask; |
| 30 | + testBeginWithArgs(argc, argv); |
| 31 | + initialize(); |
| 32 | + |
| 33 | + energy(calc::v0); |
| 34 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 35 | + |
| 36 | + energy(calc::v1); |
| 37 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 38 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 39 | + for (int i = 0; i < 3; ++i) |
| 40 | + for (int j = 0; j < 3; ++j) |
| 41 | + COMPARE_REALS(vir[i * 3 + j], ref_v[i][j], eps_v); |
| 42 | + |
| 43 | + energy(calc::v3); |
| 44 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 45 | + COMPARE_INTS(countReduce(nep), ref_c); |
| 46 | + |
| 47 | + energy(calc::v4); |
| 48 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 49 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 50 | + |
| 51 | + energy(calc::v5); |
| 52 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 53 | + |
| 54 | + energy(calc::v6); |
| 55 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 56 | + for (int i = 0; i < 3; ++i) |
| 57 | + for (int j = 0; j < 3; ++j) |
| 58 | + COMPARE_REALS(vir[i * 3 + j], ref_v[i][j], eps_v); |
| 59 | + |
| 60 | + finish(); |
| 61 | + testEnd(); |
| 62 | +} |
| 63 | + |
| 64 | +TEST_CASE("ExchangePolarization-2", "[ff][hippo][expol]") |
| 65 | +{ |
| 66 | + TestFile fx1(TINKER9_DIRSTR "/test/file/expol/Nawater.xyz"); |
| 67 | + TestFile fk1(TINKER9_DIRSTR "/test/file/expol/expol.key"); |
| 68 | + TestFile fp1(TINKER9_DIRSTR "/test/file/expol/expol.prm"); |
| 69 | + |
| 70 | + const char* xn = "Nawater.xyz"; |
| 71 | + const char* kn = "expol.key"; |
| 72 | + const char* argv[] = {"dummy", xn, "-k", kn}; |
| 73 | + int argc = 4; |
| 74 | + |
| 75 | + const double eps_e = testGetEps(0.0001, 0.0001); |
| 76 | + const double eps_g = testGetEps(0.0001, 0.0001); |
| 77 | + const double eps_v = testGetEps(0.001, 0.001); |
| 78 | + |
| 79 | + TestReference r(TINKER9_DIRSTR "/test/ref/expol.2.txt"); |
| 80 | + auto ref_c = r.getCount(); |
| 81 | + auto ref_e = r.getEnergy(); |
| 82 | + auto ref_v = r.getVirial(); |
| 83 | + auto ref_g = r.getGradient(); |
| 84 | + |
| 85 | + rc_flag = calc::xyz | calc::vmask; |
| 86 | + testBeginWithArgs(argc, argv); |
| 87 | + initialize(); |
| 88 | + |
| 89 | + energy(calc::v0); |
| 90 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 91 | + |
| 92 | + energy(calc::v1); |
| 93 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 94 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 95 | + for (int i = 0; i < 3; ++i) |
| 96 | + for (int j = 0; j < 3; ++j) |
| 97 | + COMPARE_REALS(vir[i * 3 + j], ref_v[i][j], eps_v); |
| 98 | + |
| 99 | + energy(calc::v3); |
| 100 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 101 | + COMPARE_INTS(countReduce(nep), ref_c); |
| 102 | + |
| 103 | + energy(calc::v4); |
| 104 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 105 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 106 | + |
| 107 | + energy(calc::v5); |
| 108 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 109 | + |
| 110 | + energy(calc::v6); |
| 111 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 112 | + for (int i = 0; i < 3; ++i) |
| 113 | + for (int j = 0; j < 3; ++j) |
| 114 | + COMPARE_REALS(vir[i * 3 + j], ref_v[i][j], eps_v); |
| 115 | + |
| 116 | + finish(); |
| 117 | + testEnd(); |
| 118 | +} |
| 119 | + |
| 120 | +TEST_CASE("ExchangePolarization-3", "[ff][hippo][expol]") |
| 121 | +{ |
| 122 | + TestFile fx1(TINKER9_DIRSTR "/test/file/expol/Clwater.xyz"); |
| 123 | + TestFile fk1(TINKER9_DIRSTR "/test/file/expol/expol.key"); |
| 124 | + TestFile fp1(TINKER9_DIRSTR "/test/file/expol/expol.prm"); |
| 125 | + |
| 126 | + const char* xn = "Clwater.xyz"; |
| 127 | + const char* kn = "expol.key"; |
| 128 | + const char* argv[] = {"dummy", xn, "-k", kn}; |
| 129 | + int argc = 4; |
| 130 | + |
| 131 | + const double eps_e = testGetEps(0.0001, 0.0001); |
| 132 | + const double eps_g = testGetEps(0.0001, 0.0001); |
| 133 | + const double eps_v = testGetEps(0.001, 0.001); |
| 134 | + |
| 135 | + TestReference r(TINKER9_DIRSTR "/test/ref/expol.3.txt"); |
| 136 | + auto ref_c = r.getCount(); |
| 137 | + auto ref_e = r.getEnergy(); |
| 138 | + auto ref_v = r.getVirial(); |
| 139 | + auto ref_g = r.getGradient(); |
| 140 | + |
| 141 | + rc_flag = calc::xyz | calc::vmask; |
| 142 | + testBeginWithArgs(argc, argv); |
| 143 | + initialize(); |
| 144 | + |
| 145 | + energy(calc::v0); |
| 146 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 147 | + |
| 148 | + energy(calc::v1); |
| 149 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 150 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 151 | + for (int i = 0; i < 3; ++i) |
| 152 | + for (int j = 0; j < 3; ++j) |
| 153 | + COMPARE_REALS(vir[i * 3 + j], ref_v[i][j], eps_v); |
| 154 | + |
| 155 | + energy(calc::v3); |
| 156 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 157 | + COMPARE_INTS(countReduce(nep), ref_c); |
| 158 | + |
| 159 | + energy(calc::v4); |
| 160 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 161 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 162 | + |
| 163 | + energy(calc::v5); |
| 164 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 165 | + |
| 166 | + energy(calc::v6); |
| 167 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 168 | + for (int i = 0; i < 3; ++i) |
| 169 | + for (int j = 0; j < 3; ++j) |
| 170 | + COMPARE_REALS(vir[i * 3 + j], ref_v[i][j], eps_v); |
| 171 | + |
| 172 | + finish(); |
| 173 | + testEnd(); |
| 174 | +} |
| 175 | + |
| 176 | +TEST_CASE("ExchangePolarization-4", "[ff][hippo][expol]") |
| 177 | +{ |
| 178 | + TestFile fx1(TINKER9_DIRSTR "/test/file/expol/water2Na2Clbox.xyz"); |
| 179 | + TestFile fk1(TINKER9_DIRSTR "/test/file/expol/expol.key"); |
| 180 | + TestFile fp1(TINKER9_DIRSTR "/test/file/expol/expol.prm"); |
| 181 | + |
| 182 | + const char* xn = "water2Na2Clbox.xyz"; |
| 183 | + const char* kn = "expol.key"; |
| 184 | + const char* argv[] = {"dummy", xn, "-k", kn}; |
| 185 | + int argc = 4; |
| 186 | + |
| 187 | + const double eps_e = testGetEps(0.0001, 0.0001); |
| 188 | + const double eps_g = testGetEps(0.0001, 0.0001); |
| 189 | + const double eps_v = testGetEps(0.001, 0.001); |
| 190 | + |
| 191 | + TestReference r(TINKER9_DIRSTR "/test/ref/expol.4.txt"); |
| 192 | + auto ref_c = r.getCount(); |
| 193 | + auto ref_e = r.getEnergy(); |
| 194 | + auto ref_v = r.getVirial(); |
| 195 | + auto ref_g = r.getGradient(); |
| 196 | + |
| 197 | + rc_flag = calc::xyz | calc::vmask; |
| 198 | + testBeginWithArgs(argc, argv); |
| 199 | + initialize(); |
| 200 | + |
| 201 | + energy(calc::v0); |
| 202 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 203 | + |
| 204 | + energy(calc::v1); |
| 205 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 206 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 207 | + for (int i = 0; i < 3; ++i) |
| 208 | + for (int j = 0; j < 3; ++j) |
| 209 | + COMPARE_REALS(vir[i * 3 + j], ref_v[i][j], eps_v); |
| 210 | + |
| 211 | + energy(calc::v3); |
| 212 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 213 | + COMPARE_INTS(countReduce(nep), ref_c); |
| 214 | + |
| 215 | + energy(calc::v4); |
| 216 | + COMPARE_REALS(esum, ref_e, eps_e); |
| 217 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 218 | + |
| 219 | + energy(calc::v5); |
| 220 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 221 | + |
| 222 | + energy(calc::v6); |
| 223 | + COMPARE_GRADIENT(ref_g, eps_g); |
| 224 | + for (int i = 0; i < 3; ++i) |
| 225 | + for (int j = 0; j < 3; ++j) |
| 226 | + COMPARE_REALS(vir[i * 3 + j], ref_v[i][j], eps_v); |
| 227 | + |
| 228 | + finish(); |
| 229 | + testEnd(); |
| 230 | +} |
0 commit comments