Skip to content
Merged
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
5 changes: 5 additions & 0 deletions source/source_base/module_device/memory_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ void set_dsp_cluster_id(int id)
g_dsp_cluster_id = id;
}

int get_dsp_cluster_id()
{
return g_dsp_cluster_id;
}

template <typename FPTYPE>
struct resize_memory_op_mt<FPTYPE, base_device::DEVICE_CPU>
{
Expand Down
3 changes: 3 additions & 0 deletions source/source_base/module_device/memory_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ struct delete_memory_op<FPTYPE, base_device::DEVICE_GPU>
/// Defaults to 0 if never set.
void set_dsp_cluster_id(int id);

/// @brief Read back the injected DSP cluster id. Returns 0 if never set.
int get_dsp_cluster_id();

template <typename FPTYPE, typename Device>
struct resize_memory_op_mt
{
Expand Down
10 changes: 8 additions & 2 deletions source/source_base/tool_quit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ namespace ModuleBase
namespace
{
std::string g_quit_out_dir;
std::string g_quit_calculation;
}

void set_quit_out_dir(const std::string& dir)
{
g_quit_out_dir = dir;
}

void set_quit_calculation(const std::string& calculation)
{
g_quit_calculation = calculation;
}

//==========================================================
// GLOBAL FUNCTION :
// NAME : WARNING( write information into GlobalV::ofs_warning)
Expand Down Expand Up @@ -139,7 +145,7 @@ void WARNING_QUIT(const std::string &file,const std::string &description,int ret

//Check and print warning information for all cores.
//Maybe in the future warning.log should be replaced by error.log.
void CHECK_WARNING_QUIT(const bool error_in, const std::string &file,const std::string &calculation,const std::string &description)
void CHECK_WARNING_QUIT(const bool error_in, const std::string &file, const std::string &description)
{
#ifdef __NORMAL
if(error_in) std::cout << description << std::endl;
Expand All @@ -150,7 +156,7 @@ void CHECK_WARNING_QUIT(const bool error_in, const std::string &file,const std::
std::cout.clear();
if(!GlobalV::ofs_running.is_open())
{
std::string logfile = g_quit_out_dir + "running_" + calculation + ".log";
std::string logfile = g_quit_out_dir + "running_" + g_quit_calculation + ".log";
GlobalV::ofs_running.open( logfile.c_str(), std::ios::app );
}
if(!GlobalV::ofs_warning.is_open())
Expand Down
12 changes: 11 additions & 1 deletion source/source_base/tool_quit.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ void WARNING(const std::string &file, const std::string &description);
*/
void set_quit_out_dir(const std::string& dir);

/**
* @brief Inject the calculation tag used by CHECK_WARNING_QUIT to compose the
* fallback log filename ("running_<calculation>.log") when ofs_running
* is not already open.
*
* Caller-injected (typically once after input parameters are read).
* If never set, the fallback filename uses an empty tag.
*/
void set_quit_calculation(const std::string& calculation);

/**
* @brief Close .log files and exit
*
Expand Down Expand Up @@ -71,7 +81,7 @@ void set_quit_out_dir(const std::string& dir);
* @param file The file where warning happens
* @param description The warning information
*/
void CHECK_WARNING_QUIT(const bool error, const std::string &file,const std::string &calculation,const std::string &description);
void CHECK_WARNING_QUIT(const bool error, const std::string &file, const std::string &description);

} // namespace ModuleBase

Expand Down
18 changes: 11 additions & 7 deletions source/source_basis/module_ao/ORB_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "source_base/parallel_common.h"
#include "source_base/timer.h"
#include "source_base/tool_check.h"
#include "source_io/module_parameter/parameter.h"

#include <algorithm>
#include <cassert>
Expand Down Expand Up @@ -58,6 +57,7 @@ void LCAO_Orbitals::init(
const double& lcao_rmax_in,
const bool& deepks_setorb,
const int& out_mat_r,
const bool& out_element_info,
const bool& force_flag,
const int& my_rank
)
Expand Down Expand Up @@ -86,7 +86,7 @@ void LCAO_Orbitals::init(
#ifdef __MPI
bcast_files(ntype, my_rank);
#endif
Read_Orbitals(ofs_in, ntype, lmax, deepks_setorb, out_mat_r, force_flag, my_rank);
Read_Orbitals(ofs_in, ntype, lmax, deepks_setorb, out_mat_r, out_element_info, force_flag, my_rank);
return;
}

Expand Down Expand Up @@ -156,6 +156,7 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in,
const int& lmax_in,
const bool& deepks_setorb,
const int& out_mat_r,
const bool& out_element_info,
const bool& force_flag, // mohan add 2021-05-07
const int& my_rank) // mohan add 2021-04-26
{
Expand Down Expand Up @@ -247,7 +248,7 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in,
this->Phi = new Numerical_Orbital[ntype];
for (int it = 0; it < ntype; it++)
{
this->Read_PAO(ofs_in, it, force_flag, my_rank);
this->Read_PAO(ofs_in, it, out_element_info, force_flag, my_rank);
// caoyu add 2021-05-24 to reconstruct atom_arrange::set_sr_NL
this->rcutmax_Phi = std::max(this->rcutmax_Phi, this->Phi[it].getRcut());
}
Expand All @@ -263,7 +264,7 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in,

delete[] this->Alpha;
this->Alpha = new Numerical_Orbital[1]; // not related to atom type -- remain to be discussed
this->Read_Descriptor(ofs_in, force_flag, my_rank);
this->Read_Descriptor(ofs_in, out_element_info, force_flag, my_rank);
}

ModuleBase::timer::end("LCAO_Orbitals", "Read_Orbitals");
Expand All @@ -279,6 +280,7 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in,
//-------------------------------------------------------
void LCAO_Orbitals::Read_PAO(std::ofstream& ofs_in,
const int& it,
const bool& out_element_info,
const bool& force_flag, // mohan add 2021-05-07
const int& my_rank) // mohan add 2021-04-26
{
Expand Down Expand Up @@ -311,7 +313,7 @@ void LCAO_Orbitals::Read_PAO(std::ofstream& ofs_in,
int lmaxt = 0;
int nchimaxt = 0;

this->read_orb_file(ofs_in, in_ao, it, lmaxt, nchimaxt, this->Phi, force_flag, my_rank);
this->read_orb_file(ofs_in, in_ao, it, lmaxt, nchimaxt, this->Phi, out_element_info, force_flag, my_rank);

// lmax and nchimax for all types
this->lmax = std::max(this->lmax, lmaxt);
Expand All @@ -323,6 +325,7 @@ void LCAO_Orbitals::Read_PAO(std::ofstream& ofs_in,

// caoyu add 2021-3-16
void LCAO_Orbitals::Read_Descriptor(std::ofstream& ofs_in,
const bool& out_element_info,
const bool& force_flag, // mohan add 2021-05-07
const int& my_rank) // read descriptor basis
{
Expand Down Expand Up @@ -355,7 +358,7 @@ void LCAO_Orbitals::Read_Descriptor(std::ofstream& ofs_in,
this->lmax_d = 0;
this->nchimax_d = 0;

this->read_orb_file(ofs_in, in_de, 0, this->lmax_d, this->nchimax_d, this->Alpha, force_flag, my_rank);
this->read_orb_file(ofs_in, in_de, 0, this->lmax_d, this->nchimax_d, this->Alpha, out_element_info, force_flag, my_rank);

in_de.close();

Expand All @@ -368,6 +371,7 @@ void LCAO_Orbitals::read_orb_file(std::ofstream& ofs_in, // GlobalV::ofs_running
int& lmax,
int& nchimax,
Numerical_Orbital* ao,
const bool& out_element_info,
const bool& force_flag,
const int& my_rank)
{
Expand Down Expand Up @@ -588,7 +592,7 @@ void LCAO_Orbitals::read_orb_file(std::ofstream& ofs_in, // GlobalV::ofs_running
this->kmesh,
this->dk,
this->dr_uniform,
PARAM.inp.out_element_info,
out_element_info,
true,
force_flag); // delta k mesh in reciprocal space

Expand Down
13 changes: 9 additions & 4 deletions source/source_basis/module_ao/ORB_read.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class LCAO_Orbitals
const double& lcao_rmax_in,
const bool& deepks_setorb,
const int& out_mat_r,
const bool& out_element_info,
const bool& force_flag,
const int& my_rank
);
Expand All @@ -44,19 +45,22 @@ class LCAO_Orbitals
const int &lmax_in,
const bool &deepks_setorb, // mohan add 2021-04-25
const int &out_mat_r, // mohan add 2021-04-26
const bool &out_element_info,
const bool &force_flag, // mohan add 2021-05-07
const int &my_rank); // mohan add 2021-04-26

void Read_PAO(
std::ofstream &ofs_in,
const int& it,
const bool &out_element_info,
const bool &force_flag, // mohan add 2021-05-07
const int& my_rank); // mohan add 2021-04-26



void Read_Descriptor(
std::ofstream &ofs_in,
const bool &out_element_info,
const bool &force_flag, // mohan add 2021-05-07
const int &my_rank); //caoyu add 2020-3-16

Expand Down Expand Up @@ -119,11 +123,12 @@ class LCAO_Orbitals

void read_orb_file(
std::ofstream &ofs_in,
std::ifstream &ifs,
const int &it,
int &lmax,
int &nchimax,
std::ifstream &ifs,
const int &it,
int &lmax,
int &nchimax,
Numerical_Orbital* ao,
const bool &out_element_info,
const bool &force_flag, // mohan add 2021-05-07
const int &my_rank); //caoyu add 2021-04-26

Expand Down
4 changes: 2 additions & 2 deletions source/source_basis/module_ao/test/ORB_read_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ void LcaoOrbitalsTest::lcao_read() {
lcao_.dR = dR_;
lcao_.Rmax = Rmax_;

lcao_.Read_Orbitals(ofs_log_, ntype_, lmax_, deepks_setorb_, out_mat_r_,
force_flag_, my_rank_);
lcao_.Read_Orbitals(ofs_log_, ntype_, lmax_, deepks_setorb_, out_mat_r_,
false /* out_element_info */, force_flag_, my_rank_);
}


Expand Down
1 change: 1 addition & 0 deletions source/source_basis/module_ao/test/ORB_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void test_orb::set_orbs()
lcao_rmax,
0,
0,
false, // out_element_info
1, // force
0); // myrank

Expand Down
9 changes: 6 additions & 3 deletions source/source_basis/module_nao/numerical_radial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "source_base/global_variable.h"
#include "source_base/math_integral.h"
#include "source_base/spherical_bessel_transformer.h"
#include "source_io/module_parameter/parameter.h"

using ModuleBase::PI;

Expand Down Expand Up @@ -154,7 +153,11 @@ void NumericalRadial::build(const int l,
set_icut(for_r_space, !for_r_space);
}

void NumericalRadial::to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm, const int nk_legacy, const double lcao_dk) const
void NumericalRadial::to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm,
const int nk_legacy,
const double lcao_dk,
const bool out_element_info,
const bool cal_force) const
{
#ifdef __DEBUG
assert(rgrid_);
Expand All @@ -171,7 +174,7 @@ void NumericalRadial::to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm,

orbital_lm.set_orbital_info(symbol_, itype_, l_, izeta_, std::min(nr_, ircut_+1), rab, rgrid_,
Numerical_Orbital_Lm::Psi_Type::Psi, rvalue_, nk_legacy, lcao_dk,
0.001 /* dr_uniform */, PARAM.inp.out_element_info, true, PARAM.inp.cal_force);
0.001 /* dr_uniform */, out_element_info, true, cal_force);
delete[] rab;
}

Expand Down
6 changes: 4 additions & 2 deletions source/source_basis/module_nao/numerical_radial.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ class NumericalRadial
* use the k grid of NumericalRadial (which is FFT-compliant with r grid) to initialize
* the k grid of Numerical_Orbital_Lm.
*/
void to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm,
void to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm,
const int nk_legacy = 4005, // equivalent to lcao_ecut = 1600
const double lcao_dk = 0.01) const;
const double lcao_dk = 0.01,
const bool out_element_info = false,
const bool cal_force = false) const;

/**
* @brief Sets a SphericalBesselTransformer.
Expand Down
8 changes: 6 additions & 2 deletions source/source_basis/module_nao/radial_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,17 @@ RadialSet& RadialSet::operator=(const RadialSet& rhs)
return *this;
}

void RadialSet::to_numerical_orbital(Numerical_Orbital& no, const int nk_legacy, const double lcao_dk) const
void RadialSet::to_numerical_orbital(Numerical_Orbital& no,
const int nk_legacy,
const double lcao_dk,
const bool out_element_info,
const bool cal_force) const
{
no.chi().clear();
no.chi().resize(nchi_);
for (int i = 0; i < nchi_; i++)
{
chi_[i].to_numerical_orbital_lm(no.chi()[i], nk_legacy, lcao_dk);
chi_[i].to_numerical_orbital_lm(no.chi()[i], nk_legacy, lcao_dk, out_element_info, cal_force);
}

no.set_orbital_info(itype_, symbol_, lmax_, nzeta_, nchi_);
Expand Down
4 changes: 3 additions & 1 deletion source/source_basis/module_nao/radial_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ class RadialSet
*/
virtual void to_numerical_orbital(Numerical_Orbital&,
const int nk_legacy = 4005, // equivalent to lcao_ecut = 1600
const double lcao_dk = 0.01
const double lcao_dk = 0.01,
const bool out_element_info = false,
const bool cal_force = false
) const;

/**
Expand Down
8 changes: 5 additions & 3 deletions source/source_basis/module_nao/two_center_bundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ void TwoCenterBundle::to_LCAO_Orbitals(LCAO_Orbitals& ORB,
const double lcao_ecut,
const double lcao_dk,
const double lcao_dr,
const double lcao_rmax) const
const double lcao_rmax,
const bool out_element_info,
const bool cal_force) const
{
ORB.ntype = orb_->ntype();
ORB.lmax = orb_->lmax();
Expand Down Expand Up @@ -240,7 +242,7 @@ void TwoCenterBundle::to_LCAO_Orbitals(LCAO_Orbitals& ORB,
ORB.Phi = new Numerical_Orbital[orb_->ntype()];
for (int itype = 0; itype < orb_->ntype(); ++itype)
{
(*orb_)(itype).to_numerical_orbital(ORB.Phi[itype], ORB.kmesh, ORB.dk);
(*orb_)(itype).to_numerical_orbital(ORB.Phi[itype], ORB.kmesh, ORB.dk, out_element_info, cal_force);
}

if (PARAM.globalv.deepks_setorb)
Expand All @@ -252,7 +254,7 @@ void TwoCenterBundle::to_LCAO_Orbitals(LCAO_Orbitals& ORB,
ORB.Alpha = new Numerical_Orbital[alpha_->ntype()];
for (int itype = 0; itype < alpha_->ntype(); ++itype)
{
(*alpha_)(itype).to_numerical_orbital(ORB.Alpha[itype], ORB.kmesh, ORB.dk);
(*alpha_)(itype).to_numerical_orbital(ORB.Alpha[itype], ORB.kmesh, ORB.dk, out_element_info, cal_force);
}
}
}
4 changes: 3 additions & 1 deletion source/source_basis/module_nao/two_center_bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class TwoCenterBundle
const double lcao_ecut,
const double lcao_dk,
const double lcao_dr,
const double lcao_rmax) const;
const double lcao_rmax,
const bool out_element_info,
const bool cal_force) const;

std::unique_ptr<TwoCenterIntegrator> kinetic_orb;
std::unique_ptr<TwoCenterIntegrator> overlap_orb;
Expand Down
6 changes: 2 additions & 4 deletions source/source_basis/module_pw/pw_basis_k.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include "pw_basis_k.h"

#include "source_base/constants.h"
#include "source_base/global_variable.h"
#include "source_base/memory_recorder.h"
#include "source_base/module_device/memory_op.h"
#include "source_base/timer.h"
#include "source_io/module_parameter/parameter.h"

#include <utility>
namespace ModulePW
Expand Down Expand Up @@ -157,7 +156,6 @@ void PW_Basis_K::setupIndGk()
}
ModuleBase::CHECK_WARNING_QUIT((ng == 0),
"pw_basis_k.cpp",
PARAM.inp.calculation,
no_pw_message);
if (this->npwk_max < ng)
{
Expand Down Expand Up @@ -216,7 +214,7 @@ void PW_Basis_K::setuptransform()
std::string fft_device = this->device;
#if defined(__DSP)
fft_device = "dsp";
this->fft_bundle.set_dsp_cluster_id(GlobalV::MY_RANK % PARAM.inp.dsp_count);
this->fft_bundle.set_dsp_cluster_id(base_device::memory::get_dsp_cluster_id());
#endif
this->fft_bundle.setfft(fft_device, this->precision);
if (this->xprime)
Expand Down
Loading
Loading