Repository navigation
Expand file tree
/
Copy pathtest_blj.cpp
More file actions
78 lines (65 loc) · 1.73 KB
/
Copy pathtest_blj.cpp
File metadata and controls
78 lines (65 loc) · 1.73 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <memory>
#include "pele/atomlist_potential.hpp"
#include "pele/combine_potentials.hpp"
#include "pele/distance.hpp"
#include "pele/lj.hpp"
#include "pele/lj_cut.hpp"
#include "test_utils.hpp"
class BLJCutTest : public PotentialTest {
public:
double c6, c12, rcut;
size_t natoms;
size_t ntypeA;
pele::Array<size_t> atomsA, atomsB;
virtual void setup_potential() {
auto compot = new pele::CombinedPotential();
compot->add_potential(
std::make_shared<pele::LJCutAtomList>(c6, c12, rcut, atomsA));
compot->add_potential(
std::make_shared<pele::LJCutAtomList>(c6, c12, rcut, atomsA, atomsB));
compot->add_potential(
std::make_shared<pele::LJCutAtomList>(c6, c12, rcut, atomsB));
pot = std::shared_ptr<pele::BasePotential>(compot);
}
virtual void SetUp() {
c6 = 1.2;
c12 = 2.3;
rcut = 2.5;
natoms = 4;
ntypeA = 2;
atomsA = pele::Array<size_t>(ntypeA);
for (size_t i = 0; i < atomsA.size(); ++i) {
atomsA[i] = i;
}
size_t ntypeB = natoms - ntypeA;
atomsB = pele::Array<size_t>(ntypeB);
for (size_t i = 0; i < ntypeB; ++i) {
atomsB[i] = i + ntypeA;
}
x = pele::Array<double>(3 * natoms);
x[0] = 0.1;
x[1] = 0.2;
x[2] = 0.3;
x[3] = 0.44;
x[4] = 0.55;
x[5] = 1.66;
x[6] = 0;
x[7] = 0;
x[8] = -3.;
x[9] = 1.38;
x[10] = 0.55;
x[11] = 1.66;
x[9] = .4;
x[10] = 1.57;
x[11] = 1.66;
etrue = 0.65332411282951708;
setup_potential();
}
};
TEST_F(BLJCutTest, Energy_Works) { test_energy(); }
TEST_F(BLJCutTest, EnergyGradient_AgreesWithNumerical) {
test_energy_gradient();
}
TEST_F(BLJCutTest, EnergyGradientHessian_AgreesWithNumerical) {
test_energy_gradient_hessian();
}