Skip to content

Commit abdc863

Browse files
mohanchenabacus_fixer
andauthored
For source_cell module, standardize code formatting, align contents, and substitute tabs with spaces (deepmodeling#7669)
* Unify the code formatting, align code elements, and replace tabs with spaces. * fix bug * fix --------- Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
1 parent f26d766 commit abdc863

54 files changed

Lines changed: 4721 additions & 4721 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

source/source_cell/atom_pseudo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void Atom_pseudo::set_d_so(ModuleBase::ComplexMatrix& d_so_in,
6767
else // zhengdy-soc
6868
{
6969
this->d_so.create(spin_dimension, nproj_soc + 1, nproj_soc + 1);
70-
// std::cout << "lmax=" << lmax << std::endl;
70+
// std::cout << "lmax=" << lmax << std::endl;
7171

7272
if (this->lmax > -1)
7373
{
@@ -87,10 +87,10 @@ void Atom_pseudo::set_d_so(ModuleBase::ComplexMatrix& d_so_in,
8787
if (fabs(this->d_so(is, L1, L2).real()) > 1.0e-8
8888
|| fabs(this->d_so(is, L1, L2).imag()) > 1.0e-8)
8989
{
90-
// std::cout << "tt in atom is=" << is << " L1=" <<
90+
// std::cout << "tt in atom is=" << is << " L1=" <<
9191
//L1
9292
//<< " L2="
93-
// << L2 << " " << d_so(is, L1, L2) << std::endl;
93+
// << L2 << " " << d_so(is, L1, L2) << std::endl;
9494

9595
this->index1_soc[is][non_zero_count_soc[is]] = L1;
9696
this->index2_soc[is][non_zero_count_soc[is]] = L2;

source/source_cell/atom_pseudo.h

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,41 @@ class Atom_pseudo : public pseudo
1111
{
1212
public:
1313

14-
Atom_pseudo();
15-
~Atom_pseudo();
16-
17-
// mohan add 2021-05-07
18-
ModuleBase::ComplexArray d_so; //(:,:,:), spin-orbit case
19-
ModuleBase::matrix d_real; //(:,:), non-spin-orbit case
20-
int nproj;
21-
int nproj_soc; // dimension of D_ij^so
22-
std::vector<int> non_zero_count_soc = {0, 0, 0, 0};
23-
std::vector<std::vector<int>> index1_soc = {{}, {}, {}, {}};
24-
std::vector<std::vector<int>> index2_soc = {{}, {}, {}, {}};
25-
26-
void set_d_so( // mohan add 2021-05-07
27-
ModuleBase::ComplexMatrix &d_so_in,
28-
const int &nproj_in,
29-
const int &nproj_in_so,
30-
const bool has_so,
31-
const bool lspinorb,
32-
const int nspin);
33-
34-
35-
inline void get_d(const int& is, const int& p1, const int& p2, const std::complex<double>*& tmp_d)
36-
{
37-
tmp_d = &this->d_so(is, p1, p2);
38-
return;
39-
}
40-
inline void get_d(const int& is, const int& p1, const int& p2, const double*& tmp_d)
41-
{
42-
tmp_d = &this->d_real(p1, p2);
43-
return;
44-
}
45-
14+
Atom_pseudo();
15+
~Atom_pseudo();
16+
17+
// mohan add 2021-05-07
18+
ModuleBase::ComplexArray d_so; //(:,:,:), spin-orbit case
19+
ModuleBase::matrix d_real; //(:,:), non-spin-orbit case
20+
int nproj;
21+
int nproj_soc; // dimension of D_ij^so
22+
std::vector<int> non_zero_count_soc = {0, 0, 0, 0};
23+
std::vector<std::vector<int>> index1_soc = {{}, {}, {}, {}};
24+
std::vector<std::vector<int>> index2_soc = {{}, {}, {}, {}};
25+
26+
void set_d_so( // mohan add 2021-05-07
27+
ModuleBase::ComplexMatrix &d_so_in,
28+
const int &nproj_in,
29+
const int &nproj_in_so,
30+
const bool has_so,
31+
const bool lspinorb,
32+
const int nspin);
33+
34+
35+
inline void get_d(const int& is, const int& p1, const int& p2, const std::complex<double>*& tmp_d)
36+
{
37+
tmp_d = &this->d_so(is, p1, p2);
38+
return;
39+
}
40+
inline void get_d(const int& is, const int& p1, const int& p2, const double*& tmp_d)
41+
{
42+
tmp_d = &this->d_real(p1, p2);
43+
return;
44+
}
45+
4646

4747
#ifdef __MPI
48-
void bcast_atom_pseudo(void); // for upf201
48+
void bcast_atom_pseudo(void); // for upf201
4949
#endif
5050

5151
};

source/source_cell/atom_spec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Atom
1212
Atom_pseudo ncpp;
1313
double mass = 0.0; // the mass of atom
1414
std::vector<ModuleBase::Vector3<int>> mbl; // whether the atoms can move or not
15-
bool flag_empty_element = false; // whether is the empty element for bsse. Peize Lin add 2021.04.07
15+
bool flag_empty_element = false; // whether is the empty element for bsse. Peize Lin add 2021.04.07
1616

1717
std::vector<int> iw2m; // use iw to find m
1818
std::vector<int> iw2n; // use iw to find n

source/source_cell/cal_nelec_nband.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ void cal_nbands(const int& nelec, const int& nlocal, const std::vector<double>&
4646
}
4747

4848
double occupied_bands = static_cast<double>(nelec / ModuleBase::DEGSPIN);
49-
if (lspinorb == 1)
50-
{
51-
occupied_bands = static_cast<double>(nelec);
52-
}
49+
if (lspinorb == 1)
50+
{
51+
occupied_bands = static_cast<double>(nelec);
52+
}
5353

5454
if ((occupied_bands - std::floor(occupied_bands)) > 0.0)
5555
{

source/source_cell/k_vector_utils.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ void kvec_c2d(K_Vectors& kv, const ModuleBase::Matrix3& latvec)
6969
ModuleBase::Matrix3 RT = latvec.Transpose();
7070
for (int i = 0; i < nks; i++)
7171
{
72-
// std::cout << " ik=" << i
73-
// << " kvec.x=" << kvec_c[i].x
74-
// << " kvec.y=" << kvec_c[i].y
75-
// << " kvec.z=" << kvec_c[i].z << std::endl;
72+
// std::cout << " ik=" << i
73+
// << " kvec.x=" << kvec_c[i].x
74+
// << " kvec.y=" << kvec_c[i].y
75+
// << " kvec.z=" << kvec_c[i].z << std::endl;
7676
// wrong! kvec_d[i] = RT * kvec_c[i];
7777
// mohan fixed bug 2011-03-07
7878
kv.kvec_d[i] = kv.kvec_c[i] * RT;
@@ -588,10 +588,10 @@ void kvec_ibz_kpoint(K_Vectors& kv,
588588
ModuleBase::Vector3<double> kvec_rot;
589589
ModuleBase::Vector3<double> kvec_rot_k;
590590

591-
// for(int i=0; i<nrotkm; i++)
592-
// {
593-
// out.printM3("rot matrix",kgmatrix[i]);
594-
// }
591+
// for(int i=0; i<nrotkm; i++)
592+
// {
593+
// out.printM3("rot matrix",kgmatrix[i]);
594+
// }
595595
auto restrict_kpt = [&symm](ModuleBase::Vector3<double>& kvec) {
596596
// in (-0.5, 0.5]
597597
kvec.x = fmod(kvec.x + 100.5 - 0.5 * symm.epsilon, 1) - 0.5 + 0.5 * symm.epsilon;
@@ -691,20 +691,20 @@ void kvec_ibz_kpoint(K_Vectors& kv,
691691
}
692692
else // mohan fix bug 2010-1-30
693693
{
694-
// std::cout << "\n\n already exist ! ";
694+
// std::cout << "\n\n already exist ! ";
695695

696-
// std::cout << "\n kvec_rot = " << kvec_rot.x << " " << kvec_rot.y << " " << kvec_rot.z;
697-
// std::cout << "\n kvec_d_ibz = " << kvec_d_ibz[exist_number].x
698-
// << " " << kvec_d_ibz[exist_number].y
699-
// << " " << kvec_d_ibz[exist_number].z;
696+
// std::cout << "\n kvec_rot = " << kvec_rot.x << " " << kvec_rot.y << " " << kvec_rot.z;
697+
// std::cout << "\n kvec_d_ibz = " << kvec_d_ibz[exist_number].x
698+
// << " " << kvec_d_ibz[exist_number].y
699+
// << " " << kvec_d_ibz[exist_number].z;
700700

701701
double kmol_new = kv.kvec_d[i].norm2();
702702
double kmol_old = kvec_d_ibz[exist_number].norm2();
703703

704704
kv.ibz_index[i] = exist_number;
705705

706-
// std::cout << "\n kmol_new = " << kmol_new;
707-
// std::cout << "\n kmol_old = " << kmol_old;
706+
// std::cout << "\n kmol_new = " << kmol_new;
707+
// std::cout << "\n kmol_old = " << kmol_old;
708708

709709
// why we need this step?
710710
// because in pw_basis.cpp, while calculate ggwfc2,
@@ -718,7 +718,7 @@ void kvec_ibz_kpoint(K_Vectors& kv,
718718
kvec_d_ibz[exist_number] = kv.kvec_d[i];
719719
}
720720
}
721-
// BLOCK_HERE("check k point");
721+
// BLOCK_HERE("check k point");
722722
}
723723

724724
delete[] kkmatrix;

source/source_cell/magnetism.cpp

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ Magnetism::~Magnetism()
1414
}
1515

1616
void Magnetism::compute_mag(const double& omega,
17-
const int& nrxx,
18-
const int& nxyz,
19-
const double* const * rho,
20-
const int& nspin,
21-
const bool& two_fermi,
22-
const double& nelec,
23-
double* nelec_spin)
17+
const int& nrxx,
18+
const int& nxyz,
19+
const double* const * rho,
20+
const int& nspin,
21+
const bool& two_fermi,
22+
const double& nelec,
23+
double* nelec_spin)
2424
{
2525
assert(omega>0.0);
2626
assert(nxyz>0);
@@ -45,61 +45,61 @@ void Magnetism::compute_mag(const double& omega,
4545
this->tot_mag *= fac;
4646
this->abs_mag *= fac;
4747

48-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Total magnetism (Bohr mag/cell)",this->tot_mag);
49-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Absolute magnetism (Bohr mag/cell)",this->abs_mag);
50-
51-
//update number of electrons for each spin
52-
//if TWO_EFERMI, no need to update
53-
if(!two_fermi)
54-
{
55-
nelec_spin[0] = (nelec + this->tot_mag) / 2;
56-
nelec_spin[1] = (nelec - this->tot_mag) / 2;
57-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Electron number for spin up", nelec_spin[0]);
58-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Electron number for spin down", nelec_spin[1]);
59-
}
48+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Total magnetism (Bohr mag/cell)",this->tot_mag);
49+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Absolute magnetism (Bohr mag/cell)",this->abs_mag);
50+
51+
//update number of electrons for each spin
52+
//if TWO_EFERMI, no need to update
53+
if(!two_fermi)
54+
{
55+
nelec_spin[0] = (nelec + this->tot_mag) / 2;
56+
nelec_spin[1] = (nelec - this->tot_mag) / 2;
57+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Electron number for spin up", nelec_spin[0]);
58+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Electron number for spin down", nelec_spin[1]);
59+
}
6060
}
6161

62-
// noncolliear :
63-
else if(nspin==4)
64-
{
65-
for(int i=0;i<3;i++)
66-
{
67-
this->tot_mag_nc[i] = 0.00;
68-
}
69-
70-
this->abs_mag = 0.00;
71-
for (int ir=0; ir<nrxx; ir++)
72-
{
73-
double diff = sqrt(pow(rho[1][ir], 2) + pow(rho[2][ir], 2) +pow(rho[3][ir], 2));
62+
// noncolliear :
63+
else if(nspin==4)
64+
{
65+
for(int i=0;i<3;i++)
66+
{
67+
this->tot_mag_nc[i] = 0.00;
68+
}
69+
70+
this->abs_mag = 0.00;
71+
for (int ir=0; ir<nrxx; ir++)
72+
{
73+
double diff = sqrt(pow(rho[1][ir], 2) + pow(rho[2][ir], 2) +pow(rho[3][ir], 2));
7474

75-
for(int i=0;i<3;i++)
76-
{
77-
this->tot_mag_nc[i] += rho[i+1][ir];
78-
}
79-
this->abs_mag += std::abs(diff);
80-
}
75+
for(int i=0;i<3;i++)
76+
{
77+
this->tot_mag_nc[i] += rho[i+1][ir];
78+
}
79+
this->abs_mag += std::abs(diff);
80+
}
8181
#ifdef __MPI
8282
Parallel_Reduce::reduce_pool(this->tot_mag_nc, 3);
8383
Parallel_Reduce::reduce_pool(this->abs_mag);
8484
#endif
85-
for(int i=0;i<3;i++)
86-
{
87-
this->tot_mag_nc[i] *= fac;
85+
for(int i=0;i<3;i++)
86+
{
87+
this->tot_mag_nc[i] *= fac;
8888
// mohan add 2025-06-21
89-
if( std::abs(this->tot_mag_nc[i]) < 1.0e-16)
90-
{
91-
this->tot_mag_nc[i] = 0.0;
92-
}
93-
}
89+
if( std::abs(this->tot_mag_nc[i]) < 1.0e-16)
90+
{
91+
this->tot_mag_nc[i] = 0.0;
92+
}
93+
}
9494

95-
this->abs_mag *= fac;
95+
this->abs_mag *= fac;
9696

9797
// mohan update 2025-06-21
98-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Total magnetism (Bohr mag/cell)",
98+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Total magnetism (Bohr mag/cell)",
9999
this->tot_mag_nc[0], this->tot_mag_nc[1], this->tot_mag_nc[2]);
100100

101-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Absolute magnetism (Bohr mag/cell)",this->abs_mag);
102-
}
101+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Absolute magnetism (Bohr mag/cell)",this->abs_mag);
102+
}
103103

104104
return;
105105
}
@@ -112,8 +112,8 @@ bool Magnetism::judge_parallel(const double a[3], const ModuleBase::Vector3<doub
112112
double cross=0.0;
113113

114114
cross = pow((a[1]*b.z-a[2]*b.y),2)
115-
+ pow((a[2]*b.x-a[0]*b.z),2)
116-
+ pow((a[0]*b.y-a[1]*b.x),2);
115+
+ pow((a[2]*b.x-a[0]*b.z),2)
116+
+ pow((a[0]*b.y-a[1]*b.x),2);
117117

118118
jp = (fabs(cross)<1e-6);
119119
return jp;

source/source_cell/magnetism.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ class Magnetism
2222

2323
double abs_mag;
2424

25-
void compute_mag(const double& omega,
26-
const int& nrxx,
27-
const int& nxyz,
28-
const double* const * rho,
29-
const int& nspin,
30-
const bool& two_fermi,
31-
const double& nelec,
32-
double* nelec_spin);
25+
void compute_mag(const double& omega,
26+
const int& nrxx,
27+
const int& nxyz,
28+
const double* const * rho,
29+
const int& nspin,
30+
const bool& two_fermi,
31+
const double& nelec,
32+
double* nelec_spin);
3333

3434
double ux_[3]={0.0};
3535

36-
bool lsign_=false;
36+
bool lsign_=false;
3737

3838
private:
3939

source/source_cell/module_neighbor/sltk_atom.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
/*** Constructors and destructor ***/
55
FAtom::FAtom()
66
{
7-
x = 0.0;
8-
y = 0.0;
9-
z = 0.0;
10-
type = 0;
11-
natom = 0;
12-
cell_x = 0;
13-
cell_y = 0;
14-
cell_z = 0;
7+
x = 0.0;
8+
y = 0.0;
9+
z = 0.0;
10+
type = 0;
11+
natom = 0;
12+
cell_x = 0;
13+
cell_y = 0;
14+
cell_z = 0;
1515
}

0 commit comments

Comments
 (0)