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
4 changes: 2 additions & 2 deletions source/module_base/global_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ static inline const T* VECTOR_TO_PTR(const std::valarray<T>& v)
// Peize Lin add 2016-07-18
//==========================================================
template <typename T>
std::string TO_STRING(const T& n)
std::string TO_STRING(const T& t, const int n=20) // n=20 since LDBL_EPSILON is 1E-16 or 1E-19
{
std::stringstream newstr;
newstr << n;
newstr << std::setprecision(n) << t;
return newstr.str();
}

Expand Down
2 changes: 1 addition & 1 deletion source/module_base/gram_schmidt_orth-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Func_Type Gram_Schmidt_Orth<Func_Type,R_Type>::cal_norm( const std::vector<Func_
}
default:
{
throw std::invalid_argument("coordinate must be Cartesian or Sphere "+ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__));
throw std::invalid_argument("coordinate must be Cartesian or Sphere "+std::string(__FILE__)+" line "+std::to_string(__LINE__));
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/module_base/mathzone_add1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ double Mathzone_Add1::Uni_RadialF

if (newr < 0.0)
{
throw std::runtime_error("newr should >= 0. "+ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__));
throw std::runtime_error("newr should >= 0. "+std::string(__FILE__)+" line "+std::to_string(__LINE__));

}
else if ( rmax <= newr )
Expand Down
2 changes: 1 addition & 1 deletion source/module_base/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Random
const int a = std::rand() % 2;
if(a==0) return between0and1();
else if(a==1) return betweenMinus1and0();
else throw(ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__)); // Peize Lin add to fix warning 2019-05-01
else throw(std::string(__FILE__)+" line "+std::to_string(__LINE__)); // Peize Lin add to fix warning 2019-05-01
}

static double between0and1(void)
Expand Down
4 changes: 2 additions & 2 deletions source/module_basis/module_ao/ORB_atomic_lm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void Numerical_Orbital_Lm::set_orbital_info
this->psik2[ik] = psi_in[ik];
break;
default:
throw std::domain_error(ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__));
throw std::domain_error(std::string(__FILE__)+" line "+std::to_string(__LINE__));
}

switch(psi_type)
Expand All @@ -111,7 +111,7 @@ void Numerical_Orbital_Lm::set_orbital_info
}
else
{
throw std::domain_error("flag_sbpool false not finished in Numerical_Orbital_Lm::set_orbital_info_k. "+ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__));
throw std::domain_error("flag_sbpool false not finished in Numerical_Orbital_Lm::set_orbital_info_k. "+std::string(__FILE__)+" line "+std::to_string(__LINE__));
}
break;
default: break;
Expand Down
22 changes: 19 additions & 3 deletions source/module_hamilt_general/module_xc/exx_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,29 @@
#include "module_ri/conv_coulomb_pot_k.h"
#include "xc_functional.h"

#include <vector>
#include <map>
#include <unordered_map>
#include <string>

