@@ -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+ const std::vector<VALUETYPE>& coord = this ->coord ;
106+ const 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 ;
0 commit comments