Skip to content

Commit 398df6d

Browse files
Liu-RXhongriTianqi
andauthored
add unformatted (binary) file support for UNK file output in Wannier90 interface (#3036)
Co-authored-by: Zhao Tianqi <hongriTianqi@users.noreply.github.com>
1 parent 444dac9 commit 398df6d

File tree

17 files changed

+112
-33
lines changed

17 files changed

+112
-33
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@
288288
- [out\_wannier\_amn](#out_wannier_amn)
289289
- [out\_wannier\_eig](#out_wannier_eig)
290290
- [out\_wannier\_unk](#out_wannier_unk)
291+
- [out\_wannier\_wvfn\_formatted](#out_wannier_wvfn_formatted)
291292
- [TDDFT: time dependent density functional theory](#tddft-time-dependent-density-functional-theory)
292293
- [td\_edm](#td_edm)
293294
- [td\_print\_eij](#td_print_eij)
@@ -2650,11 +2651,18 @@ These variables are used to control berry phase and wannier90 interface paramete
26502651
### out_wannier_unk
26512652

26522653
- **Type**: Bool
2653-
- **Description**: write the "*.UNK" file or not.
2654-
- 0: don't write the "*.UNK" file.
2655-
- 1: write the "*.UNK" file.
2654+
- **Description**: write the "UNK.*" file or not.
2655+
- 0: don't write the "UNK.*" file.
2656+
- 1: write the "UNK.*" file.
26562657
- **Default**: 1
26572658

2659+
### out_wannier_wvfn_formatted
2660+
2661+
- **Type**: Bool
2662+
- **Description**: write the "UNK.*" file in ASCII format or binary format.
2663+
- 0: write the "UNK.*" file in binary format.
2664+
- 1: write the "UNK.*" file in ASCII format (text file format).
2665+
26582666
[back to top](#full-list-of-input-keywords)
26592667

26602668
## TDDFT: time dependent density functional theory

docs/advanced/interface/Wannier90.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ To construct the MLWFs using the wave functions of ABACUS generally requires fou
9494
- [out_wannier_mmn](../input_files/input-main.md#out_wannier_mmn): control whether to output the "*.mmn" file.
9595
- [out_wannier_amn](../input_files/input-main.md#out_wannier_amn): control whether to output the "*.amn" file.
9696
- [out_wannier_eig](../input_files/input-main.md#out_wannier_eig): control whether to output the "*.eig" file.
97-
- [out_wannier_unk](../input_files/input-main.md#out_wannier_unk): control whether to output the "*.UNK" file.
97+
- [out_wannier_unk](../input_files/input-main.md#out_wannier_unk): control whether to output the "UNK.*" file.
98+
- [out_wannier_wvfn_formatted](../input_files/input-main.md#out_wannier_wvfn_formatted): control what format of the Wannier function file to output, `true`: output the formatted text file; `false`: output the binary file. Note that the `wvfn_formatted` option in `*.win` file (input file of Wannier90) has to be set accordingly with this option.
9899
99100
Note: You need to turn off the symmetry during the entire nscf calculation.
100101

source/module_esolver/esolver_ks_lcao_elec.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ namespace ModuleESolver
631631
INPUT.out_wannier_amn,
632632
INPUT.out_wannier_unk,
633633
INPUT.out_wannier_eig,
634+
INPUT.out_wannier_wvfn_formatted,
634635
this->GridT,
635636
this->pelec->ekb,
636637
this->pw_wfc,

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ void ESolver_KS_PW<T, Device>::nscf()
976976
if (INPUT.towannier90)
977977
{
978978
toWannier90 myWannier(this->kv.nkstot, GlobalC::ucell.G);
979-
myWannier.init_wannier_pw(INPUT.out_wannier_mmn, INPUT.out_wannier_amn, INPUT.out_wannier_unk, INPUT.out_wannier_eig, this->pelec->ekb, this->pw_wfc, this->pw_big, this->kv, this->psi);
979+
myWannier.init_wannier_pw(INPUT.out_wannier_mmn, INPUT.out_wannier_amn, INPUT.out_wannier_unk, INPUT.out_wannier_eig, INPUT.out_wannier_wvfn_formatted, this->pelec->ekb, this->pw_wfc, this->pw_big, this->kv, this->psi);
980980
}
981981

982982
//=======================================================

source/module_io/DEFAULT_TYPE.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ out_wannier_mmn bool
3030
out_wannier_amn bool
3131
out_wannier_unk bool
3232
out_wannier_eig bool
33+
out_wannier_wvfn_formatted bool
3334
nche_sto int
3435
nbands_sto int
3536
nbndsto_str string

source/module_io/DEFAULT_VALUE.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
out_wannier_amn true
4444
out_wannier_unk true
4545
out_wannier_eig true
46+
out_wannier_wvfn_formatted true
4647
for(int i0i<3i++){kspacing[i] = 0}
4748
min_dist_coef 0.2
4849
dft_functional "default"

source/module_io/input.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,11 @@ void Input::Default(void)
184184
out_wannier_eig = true;
185185
out_wannier_mmn = true;
186186
out_wannier_unk = true;
187-
for(int i=0;i<3;i++){kspacing[i] = 0;}
187+
out_wannier_wvfn_formatted = true;
188+
for (int i = 0; i < 3; i++)
189+
{
190+
kspacing[i] = 0;
191+
}
188192
min_dist_coef = 0.2;
189193
//----------------------------------------------------------
190194
// electrons / spin
@@ -838,6 +842,10 @@ bool Input::Read(const std::string &fn)
838842
{
839843
read_bool(ifs, out_wannier_eig);
840844
}
845+
else if (strcmp("out_wannier_wvfn_formatted", word) == 0)
846+
{
847+
read_bool(ifs, out_wannier_wvfn_formatted);
848+
}
841849
//----------------------------------------------------------
842850
// electrons / spin
843851
//----------------------------------------------------------
@@ -2908,6 +2916,7 @@ void Input::Bcast()
29082916
Parallel_Common::bcast_bool(out_wannier_amn);
29092917
Parallel_Common::bcast_bool(out_wannier_unk);
29102918
Parallel_Common::bcast_bool(out_wannier_eig);
2919+
Parallel_Common::bcast_bool(out_wannier_wvfn_formatted);
29112920

29122921
Parallel_Common::bcast_string(dft_functional);
29132922
Parallel_Common::bcast_double(xc_temperature);

source/module_io/input.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class Input
7575
bool out_wannier_amn;
7676
bool out_wannier_unk;
7777
bool out_wannier_eig;
78+
bool out_wannier_wvfn_formatted;
7879

7980
//==========================================================
8081
// Stochastic DFT

source/module_io/parameter_pool.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,10 @@ bool input_parameters_set(std::map<std::string, InputParameter> input_parameters
459459
{
460460
INPUT.out_wannier_eig = *static_cast<bool*>(input_parameters["out_wannier_eig"].get());
461461
}
462+
else if (input_parameters.count("out_wannier_wvfn_formatted") != 0)
463+
{
464+
INPUT.out_wannier_wvfn_formatted = *static_cast<bool*>(input_parameters["out_wannier_wvfn_formatted"].get());
465+
}
462466
else if (input_parameters.count("nche_sto") != 0)
463467
{
464468
INPUT.nche_sto = *static_cast<int*>(input_parameters["nche_sto"].get());

source/module_io/test/input_test.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ TEST_F(InputTest, Default)
7070
EXPECT_TRUE(INPUT.out_wannier_mmn);
7171
EXPECT_TRUE(INPUT.out_wannier_unk);
7272
EXPECT_TRUE(INPUT.out_wannier_eig);
73-
EXPECT_DOUBLE_EQ(INPUT.kspacing[0],0.0);
73+
EXPECT_TRUE(INPUT.out_wannier_wvfn_formatted);
74+
EXPECT_DOUBLE_EQ(INPUT.kspacing[0], 0.0);
7475
EXPECT_DOUBLE_EQ(INPUT.kspacing[1],0.0);
7576
EXPECT_DOUBLE_EQ(INPUT.kspacing[2],0.0);
7677
EXPECT_DOUBLE_EQ(INPUT.min_dist_coef,0.2);
@@ -414,7 +415,8 @@ TEST_F(InputTest, Read)
414415
EXPECT_TRUE(INPUT.out_wannier_mmn);
415416
EXPECT_TRUE(INPUT.out_wannier_unk);
416417
EXPECT_TRUE(INPUT.out_wannier_eig);
417-
EXPECT_DOUBLE_EQ(INPUT.kspacing[0],0.0);
418+
EXPECT_TRUE(INPUT.out_wannier_wvfn_formatted);
419+
EXPECT_DOUBLE_EQ(INPUT.kspacing[0], 0.0);
418420
EXPECT_DOUBLE_EQ(INPUT.kspacing[1],0.0);
419421
EXPECT_DOUBLE_EQ(INPUT.kspacing[2],0.0);
420422
EXPECT_DOUBLE_EQ(INPUT.min_dist_coef,0.2);

0 commit comments

Comments
 (0)