Repository navigation
Expand file tree
/
Copy pathwrite_orb_info_test.cpp
More file actions
89 lines (76 loc) · 2.26 KB
/
Copy pathwrite_orb_info_test.cpp
File metadata and controls
89 lines (76 loc) · 2.26 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
79
80
81
82
83
84
85
86
87
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#define private public
#include "source_io/module_parameter/parameter.h"
#undef private
#include "source_io/write_orb_info.h"
#include "source_cell/unitcell.h"
#include "prepare_unitcell.h"
#include "source_estate/read_pseudo.h"
#ifdef __LCAO
InfoNonlocal::InfoNonlocal(){}
InfoNonlocal::~InfoNonlocal(){}
LCAO_Orbitals::LCAO_Orbitals(){}
LCAO_Orbitals::~LCAO_Orbitals(){}
#endif
Magnetism::Magnetism()
{
this->tot_mag = 0.0;
this->abs_mag = 0.0;
this->start_mag = nullptr;
}
Magnetism::~Magnetism()
{
delete[] this->start_mag;
}
/************************************************
* unit test of write_orb_info
***********************************************/
/**
* - Tested Functions:
* - write_orb_info()
*/
TEST(OrbInfo,WriteOrbInfo)
{
UnitCell* ucell = new UnitCell;
UcellTestPrepare utp = UcellTestLib["Si"];
ucell = utp.SetUcellInfo();
ucell->set_iat2itia();
std::string pp_dir = "./support/";
std::ofstream ofs;
ofs.open("running.log");
PARAM.sys.global_out_dir = "./";
PARAM.input.pseudo_rcut = 15.0;
PARAM.input.lspinorb = false;
PARAM.input.nspin = 1;
PARAM.input.basis_type = "pw";
PARAM.input.dft_functional = "default";
PARAM.sys.nlocal = 18;
elecstate::read_cell_pseudopots(pp_dir,ofs,*ucell);
elecstate::cal_nwfc(ofs,*ucell,ucell->atoms);
ModuleIO::write_orb_info(ucell);
ofs.close();
std::ifstream ifs("Orbital");
std::string str((std::istreambuf_iterator<char>(ifs)),std::istreambuf_iterator<char>());
EXPECT_THAT(str, testing::HasSubstr("#io spec l m z sym"));
EXPECT_THAT(str, testing::HasSubstr("0 Si 0 0 1 s"));
EXPECT_THAT(str, testing::HasSubstr("0 Si 2 4 1 dxy"));
EXPECT_THAT(str, testing::HasSubstr("#sym =Symmetry name of real orbital"));
ifs.close();
delete ucell;
std::remove("Orbital");
std::remove("running.log");
}
#ifdef __MPI
#include "mpi.h"
int main(int argc, char **argv)
{
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD,&GlobalV::NPROC);
MPI_Comm_rank(MPI_COMM_WORLD,&GlobalV::MY_RANK);
testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS();
MPI_Finalize();
return result;
}
#endif