ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
KEDF_ML Class Reference

#include <kedf_ml.h>

Inheritance diagram for KEDF_ML:
Collaboration diagram for KEDF_ML:

Public Member Functions

 KEDF_ML ()
void set_para (const int nx, const double dV, const double nelec, const double tf_weight, const double vw_weight, const double chi_p, const double chi_q, const std::vector< double > &chi_xi, const std::vector< double > &chi_pnl, const std::vector< double > &chi_qnl, const int &nkernel, const std::vector< int > &kernel_type, const std::vector< double > &kernel_scaling, const std::vector< double > &yukawa_alpha, const std::vector< std::string > &kernel_file, const bool &of_ml_gamma, const bool &of_ml_p, const bool &of_ml_q, const bool &of_ml_tanhp, const bool &of_ml_tanhq, const std::vector< int > &of_ml_gammanl, const std::vector< int > &of_ml_pnl, const std::vector< int > &of_ml_qnl, const std::vector< int > &of_ml_xi, const std::vector< int > &of_ml_tanhxi, const std::vector< int > &of_ml_tanhxi_nl, const std::vector< int > &of_ml_tanh_pnl, const std::vector< int > &of_ml_tanh_qnl, const std::vector< int > &of_ml_tanhp_nl, const std::vector< int > &of_ml_tanhq_nl, const std::string device_inpt, ModulePW::PW_Basis *pw_rho, std::ostream &ofs_running)
double get_energy (const double *const *prho, ModulePW::PW_Basis *pw_rho)
 Get the energy of ML KEDF.
void ml_potential (const double *const *prho, ModulePW::PW_Basis *pw_rho, ModuleBase::matrix &rpotential)
 Get the potential of ML KEDF, and add it into rpotential.
void gen_training_data (const double *const *prho, ModulePW::PW_Basis *pw_rho, const double *veff)
 Generate training data for ML KEDF.
void localTest (const double *const *prho, ModulePW::PW_Basis *pw_rho)
 For test.
void init_data (const int &nkernel, const bool &of_ml_gamma, const bool &of_ml_p, const bool &of_ml_q, const bool &of_ml_tanhp, const bool &of_ml_tanhq, const std::vector< int > &of_ml_gammanl_, const std::vector< int > &of_ml_pnl, const std::vector< int > &of_ml_qnl, const std::vector< int > &of_ml_xi, const std::vector< int > &of_ml_tanhxi, const std::vector< int > &of_ml_tanhxi_nl, const std::vector< int > &of_ml_tanh_pnl, const std::vector< int > &of_ml_tanh_qnl, const std::vector< int > &of_ml_tanhp_nl, const std::vector< int > &of_ml_tanhq_nl, std::ostream &ofs_running)
 Initialize the data for ML KEDF, and generate the mapping between descriptor and kernel.
Public Member Functions inherited from ML_Base
 ML_Base ()
 ~ML_Base ()
void set_device (const std::string &device_inpt, std::ostream &ofs_running)
void load_vector (std::string filename, std::vector< double > &data)
void dump_vector (std::string filename, const std::vector< double > &data)
void dump_tensor (std::string filename, const torch::Tensor &data)
void dump_matrix (std::string filename, const ModuleBase::matrix &data)
torch::Tensor get_data (std::string parameter, const int ikernel) const

Public Attributes

double ml_energy = 0.
Public Attributes inherited from ML_Base
int nx_tot = 0

Additional Inherited Members