struct Exx_Info
{
struct Exx_Info_Global
{
bool cal_exx = false;

std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> coulomb_param;
// Fock:
// "alpha": "0"
// "Rcut_type": "limits" / "spencer"
// "lambda": "0.3"
// //"Rcut"
// Erfc:
// "alpha": "0"
// "omega": "0.11"
// "Rcut_type": "limits"
// //"Rcut"

Conv_Coulomb_Pot_K::Ccp_Type ccp_type;
double hybrid_alpha = 0.25;
double hse_omega = 0.11;
Expand All @@ -35,8 +52,7 @@ struct Exx_Info

struct Exx_Info_RI
{
const Conv_Coulomb_Pot_K::Ccp_Type& ccp_type;
const double& hse_omega;
const std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param;

bool real_number = false;

Expand All @@ -58,7 +74,7 @@ struct Exx_Info
int abfs_Lmax = 0; // tmp

Exx_Info_RI(const Exx_Info::Exx_Info_Global& info_global)
: ccp_type(info_global.ccp_type), hse_omega(info_global.hse_omega)
: coulomb_param(info_global.coulomb_param)
{
}
};
Expand Down
56 changes: 32 additions & 24 deletions source/module_hamilt_general/module_xc/xc_functional_libxc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,44 +149,52 @@ XC_Functional_Libxc::set_xc_type_libxc(const std::string& xc_func_in)

const std::vector<double> in_built_xc_func_ext_params(const int id)
{
const std::map<int, std::vector<double>> mymap = {
switch(id)
{
// finite temperature XC functionals
{XC_LDA_XC_KSDT, {PARAM.inp.xc_temperature * 0.5}},
{XC_LDA_XC_CORRKSDT, {PARAM.inp.xc_temperature * 0.5}},
{XC_LDA_XC_GDSMFB, {PARAM.inp.xc_temperature * 0.5}},
// hybrid functionals
case XC_LDA_XC_KSDT:
return {PARAM.inp.xc_temperature * 0.5};
case XC_LDA_XC_CORRKSDT:
return {PARAM.inp.xc_temperature * 0.5};
case XC_LDA_XC_GDSMFB:
return {PARAM.inp.xc_temperature * 0.5};
#ifdef __EXX
{XC_HYB_GGA_XC_PBEH, {GlobalC::exx_info.info_global.hybrid_alpha,
GlobalC::exx_info.info_global.hse_omega,
GlobalC::exx_info.info_global.hse_omega}},
{XC_HYB_GGA_XC_HSE06, {GlobalC::exx_info.info_global.hybrid_alpha,
GlobalC::exx_info.info_global.hse_omega,
GlobalC::exx_info.info_global.hse_omega}},
// hybrid functionals
case XC_HYB_GGA_XC_PBEH:
return {GlobalC::exx_info.info_global.hybrid_alpha,
GlobalC::exx_info.info_global.hse_omega,
GlobalC::exx_info.info_global.hse_omega};
case XC_HYB_GGA_XC_HSE06:
return {GlobalC::exx_info.info_global.hybrid_alpha,
GlobalC::exx_info.info_global.hse_omega,
GlobalC::exx_info.info_global.hse_omega};
// short-range of B88_X
{XC_GGA_X_ITYH, {PARAM.inp.exx_hse_omega}},
case XC_GGA_X_ITYH:
return {PARAM.inp.exx_hse_omega};
// short-range of LYP_C
{XC_GGA_C_LYPR, {0.04918, 0.132, 0.2533, 0.349,
0.35/2.29, 2.0/2.29, PARAM.inp.exx_hse_omega}},
case XC_GGA_C_LYPR:
return {0.04918, 0.132, 0.2533, 0.349,
0.35/2.29, 2.0/2.29, PARAM.inp.exx_hse_omega};
#endif
};
auto it = mymap.find(id);
return (it != mymap.end()) ? it->second : std::vector<double>{};
default:
return std::vector<double>{};
}
}

const std::vector<double> external_xc_func_ext_params(const int id)
{
const std::map<int, std::vector<double>> mymap = {
{
PARAM.inp.xc_exch_ext[0],
{
PARAM.inp.xc_exch_ext[0],
std::vector<double>(PARAM.inp.xc_exch_ext.begin()+1,
PARAM.inp.xc_exch_ext.end())
PARAM.inp.xc_exch_ext.end())
},
{
PARAM.inp.xc_corr_ext[0],
{
PARAM.inp.xc_corr_ext[0],
std::vector<double>(PARAM.inp.xc_corr_ext.begin()+1,
PARAM.inp.xc_corr_ext.end())
PARAM.inp.xc_corr_ext.end())
}
};
};
auto it = mymap.find(id);
return (it != mymap.end()) ? it->second : std::vector<double>{};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void XC_Functional::gcxc(const double &rho, const double &grho, double &sxc,
v2 = v2x + v2c;
break;
default: //SCAN_X,SCAN_C,HSE, and so on
throw std::domain_error("functional unfinished in "+ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__));
throw std::domain_error("functional unfinished in "+std::string(__FILE__)+" line "+std::to_string(__LINE__));
}
sxc += s;
v1xc += v1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void XC_Functional::xc_spin(const double &rho, const double &zeta,

// Cases that are only realized in LIBXC
default:
throw std::domain_error("functional unfinished in "+ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__)); break;
throw std::domain_error("functional unfinished in "+std::string(__FILE__)+" line "+std::to_string(__LINE__)); break;

}
exc += e;
Expand Down
10 changes: 5 additions & 5 deletions source/module_hsolver/diago_lapack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ int DiagoLapack<T>::dsygvx_once(const int ncol,
// Throw error if it returns info
if (info)
throw std::runtime_error("info = " + ModuleBase::GlobalFunc::TO_STRING(info) + ".\n"
+ ModuleBase::GlobalFunc::TO_STRING(__FILE__) + " line "
+ ModuleBase::GlobalFunc::TO_STRING(__LINE__));
+ std::string(__FILE__) + " line "
+ std::to_string(__LINE__));
//lwork = work[0];
//work.resize(std::max(lwork, 3), 0);
//iwork.resize(iwork[0], 0);
Expand Down Expand Up @@ -205,8 +205,8 @@ int DiagoLapack<T>::zhegvx_once(const int ncol,

if (info)
throw std::runtime_error("info=" + ModuleBase::GlobalFunc::TO_STRING(info) + ". "
+ ModuleBase::GlobalFunc::TO_STRING(__FILE__) + " line "
+ ModuleBase::GlobalFunc::TO_STRING(__LINE__));
+ std::string(__FILE__) + " line "
+ std::to_string(__LINE__));

