@@ -132,6 +132,7 @@ class PsiIntializerUnitTest : public ::testing::Test {
132132 this ->p_ucell ->a2 = {0.0 , 10.0 , 0.0 };
133133 this ->p_ucell ->a3 = {0.0 , 0.0 , 10.0 };
134134 this ->p_ucell ->lat0 = 1.0 ;
135+ this ->p_ucell ->omega = 1000.0 ;
135136 this ->p_ucell ->latvec .e11 = 10.0 ; this ->p_ucell ->latvec .e12 = 0.0 ; this ->p_ucell ->latvec .e13 = 0.0 ;
136137 this ->p_ucell ->latvec .e21 = 0.0 ; this ->p_ucell ->latvec .e22 = 10.0 ; this ->p_ucell ->latvec .e23 = 0.0 ;
137138 this ->p_ucell ->latvec .e31 = 0.0 ; this ->p_ucell ->latvec .e32 = 0.0 ; this ->p_ucell ->latvec .e33 = 10.0 ;
@@ -141,14 +142,14 @@ class PsiIntializerUnitTest : public ::testing::Test {
141142 this ->p_ucell ->tpiba = 2.0 * M_PI / this ->p_ucell ->lat0 ;
142143 this ->p_ucell ->tpiba2 = this ->p_ucell ->tpiba * this ->p_ucell ->tpiba ;
143144 // atom
144- if (this ->p_ucell ->atom_label != nullptr ) { delete[] this ->p_ucell ->atom_label ;
145- }
145+ delete[] this ->p_ucell ->atom_label ;
146146 this ->p_ucell ->atom_label = new std::string[1 ];
147147 this ->p_ucell ->atom_label [0 ] = " Si" ;
148148 // atom properties
149149 this ->p_ucell ->nat = 1 ;
150150 this ->p_ucell ->ntype = 1 ;
151151 this ->p_ucell ->atoms = new Atom[1 ];
152+ this ->p_ucell ->set_atom_flag = true ;
152153 this ->p_ucell ->atoms [0 ].label = " Si" ;
153154 this ->p_ucell ->atoms [0 ].mass = 28.0855 ;
154155 this ->p_ucell ->atoms [0 ].na = 1 ;
@@ -165,19 +166,20 @@ class PsiIntializerUnitTest : public ::testing::Test {
165166 this ->p_ucell ->pseudo_fn [0 ] = " Si_NCSR_ONCVPSP_v0.5_dojo.upf" ;
166167 this ->p_ucell ->natomwfc = 4 ;
167168 this ->p_ucell ->atoms [0 ].ncpp .nchi = 2 ;
168- this ->p_ucell ->atoms [0 ].ncpp .mesh = 10 ;
169- this ->p_ucell ->atoms [0 ].ncpp .msh = 10 ;
169+ this ->p_ucell ->atoms [0 ].ncpp .els = std::vector<std::string>(2 , " " );
170+ this ->p_ucell ->atoms [0 ].ncpp .mesh = 11 ;
171+ this ->p_ucell ->atoms [0 ].ncpp .msh = 11 ;
170172 this ->p_ucell ->atoms [0 ].ncpp .lmax = 2 ;
171173 // if(this->p_ucell->atoms[0].ncpp.rab != nullptr) delete[] this->p_ucell->atoms[0].ncpp.rab;
172- this ->p_ucell ->atoms [0 ].ncpp .rab = std::vector<double >(10 , 0.0 );
173- for (int i = 0 ; i < 10 ; ++i) { this ->p_ucell ->atoms [0 ].ncpp .rab [i] = 0.01 ;
174+ this ->p_ucell ->atoms [0 ].ncpp .rab = std::vector<double >(11 , 0.0 );
175+ for (int i = 0 ; i < 11 ; ++i) { this ->p_ucell ->atoms [0 ].ncpp .rab [i] = 0.01 ;
174176}
175177 // if(this->p_ucell->atoms[0].ncpp.r != nullptr) delete[] this->p_ucell->atoms[0].ncpp.r;
176- this ->p_ucell ->atoms [0 ].ncpp .r = std::vector<double >(10 , 0.0 );
177- for (int i = 0 ; i < 10 ; ++i) { this ->p_ucell ->atoms [0 ].ncpp .r [i] = 0.01 *i;
178+ this ->p_ucell ->atoms [0 ].ncpp .r = std::vector<double >(11 , 0.0 );
179+ for (int i = 0 ; i < 11 ; ++i) { this ->p_ucell ->atoms [0 ].ncpp .r [i] = 0.01 *i;
178180}
179- this ->p_ucell ->atoms [0 ].ncpp .chi .create (2 , 10 );
180- for (int i = 0 ; i < 2 ; ++i) { for (int j = 0 ; j < 10 ; ++j) { this ->p_ucell ->atoms [0 ].ncpp .chi (i, j) = 0.01 ;
181+ this ->p_ucell ->atoms [0 ].ncpp .chi .create (2 , 11 );
182+ for (int i = 0 ; i < 2 ; ++i) { for (int j = 0 ; j < 11 ; ++j) { this ->p_ucell ->atoms [0 ].ncpp .chi (i, j) = 0.01 ;
181183}
182184}
183185 // if(this->p_ucell->atoms[0].ncpp.lchi != nullptr) delete[] this->p_ucell->atoms[0].ncpp.lchi;
@@ -259,20 +261,21 @@ class PsiIntializerUnitTest : public ::testing::Test {
259261 this ->p_pw_wfc ->kvec_d = new ModuleBase::Vector3<double >[1 ];
260262 this ->p_pw_wfc ->kvec_d [0 ] = {0.0 , 0.0 , 0.0 };
261263
262- this ->p_pspot_vnl ->lmaxkb = 0 ;
264+ this ->p_pspot_vnl ->lmaxkb = 1 ;
263265
264266 this ->p_parakpts ->startk_pool .resize (1 );
265267 this ->p_parakpts ->startk_pool [0 ] = 0 ;
266268
267269 }
268270 void TearDown () override
269271 {
272+ delete this ->psi_init ;
270273 delete this ->p_sf ;
271274 delete this ->p_pw_wfc ;
272275 delete this ->p_ucell ;
273276 delete this ->p_pspot_vnl ;
274277 delete this ->p_parakpts ;
275- }
278+ }
276279};
277280
278281TEST_F (PsiIntializerUnitTest, ConstructorRandom) {
@@ -327,7 +330,7 @@ TEST_F(PsiIntializerUnitTest, CalPsigRandom) {
327330 const int nbasis = this ->p_pw_wfc ->npwk_max * PARAM.globalv .npol ;
328331 psi::Psi<std::complex <double >>* psi = new psi::Psi<std::complex <double >>(1 , nbands_start, nbasis, nullptr );
329332 this ->psi_init ->init_psig (psi->get_pointer (), 0 );
330- EXPECT_NEAR (0 , psi->operator ()(0 ,0 ,0 ).real (), 1e-12 );
333+ EXPECT_NEAR (- 0.66187696761064307 , psi->operator ()(0 ,0 ,0 ).real (), 1e-4 );
331334 delete psi;
332335}
333336
0 commit comments