|
10 | 10 | initilize_test_env() |
11 | 11 |
|
12 | 12 | class TestAbacusCalBand(unittest.TestCase): |
| 13 | + """ |
| 14 | + Test tool function abacus_cal_band while ABACUS calculation uses LCAO basis. |
| 15 | + """ |
13 | 16 | def setUp(self): |
14 | 17 | self.test_dir = tempfile.TemporaryDirectory() |
15 | 18 | self.addCleanup(self.test_dir.cleanup) |
@@ -84,14 +87,92 @@ def test_abacus_cal_band_nscf_nspin1(self): |
84 | 87 |
|
85 | 88 | def test_abacus_cal_band_nscf_nspin2(self): |
86 | 89 | """ |
87 | | - Test plot band structure in NSCF mode in nspin=1 case |
| 90 | + Test plot band structure in NSCF mode in nspin=2 case |
| 91 | + """ |
| 92 | + test_func_name = inspect.currentframe().f_code.co_name |
| 93 | + ref_results = load_test_ref_result(test_func_name) |
| 94 | + |
| 95 | + test_work_dir = self.test_path / test_func_name |
| 96 | + shutil.copytree(self.abacus_inputs_dir_fe_bcc_prim, test_work_dir) |
| 97 | + shutil.copy2(self.fe_stru_band, test_work_dir / "STRU") |
| 98 | + |
| 99 | + outputs = abacus_cal_band(test_work_dir, mode='nscf') |
| 100 | + |
| 101 | + band_calc_dir = outputs['band_calc_dir'] |
| 102 | + band_picture = outputs['band_picture'] |
| 103 | + self.assertIsInstance(band_calc_dir, get_path_type()) |
| 104 | + self.assertIsInstance(band_picture, get_path_type()) |
| 105 | + self.assertAlmostEqual(outputs['band_gap'], ref_results['band_gap'], places=4) |
| 106 | + |
| 107 | +class TestAbacusCalBandPw(unittest.TestCase): |
| 108 | + """ |
| 109 | + Test tool function abacus_cal_band while ABACUS calculation uses PW basis. |
| 110 | + """ |
| 111 | + def setUp(self): |
| 112 | + self.test_dir = tempfile.TemporaryDirectory() |
| 113 | + self.addCleanup(self.test_dir.cleanup) |
| 114 | + self.test_path = Path(self.test_dir.name) |
| 115 | + self.abacus_inputs_dir_si_prim = Path(__file__).parent / 'abacus_inputs_dirs/Si-prim/' |
| 116 | + self.abacus_inputs_dir_fe_bcc_prim = Path(__file__).parent / 'abacus_inputs_dirs/Fe-BCC-prim/' |
| 117 | + self.si_stru_band = self.abacus_inputs_dir_si_prim / "STRU_band" |
| 118 | + self.input_pw_si = self.abacus_inputs_dir_si_prim / "INPUT_pw" |
| 119 | + self.fe_stru_band = self.abacus_inputs_dir_fe_bcc_prim / "STRU_band" |
| 120 | + self.input_pw_fe= self.abacus_inputs_dir_fe_bcc_prim / "INPUT_pw" |
| 121 | + |
| 122 | + self.original_cwd = os.getcwd() |
| 123 | + os.chdir(self.test_path) |
| 124 | + |
| 125 | + def tearDown(self): |
| 126 | + os.chdir(self.original_cwd) |
| 127 | + |
| 128 | + def test_abacus_cal_band_pyatb_pw(self): |
| 129 | + """ |
| 130 | + Test plot band structure in PYATB mode using PW basis. Should return a message. |
| 131 | + """ |
| 132 | + test_func_name = inspect.currentframe().f_code.co_name |
| 133 | + ref_results = load_test_ref_result(test_func_name) |
| 134 | + |
| 135 | + test_work_dir = self.test_path / test_func_name |
| 136 | + shutil.copytree(self.abacus_inputs_dir_si_prim, test_work_dir) |
| 137 | + shutil.copy2(self.si_stru_band, test_work_dir / "STRU") |
| 138 | + shutil.copy2(self.input_pw_si, test_work_dir / "INPUT") |
| 139 | + |
| 140 | + outputs = abacus_cal_band(test_work_dir, mode='pyatb') |
| 141 | + print(outputs) |
| 142 | + self.assertEqual(outputs['message'], ref_results['message']) |
| 143 | + |
| 144 | + def test_abacus_cal_band_nscf_pw_nspin1(self): |
| 145 | + """ |
| 146 | + Test plot band structure in NSCF mode using PW basis in nspin=1 case |
| 147 | + """ |
| 148 | + test_func_name = inspect.currentframe().f_code.co_name |
| 149 | + ref_results = load_test_ref_result(test_func_name) |
| 150 | + |
| 151 | + test_work_dir = self.test_path / test_func_name |
| 152 | + shutil.copytree(self.abacus_inputs_dir_si_prim, test_work_dir) |
| 153 | + shutil.copy2(self.si_stru_band, test_work_dir / "STRU") |
| 154 | + shutil.copy2(self.input_pw_si, test_work_dir / "INPUT") |
| 155 | + |
| 156 | + outputs = abacus_cal_band(test_work_dir, mode='nscf') |
| 157 | + print(outputs) |
| 158 | + |
| 159 | + band_calc_dir = outputs['band_calc_dir'] |
| 160 | + band_picture = outputs['band_picture'] |
| 161 | + self.assertIsInstance(band_calc_dir, get_path_type()) |
| 162 | + self.assertIsInstance(band_picture, get_path_type()) |
| 163 | + self.assertAlmostEqual(outputs['band_gap'], ref_results['band_gap'], places=4) |
| 164 | + |
| 165 | + def test_abacus_cal_band_nscf_pw_nspin2(self): |
| 166 | + """ |
| 167 | + Test plot band structure in NSCF mode using PW basis in nspin=2 case |
88 | 168 | """ |
89 | 169 | test_func_name = inspect.currentframe().f_code.co_name |
90 | 170 | ref_results = load_test_ref_result(test_func_name) |
91 | 171 |
|
92 | 172 | test_work_dir = self.test_path / test_func_name |
93 | 173 | shutil.copytree(self.abacus_inputs_dir_fe_bcc_prim, test_work_dir) |
94 | 174 | shutil.copy2(self.fe_stru_band, test_work_dir / "STRU") |
| 175 | + shutil.copy2(self.input_pw_fe, test_work_dir / "INPUT") |
95 | 176 |
|
96 | 177 | outputs = abacus_cal_band(test_work_dir, mode='nscf') |
97 | 178 |
|
|
0 commit comments