Skip to content

Commit ae1ea76

Browse files
committed
remove some variable and format
1 parent 34f1ec8 commit ae1ea76

File tree

7 files changed

+94
-160
lines changed

7 files changed

+94
-160
lines changed

source/module_cell/module_neighbor/sltk_atom.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
/*** Constructors and destructor ***/
55
FAtom::FAtom()
66
{
7-
d_x = 0.0;
8-
d_y = 0.0;
9-
d_z = 0.0;
7+
x = 0.0;
8+
y = 0.0;
9+
z = 0.0;
1010
type = 0;
1111
natom = 0;
1212
}

source/module_cell/module_neighbor/sltk_atom.h

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
// the type and the index,
1111
class FAtom
1212
{
13-
private:
14-
double d_x;
15-
double d_y;
16-
double d_z;
13+
public:
14+
double x;
15+
double y;
16+
double z;
1717
std::vector<FAtom *> adjacent;
1818

1919
int type;
@@ -22,19 +22,15 @@ class FAtom
2222
int cell_x;
2323
int cell_y;
2424
int cell_z;
25-
public:
26-
//==========================================================
27-
// Default Constructor and deconstructor
28-
//==========================================================
2925

3026
FAtom();
3127
FAtom(const double& x_in, const double& y_in, const double& z_in,
3228
const int& type_in, const int& natom_in,
3329
const int& cell_x_in, const int& cell_y_in, const int& cell_z_in)
3430
{
35-
d_x = x_in;
36-
d_y = y_in;
37-
d_z = z_in;
31+
x = x_in;
32+
y = y_in;
33+
z = z_in;
3834
type = type_in;
3935
natom = natom_in;
4036
cell_x = cell_x_in;
@@ -52,18 +48,6 @@ class FAtom
5248
}
5349
const std::vector<FAtom *>& getAdjacent() const { return adjacent; }
5450
void clearAdjacent() { adjacent.clear(); }
55-
//==========================================================
56-
// MEMBER FUNCTION :
57-
// EXPLAIN : get value
58-
//==========================================================
59-
const double& x() const { return d_x; }
60-
const double& y() const { return d_y; }
61-
const double& z() const { return d_z; }
62-
const int& getType() const { return type;}
63-
const int& getNatom() const { return natom;}
64-
const int& getCellX() const { return cell_x; }
65-
const int& getCellY() const { return cell_y; }
66-
const int& getCellZ() const { return cell_z; }
6751
};
6852

6953
#endif

source/module_cell/module_neighbor/sltk_atom_arrange.cpp

Lines changed: 61 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#include "sltk_atom_arrange.h"
2+
3+
#include "module_base/timer.h"
24
#include "module_parameter/parameter.h"
35
#include "sltk_grid.h"
46
#include "sltk_grid_driver.h"
5-
#include "module_base/timer.h"
67

7-
// update the followig class in near future
8+
// update the followig class in near future
89
#include "module_cell/unitcell.h"
910

1011
atom_arrange::atom_arrange()
@@ -15,92 +16,81 @@ atom_arrange::~atom_arrange()
1516
{
1617
}
1718

