Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ OBJS_MD=fire.o\

OBJS_NEIGHBOR=sltk_atom.o\
sltk_atom_arrange.o\
sltk_atom_input.o\
sltk_grid.o\
sltk_grid_driver.o\

Expand Down
1 change: 0 additions & 1 deletion source/module_cell/module_neighbor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ add_library(
OBJECT
sltk_atom.cpp
sltk_atom_arrange.cpp
sltk_atom_input.cpp
sltk_grid.cpp
sltk_grid_driver.cpp
)
Expand Down
6 changes: 3 additions & 3 deletions source/module_cell/module_neighbor/sltk_atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
/*** Constructors and destructor ***/
FAtom::FAtom()
{
d_x = 0.0;
d_y = 0.0;
d_z = 0.0;
x = 0.0;
y = 0.0;
z = 0.0;
type = 0;
natom = 0;
}
30 changes: 7 additions & 23 deletions source/module_cell/module_neighbor/sltk_atom.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
// the type and the index,
class FAtom
{
private:
double d_x;
double d_y;
double d_z;
public:
double x;
double y;
double z;
std::vector<FAtom *> adjacent;

int type;
Expand All @@ -22,19 +22,15 @@ class FAtom
int cell_x;
int cell_y;
int cell_z;
public:
//==========================================================
// Default Constructor and deconstructor
//==========================================================

FAtom();
FAtom(const double& x_in, const double& y_in, const double& z_in,
const int& type_in, const int& natom_in,
const int& cell_x_in, const int& cell_y_in, const int& cell_z_in)
{
d_x = x_in;
d_y = y_in;
d_z = z_in;
x = x_in;
y = y_in;
z = z_in;
type = type_in;
natom = natom_in;
cell_x = cell_x_in;
Expand All @@ -52,18 +48,6 @@ class FAtom
}
const std::vector<FAtom *>& getAdjacent() const { return adjacent; }
void clearAdjacent() { adjacent.clear(); }
//==========================================================
// MEMBER FUNCTION :
// EXPLAIN : get value
//==========================================================
const double& x() const { return d_x; }
const double& y() const { return d_y; }
const double& z() const { return d_z; }
const int& getType() const { return type;}
const int& getNatom() const { return natom;}
const int& getCellX() const { return cell_x; }
const int& getCellY() const { return cell_y; }
const int& getCellZ() const { return cell_z; }
};

#endif
199 changes: 64 additions & 135 deletions source/module_cell/module_neighbor/sltk_atom_arrange.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "sltk_atom_arrange.h"
#include "sltk_atom_input.h"

#include "module_base/timer.h"
#include "module_parameter/parameter.h"
#include "sltk_grid.h"
#include "sltk_grid_driver.h"
#include "module_base/timer.h"

// update the followig class in near future
// update the followig class in near future
#include "module_cell/unitcell.h"

atom_arrange::atom_arrange()
Expand All @@ -16,126 +16,81 @@ atom_arrange::~atom_arrange()
{
}

