@@ -100,49 +100,48 @@ TYPED_TEST(TestInferDeepSpinTFAHPP, cpu_build_nlist) {
100100 // }
101101}
102102
103- // TYPED_TEST(TestInferDeepSpinTFAHPP, cpu_build_nlist_atomic) {
104- // using VALUETYPE = TypeParam;
105- // std::vector<VALUETYPE>& coord = this->coord;
106- // std::vector<VALUETYPE>& spin = this->spin;
107- // std::vector<int>& atype = this->atype;
108- // std::vector<VALUETYPE>& box = this->box;
109- // std::vector<VALUETYPE>& expected_e = this->expected_e;
110- // std::vector<VALUETYPE>& expected_f = this->expected_f;
111- // std::vector<VALUETYPE>& expected_fm = this->expected_fm;
112- // // std::vector<VALUETYPE>& expected_v = this->expected_v;
113- // unsigned int& natoms = this->natoms;
114- // double& expected_tot_e = this->expected_tot_e;
115- // // std::vector<VALUETYPE>& expected_tot_v = this->expected_tot_v;
116- // deepmd::hpp::DeepSpin& dp = this->dp;
117- // double ener;
118- // std::vector<VALUETYPE> force, force_mag, virial, atom_ener, atom_vir;
119- // dp.compute(ener, force, force_mag, virial, atom_ener, atom_vir, coord,
120- // spin,
121- // atype, box);
103+ TYPED_TEST (TestInferDeepSpinTFAHPP, cpu_build_nlist_atomic) {
104+ using VALUETYPE = TypeParam;
105+ std::vector<VALUETYPE>& coord = this ->coord ;
106+ std::vector<VALUETYPE>& spin = this ->spin ;
107+ std::vector<int >& atype = this ->atype ;
108+ std::vector<VALUETYPE>& box = this ->box ;
109+ std::vector<VALUETYPE>& expected_e = this ->expected_e ;
110+ std::vector<VALUETYPE>& expected_f = this ->expected_f ;
111+ std::vector<VALUETYPE>& expected_fm = this ->expected_fm ;
112+ // std::vector<VALUETYPE>& expected_v = this->expected_v;
113+ unsigned int & natoms = this ->natoms ;
114+ double & expected_tot_e = this ->expected_tot_e ;
115+ // std::vector<VALUETYPE>& expected_tot_v = this->expected_tot_v;
116+ deepmd::hpp::DeepSpin& dp = this ->dp ;
117+ double ener;
118+ std::vector<VALUETYPE> force, force_mag, virial, atom_ener, atom_vir;
119+ dp.compute (ener, force, force_mag, virial, atom_ener, atom_vir, coord, spin,
120+ atype, box);
122121
123- // EXPECT_EQ(force.size(), natoms * 3);
124- // EXPECT_EQ(force_mag.size(), natoms * 3);
125- // // EXPECT_EQ(virial.size(), 9);
126- // EXPECT_EQ(atom_ener.size(), natoms);
127- // // EXPECT_EQ(atom_vir.size(), natoms * 9);
122+ EXPECT_EQ (force.size (), natoms * 3 );
123+ EXPECT_EQ (force_mag.size (), natoms * 3 );
124+ // EXPECT_EQ(virial.size(), 9);
125+ EXPECT_EQ (atom_ener.size (), natoms);
126+ // EXPECT_EQ(atom_vir.size(), natoms * 9);
128127
129- // EXPECT_LT(fabs(ener - expected_tot_e), EPSILON);
130- // for (int ii = 0; ii < natoms * 3; ++ii) {
131- // EXPECT_LT(fabs(force[ii] - expected_f[ii]), EPSILON);
132- // }
133- // for (int ii = 0; ii < natoms * 3; ++ii) {
134- // EXPECT_LT(fabs(force_mag[ii] - expected_fm[ii]), EPSILON);
135- // }
136- // // for (int ii = 0; ii < 3 * 3; ++ii) {
137- // // EXPECT_LT(fabs(virial[ii] - expected_tot_v[ii]), EPSILON);
138- // // }
139- // for (int ii = 0; ii < natoms; ++ii) {
140- // EXPECT_LT(fabs(atom_ener[ii] - expected_e[ii]), EPSILON);
141- // }
142- // // for (int ii = 0; ii < natoms * 9; ++ii) {
143- // // EXPECT_LT(fabs(atom_vir[ii] - expected_v[ii]), EPSILON);
144- // // }
145- // }
128+ EXPECT_LT (fabs (ener - expected_tot_e), EPSILON);
129+ for (int ii = 0 ; ii < natoms * 3 ; ++ii) {
130+ EXPECT_LT (fabs (force[ii] - expected_f[ii]), EPSILON);
131+ }
132+ for (int ii = 0 ; ii < natoms * 3 ; ++ii) {
133+ EXPECT_LT (fabs (force_mag[ii] - expected_fm[ii]), EPSILON);
134+ }
135+ // for (int ii = 0; ii < 3 * 3; ++ii) {
136+ // EXPECT_LT(fabs(virial[ii] - expected_tot_v[ii]), EPSILON);
137+ // }
138+ for (int ii = 0 ; ii < natoms; ++ii) {
139+ EXPECT_LT (fabs (atom_ener[ii] - expected_e[ii]), EPSILON);
140+ }
141+ // for (int ii = 0; ii < natoms * 9; ++ii) {
142+ // EXPECT_LT(fabs(atom_vir[ii] - expected_v[ii]), EPSILON);
143+ // }
144+ }
146145
147146TYPED_TEST (TestInferDeepSpinTFAHPP, print_summary) {
148147 deepmd::hpp::DeepSpin& dp = this ->dp ;
@@ -157,7 +156,7 @@ class TestInferDeepSpinTFANoPbcHPP : public ::testing::Test {
157156 std::vector<VALUETYPE> spin = {0 ., 0 ., 1.2737 , 0 ., 0 ., 1.2737 ,
158157 0 ., 0 ., 0 ., 0 ., 0 ., 0 .};
159158 std::vector<int > atype = {0 , 0 , 1 , 1 };
160- std::vector<VALUETYPE> box = {};
159+ std::vector<VALUETYPE> box = {100 ., 0 ., 0 ., 0 ., 100 ., 0 ., 0 ., 0 ., 100 . };
161160 std::vector<VALUETYPE> expected_e = {-7.313160384523243 , -7.312173646552338 ,
162161 -2.8984477845267067 ,
163162 -2.8984477845267067 };
@@ -239,44 +238,43 @@ TYPED_TEST(TestInferDeepSpinTFANoPbcHPP, cpu_build_nlist) {
239238 // }
240239}
241240
242- // TYPED_TEST(TestInferDeepSpinTFANoPbcHPP, cpu_lmp_nlist) {
243- // using VALUETYPE = TypeParam;
244- // std::vector<VALUETYPE>& coord = this->coord;
245- // std::vector<VALUETYPE>& spin = this->spin;
246- // std::vector<int>& atype = this->atype;
247- // std::vector<VALUETYPE>& box = this->box;
248- // std::vector<VALUETYPE>& expected_e = this->expected_e;
249- // std::vector<VALUETYPE>& expected_f = this->expected_f;
250- // std::vector<VALUETYPE>& expected_fm = this->expected_fm;
251- // // std::vector<VALUETYPE>& expected_v = this->expected_v;
252- // unsigned int& natoms = this->natoms;
253- // double& expected_tot_e = this->expected_tot_e;
254- // // std::vector<VALUETYPE>& expected_tot_v = this->expected_tot_v;
255- // deepmd::hpp::DeepSpin& dp = this->dp;
256- // double ener;
257- // std::vector<VALUETYPE> force, force_mag, virial;
258- // std::vector<std::vector<int> > nlist_data = {{1}, {0}, {3}, {2}};
259- // std::vector<int> ilist(natoms), numneigh(natoms);
260- // std::vector<int*> firstneigh(natoms);
261- // deepmd::hpp::InputNlist inlist(natoms, &ilist[0], &numneigh[0],
262- // &firstneigh[0]);
263- // deepmd::hpp::convert_nlist(inlist, nlist_data);
264- // dp.compute(ener, force, force_mag, virial, coord, spin, atype, box, 0,
265- // inlist,
266- // 0);
241+ TYPED_TEST (TestInferDeepSpinTFANoPbcHPP, cpu_lmp_nlist) {
242+ using VALUETYPE = TypeParam;
243+ std::vector<VALUETYPE>& coord = this ->coord ;
244+ std::vector<VALUETYPE>& spin = this ->spin ;
245+ std::vector<int >& atype = this ->atype ;
246+ std::vector<VALUETYPE>& box = this ->box ;
247+ std::vector<VALUETYPE>& expected_e = this ->expected_e ;
248+ std::vector<VALUETYPE>& expected_f = this ->expected_f ;
249+ std::vector<VALUETYPE>& expected_fm = this ->expected_fm ;
250+ // std::vector<VALUETYPE>& expected_v = this->expected_v;
251+ unsigned int & natoms = this ->natoms ;
252+ double & expected_tot_e = this ->expected_tot_e ;
253+ // std::vector<VALUETYPE>& expected_tot_v = this->expected_tot_v;
254+ deepmd::hpp::DeepSpin& dp = this ->dp ;
255+ double ener;
256+ std::vector<VALUETYPE> force, force_mag, virial;
257+ std::vector<std::vector<int > > nlist_data = {{1 }, {0 }, {3 }, {2 }};
258+ std::vector<int > ilist (natoms), numneigh (natoms);
259+ std::vector<int *> firstneigh (natoms);
260+ deepmd::hpp::InputNlist inlist (natoms, &ilist[0 ], &numneigh[0 ],
261+ &firstneigh[0 ]);
262+ deepmd::hpp::convert_nlist (inlist, nlist_data);
263+ dp.compute (ener, force, force_mag, virial, coord, spin, atype, box, 0 , inlist,
264+ 0 );
267265
268- // EXPECT_EQ(force.size(), natoms * 3);
269- // EXPECT_EQ(force_mag.size(), natoms * 3);
270- // // EXPECT_EQ(virial.size(), 9);
266+ EXPECT_EQ (force.size (), natoms * 3 );
267+ EXPECT_EQ (force_mag.size (), natoms * 3 );
268+ // EXPECT_EQ(virial.size(), 9);
271269
272- // EXPECT_LT(fabs(ener - expected_tot_e), EPSILON);
273- // for (int ii = 0; ii < natoms * 3; ++ii) {
274- // EXPECT_LT(fabs(force[ii] - expected_f[ii]), EPSILON);
275- // }
276- // for (int ii = 0; ii < natoms * 3; ++ii) {
277- // EXPECT_LT(fabs(force_mag[ii] - expected_fm[ii]), EPSILON);
278- // }
279- // // for (int ii = 0; ii < 3 * 3; ++ii) {
280- // // EXPECT_LT(fabs(virial[ii] - expected_tot_v[ii]), EPSILON);
281- // // }
282- // }
270+ EXPECT_LT (fabs (ener - expected_tot_e), EPSILON);
271+ for (int ii = 0 ; ii < natoms * 3 ; ++ii) {
272+ EXPECT_LT (fabs (force[ii] - expected_f[ii]), EPSILON);
273+ }
274+ for (int ii = 0 ; ii < natoms * 3 ; ++ii) {
275+ EXPECT_LT (fabs (force_mag[ii] - expected_fm[ii]), EPSILON);
276+ }
277+ // for (int ii = 0; ii < 3 * 3; ++ii) {
278+ // EXPECT_LT(fabs(virial[ii] - expected_tot_v[ii]), EPSILON);
279+ // }
280+ }
0 commit comments