18-
double atom_arrange::set_sr_NL(
19-
std::ofstream &ofs_in,
20-
const std::string &output_level,
21-
const double &rcutmax_Phi,
22-
const double &rcutmax_Beta,
23-
const bool gamma_only_local)
19+
double atom_arrange::set_sr_NL(std::ofstream& ofs_in,
20+
const std::string& output_level,
21+
const double& rcutmax_Phi,
22+
const double& rcutmax_Beta,
23+
const bool gamma_only_local)
2424
{
25-
ModuleBase::TITLE("atom_arrange","set_sr_NL");
26-
27-
if(output_level != "m") //xiaohui add 'output_level', 2015-09-16
28-
{
29-
ofs_in << "\n\n\n\n";
30-
ofs_in << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
31-
ofs_in << " | |" << std::endl;
32-
ofs_in << " | Search adjacent atoms: |" << std::endl;
33-
ofs_in << " | Set the adjacent atoms for each atom and set the periodic boundary |" << std::endl;
34-
ofs_in << " | condition for the atoms on real space FFT grid. For k-dependent |" << std::endl;
35-
ofs_in << " | algorithm, we also need to set the sparse H and S matrix element |" << std::endl;
36-
ofs_in << " | for each atom. |" << std::endl;
37-
ofs_in << " | |" << std::endl;
38-
ofs_in << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
39-
ofs_in << "\n\n\n\n";
40-
}
41-
42-
43-
//xiaohui add 'output_level' line, 2015-09-16
44-
if(output_level != "m") { ofs_in << "\n SETUP SEARCHING RADIUS FOR PROGRAM TO SEARCH ADJACENT ATOMS" << std::endl;
45-
}
46-
if(output_level != "m") { ofs_in << std::setprecision(3);
47-
}
48-
if(output_level != "m") { ModuleBase::GlobalFunc::OUT(ofs_in,"longest orb rcut (Bohr)",rcutmax_Phi);
49-
}
25+
ModuleBase::TITLE("atom_arrange", "set_sr_NL");
26+
27+
if (output_level != "m") // xiaohui add 'output_level', 2015-09-16
28+
{
29+
ofs_in << "\n\n\n\n";
30+
ofs_in << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
31+
ofs_in << " | |" << std::endl;
32+
ofs_in << " | Search adjacent atoms: |" << std::endl;
33+
ofs_in << " | Set the adjacent atoms for each atom and set the periodic boundary |" << std::endl;
34+
ofs_in << " | condition for the atoms on real space FFT grid. For k-dependent |" << std::endl;
35+
ofs_in << " | algorithm, we also need to set the sparse H and S matrix element |" << std::endl;
36+
ofs_in << " | for each atom. |" << std::endl;
37+
ofs_in << " | |" << std::endl;
38+
ofs_in << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
39+
ofs_in << "\n\n\n\n";
40+
ofs_in << "\n SETUP SEARCHING RADIUS FOR PROGRAM TO SEARCH ADJACENT ATOMS" << std::endl;
41+
ofs_in << std::setprecision(3);
42+
ModuleBase::GlobalFunc::OUT(ofs_in, "longest orb rcut (Bohr)", rcutmax_Phi);
43+
ModuleBase::GlobalFunc::OUT(ofs_in, "longest nonlocal projector rcut (Bohr)", rcutmax_Beta);
44+
}
5045

51-
// std::cout << " LONGEST NL PROJ RCUT : " << longest_nl_proj_rcut << std::endl;
52-
if(output_level != "m") { ModuleBase::GlobalFunc::OUT(ofs_in,"longest nonlocal projector rcut (Bohr)", rcutmax_Beta);
53-
}
46+
// check in use_overlap_matrix,
47+
double sr = 0.0;
48+
if (gamma_only_local)
49+
{
50+
sr = 2 * rcutmax_Phi + 0.01;
51+
}
52+
else
53+
{
54+
sr = 2 * (rcutmax_Phi + rcutmax_Beta) + 0.01; // 0.01 is added to make safe.
55+
// sr = 2 * longest_orb_rcut + 0.01;
56+
}
5457

55-
// check in use_overlap_matrix,
56-
double sr = 0.0;
57-
if(gamma_only_local)
58-
{
59-
sr = 2 * rcutmax_Phi + 0.01;
60-
}
61-
else
62-
{
63-
sr = 2 * (rcutmax_Phi +rcutmax_Beta) + 0.01; // 0.01 is added to make safe.
64-
//sr = 2 * longest_orb_rcut + 0.01;
65-
}
66-
67-
return sr;
58+
return sr;
6859
}
6960

70-
void atom_arrange::search(
71-
const bool pbc_flag,
72-
std::ofstream &ofs_in,
73-
Grid_Driver &grid_d,
74-
const UnitCell &ucell,
75-
const double &search_radius_bohr,
76-
const int &test_atom_in,
77-
const bool test_only)
61+
void atom_arrange::search(const bool pbc_flag,
62+
std::ofstream& ofs_in,
63+
Grid_Driver& grid_d,
64+
const UnitCell& ucell,
65+
const double& search_radius_bohr,
66+
const int& test_atom_in,
67+
const bool test_only)
7868
{
79-
ModuleBase::TITLE("atom_arrange", "search");
80-
ModuleBase::timer::tick("atom_arrange","search");
81-
assert( search_radius_bohr > 0.0 );
69+
ModuleBase::TITLE("atom_arrange", "search");
70+
ModuleBase::timer::tick("atom_arrange", "search");
71+
assert(search_radius_bohr > 0.0);
8272

83-
ModuleBase::GlobalFunc::OUT(ofs_in,"searching radius is (Bohr))", search_radius_bohr);
84-
ModuleBase::GlobalFunc::OUT(ofs_in,"searching radius unit is (Bohr))",ucell.lat0);
73+
ModuleBase::GlobalFunc::OUT(ofs_in, "searching radius is (Bohr))", search_radius_bohr);
74+
ModuleBase::GlobalFunc::OUT(ofs_in, "searching radius unit is (Bohr))", ucell.lat0);
8575

86-
assert(ucell.nat > 0);
76+
assert(ucell.nat > 0);
8777

88-
const double radius_lat0unit = search_radius_bohr / ucell.lat0;
78+
const double radius_lat0unit = search_radius_bohr / ucell.lat0;
8979

9080
ModuleBase::timer::tick("atom_arrange", "grid_d.init");
9181

92-
grid_d.init(ofs_in, ucell, radius_lat0unit, pbc_flag);
82+
grid_d.init(ofs_in, ucell, radius_lat0unit, pbc_flag);
9383
ModuleBase::timer::tick("atom_arrange", "grid_d.init");
9484

9585
ModuleBase::timer::tick("atom_arrange", "search");
9686

97-
// test the adjacent atoms and the box.
98-
if(test_only)
99-
{
100-
std::cout << "radius_lat0unit = " << radius_lat0unit << std::endl;
101-
std::cout << "search_radius_bohr = " << search_radius_bohr << std::endl;
87+
// test the adjacent atoms and the box.
88+
if (test_only)
89+
{
90+
std::cout << "radius_lat0unit = " << radius_lat0unit << std::endl;
91+
std::cout << "search_radius_bohr = " << search_radius_bohr << std::endl;
10292

103-
ofs_in << " " << std::setw(5) << "Type" << std::setw(5) << "Atom" << std::setw(8) << "AdjNum" << std::endl;
93+
ofs_in << " " << std::setw(5) << "Type" << std::setw(5) << "Atom" << std::setw(8) << "AdjNum" << std::endl;
10494
std::cout << std::setw(8) << "Labels" << std::setw(15) << "tau.x" << std::setw(15) << "tau.y" << std::setw(15)
10595
<< "tau.z" << std::setw(8) << "box.x" << std::setw(8) << "box.y" << std::setw(8) << "box.z"
10696
<< std::endl;

source/module_cell/module_neighbor/sltk_grid.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ void Grid::Build_Hash_Table(const UnitCell& ucell)
199199
double z = ucell.atoms[i].tau[j].z + vec1[2] * ix + vec2[2] * iy + vec3[2] * iz;
200200
FAtom atom(x, y, z, i, j, ix, iy, iz);
201201
int a, b, c;
202-
a = atom.getCellX() + true_cell_x;
203-
b = atom.getCellY() + true_cell_y;
204-
c = atom.getCellZ() + true_cell_z;
202+
a = ix + glayerX_minus;
203+
b = iy + glayerY_minus;
204+
c = iz + glayerZ_minus;
205205

206-
this->Cell[a][b][c].atom_map[atom.getType()][atom.getNatom()] = atom;
206+
this->Cell[a][b][c].atom_map[atom.type][atom.natom] = atom;
207207
}
208208
}
209209
}
@@ -260,12 +260,12 @@ void Grid::Construct_Adjacent_final(const int i,
260260
const int k2,
261261
FAtom& fatom2)
262262
{
263-
const double x = fatom1.x();
264-
const double y = fatom1.y();
265-
const double z = fatom1.z();
266-
double x2 = fatom2.x();
267-
double y2 = fatom2.y();
268-
double z2 = fatom2.z();
263+
const double x = fatom1.x;
264+
const double y = fatom1.y;
265+
const double z = fatom1.z;
266+
double x2 = fatom2.x;
267+
double y2 = fatom2.y;
268+
double z2 = fatom2.z;
269269

270270
double delta_x = x - x2;
271271
double delta_y = y - y2;

source/module_cell/module_neighbor/sltk_grid_driver.cpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,46 +40,26 @@ void Grid_Driver::Find_atom(
4040
AdjacentAtomInfo* local_adjs = adjs == nullptr ? &this->adj_info : adjs;
4141
local_adjs->clear();
4242
const std::vector<FAtom *> & all_atom = Cell[this->true_cell_x][this->true_cell_y][this->true_cell_z].atom_map[ntype][nnumber].getAdjacent();
43-
//std::cout << "ntype = "<< ntype << " atom size = " << all_atom.size() << std::endl;
44-
45-
ModuleBase::Vector3<double> vec1(ucell.latvec.e11, ucell.latvec.e12, ucell.latvec.e13);
46-
ModuleBase::Vector3<double> vec2(ucell.latvec.e21, ucell.latvec.e22, ucell.latvec.e23);
47-
ModuleBase::Vector3<double> vec3(ucell.latvec.e31, ucell.latvec.e32, ucell.latvec.e33);
4843

4944
for(const FAtom * atom : all_atom)
5045
{
5146
// std::cout << "atom type = " << atom.getType() << " number = " << atom.getNatom() << " box = " << atom.getCellX() << " " << atom.getCellY() << " " << atom.getCellZ()
5247
// << " tau = " << atom.x() << " " << atom.y() << " " << atom.z() << std::endl;
53-
local_adjs->ntype.push_back(atom->getType());
54-
local_adjs->natom.push_back(atom->getNatom());
55-
local_adjs->box.push_back(ModuleBase::Vector3<int>(atom->getCellX(), atom->getCellY(), atom->getCellZ()));
56-
local_adjs->adjacent_tau.push_back(ModuleBase::Vector3<double>(atom->x(), atom->y(), atom->z()));
48+
local_adjs->ntype.push_back(atom->type);
49+
local_adjs->natom.push_back(atom->natom);
50+
local_adjs->box.push_back(ModuleBase::Vector3<int>(atom->cell_x, atom->cell_y, atom->cell_z));
51+
local_adjs->adjacent_tau.push_back(ModuleBase::Vector3<double>(atom->x, atom->y, atom->z));
5752
local_adjs->adj_num++;
5853
}
5954
local_adjs->ntype.push_back(ntype);
6055
local_adjs->natom.push_back(nnumber);
6156
local_adjs->box.push_back(ModuleBase::Vector3<int>(0, 0, 0));
6257
local_adjs->adjacent_tau.push_back(ModuleBase::Vector3<double>(cartesian_pos.x, cartesian_pos.y, cartesian_pos.z));
6358

64-
6559
ModuleBase::timer::tick("Grid_Driver","Find_atom");
6660
return;
6761
}
6862

69-
ModuleBase::Vector3<double> Grid_Driver::Calculate_adjacent_site(const double x, const double y, const double z,
70-
const double &box11, const double &box12, const double &box13,
71-
const double &box21, const double &box22, const double &box23,
72-
const double &box31, const double &box32, const double &box33,
73-
const short box_x, const short box_y, const short box_z) const
74-
{
75-
ModuleBase::Vector3<double> adjacent_site(0, 0, 0);
76-
adjacent_site.x = x + box_x * box11 + box_y * box12 + box_z * box13;
77-
adjacent_site.y = y + box_x * box21 + box_y * box22 + box_z * box23;
78-
adjacent_site.z = z + box_x * box31 + box_y * box32 + box_z * box33;
79-
80-
return adjacent_site;
81-
}
82-
8363
// filter_adjs delete not adjacent atoms in adjs
8464
void filter_adjs(const std::vector<bool>& is_adj, AdjacentAtomInfo& adjs)
8565
{

source/module_cell/module_neighbor/sltk_grid_driver.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,6 @@ class Grid_Driver : public Grid
103103
mutable AdjacentAtomInfo adj_info;
104104

105105
const int test_deconstructor; // caoyu reconst 2021-05-24
106-
107-
//==========================================================
108-
// MEMBER FUNCTIONS :
109-
// NAME : Calculate_adjacent_site
110-
//==========================================================
111-
ModuleBase::Vector3<double> Calculate_adjacent_site(const double x,
112-
const double y,
113-
const double z,
114-
const double& box11,
115-
const double& box12,
116-
const double& box13,
117-
const double& box21,
118-
const double& box22,
119-
const double& box23,
120-
const double& box31,
121-
const double& box32,
122-
const double& box33,
123-
const short box_x, // three dimensions of the target box
124-
const short box_y,
125-
const short box_z) const;
126106
};
127107

128108
namespace GlobalC

source/module_cell/module_neighbor/test/sltk_atom_test.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ TEST_F(SltkAtomTest, AllocateAdjacentSet)
3232
test.clearAdjacent();
3333
FAtom test_temp(1.0, 2.0, 3.0, 4, 5, 0, 1, 2);
3434
test.addAdjacent(test_temp);
35-
EXPECT_EQ(test.getAdjacent().front()->getType(), 4);
35+
EXPECT_EQ(test.getAdjacent().front()->type, 4);
3636
}
3737

3838

3939
TEST_F(SltkAtomTest, SetterGetters)
4040
{
4141
FAtom test_temp(1.0, 2.0, 3.0, 4, 5, 0, 1, 2);
4242

43-
EXPECT_DOUBLE_EQ(test_temp.x(), 1.0);
44-
EXPECT_DOUBLE_EQ(test_temp.y(), 2.0);
45-
EXPECT_DOUBLE_EQ(test_temp.z(), 3.0);
46-
EXPECT_EQ(test_temp.getType(), 4);
47-
EXPECT_EQ(test_temp.getNatom(), 5);
48-
EXPECT_EQ(test_temp.getCellX(), 0);
49-
EXPECT_EQ(test_temp.getCellY(), 1);
50-
EXPECT_EQ(test_temp.getCellZ(), 2);
43+
EXPECT_DOUBLE_EQ(test_temp.x, 1.0);
44+
EXPECT_DOUBLE_EQ(test_temp.y, 2.0);
45+
EXPECT_DOUBLE_EQ(test_temp.z, 3.0);
46+
EXPECT_EQ(test_temp.type, 4);
47+
EXPECT_EQ(test_temp.natom, 5);
48+
EXPECT_EQ(test_temp.cell_x, 0);
49+
EXPECT_EQ(test_temp.cell_y, 1);
50+
EXPECT_EQ(test_temp.cell_z, 2);
5151
}

0 commit comments

Comments
 (0)