Skip to content

Commit dbc9f7d

Browse files
committed
Test: add tests for pw ldos
1 parent 03dbbe6 commit dbc9f7d

File tree

13 files changed

+2351
-13
lines changed

13 files changed

+2351
-13
lines changed

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
421421
}
422422

423423
// out ldos
424-
if (PARAM.inp.out_ldos)
424+
if (PARAM.inp.out_ldos[0])
425425
{
426426
ModuleIO::Cal_ldos<TK>::cal_ldos_lcao(reinterpret_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec),
427427
this->psi[0],

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ void ESolver_KS_PW<T, Device>::after_all_runners(UnitCell& ucell)
853853
}
854854

855855
// out ldos
856-
if (PARAM.inp.out_ldos)
856+
if (PARAM.inp.out_ldos[0])
857857
{
858858
ModuleIO::Cal_ldos<std::complex<double>>::cal_ldos_pw(
859859
reinterpret_cast<elecstate::ElecStatePW<std::complex<double>>*>(this->pelec),

source/module_io/cal_ldos.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ void Cal_ldos<T>::cal_ldos_pw(const elecstate::ElecStatePW<std::complex<double>>
4343
fn << PARAM.globalv.global_out_dir << "LDOS_" << PARAM.inp.stm_bias << "eV"
4444
<< ".cube";
4545

46-
ModuleIO::write_vdata_palgrid(pgrid, ldos.data(), 0, PARAM.inp.nspin, 0, fn.str(), 0, &ucell, 11, 0);
46+
const int precision = PARAM.inp.out_ldos[1];
47+
ModuleIO::write_vdata_palgrid(pgrid, ldos.data(), 0, PARAM.inp.nspin, 0, fn.str(), 0, &ucell, precision, 0);
4748
}
4849

4950
#ifdef __LCAO

source/module_io/read_input_item_output.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,17 @@ void ReadInput::item_output()
145145
}
146146
{
147147
Input_Item item("out_ldos");
148-
item.annotation = "output local density of states";
149-
read_sync_bool(input.out_ldos);
148+
item.annotation = "output local density of states, second parameter controls the precision";
149+
item.read_value = [](const Input_Item& item, Parameter& para) {
150+
const size_t count = item.get_size();
151+
if (count != 1 && count != 2)
152+
{
153+
ModuleBase::WARNING_QUIT("ReadInput", "out_ldos should have 1 or 2 values");
154+
}
155+
para.input.out_ldos[0] = assume_as_boolean(item.str_values[0]);
156+
para.input.out_ldos[1] = (count == 2) ? std::stoi(item.str_values[1]) : 3;
157+
};
158+
sync_intvec(input.out_ldos, 2, 0);
150159
this->add_item(item);
151160
}
152161
{

source/module_io/read_input_item_postprocess.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void ReadInput::item_postprocess()
5858
item.annotation = "bias voltage used to calculate ldos";
5959
read_sync_double(input.stm_bias);
6060
item.check_value = [](const Input_Item& item, const Parameter& para) {
61-
if (para.input.out_ldos && para.input.stm_bias == 0.0)
61+
if (para.input.out_ldos[0] && para.input.stm_bias == 0.0)
6262
{
6363
ModuleBase::WARNING_QUIT("ReadInput", "a nonzero stm_bias is required for ldos calculation");
6464
}

source/module_io/test/read_input_ptest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ TEST_F(InputParaTest, ParaRead)
201201
EXPECT_EQ(param.inp.out_wfc_pw, 0);
202202
EXPECT_EQ(param.inp.out_wfc_r, 0);
203203
EXPECT_EQ(param.inp.out_dos, 0);
204-
EXPECT_EQ(param.inp.out_ldos, true);
204+
EXPECT_EQ(param.inp.out_ldos[0], 1);
205+
EXPECT_EQ(param.inp.out_ldos[1], 3);
205206
EXPECT_EQ(param.inp.out_band[0], 0);
206207
EXPECT_EQ(param.inp.out_band[1], 8);
207208
EXPECT_EQ(param.inp.out_proj_band, 0);

source/module_io/test/support/INPUT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ out_pot 2 #output realspace potential
6565
out_wfc_pw 0 #output wave functions
6666
out_wfc_r 0 #output wave functions in realspace
6767
out_dos 0 #output energy and dos
68-
out_ldos True #output local density of states
68+
out_ldos 1 #output local density of states, second parameter controls the precision
6969
out_band 0 #output energy and band structure
7070
out_proj_band FaLse #output projected band structure
7171
restart_save f #print to disk every step for restart

source/module_io/test_serial/read_input_item_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ TEST_F(InputTest, Item_test)
393393
}
394394
{ // stm_bias
395395
auto it = find_label("stm_bias", readinput.input_lists);
396-
param.input.out_ldos = true;
396+
param.input.out_ldos[0] = 1;
397397
param.input.stm_bias = 0.0;
398398

399399
testing::internal::CaptureStdout();

source/module_parameter/input_parameter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ struct Input_para
363363
int printe = 0; ///< Print out energy for each band for every printe step, default is scf_nmax
364364
std::vector<int> out_band = {0, 8}; ///< band calculation pengfei 2014-10-13
365365
int out_dos = 0; ///< dos calculation. mohan add 20090909
366-
bool out_ldos = false; ///< ldos calculation
366+
std::vector<int> out_ldos = {0, 3}; ///< ldos calculation
367367
bool out_mul = false; ///< qifeng add 2019-9-10
368368
bool out_proj_band = false; ///< projected band structure calculation jiyy add 2022-05-11
369369
std::string out_level = "ie"; ///< control the output information.

tests/integrate/101_PW_15_pseudopots/INPUT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ smearing_sigma 0.002
2323
#Parameters (5.Mixing)
2424
mixing_type broyden
2525
mixing_beta 0.7
26+
27+
out_ldos 1
28+
stm_bias 2

0 commit comments

Comments
 (0)