// GlobalV::ofs_running<<"lwork="<<work[0]<<"\t"<<"lrwork="<<rwork[0]<<"\t"<<"liwork="<<iwork[0]<<std::endl;

Expand Down Expand Up @@ -290,7 +290,7 @@ void DiagoLapack<T>::post_processing(const int info, const std::vector<int>& vec
{
const std::string str_info = "info = " + ModuleBase::GlobalFunc::TO_STRING(info) + ".\n";
const std::string str_FILE
= ModuleBase::GlobalFunc::TO_STRING(__FILE__) + " line " + ModuleBase::GlobalFunc::TO_STRING(__LINE__) + ".\n";
= std::string(__FILE__) + " line " + std::to_string(__LINE__) + ".\n";
const std::string str_info_FILE = str_info + str_FILE;

if (info == 0)
Expand Down
18 changes: 9 additions & 9 deletions source/module_hsolver/diago_scalapack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ namespace hsolver
&info);
if (info) {
throw std::runtime_error("info = " + ModuleBase::GlobalFunc::TO_STRING(info) + ".\n"
+ ModuleBase::GlobalFunc::TO_STRING(__FILE__) + " line "
+ ModuleBase::GlobalFunc::TO_STRING(__LINE__));
+ std::string(__FILE__) + " line "
+ std::to_string(__LINE__));
}

// GlobalV::ofs_running<<"lwork="<<work[0]<<"\t"<<"liwork="<<iwork[0]<<std::endl;
Expand Down Expand Up @@ -198,8 +198,8 @@ namespace hsolver
return std::make_pair(info, ifail);
} else {
throw std::runtime_error("info = " + ModuleBase::GlobalFunc::TO_STRING(info) + ".\n"
+ ModuleBase::GlobalFunc::TO_STRING(__FILE__) + " line "
+ ModuleBase::GlobalFunc::TO_STRING(__LINE__));
+ std::string(__FILE__) + " line "
+ std::to_string(__LINE__));
}
}
template<typename T>
Expand Down Expand Up @@ -269,8 +269,8 @@ namespace hsolver
&info);
if (info) {
throw std::runtime_error("info=" + ModuleBase::GlobalFunc::TO_STRING(info) + ". "
+ ModuleBase::GlobalFunc::TO_STRING(__FILE__) + " line "
+ ModuleBase::GlobalFunc::TO_STRING(__LINE__));
+ std::string(__FILE__) + " line "
+ std::to_string(__LINE__));
}

// GlobalV::ofs_running<<"lwork="<<work[0]<<"\t"<<"lrwork="<<rwork[0]<<"\t"<<"liwork="<<iwork[0]<<std::endl;
Expand Down Expand Up @@ -334,8 +334,8 @@ namespace hsolver
return std::make_pair(info, ifail);
} else {
throw std::runtime_error("info = " + ModuleBase::GlobalFunc::TO_STRING(info) + ".\n"
+ ModuleBase::GlobalFunc::TO_STRING(__FILE__) + " line "
+ ModuleBase::GlobalFunc::TO_STRING(__LINE__));
+ std::string(__FILE__) + " line "
+ std::to_string(__LINE__));
}
}
template<typename T>
Expand Down Expand Up @@ -381,7 +381,7 @@ namespace hsolver
{
const std::string str_info = "info = " + ModuleBase::GlobalFunc::TO_STRING(info) + ".\n";
const std::string str_FILE
= ModuleBase::GlobalFunc::TO_STRING(__FILE__) + " line " + ModuleBase::GlobalFunc::TO_STRING(__LINE__) + ".\n";
= std::string(__FILE__) + " line " + std::to_string(__LINE__) + ".\n";
const std::string str_info_FILE = str_info + str_FILE;

if (info == 0)
Expand Down
Loading
Loading