Protected Member Functions inherited from ML_Base
void update_input (const double *const *prho, const ModulePW::PW_Basis *pw_rho)
void nn_forward (const double *const *prho, const ModulePW::PW_Basis *pw_rho, bool cal_grad)
void get_potential_ (const double *const *prho, const ModulePW::PW_Basis *pw_rho, ModuleBase::matrix &rpotential)
double pot_gamma_term (int ir)
double pot_p_term_1 (int ir)
double pot_q_term_1 (int ir)
double pot_xi_term_1 (int ir)
double pot_tanhxi_term_1 (int ir)
double pot_tanhp_term_1 (int ir)
double pot_tanhq_term_1 (int ir)
void pot_gammanl_term (const double *const *prho, const std::vector< double > &tau_lda, const ModulePW::PW_Basis *pw_rho, std::vector< double > &rGammanlTerm)
void pot_xi_nl_term (const double *const *prho, const std::vector< double > &tau_lda, const ModulePW::PW_Basis *pw_rho, std::vector< double > &rXinlTerm)
void pot_tanhxi_nl_term (const double *const *prho, const std::vector< double > &tau_lda, const ModulePW::PW_Basis *pw_rho, std::vector< double > &rTanhxinlTerm)
void pot_tanhxi_nl_nl_term (const double *const *prho, const std::vector< double > &tau_lda, const ModulePW::PW_Basis *pw_rho, std::vector< double > &rTanhxi_nlTerm)
void pot_p_pnl_term (const double *const *prho, const std::vector< double > &tau_lda, const ModulePW::PW_Basis *pw_rho, std::vector< double > &rPPnlTerm)
void pot_q_qnl_term (const double *const *prho, const std::vector< double > &tau_lda, const ModulePW::PW_Basis *pw_rho, std::vector< double > &rQQnlTerm)
void pot_tanhp_tanh_pnl_term (const double *const *prho, const std::vector< double > &tau_lda, const ModulePW::PW_Basis *pw_rho, std::vector< double > &rTanhpTanh_pnlTerm)
void pot_tanhq_tanh_qnl_term (const double *const *prho, const std::vector< double > &tau_lda, const ModulePW::PW_Basis *pw_rho, std::vector< double > &rTanhqTanh_qnlTerm)
void pot_tanhp_tanhp_nl_term (const double *const *prho, const std::vector< double > &tau_lda, const ModulePW::PW_Basis *pw_rho, std::vector< double > &rTanhpTanhp_nlTerm)
void pot_tanhq_tanhq_nl_term (const double *const *prho, const std::vector< double > &tau_lda, const ModulePW::PW_Basis *pw_rho, std::vector< double > &rTanhqTanhq_nlTerm)
Protected Attributes inherited from ML_Base
ModuleIO::Cal_MLKEDF_Descriptors * cal_tool = nullptr
int nx = 0
double dV = 0.
double pqcoef = 1.0 / (4.0 * std::pow(3*std::pow(M_PI, 2.0), 2.0/3.0))
double feg_net_F = 0.0
double feg3_correct = 0.541324854612918
double energy_prefactor = 0.0
double energy_exponent = 0.0
int ninput = 0
std::vector< double > gamma
std::vector< double > p
std::vector< double > q
std::vector< std::vector< double > > gammanl
std::vector< std::vector< double > > pnl
std::vector< std::vector< double > > qnl
std::vector< std::vector< double > > nablaRho
std::vector< double > chi_xi
double chi_p = 1.0
double chi_q = 1.0
std::vector< std::vector< double > > xi
std::vector< std::vector< double > > tanhxi
std::vector< std::vector< double > > tanhxi_nl
std::vector< double > tanhp
std::vector< double > tanhq
std::vector< double > chi_pnl
std::vector< double > chi_qnl
std::vector< std::vector< double > > tanh_pnl
std::vector< std::vector< double > > tanh_qnl
std::vector< std::vector< double > > tanhp_nl
std::vector< std::vector< double > > tanhq_nl
torch::DeviceType device_type = torch::kCPU
torch::Device device = torch::Device(torch::kCPU)
torch::Device device_CPU = torch::Device(torch::kCPU)
std::shared_ptr< NN_OFImpl > nn
double * enhancement_cpu_ptr = nullptr
double * gradient_cpu_ptr = nullptr
int nkernel = 1
bool ml_gamma = false
bool ml_p = false
bool ml_q = false
bool ml_tanhp = false
bool ml_tanhq = false
bool ml_gammanl = false
bool ml_pnl = false
bool ml_qnl = false
bool ml_xi = false
bool ml_tanhxi = false
bool ml_tanhxi_nl = false
bool ml_tanh_pnl = false
bool ml_tanh_qnl = false
bool ml_tanhp_nl = false
bool ml_tanhq_nl = false
std::vector< std::string > descriptor_type
std::vector< int > kernel_index
std::map< std::string, std::vector< int > > descriptor2kernel
std::map< std::string, std::vector< int > > descriptor2index
std::map< std::string, std::vector< bool > > gene_data_label

Constructor & Destructor Documentation

◆ KEDF_ML()

KEDF_ML::KEDF_ML ( )
inline

Member Function Documentation

◆ gen_training_data()

void KEDF_ML::gen_training_data ( const double *const * prho,
ModulePW::PW_Basis * pw_rho,
const double * veff )

Generate training data for ML KEDF.

Parameters
prhocharge density
wtKEDF_WT
tfKEDF_TF
pw_rhoPW_Basis
veffeffective potential
Here is the call graph for this function:

◆ get_energy()

double KEDF_ML::get_energy ( const double *const * prho,
ModulePW::PW_Basis * pw_rho )

Get the energy of ML KEDF.

\‍[ E_{ML} = c_{TF} * \int{F(\rho) \rho^{5/3} dr} \‍]

Parameters
prhocharge density
pw_rhoPW_Basis
Returns
the energy of ML KEDF
Here is the call graph for this function:

◆ init_data()

void KEDF_ML::init_data ( const int & nkernel,
const bool & of_ml_gamma,
const bool & of_ml_p,
const bool & of_ml_q,
const bool & of_ml_tanhp,
const bool & of_ml_tanhq,
const std::vector< int > & of_ml_gammanl,
const std::vector< int > & of_ml_pnl,
const std::vector< int > & of_ml_qnl,
const std::vector< int > & of_ml_xi,
const std::vector< int > & of_ml_tanhxi,
const std::vector< int > & of_ml_tanhxi_nl,
const std::vector< int > & of_ml_tanh_pnl,
const std::vector< int > & of_ml_tanh_qnl,
const std::vector< int > & of_ml_tanhp_nl,
const std::vector< int > & of_ml_tanhq_nl,
std::ostream & ofs_running )

Initialize the data for ML KEDF, and generate the mapping between descriptor and kernel.

Parameters
nkernelnumber of kernels
of_ml_gammawhether to use gamma descriptor
of_ml_pwhether to use p descriptor
of_ml_qwhether to use q descriptor
of_ml_tanhpwhether to use tanhp descriptor
of_ml_tanhqwhether to use tanhq descriptor
of_ml_gammanlwhether to use gammanl descriptor
of_ml_pnlwhether to use pnl descriptor
of_ml_qnlwhether to use qnl descriptor
of_ml_xiwhether to use xi descriptor
of_ml_tanhxiwhether to use tanhxi descriptor
of_ml_tanhxi_nlwhether to use tanhxi_nl descriptor
of_ml_tanh_pnlwhether to use tanh_pnl descriptor
of_ml_tanh_qnlwhether to use tanh_qnl descriptor
of_ml_tanhp_nlwhether to use tanhp_nl descriptor
of_ml_tanhq_nlwhether to use tanhq_nl descriptor
Here is the call graph for this function:
Here is the caller graph for this function:

◆ localTest()

void KEDF_ML::localTest ( const double *const * pprho,
ModulePW::PW_Basis * pw_rho )

For test.

Parameters
prhocharge density
pw_rhoPW_Basis
Here is the call graph for this function:

◆ ml_potential()

void KEDF_ML::ml_potential ( const double *const * prho,
ModulePW::PW_Basis * pw_rho,
ModuleBase::matrix & rpotential )

Get the potential of ML KEDF, and add it into rpotential.

Parameters
prhocharge density
pw_rhoPW_Basis
rpotentialrpotential => rpotential + V_{ML}
Here is the call graph for this function:

◆ set_para()

void KEDF_ML::set_para ( const int nx,
const double dV,
const double nelec,
const double tf_weight,
const double vw_weight,
const double chi_p,
const double chi_q,
const std::vector< double > & chi_xi,
const std::vector< double > & chi_pnl,
const std::vector< double > & chi_qnl,
const int & nkernel,
const std::vector< int > & kernel_type,
const std::vector< double > & kernel_scaling,
const std::vector< double > & yukawa_alpha,
const std::vector< std::string > & kernel_file,
const bool & of_ml_gamma,
const bool & of_ml_p,
const bool & of_ml_q,
const bool & of_ml_tanhp,
const bool & of_ml_tanhq,
const std::vector< int > & of_ml_gammanl,
const std::vector< int > & of_ml_pnl,
const std::vector< int > & of_ml_qnl,
const std::vector< int > & of_ml_xi,
const std::vector< int > & of_ml_tanhxi,
const std::vector< int > & of_ml_tanhxi_nl,
const std::vector< int > & of_ml_tanh_pnl,
const std::vector< int > & of_ml_tanh_qnl,
const std::vector< int > & of_ml_tanhp_nl,
const std::vector< int > & of_ml_tanhq_nl,
const std::string device_inpt,
ModulePW::PW_Basis * pw_rho,
std::ostream & ofs_running )
Here is the call graph for this function:

Member Data Documentation

◆ ml_energy

double KEDF_ML::ml_energy = 0.

The documentation for this class was generated from the following files: