Skip to content

Commit daa09b4

Browse files
authored
Merge pull request #816 from dyzheng/new
Update from abacusmodeling/abacus-develop : 1, openmp for LCAO; 2, restart with PlusU; 3, out_hs for all k-points
2 parents 5366a1f + 03c335b commit daa09b4

File tree

20 files changed

+1130
-568
lines changed

20 files changed

+1130
-568
lines changed

doc/input-main.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ This part of variables are used to control the output of properties.
813813
814814
- out_mat_hs<a id="out_mat_hs"></a>
815815
- *Type*: Boolean
816-
- *Description*: Only for LCAO calculations. When set to 1, ABACUS will generate two files `data-H` and `data-S` that store the Hamiltonian and S matrix in k space, respectively.
816+
- *Description*: Only for LCAO calculations. When set to 1, ABACUS will generate two lists of files `data-$k-H` and `data-$k-S` that store the Hamiltonian and S matrix for each k point in k space, respectively.
817817
- *Default*: 0
818818
819819
[back to top](#input-file)

source/module_neighbor/sltk_grid_driver.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,33 @@ ModuleBase::Vector3<double> Grid_Driver::Calculate_adjacent_site
314314

315315
return adjacent_site;
316316
}
317+
318+
std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>> Grid_Driver::get_adjs(const UnitCell_pseudo& ucell_in, const size_t &iat)
319+
{
320+
const int it = ucell_in.iat2it[iat];
321+
const int ia = ucell_in.iat2ia[iat];
322+
const ModuleBase::Vector3<double> &tau = ucell_in.atoms[it].tau[ia];
323+
324+
std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>> adjs;
325+
this->Find_atom(ucell_in, tau, it, ia);
326+
for(int ad=0; ad<this->getAdjacentNum()+1; ad++)
327+
{
328+
const size_t it_ad = this->getType(ad);
329+
const size_t ia_ad = this->getNatom(ad);
330+
const ModuleBase::Vector3<int> box_ad = this->getBox(ad);
331+
const ModuleBase::Vector3<double> tau_ad = this->getAdjacentTau(ad);
332+
333+
adjs.push_back(std::make_tuple(it_ad, ia_ad, box_ad, tau_ad));
334+
}
335+
return adjs;
336+
}
337+
338+
std::vector<std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>>> Grid_Driver::get_adjs(const UnitCell_pseudo& ucell_in)
339+
{
340+
std::vector<std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>>> adjs(ucell_in.nat);
341+
for(size_t iat=0; iat<ucell_in.nat; iat++)
342+
{
343+
adjs[iat] = Grid_Driver::get_adjs(ucell_in, iat);
344+
}
345+
return adjs;
346+
}

source/module_neighbor/sltk_grid_driver.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
#include "sltk_atom.h"
77
#include "sltk_atom_input.h"
88
#include "sltk_grid.h"
9-
#include "../module_base/global_function.h"
10-
#include "../module_base/global_variable.h"
11-
#include "../module_base/vector3.h"
12-
#include "../src_pw/pw_basis.h"
9+
#include "module_base/global_function.h"
10+
#include "module_base/global_variable.h"
11+
#include "module_base/vector3.h"
12+
#include "src_pw/pw_basis.h"
13+
#include "module_cell/unitcell_pseudo.h"
14+
#include <tuple>
1315

1416
class Grid_Driver : public Grid
1517
{
@@ -50,6 +52,9 @@ class Grid_Driver : public Grid
5052
const ModuleBase::Vector3<double>& getAdjacentTau(const int i) const { return adjacent_tau[i]; }
5153
const ModuleBase::Vector3<int>& getBox(const int i) const {return box[i];}
5254

55+
std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>> get_adjs(const UnitCell_pseudo& ucell_in, const size_t &iat);
56+
std::vector<std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>>> get_adjs(const UnitCell_pseudo& ucell_in);
57+
5358
private:
5459

5560
mutable int adj_num;

source/src_io/write_HS.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
#include "../src_parallel/parallel_reduce.h"
44
#include "../module_base/timer.h"
55

6-
void HS_Matrix::saving_HS(const double *Hloc, const double* Sloc, bool bit, const int &out_mat_hs, const Parallel_Orbitals &pv)
6+
void HS_Matrix::saving_HS(const double *Hloc, const double* Sloc, const bool bit, const int &out_mat_hs, const std::string &file_name, const Parallel_Orbitals &pv)
77
{
88
if(out_mat_hs==1)
99
{
10-
save_HS(Hloc, Sloc, bit, pv);
10+
save_HS(Hloc, Sloc, bit, file_name, pv);
1111
}
1212
else if(out_mat_hs==2)
1313
{
14-
save_HS(Hloc, Sloc, bit, pv);
14+
save_HS(Hloc, Sloc, bit, file_name, pv);
1515
}
1616
else if(out_mat_hs==3)
1717
{
@@ -108,7 +108,7 @@ void HS_Matrix::save_HS_ccf(const int &iter, const int &Hnnz, const int *colptr_
108108

109109
// mohan add 2010/3/20, output H and S matrix, convinence for diagonalization
110110
// test or save the middle information for next start.
111-
void HS_Matrix::save_HS(const double *H, const double *S, bool bit, const Parallel_Orbitals &pv)
111+
void HS_Matrix::save_HS(const double *H, const double *S, const bool bit, const std::string &file_name, const Parallel_Orbitals &pv)
112112
{
113113
ModuleBase::TITLE("HS_Matrix","save_HS_bit");
114114
ModuleBase::timer::tick("HS_Matrix","save_HS_bit");
@@ -119,13 +119,13 @@ void HS_Matrix::save_HS(const double *H, const double *S, bool bit, const Parall
119119

120120
if(bit)
121121
{
122-
ssh << GlobalV::global_out_dir << "data-H-bit";
123-
sss << GlobalV::global_out_dir << "data-S-bit";
122+
ssh << GlobalV::global_out_dir << file_name+"-H-bit";
123+
sss << GlobalV::global_out_dir << file_name+"-S-bit";
124124
}
125125
else
126126
{
127-
ssh << GlobalV::global_out_dir << "data-H";
128-
sss << GlobalV::global_out_dir << "data-S";
127+
ssh << GlobalV::global_out_dir << file_name+"-H";
128+
sss << GlobalV::global_out_dir << file_name+"-S";
129129
}
130130

131131
if (bit)
@@ -369,11 +369,11 @@ void HS_Matrix::save_HS(const double *H, const double *S, bool bit, const Parall
369369
}
370370

371371
//LiuXh, 2017-03-21
372-
void HS_Matrix::saving_HS_complex(std::complex<double> *Hloc, std::complex<double>* Sloc, bool bit, const int &out_mat_hs, const Parallel_Orbitals &pv)
372+
void HS_Matrix::saving_HS_complex(std::complex<double> *Hloc, std::complex<double>* Sloc, const bool bit, const int &out_mat_hs, const std::string &file_name, const Parallel_Orbitals &pv)
373373
{
374374
if(out_mat_hs==1)
375375
{
376-
save_HS_complex(Hloc, Sloc, bit, pv);
376+
save_HS_complex(Hloc, Sloc, bit, file_name, pv);
377377
}
378378
else if(out_mat_hs==0)
379379
{
@@ -387,7 +387,7 @@ void HS_Matrix::saving_HS_complex(std::complex<double> *Hloc, std::complex<doubl
387387
}
388388

389389
//LiuXh, 2017-03-21
390-
void HS_Matrix::save_HS_complex(std::complex<double> *H, std::complex<double> *S, bool bit, const Parallel_Orbitals &pv)
390+
void HS_Matrix::save_HS_complex(std::complex<double> *H, std::complex<double> *S, const bool bit, const std::string &file_name, const Parallel_Orbitals &pv)
391391
{
392392
ModuleBase::TITLE("HS_Matrix","save_HS_bit");
393393
ModuleBase::timer::tick("HS_Matrix","save_HS_bit");
@@ -398,13 +398,13 @@ void HS_Matrix::save_HS_complex(std::complex<double> *H, std::complex<double> *S
398398

399399
if(bit)
400400
{
401-
ssh << GlobalV::global_out_dir << "data-H-bit";
402-
sss << GlobalV::global_out_dir << "data-S-bit";
401+
ssh << GlobalV::global_out_dir << file_name+"-H-bit";
402+
sss << GlobalV::global_out_dir << file_name+"-S-bit";
403403
}
404404
else
405405
{
406-
ssh << GlobalV::global_out_dir << "data-H";
407-
sss << GlobalV::global_out_dir << "data-S";
406+
ssh << GlobalV::global_out_dir << file_name+"-H";
407+
sss << GlobalV::global_out_dir << file_name+"-S";
408408
}
409409

410410
if (bit)

source/src_io/write_HS.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
#include "../module_base/global_variable.h"
66
#include "src_lcao/LCAO_matrix.h"
77

8+
#include <string>
9+
810
// mohan add this file 2010-09-10
911
namespace HS_Matrix
1012
{
11-
void saving_HS(const double *Hloc, const double* Sloc, bool bit, const int &out_mat_hs, const Parallel_Orbitals &pv);
13+
void saving_HS(const double *Hloc, const double* Sloc, const bool bit, const int &out_hs, const std::string &file_name, const Parallel_Orbitals &pv);
1214

13-
void save_HS(const double *H, const double *S, bool bit, const Parallel_Orbitals &pv);
15+
void save_HS(const double *H, const double *S, const bool bit, const std::string &file_name, const Parallel_Orbitals &pv);
1416

15-
void save_HS_complex(const std::complex<double> *H, const std::complex<double> *S, bool bit, const Parallel_Orbitals &pv);
17+
void save_HS_complex(const std::complex<double> *H, const std::complex<double> *S, const bool bit, const std::string &file__name, const Parallel_Orbitals &pv);
1618

1719
void save_HSR_tr(const int current_spin, LCAO_Matrix &lm); //LiuXh add 2019-07-15
1820

@@ -38,9 +40,9 @@ namespace HS_Matrix
3840
// void save_HS_ccf(const int &iter, const int &Hnnz, const int *colptr_H, const int *rowind_H,
3941
// const double *nzval_H, const double *nzval_S, bool bit);
4042

41-
void saving_HS_complex(std::complex<double> *Hloc, std::complex<double>* Sloc, bool bit, const int &out_mat_hs, const Parallel_Orbitals &pv); //LiuXh, 2017-03-21
43+
void saving_HS_complex(std::complex<double> *Hloc, std::complex<double>* Sloc, bool bit, const int &out_hs, const std::string &file__name, const Parallel_Orbitals &pv); //LiuXh, 2017-03-21
4244

43-
void save_HS_complex(std::complex<double> *H, std::complex<double> *S, bool bit, const Parallel_Orbitals &pv); //LiuXh, 2017-03-21
45+
void save_HS_complex(std::complex<double> *H, std::complex<double> *S, const bool bit, const std::string &file__name, const Parallel_Orbitals &pv); //LiuXh, 2017-03-21
4446
}
4547

4648
#endif

source/src_lcao/DM_gamma.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ void Local_Orbital_Charge::cal_dk_gamma_from_2D(void)
330330
// GlobalV::ofs_running<<"DM(1,0)"<<wfc_dm_2d.dm_gamma[is](0,1)<<" ";
331331
// GlobalV::ofs_running<<"DM(1,1)"<<wfc_dm_2d.dm_gamma[is](1,1)<<std::endl;
332332
// }
333-
GlobalV::ofs_running<<"2D block parameters:\n"<<"nblk: "<<this->ParaV->nb<<std::endl;
333+
/*GlobalV::ofs_running<<"2D block parameters:\n"<<"nblk: "<<this->ParaV->nb<<std::endl;
334334
GlobalV::ofs_running<<"DM in 2D format:\n_________________________________________\n";
335335
for(int i=0; i<this->dm_gamma[is].nr; ++i)
336336
{
@@ -340,7 +340,7 @@ void Local_Orbital_Charge::cal_dk_gamma_from_2D(void)
340340
}
341341
GlobalV::ofs_running<<std::endl;
342342
}
343-
GlobalV::ofs_running<<"=========================================\n";
343+
GlobalV::ofs_running<<"=========================================\n";*/
344344

345345
// put data from dm_gamma[is] to sender index
346346
int nNONZERO=0;
@@ -406,7 +406,7 @@ void Local_Orbital_Charge::cal_dk_gamma_from_2D(void)
406406
// }
407407
//GlobalV::ofs_running<<DM[0][0][0]<<" "<<DM[0][0][1]<<std::endl;
408408
//GlobalV::ofs_running<<DM[0][1][0]<<" "<<DM[0][1][1]<<std::endl;
409-
GlobalV::ofs_running<<"DM in local grid:\n_________________________________________\n";
409+
/*GlobalV::ofs_running<<"DM in local grid:\n_________________________________________\n";
410410
for(int i=0; i<GlobalV::NLOCAL; ++i)
411411
{
412412
int ii=GlobalC::GridT.trace_lo[i];
@@ -419,7 +419,7 @@ void Local_Orbital_Charge::cal_dk_gamma_from_2D(void)
419419
}
420420
GlobalV::ofs_running<<std::endl;
421421
}
422-
GlobalV::ofs_running<<"=========================================\n";
422+
GlobalV::ofs_running<<"=========================================\n";*/
423423

424424
}
425425
ModuleBase::timer::tick("LCAO_Charge","dm_2dTOgrid");
@@ -589,7 +589,7 @@ void Local_Orbital_Charge::cal_dk_gamma(void)
589589
} // end for col_count
590590
} // end for row_count
591591

592-
GlobalV::ofs_running<<"DM[0][0:1][0:1] in cal_dk_gamma:"<<std::endl;
592+
/*GlobalV::ofs_running<<"DM[0][0:1][0:1] in cal_dk_gamma:"<<std::endl;
593593
594594
int idx0=GlobalC::GridT.trace_lo[0];
595595
int idx1=GlobalC::GridT.trace_lo[1];
@@ -606,7 +606,7 @@ void Local_Orbital_Charge::cal_dk_gamma(void)
606606
if(idx1>=0)
607607
{
608608
GlobalV::ofs_running<<"DM(1,1)"<<DM[is][idx1][idx1]<<std::endl;
609-
}
609+
}*/
610610
} // end for is
611611
#endif //2015-09-06, xiaohui
612612

source/src_lcao/ELEC_scf.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -465,17 +465,6 @@ void ELEC_scf::scf(const int& istep,
465465
GlobalC::chi0_hilbert.Chi();
466466
}
467467

468-
//quxin add for DFT+U for nscf calculation
469-
if(INPUT.dft_plus_u)
470-
{
471-
if(GlobalC::CHR.out_chg)
472-
{
473-
std::stringstream sst;
474-
sst << GlobalV::global_out_dir << "onsite.dm";
475-
GlobalC::dftu.write_occup_m( sst.str() );
476-
}
477-
}
478-
479468
for(int is=0; is<GlobalV::NSPIN; is++)
480469
{
481470
const int precision = 3;

source/src_lcao/LCAO_diago.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void Diago_LCAO_Matrix::using_HPSEPS_complex(const int &ik, Local_Orbital_wfc &l
4646
//lowf.ParaV->out_mat_hs=1;//zhengdy-soc-test
4747
bool bit = false; //LiuXh, 2017-03-21
4848
//if set bit = true, there would be error in soc-multi-core calculation, noted by zhengdy-soc
49-
HS_Matrix::saving_HS_complex(this->LM->Hloc2.data(), this->LM->Sloc2.data(), bit, this->out_mat_hs, *lowf.ParaV); //LiuXh, 2017-03-21
49+
HS_Matrix::saving_HS_complex(this->LM->Hloc2.data(), this->LM->Sloc2.data(), bit, this->out_mat_hs, "data-"+std::to_string(ik), *lowf.ParaV); //LiuXh, 2017-03-21
5050
GlobalV::ofs_running << std::setprecision(6); //LiuXh, 2017-03-21
5151

5252
this->diago_complex_begin(ik, lowf, this->LM->Hloc2.data(), this->LM->Sloc2.data(), this->LM->Sdiag2.data(), GlobalC::wf.ekb[ik]);
@@ -145,7 +145,7 @@ void Diago_LCAO_Matrix::using_LAPACK(const int &ik, Local_Orbital_wfc &lowf)cons
145145
// save H and S matrix to disk.
146146
// bool bit = false;
147147
bool bit = true;//zhengdy-soc
148-
HS_Matrix::saving_HS(this->LM->Hloc.data(), this->LM->Sloc.data(), bit, this->out_mat_hs, *lowf.ParaV);
148+
HS_Matrix::saving_HS(this->LM->Hloc.data(), this->LM->Sloc.data(), bit, this->out_mat_hs, "data-"+std::to_string(ik), *lowf.ParaV);
149149

150150
ModuleBase::matrix Htmp(GlobalV::NLOCAL,GlobalV::NLOCAL);
151151
ModuleBase::matrix Stmp(GlobalV::NLOCAL,GlobalV::NLOCAL);
@@ -260,7 +260,7 @@ void Diago_LCAO_Matrix::using_HPSEPS_double(const int &ik, Local_Orbital_wfc &lo
260260

261261
// save H and S matrix to disk.
262262
bool bit = false;
263-
HS_Matrix::saving_HS(this->LM->Hloc.data(), this->LM->Sloc.data(), bit, this->out_mat_hs, *lowf.ParaV);
263+
HS_Matrix::saving_HS(this->LM->Hloc.data(), this->LM->Sloc.data(), bit, this->out_mat_hs, "data-"+std::to_string(ik), *lowf.ParaV);
264264
GlobalV::ofs_running << std::setprecision(6);
265265

266266
// Distribution of matrix for

0 commit comments

Comments
 (0)