Skip to content

Commit

Permalink
Merge branch 'deepmodeling:develop' into pchg_wf_param
Browse files Browse the repository at this point in the history
  • Loading branch information
AsTonyshment committed Sep 24, 2024
2 parents 30a4141 + acb792d commit 774840d
Show file tree
Hide file tree
Showing 45 changed files with 551 additions and 486 deletions.
26 changes: 0 additions & 26 deletions source/module_base/global_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,30 +274,4 @@ void ModuleBase::Global_File::close_all_log(const int rank, const bool out_alllo
#endif
return;
}

void ModuleBase::Global_File::delete_tmp_files()
{
if (GlobalV::MY_RANK == 0)
{
for (int is = 0; is < PARAM.inp.nspin; ++is)
{
std::string tmp_chg_1 = PARAM.globalv.global_out_dir + "NOW_SPIN" + std::to_string(is + 1) + "_CHG.cube";
std::string tmp_chg_2 = PARAM.globalv.global_out_dir + "OLD1_SPIN" + std::to_string(is + 1) + "_CHG.cube";
std::string tmp_chg_3 = PARAM.globalv.global_out_dir + "OLD2_SPIN" + std::to_string(is + 1) + "_CHG.cube";

if (access(tmp_chg_1.c_str(), 0) == 0)
{
std::remove(tmp_chg_1.c_str());
}
if (access(tmp_chg_2.c_str(), 0) == 0)
{
std::remove(tmp_chg_2.c_str());
}
if (access(tmp_chg_3.c_str(), 0) == 0)
{
std::remove(tmp_chg_3.c_str());
}
}
}
}
}
8 changes: 1 addition & 7 deletions source/module_base/global_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ namespace Global_File
void make_dir_atom(const std::string &label);
void open_log ( std::ofstream &ofs, const std::string &fn, const std::string &calculation, const bool &restart);
void close_log( std::ofstream &ofs, const std::string &fn);
void close_all_log(const int rank, const bool out_alllog = false,const std::string &calculation = "md");

/**
* @brief delete tmperary files
*
*/
void delete_tmp_files();
void close_all_log(const int rank, const bool out_alllog = false, const std::string& calculation = "md");
}
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions source/module_base/sph_bessel_recursive.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define SPH_BESSEL_RECURSIVE_H

#include <vector>
#include"stddef.h"
#include<cstddef>

namespace ModuleBase
{
Expand All @@ -32,7 +32,7 @@ class Sph_Bessel_Recursive::D1

private:
std::vector<std::vector<double>> jlx; // jlx[l][x]
double dx;
double dx = 0.0;
bool finish_set_dx = false;

void cal_jlx_0( const int l_size );
Expand All @@ -56,7 +56,7 @@ class Sph_Bessel_Recursive::D2

private:
std::vector<std::vector<std::vector<double>>> jlx; // jlx[l][x1][x2]
double dx;
double dx = 0.0;
bool finish_set_dx = false;

void cal_jlx_0( const int l_size, const size_t ix1_size, const size_t ix2_size );
Expand Down
22 changes: 0 additions & 22 deletions source/module_base/test/global_file_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,26 +157,4 @@ TEST_F(GlobalFile,closealllog)
}
remove("running.log");
remove("warning.log");
}