double atom_arrange::set_sr_NL(
std::ofstream &ofs_in,
const std::string &output_level,
const double &rcutmax_Phi,
const double &rcutmax_Beta,
const bool gamma_only_local)
double atom_arrange::set_sr_NL(std::ofstream& ofs_in,
const std::string& output_level,
const double& rcutmax_Phi,
const double& rcutmax_Beta,
const bool gamma_only_local)
{
ModuleBase::TITLE("atom_arrange","set_sr_NL");

if(output_level != "m") //xiaohui add 'output_level', 2015-09-16
{
ofs_in << "\n\n\n\n";
ofs_in << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
ofs_in << " | |" << std::endl;
ofs_in << " | Search adjacent atoms: |" << std::endl;
ofs_in << " | Set the adjacent atoms for each atom and set the periodic boundary |" << std::endl;
ofs_in << " | condition for the atoms on real space FFT grid. For k-dependent |" << std::endl;
ofs_in << " | algorithm, we also need to set the sparse H and S matrix element |" << std::endl;
ofs_in << " | for each atom. |" << std::endl;
ofs_in << " | |" << std::endl;
ofs_in << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
ofs_in << "\n\n\n\n";
}


//xiaohui add 'output_level' line, 2015-09-16
if(output_level != "m") { ofs_in << "\n SETUP SEARCHING RADIUS FOR PROGRAM TO SEARCH ADJACENT ATOMS" << std::endl;
}
if(output_level != "m") { ofs_in << std::setprecision(3);
}
if(output_level != "m") { ModuleBase::GlobalFunc::OUT(ofs_in,"longest orb rcut (Bohr)",rcutmax_Phi);
}
ModuleBase::TITLE("atom_arrange", "set_sr_NL");

if (output_level != "m") // xiaohui add 'output_level', 2015-09-16
{
ofs_in << "\n\n\n\n";
ofs_in << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
ofs_in << " | |" << std::endl;
ofs_in << " | Search adjacent atoms: |" << std::endl;
ofs_in << " | Set the adjacent atoms for each atom and set the periodic boundary |" << std::endl;
ofs_in << " | condition for the atoms on real space FFT grid. For k-dependent |" << std::endl;
ofs_in << " | algorithm, we also need to set the sparse H and S matrix element |" << std::endl;
ofs_in << " | for each atom. |" << std::endl;
ofs_in << " | |" << std::endl;
ofs_in << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
ofs_in << "\n\n\n\n";
ofs_in << "\n SETUP SEARCHING RADIUS FOR PROGRAM TO SEARCH ADJACENT ATOMS" << std::endl;
ofs_in << std::setprecision(3);
ModuleBase::GlobalFunc::OUT(ofs_in, "longest orb rcut (Bohr)", rcutmax_Phi);
ModuleBase::GlobalFunc::OUT(ofs_in, "longest nonlocal projector rcut (Bohr)", rcutmax_Beta);
}

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

// check in use_overlap_matrix,
double sr = 0.0;
if(gamma_only_local)
{
sr = 2 * rcutmax_Phi + 0.01;
}
else
{
sr = 2 * (rcutmax_Phi +rcutmax_Beta) + 0.01; // 0.01 is added to make safe.
//sr = 2 * longest_orb_rcut + 0.01;
}

return sr;
return sr;
}

