66#include < type_traits>
77
88#define DETAILINFO false
9- #define PASSTHRESHOLD 1e-4
9+ #define PASSTHRESHOLD 1e-12
1010#define PRINT_NEW_MATRIX false // print out the H matrix after doing block-cycle distribution
11- #define PRINT_HS false
11+ #define PRINT_HS false
1212
1313/* ***********************************************
1414 * unit test of ELPA
@@ -49,6 +49,7 @@ template <class T> class ElpaPrepare
4949 double *e_elpa = nullptr ;
5050 double lapack_time = 0.0 , elpa_time = 0.0 ;
5151 int mypnum = 0 ;
52+ std::string sfname, hfname;
5253
5354 void random_HS ()
5455 {
@@ -61,17 +62,9 @@ template <class T> class ElpaPrepare
6162 bool readsfile = false ;
6263 if (mypnum == 0 )
6364 {
64- std::vector<T> htmp,stmp;
65- if (std::is_same<T, double >::value)
66- {
67- readhfile = LCAO_DIAGO_TEST::read_hs<std::vector<T>>(std::string (" H-GammaOnly.dat" ),htmp);
68- readsfile = LCAO_DIAGO_TEST::read_hs<std::vector<T>>(std::string (" S-GammaOnly.dat" ),stmp);
69- }
70- else if ((std::is_same<T, std::complex <double >>::value))
71- {
72- readhfile = LCAO_DIAGO_TEST::read_hs<std::vector<T>>(std::string (" H-KPoints.dat" ),htmp);
73- readsfile = LCAO_DIAGO_TEST::read_hs<std::vector<T>>(std::string (" S-KPoints.dat" ),stmp);
74- }
65+ std::vector<T> htmp, stmp;
66+ readhfile = LCAO_DIAGO_TEST::read_hs<std::vector<T>>(hfname, htmp);
67+ readsfile = LCAO_DIAGO_TEST::read_hs<std::vector<T>>(sfname, stmp);
7568 if (htmp.size () != stmp.size ())
7669 {
7770 printf (" Error: dimensions of H and S are not equal, %d, %d" , htmp.size (), stmp.size ());
@@ -81,12 +74,12 @@ template <class T> class ElpaPrepare
8174 hmatrix = new T[htmp.size ()];
8275 smatrix = new T[stmp.size ()];
8376
84- for (int i= 0 ;i< htmp.size ();i++)
77+ for (int i = 0 ; i < htmp.size (); i++)
8578 {
8679 hmatrix[i] = htmp[i];
8780 smatrix[i] = stmp[i];
8881 }
89-
82+
9083 n = sqrt (stmp.size ());
9184 nblk = 1 ;
9285 }
@@ -101,8 +94,10 @@ template <class T> class ElpaPrepare
10194 e_lapack[i] = 0.0 ;
10295 e_elpa[i] = 1.0 ;
10396 }
104- if (readhfile && readsfile) return true ;
105- else return false ;
97+ if (readhfile && readsfile)
98+ return true ;
99+ else
100+ return false ;
106101 }
107102
108103 void new_matrix ()
@@ -120,7 +115,10 @@ template <class T> class ElpaPrepare
120115
121116 void print_hs ()
122117 {
123- if (! PRINT_HS) {return ;}
118+ if (!PRINT_HS)
119+ {
120+ return ;
121+ }
124122 if (mypnum == 0 )
125123 {
126124 std::ofstream fp (" hmatrix.dat" );
@@ -197,6 +195,18 @@ class ElpaComplexDoubleTest : public ::testing::TestWithParam<ElpaPrepare<std::c
197195TEST (VerifyElpaDiaoDouble, ReadHS)
198196{
199197 ElpaPrepare<double > edp;
198+ edp.hfname = " H-GammaOnly.dat" ;
199+ edp.sfname = " S-GammaOnly.dat" ;
200+ ASSERT_TRUE (edp.read_HS ());
201+ edp.print_hs ();
202+ edp.run_diago ();
203+ }
204+
205+ TEST (VerifyElpaDiaoDouble, ReadLargeHS)
206+ {
207+ ElpaPrepare<double > edp;
208+ edp.hfname = " H-GammaOnly-large.dat" ;
209+ edp.sfname = " S-GammaOnly-large.dat" ;
200210 ASSERT_TRUE (edp.read_HS ());
201211 edp.print_hs ();
202212 edp.run_diago ();
@@ -205,11 +215,24 @@ TEST(VerifyElpaDiaoDouble, ReadHS)
205215TEST (VerifyElpaDiaoComplexDouble, ReadHS)
206216{
207217 ElpaPrepare<std::complex <double >> edp;
218+ edp.hfname = " H-KPoints.dat" ;
219+ edp.sfname = " S-KPoints.dat" ;
208220 ASSERT_TRUE (edp.read_HS ());
209221 edp.print_hs ();
210222 edp.run_diago ();
211223}
212224
225+ TEST (VerifyElpaDiaoComplexDouble, ReadLargeHS)
226+ {
227+ ElpaPrepare<std::complex <double >> edp;
228+ edp.hfname = " H-KPoints-large.dat" ;
229+ edp.sfname = " S-KPoints-large.dat" ;
230+ ASSERT_TRUE (edp.read_HS ());
231+ edp.print_hs ();
232+ edp.run_diago ();
233+ }
234+
235+ /* *
213236TEST_P(ElpaDoubleTest, RandomHS)
214237{
215238 ElpaPrepare<double> edp = GetParam();
@@ -219,16 +242,17 @@ TEST_P(ElpaDoubleTest, RandomHS)
219242 edp.run_diago();
220243}
221244
222- INSTANTIATE_TEST_SUITE_P (VerifyElpaB2DDiag,
223- ElpaDoubleTest,
224- ::testing::Values (ElpaPrepare<double >(5 , 1 , 0 ),
225- // ElpaPrepare<double>(100,1,7),
226- // ElpaPrepare<double>(500,1,0),
227- ElpaPrepare<double>(500 , 1 , 7 ),
228- ElpaPrepare<double>(500 , 32 , 7 )
229- // ElpaPrepare<double>(1000,64,10)
230- // ElpaDoublePrepare<double>(2000,128,7)
231- ));
245+ INSTANTIATE_TEST_SUITE_P(
246+ VerifyElpaB2DDiag,
247+ ElpaDoubleTest,
248+ ::testing::Values(ElpaPrepare<double>(5, 1, 0),
249+ // ElpaPrepare<double>(100,1,7),
250+ // ElpaPrepare<double>(500,1,0),
251+ ElpaPrepare<double>(500, 1, 7),
252+ ElpaPrepare<double>(500, 32, 7)
253+ // ElpaPrepare<double>(1000,64,10)
254+ // ElpaDoublePrepare<double>(2000,128,7)
255+ ));
232256
233257TEST_P(ElpaComplexDoubleTest, RandomHS)
234258{
@@ -239,17 +263,18 @@ TEST_P(ElpaComplexDoubleTest, RandomHS)
239263 edp.run_diago();
240264}
241265
242- INSTANTIATE_TEST_SUITE_P (VerifyElpaB2DDiag,
243- ElpaComplexDoubleTest,
244- ::testing::Values (ElpaPrepare<std::complex <double >>(5 , 1 , 0 ),
245- // ElpaPrepare<std::complex<double>>(100,1,7),
246- // ElpaPrepare<std::complex<double>>(500,1,0),
247- ElpaPrepare<std::complex<double>>(500 , 1 , 7 ),
248- ElpaPrepare<std::complex<double>>(500 , 32 , 7 )
249- // ElpaPrepare<std::complex<double>>(800,64,9)
250- // ElpaDoublePrepare<double>(2000,128,7)
251- ));
252-
266+ INSTANTIATE_TEST_SUITE_P(
267+ VerifyElpaB2DDiag,
268+ ElpaComplexDoubleTest,
269+ ::testing::Values(ElpaPrepare<std::complex<double>>(5, 1, 0),
270+ // ElpaPrepare<std::complex<double>>(100,1,7),
271+ // ElpaPrepare<std::complex<double>>(500,1,0),
272+ ElpaPrepare<std::complex<double>>(500, 1, 7),
273+ ElpaPrepare<std::complex<double>>(500, 32, 7)
274+ // ElpaPrepare<std::complex<double>>(800,64,9)
275+ // ElpaDoublePrepare<double>(2000,128,7)
276+ ));
277+ */
253278int main (int argc, char **argv)
254279{
255280 MPI_Init (&argc, &argv);
0 commit comments