Skip to content

Commit bd415d2

Browse files
author
jiyuang
committed
add a new parameter named "out_proj_band"
1 parent 6e479ca commit bd415d2

File tree

8 files changed

+83
-66
lines changed

8 files changed

+83
-66
lines changed

docs/examples/band-struc.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pw_diag_thr 1.0e-7
2727
#Parameters (File)
2828
init_chg file
2929
out_band 1
30+
out_proj_band 1
3031
3132
#Parameters (Smearing)
3233
smearing_method gaussian
@@ -58,9 +59,9 @@ points.
5859
Run the program, and you will see a file named BANDS_1.dat in the output directory. Plot it
5960
to get energy band structure.
6061

61-
Along with the BANDS_1.dat file, we also produce the projected band structure in a file called PBAND_1 in xml format.
62+
If "out_proj_band" set 1, it will also produce the projected band structure in a file called PBAND_1 in xml format.
6263

63-
The PDOS file starts with number of atomic orbitals in the system, the text contents of element <band structure> is the same as data in the BANDS_1.dat file, such as:
64+
The PBAND_1 file starts with number of atomic orbitals in the system, the text contents of element <band structure> is the same as data in the BANDS_1.dat file, such as:
6465
```
6566
<pband>
6667
<nspin>1</nspin>

docs/input-main.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
- [Variables related to output information](#variables-related-to-output-information)
3434

35-
[out_force](#out_force) | [out_mul](#out_mul) | [out_chg](#out_chg) | [out_pot](#out_pot) | [out_dm](#out-dm) | [out_wfc_pw](#out_wfc_pw) | [out_wfc_r](#out_wfc_r) | [out_wfc_lcao](#out_wfc_lcao) | [out_dos](#out-dos) | [out_band](#out-band) | [out_stru](#out-stru) | [out_level](#out_level) | [out_alllog](#out-alllog) | [out_mat_hs](#out_mat_hs) | [out_mat_r](#out_mat_r) | [out_mat_hs2](#out_mat_hs2) | [out_element_info](#out-element-info) | [restart_save](#restart_save) | [restart_load](#restart_load)
35+
[out_force](#out_force) | [out_mul](#out_mul) | [out_chg](#out_chg) | [out_pot](#out_pot) | [out_dm](#out-dm) | [out_wfc_pw](#out_wfc_pw) | [out_wfc_r](#out_wfc_r) | [out_wfc_lcao](#out_wfc_lcao) | [out_dos](#out-dos) | [out_band](#out-band) | [out_proj_band](#out-proj-band) | [out_stru](#out-stru) | [out_level](#out_level) | [out_alllog](#out-alllog) | [out_mat_hs](#out_mat_hs) | [out_mat_r](#out_mat_r) | [out_mat_hs2](#out_mat_hs2) | [out_element_info](#out-element-info) | [restart_save](#restart_save) | [restart_load](#restart_load)
3636

3737
- [Density of states](#density-of-states)
3838

@@ -723,6 +723,12 @@ This part of variables are used to control the output of properties.
723723
- **Description**: Controls whether to output the band structure. For mroe information, refer to the [worked example](examples/band-struc.md)
724724
- **Default**: 0
725725
726+
#### out_proj_band
727+
728+
- **Type**: Integer
729+
- **Description**: Controls whether to output the projected band structure. For mroe information, refer to the [worked example](examples/band-struc.md)
730+
- **Default**: 0
731+
726732
#### out_stru
727733
728734
- **Type**: Boolean

source/input.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ void Input::Default(void)
266266
out_wfc_r = 0;
267267
out_dos = 0;
268268
out_band = 0;
269+
out_proj_band = 0;
269270
out_mat_hs = 0;
270271
out_mat_hs2 = 0; // LiuXh add 2019-07-15
271272
out_mat_r = 0; // jingan add 2019-8-14
@@ -985,6 +986,10 @@ bool Input::Read(const std::string &fn)
985986
{
986987
read_value(ifs, out_band);
987988
}
989+
else if (strcmp("out_proj_band", word) == 0)
990+
{
991+
read_value(ifs, out_proj_band);
992+
}
988993

989994
else if (strcmp("out_mat_hs", word) == 0)
990995
{
@@ -1929,6 +1934,7 @@ void Input::Bcast()
19291934
Parallel_Common::bcast_int(out_wfc_r);
19301935
Parallel_Common::bcast_int(out_dos);
19311936
Parallel_Common::bcast_int(out_band);
1937+
Parallel_Common::bcast_int(out_proj_band);
19321938
Parallel_Common::bcast_int(out_mat_hs);
19331939
Parallel_Common::bcast_int(out_mat_hs2); // LiuXh add 2019-07-15
19341940
Parallel_Common::bcast_int(out_mat_r); // jingan add 2019-8-14
@@ -2215,6 +2221,7 @@ void Input::Check(void)
22152221
out_stru = 0;
22162222
out_dos = 0;
22172223
out_band = 0;
2224+
out_proj_band = 0;
22182225
cal_force = 0;
22192226
init_wfc = "file";
22202227
init_chg = "atomic"; // useless,
@@ -2236,6 +2243,7 @@ void Input::Check(void)
22362243
out_stru = 0;
22372244
out_dos = 0;
22382245
out_band = 0;
2246+
out_proj_band = 0;
22392247
cal_force = 0;
22402248
init_wfc = "file";
22412249
init_chg = "atomic";

source/input.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ class Input
204204
int out_wfc_r; // 0: no; 1: yes
205205
int out_dos; // dos calculation. mohan add 20090909
206206
int out_band; // band calculation pengfei 2014-10-13
207+
int out_proj_band; // projected band structure calculation jiyy add 2022-05-11
207208
int out_mat_hs; // output H matrix and S matrix in local basis.
208209
int out_mat_hs2; // LiuXh add 2019-07-16, output H(R) matrix and S(R) matrix in local basis.
209210
int out_mat_r; // jingan add 2019-8-14, output r(R) matrix.

source/input_conv.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ void Input_Conv::Convert(void)
432432
GlobalC::wf.out_wfc_r = INPUT.out_wfc_r;
433433
GlobalC::en.out_dos = INPUT.out_dos;
434434
GlobalC::en.out_band = INPUT.out_band;
435+
GlobalC::en.out_proj_band = INPUT.out_proj_band;
435436
#ifdef __LCAO
436437
Local_Orbital_Charge::out_dm = INPUT.out_dm;
437438
Pdiag_Double::out_mat_hs = INPUT.out_mat_hs;

source/src_io/energy_dos.cpp

Lines changed: 59 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void energy::perform_dos(Local_Orbital_wfc &lowf, LCAO_Hamilt &uhm)
2929

3030
const Parallel_Orbitals* pv = uhm.LM->ParaV;
3131

32-
if(out_dos !=0 || out_band !=0)
32+
if(out_dos !=0 || out_band !=0 || out_proj_band !=0)
3333
{
3434
GlobalV::ofs_running << "\n\n\n\n";
3535
GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
@@ -536,34 +536,7 @@ void energy::perform_dos(Local_Orbital_wfc &lowf, LCAO_Hamilt &uhm)
536536

537537
out << "<"<<"/"<<"pdos"<<">" <<std::endl;
538538
out.close();}
539-
{ std::stringstream os;
540-
os<<GlobalV::global_out_dir<<"Orbital";
541-
std::ofstream out(os.str().c_str());
542-
out<< std::setw(5)<<"io"<< std::setw(8) <<"spec" <<std::setw(5)<<"l"<<std::setw(5)<<"m"<<std::setw(5)<<"z"<<std::setw(5)<<"sym"<<std::endl;
543-
544-
545-
for (int i=0; i<GlobalC::ucell.nat; i++)
546-
{
547-
int t = GlobalC::ucell.iat2it[i];
548-
Atom* atom1 = &GlobalC::ucell.atoms[t];
549-
for(int j=0; j<atom1->nw; ++j)
550-
{
551-
const int L1 = atom1->iw2l[j];
552-
const int N1 = atom1->iw2n[j];
553-
const int m1 = atom1->iw2m[j];
554-
out <<std::setw(5) << i << std::setw(8)
555-
<< GlobalC::ucell.atoms[t].label <<std::setw(5)
556-
<<L1<<std::setw(5) <<m1<<std::setw(5)<<N1+1<<std::setw(15)<< GlobalC::en.Name_Angular[L1][m1] << std::endl;
557-
}
558-
}
559-
out <<std::endl<<std::endl;
560-
out <<std::setw(5)<< "io"<<std::setw(2)<<"="<<std::setw(2)<<"Orbital index in supercell"<<std::endl;
561-
out <<std::setw(5)<< "spec"<<std::setw(2)<<"="<<std::setw(2)<<"Atomic species label"<<std::endl;
562-
out <<std::setw(5)<< "l"<<std::setw(2)<<"="<<std::setw(2)<<"Angular mumentum quantum number"<<std::endl;
563-
out <<std::setw(5)<< "m"<<std::setw(2)<<"="<<std::setw(2)<<"Magnetic quantum number"<<std::endl;
564-
out <<std::setw(5)<< "z"<<std::setw(2)<<"="<<std::setw(2)<<"Zeta index of orbital"<<std::endl;
565-
out <<std::setw(5)<< "sym"<<std::setw(2)<<"="<<std::setw(2)<<"Symmetry name of real orbital"<<std::endl;
566-
out.close();}
539+
this->print_orbital_file();
567540

568541
}
569542
delete[] pdos;
@@ -642,6 +615,28 @@ void energy::perform_dos(Local_Orbital_wfc &lowf, LCAO_Hamilt &uhm)
642615
nks = GlobalC::kv.nkstot/2;
643616
}
644617

618+
for(int is=0; is<nspin0; is++)
619+
{
620+
std::stringstream ss2;
621+
ss2 << GlobalV::global_out_dir << "BANDS_" << is+1 << ".dat";
622+
GlobalV::ofs_running << "\n Output bands in file: " << ss2.str() << std::endl;
623+
Dos::nscf_band(is, ss2.str(), nks, GlobalV::NBANDS, this->ef*0, GlobalC::wf.ekb);
624+
625+
}
626+
}//out_band
627+
628+
if(this->out_proj_band) // Projeced band structure added by jiyy-2022-4-20
629+
{
630+
int nks=0;
631+
if(nspin0==1)
632+
{
633+
nks = GlobalC::kv.nkstot;
634+
}
635+
else if(nspin0==2)
636+
{
637+
nks = GlobalC::kv.nkstot/2;
638+
}
639+
645640
ModuleBase::ComplexMatrix weightk;
646641
ModuleBase::matrix weight;
647642
int NUM = 0;
@@ -660,12 +655,7 @@ void energy::perform_dos(Local_Orbital_wfc &lowf, LCAO_Hamilt &uhm)
660655

661656
for(int is=0; is<nspin0; is++)
662657
{
663-
std::stringstream ss2;
664-
ss2 << GlobalV::global_out_dir << "BANDS_" << is+1 << ".dat";
665-
GlobalV::ofs_running << "\n Output bands in file: " << ss2.str() << std::endl;
666-
Dos::nscf_band(is, ss2.str(), nks, GlobalV::NBANDS, this->ef*0, GlobalC::wf.ekb);
667658

668-
// Projeced band structure added by jiyy-2022-4-20
669659
if(GlobalV::GAMMA_ONLY_LOCAL)
670660
{
671661
std::vector<ModuleBase::matrix> Mulk;
@@ -893,35 +883,41 @@ void energy::perform_dos(Local_Orbital_wfc &lowf, LCAO_Hamilt &uhm)
893883
out << "<"<<"/"<<"pband"<<">" <<std::endl;
894884
out.close();}
895885
}//is
896-
{ std::stringstream os;
897-
os<<GlobalV::global_out_dir<<"Orbital";
898-
std::ofstream out(os.str().c_str());
899-
out<< std::setw(5)<<"io"<< std::setw(8) <<"spec" <<std::setw(5)<<"l"<<std::setw(5)<<"m"<<std::setw(5)<<"z"<<std::setw(5)<<"sym"<<std::endl;
900-
901-
902-
for (int i=0; i<GlobalC::ucell.nat; i++)
903-
{
904-
int t = GlobalC::ucell.iat2it[i];
905-
Atom* atom1 = &GlobalC::ucell.atoms[t];
906-
for(int j=0; j<atom1->nw; ++j)
907-
{
908-
const int L1 = atom1->iw2l[j];
909-
const int N1 = atom1->iw2n[j];
910-
const int m1 = atom1->iw2m[j];
911-
out <<std::setw(5) << i << std::setw(8)
912-
<< GlobalC::ucell.atoms[t].label <<std::setw(5)
913-
<<L1<<std::setw(5) <<m1<<std::setw(5)<<N1+1<<std::setw(15)<< GlobalC::en.Name_Angular[L1][m1] << std::endl;
914-
}
915-
}
916-
out <<std::endl<<std::endl;
917-
out <<std::setw(5)<< "io"<<std::setw(2)<<"="<<std::setw(2)<<"Orbital index in supercell"<<std::endl;
918-
out <<std::setw(5)<< "spec"<<std::setw(2)<<"="<<std::setw(2)<<"Atomic species label"<<std::endl;
919-
out <<std::setw(5)<< "l"<<std::setw(2)<<"="<<std::setw(2)<<"Angular mumentum quantum number"<<std::endl;
920-
out <<std::setw(5)<< "m"<<std::setw(2)<<"="<<std::setw(2)<<"Magnetic quantum number"<<std::endl;
921-
out <<std::setw(5)<< "z"<<std::setw(2)<<"="<<std::setw(2)<<"Zeta index of orbital"<<std::endl;
922-
out <<std::setw(5)<< "sym"<<std::setw(2)<<"="<<std::setw(2)<<"Symmetry name of real orbital"<<std::endl;
923-
out.close();}
924-
}//out_band
886+
this->print_orbital_file();
887+
}//out_proj_band
925888
return;
926889
}
927890

891+
void energy::print_orbital_file(void)
892+
{
893+
std::stringstream os;
894+
os<<GlobalV::global_out_dir<<"Orbital";
895+
std::ofstream out(os.str().c_str());
896+
out<< std::setw(5)<<"io"<< std::setw(8) <<"spec" <<std::setw(5)<<"l"<<std::setw(5)<<"m"<<std::setw(5)<<"z"<<std::setw(5)<<"sym"<<std::endl;
897+
898+
899+
for (int i=0; i<GlobalC::ucell.nat; i++)
900+
{
901+
int t = GlobalC::ucell.iat2it[i];
902+
Atom* atom1 = &GlobalC::ucell.atoms[t];
903+
for(int j=0; j<atom1->nw; ++j)
904+
{
905+
const int L1 = atom1->iw2l[j];
906+
const int N1 = atom1->iw2n[j];
907+
const int m1 = atom1->iw2m[j];
908+
out <<std::setw(5) << i << std::setw(8)
909+
<< GlobalC::ucell.atoms[t].label <<std::setw(5)
910+
<<L1<<std::setw(5) <<m1<<std::setw(5)<<N1+1<<std::setw(15)<< GlobalC::en.Name_Angular[L1][m1] << std::endl;
911+
}
912+
}
913+
out <<std::endl<<std::endl;
914+
out <<std::setw(5)<< "io"<<std::setw(2)<<"="<<std::setw(2)<<"Orbital index in supercell"<<std::endl;
915+
out <<std::setw(5)<< "spec"<<std::setw(2)<<"="<<std::setw(2)<<"Atomic species label"<<std::endl;
916+
out <<std::setw(5)<< "l"<<std::setw(2)<<"="<<std::setw(2)<<"Angular mumentum quantum number"<<std::endl;
917+
out <<std::setw(5)<< "m"<<std::setw(2)<<"="<<std::setw(2)<<"Magnetic quantum number"<<std::endl;
918+
out <<std::setw(5)<< "z"<<std::setw(2)<<"="<<std::setw(2)<<"Zeta index of orbital"<<std::endl;
919+
out <<std::setw(5)<< "sym"<<std::setw(2)<<"="<<std::setw(2)<<"Symmetry name of real orbital"<<std::endl;
920+
out.close();
921+
922+
return;
923+
}

source/src_io/write_input.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ void Input::Print(const std::string &fn) const
9797
ModuleBase::GlobalFunc::OUTP(ofs, "out_wfc_r", out_wfc_r, "output wave functions in realspace");
9898
ModuleBase::GlobalFunc::OUTP(ofs, "out_dos", out_dos, "output energy and dos");
9999
ModuleBase::GlobalFunc::OUTP(ofs, "out_band", out_band, "output energy and band structure");
100+
ModuleBase::GlobalFunc::OUTP(ofs, "out_proj_band", out_proj_band, "output projected band structure");
100101
ModuleBase::GlobalFunc::OUTP(ofs, "restart_save", restart_save, "print to disk every step for restart");
101102
ModuleBase::GlobalFunc::OUTP(ofs, "restart_load", restart_load, "restart from disk");
102103
ModuleBase::GlobalFunc::OUTP(ofs, "read_file_dir", read_file_dir, "directory of files for reading");

source/src_pw/energy.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class energy
5858

5959
int out_dos; // control dos calculation
6060
int out_band; // control band calculation pengfei 2014-10-13
61+
int out_proj_band; // control projected band calculation jiyy add 2022-05-11
6162
const std::string Name_Angular[5][11] =
6263
{
6364
{"s"},
@@ -89,6 +90,8 @@ class energy
8990

9091
void print_format(const std::string &name, const double &value);
9192

93+
void print_orbital_file();
94+
9295
void calculate_harris(const int &flag); //mohan add 2012-06-05
9396

9497
double delta_e(void);

0 commit comments

Comments
 (0)