void atom_arrange::search(
const bool pbc_flag,
std::ofstream &ofs_in,
Grid_Driver &grid_d,
const UnitCell &ucell,
const double &search_radius_bohr,
const int &test_atom_in,
const bool test_only)
void atom_arrange::search(const bool pbc_flag,
std::ofstream& ofs_in,
Grid_Driver& grid_d,
const UnitCell& ucell,
const double& search_radius_bohr,
const int& test_atom_in,
const bool test_only)
{
ModuleBase::TITLE("atom_arrange", "search");
ModuleBase::timer::tick("atom_arrange","search");
/* std::cout << "pbc_flag = " << pbc_flag << std::endl;
std::cout << "search_radius_bohr = " << search_radius_bohr << std::endl;
std::cout << "test_atom_in = " << test_atom_in << std::endl;
std::cout << "test_only = " << test_only << std::endl;
*/
assert( search_radius_bohr > 0.0 );

// OUT(ofs_in,"Atom coordinates reading from",PARAM.inp.stru_file);
// OUT(ofs_in,"The coordinate type",ucell.Coordinate);
// OUT(ofs_in,"Use cartesian(unit:lat0) coordinate","TRUE");
// if(PARAM.inp.out_level != "m") OUT(ofs_in,"searching radius is (Bohr))", search_radius_bohr);
// if(PARAM.inp.out_level != "m") OUT(ofs_in,"searching radius unit is (Bohr))",ucell.lat0);

ModuleBase::GlobalFunc::OUT(ofs_in,"searching radius is (Bohr))", search_radius_bohr);
ModuleBase::GlobalFunc::OUT(ofs_in,"searching radius unit is (Bohr))",ucell.lat0);

assert(ucell.nat > 0);
//=============================
// Initial Atom information
//=============================

const double radius_lat0unit = search_radius_bohr / ucell.lat0;
ModuleBase::timer::tick("atom_arrange", "Atom_input");

Atom_input at(
ofs_in,
ucell,
ucell.nat,
ucell.ntype,
pbc_flag,
radius_lat0unit,
test_atom_in);
ModuleBase::timer::tick("atom_arrange", "Atom_input");

//===========================================
// Print important information in Atom_input
//===========================================
// at.print(std::cout);
// at.print_xyz_format("1.xyz");
//=========================================
// Construct Grid , Cells , Adjacent atoms
//=========================================
ModuleBase::TITLE("atom_arrange", "search");
ModuleBase::timer::tick("atom_arrange", "search");
assert(search_radius_bohr > 0.0);

ModuleBase::GlobalFunc::OUT(ofs_in, "searching radius is (Bohr))", search_radius_bohr);
ModuleBase::GlobalFunc::OUT(ofs_in, "searching radius unit is (Bohr))", ucell.lat0);

assert(ucell.nat > 0);

const double radius_lat0unit = search_radius_bohr / ucell.lat0;

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

grid_d.init(ofs_in, ucell, at);
grid_d.init(ofs_in, ucell, radius_lat0unit, pbc_flag);
ModuleBase::timer::tick("atom_arrange", "grid_d.init");

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

// test the adjacent atoms and the box.
if(test_only)
{
std::cout << "radius_lat0unit = " << radius_lat0unit << std::endl;
std::cout << "search_radius_bohr = " << search_radius_bohr << std::endl;
// test the adjacent atoms and the box.
if (test_only)
{
std::cout << "radius_lat0unit = " << radius_lat0unit << std::endl;
std::cout << "search_radius_bohr = " << search_radius_bohr << std::endl;

ofs_in << " " << std::setw(5) << "Type" << std::setw(5) << "Atom" << std::setw(8) << "AdjNum" << std::endl;
ofs_in << " " << std::setw(5) << "Type" << std::setw(5) << "Atom" << std::setw(8) << "AdjNum" << std::endl;
std::cout << std::setw(8) << "Labels" << std::setw(15) << "tau.x" << std::setw(15) << "tau.y" << std::setw(15)
<< "tau.z" << std::setw(8) << "box.x" << std::setw(8) << "box.y" << std::setw(8) << "box.z"
<< std::endl;
Expand Down Expand Up @@ -163,29 +118,3 @@ void atom_arrange::search(

return;
}


//2015-05-07
void atom_arrange::delete_vector(
std::ofstream &ofs_in,
const bool pbc_flag, // GlobalV::SEARCH_PBC
Grid_Driver &grid_d,
const UnitCell &ucell,
const double &search_radius_bohr,
const int &test_atom_in)
{
const double radius_lat0unit2 = search_radius_bohr / ucell.lat0;

Atom_input at2(
ofs_in,
ucell,
ucell.nat,
ucell.ntype,
pbc_flag,
radius_lat0unit2,
test_atom_in);

grid_d.delete_vector(at2.getGrid_layerX_minus(),at2.getGrid_layerY_minus(),at2.getGrid_layerZ_minus());

grid_d.delete_Cell();
}
13 changes: 0 additions & 13 deletions source/module_cell/module_neighbor/sltk_atom_arrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "sltk_grid.h"
#include "sltk_grid_driver.h"
#include "sltk_atom_input.h"


class atom_arrange
Expand All @@ -29,18 +28,6 @@ class atom_arrange
const double& rcutmax_Phi,
const double& rcutmax_Beta,
const bool gamma_only_local);

//2015-05-07
static void delete_vector(
std::ofstream &ofs_in,
const bool pbc_flag,
Grid_Driver &grid_d,
const UnitCell &ucell,
const double &search_radius_bohr,
const int &test_atom_in);

private:

};

#endif
Loading
Loading