TEST_F(GlobalFile, DeleteTmpFiles)
{

std::string tmp_chg_1 = PARAM.sys.global_out_dir + "NOW_SPIN1_CHG.cube";
std::string tmp_chg_2 = PARAM.sys.global_out_dir + "OLD1_SPIN1_CHG.cube";
std::string tmp_chg_3 = PARAM.sys.global_out_dir + "OLD2_SPIN1_CHG.cube";
std::ofstream ofs1(tmp_chg_1.c_str());
std::ofstream ofs2(tmp_chg_2.c_str());
std::ofstream ofs3(tmp_chg_3.c_str());
ofs1.close();
ofs2.close();
ofs3.close();
EXPECT_TRUE(access(tmp_chg_1.c_str(), 0) == 0);
EXPECT_TRUE(access(tmp_chg_2.c_str(), 0) == 0);
EXPECT_TRUE(access(tmp_chg_3.c_str(), 0) == 0);

ModuleBase::Global_File::delete_tmp_files();
EXPECT_TRUE(access(tmp_chg_1.c_str(), 0) == -1);
EXPECT_TRUE(access(tmp_chg_2.c_str(), 0) == -1);
EXPECT_TRUE(access(tmp_chg_3.c_str(), 0) == -1);
}
75 changes: 75 additions & 0 deletions source/module_cell/cal_atoms_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#ifndef CAL_ATOMS_INFO_H
#define CAL_ATOMS_INFO_H
#include "module_parameter/parameter.h"
#include "unitcell.h"
class CalAtomsInfo
{
public:
CalAtomsInfo(){};
~CalAtomsInfo(){};

/**
* @brief Calculate the atom information from pseudopotential to set Parameter
*
* @param atoms [in] Atom pointer
* @param ntype [in] number of atom types
* @param para [out] Parameter object
*/
void cal_atoms_info(const Atom* atoms, const int& ntype, Parameter& para)
{
// calculate initial total magnetization when NSPIN=2
if (para.inp.nspin == 2 && !para.globalv.two_fermi)
{
for (int it = 0; it < ntype; ++it)
{
for (int ia = 0; ia < atoms[it].na; ++ia)
{
GlobalV::nupdown += atoms[it].mag[ia];
}
}
GlobalV::ofs_running << " The readin total magnetization is " << GlobalV::nupdown << std::endl;
}

if (!para.inp.use_paw)
{
// decide whether to be USPP
for (int it = 0; it < ntype; ++it)
{
if (atoms[it].ncpp.tvanp)
{
GlobalV::use_uspp = true;
}
}

// calculate the total number of local basis
GlobalV::NLOCAL = 0;
for (int it = 0; it < ntype; ++it)
{
const int nlocal_it = atoms[it].nw * atoms[it].na;
if (para.inp.nspin != 4)
{
GlobalV::NLOCAL += nlocal_it;
}
else
{
GlobalV::NLOCAL += nlocal_it * 2; // zhengdy-soc
}
}
}

// calculate the total number of electrons
cal_nelec(atoms, ntype, GlobalV::nelec);

// autoset and check GlobalV::NBANDS
std::vector<double> nelec_spin(2, 0.0);
if (para.inp.nspin == 2)
{
nelec_spin[0] = (GlobalV::nelec + GlobalV::nupdown) / 2.0;
nelec_spin[1] = (GlobalV::nelec - GlobalV::nupdown) / 2.0;
}
cal_nbands(GlobalV::nelec, GlobalV::NLOCAL, nelec_spin, GlobalV::NBANDS);

return;
}
};
#endif
4 changes: 2 additions & 2 deletions source/module_cell/module_neighbor/test/prepare_unitcell.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ UcellTestPrepare::UcellTestPrepare(std::string latname_in,
coor_type(coor_type_in),
coordinates(coordinates_in)
{
mbl = {0};
velocity = {0};
mbl = std::valarray<double>(0.0, coordinates_in.size());
velocity = std::valarray<double>(0.0, coordinates_in.size());
}

UcellTestPrepare::UcellTestPrepare(std::string latname_in,
Expand Down
4 changes: 2 additions & 2 deletions source/module_cell/test/prepare_unitcell.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ UcellTestPrepare::UcellTestPrepare(std::string latname_in,
coor_type(coor_type_in),
coordinates(coordinates_in)
{
mbl = {0};
velocity = {0};
mbl = std::valarray<double>(0.0, coordinates_in.size());
velocity = std::valarray<double>(0.0, coordinates_in.size());
}

UcellTestPrepare::UcellTestPrepare(std::string latname_in,
Expand Down
2 changes: 1 addition & 1 deletion source/module_cell/test/support/mock_unitcell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,5 @@ void UnitCell::setup(const std::string& latname_in,
const int& lmaxmax_in,
const bool& init_vel_in,
const std::string& fixed_axes_in) {}
void UnitCell::cal_nelec(double& nelec) {}
void cal_nelec(const Atom* atoms, const int& ntype, double& nelec) {}
void UnitCell::compare_atom_labels(std::string label1, std::string label2) {}
Loading

0 comments on commit 774840d

Please sign in to comment.