107 double cal_mu(
double *pphi,
double *pdEdphi,
double nelec);
static float dot(const int n, const float *const X, const int incX, const float *const Y, const int incY, base_device::AbacusDevice_t device_type=base_device::AbacusDevice_t::CpuDevice)
Definition blas_connector_vector.cpp:143
Definition kedf_manager.h:16
A class designed to deal with optimization problems with CG method. Three forms of CG methods have be...
Definition opt_cg.h:25
A interface to line search.
Definition opt_dcsrch.h:17
A class designed to deal with optimization problems with Truncated-Newton (TN) method....
Definition opt_tn.h:22
Definition esolver_fp.h:33
Definition opt_test_tools.h:19
std::vector< double * > pdLdphi_
Definition esolver_of.h:66
double ** pphi_
Definition esolver_of.h:67
bool check_exit(bool &conv_esolver)
Check convergence, return ture if converge or iter >= max_iter_, and print the necessary information.
Definition esolver_of.cpp:375
Charge * ptemp_rho_
Definition esolver_of.h:72
std::string task_
Definition esolver_of.h:68
void optimize(UnitCell &ucell)
Get the optimization direction (this->pdirection_) and the step length (this->theta).
Definition esolver_of.cpp:319
virtual void cal_stress(BaseCell &basecell, ModuleBase::matrix &stress) override
Calculate the stress.
Definition esolver_of.cpp:542
double inner_product(double *pa, double *pb, int length, double dV=1) const
Definition esolver_of.h:115
double energy_last_
Definition esolver_of.h:77
void before_opt(const int istep, UnitCell &ucell)
Prepare to optimize the charge density, update elecstate, kedf, and opts if needed calculate ewald en...
Definition esolver_of.cpp:184
std::vector< double > pdEdphi_storage_
Definition esolver_of.h:63
void test_direction(double *dEdtheta, double **ptemp_phi, UnitCell &ucell)
ONLY used for test. Check the validity of KEDF.
Definition esolver_of_tool.cpp:359
int flag_
Definition esolver_of.h:71
int max_dcsrch_
Definition esolver_of.h:70
std::vector< std::complex< double > * > precip_dir_
Definition esolver_of.h:61
double energy_current_
Definition esolver_of.h:78
std::vector< std::complex< double > > precip_dir_storage_
Definition esolver_of.h:60
psi::Psi< double > * psi_
Definition esolver_of.h:73
int max_iter_
Definition esolver_of.h:50
void update_potential(UnitCell &ucell)
Get dL/dphi = dL/drho * drho/dphi = (dE/drho - mu) * 2 * phi, as well as normdLdphi = sqrt{<dL/dphi|d...
Definition esolver_of.cpp:275
void cal_potential(double *ptemp_phi, double *rdLdphi, UnitCell &ucell)
Get dL/dphi = dL/drho * drho/dphi = (dE/drho - mu) * 2 * ptemp_phi and store it in rdLdphi.
Definition esolver_of_tool.cpp:131
std::vector< double > theta_
Definition esolver_of.h:62
virtual void before_all_runners(BaseCell &basecell, const Input_para &inp) override
Initialize of the first-principels energy solver.
Definition esolver_of.cpp:41
void allocate_array()
Allocate the arrays, as well as this->psi_ and this->ptemp_rho_.
Definition esolver_of_tool.cpp:72
std::string of_method_
Definition esolver_of.h:46
KEDF_Manager * kedf_manager_
Definition esolver_of.h:36
void after_opt(const int istep, UnitCell &ucell, const bool conv_esolver)
After optimization, output the charge density, effective potential, ..., if needed.
Definition esolver_of.cpp:431
double dV_
Definition esolver_of.h:53
double of_tolp_
Definition esolver_of.h:49
void get_direction(UnitCell &ucell)
[Interface to opt] Call optimization methods to get the optimization direction
Definition esolver_of_interface.cpp:60
std::vector< double * > pdEdphi_
Definition esolver_of.h:64
double cal_mu(double *pphi, double *pdEdphi, double nelec)
Calculate the chemical potential mu. mu = <dE/dphi|phi> / (2 * nelec).
Definition esolver_of_tool.cpp:216
void init_opt()
[Interface to opt] Initialize the opts
Definition esolver_of_interface.cpp:11
std::string of_conv_
Definition esolver_of.h:47
ModuleBase::Opt_TN * opt_tn_
Definition esolver_of.h:40
std::function< void(double *, double *)> bound_cal_potential_
Definition esolver_of.h:98
virtual void after_all_runners(BaseCell &basecell) override
Output the FINAL_ETOT.
Definition esolver_of.cpp:485
void check_direction(double *dEdtheta, double **ptemp_phi, UnitCell &ucell)
Make sure that dEdtheta<0 at theta = 0, preparing to call the line search.
Definition esolver_of_tool.cpp:309
void cal_dEdtheta(double **ptemp_phi, Charge *temp_rho, UnitCell &ucell, double *ptheta, double *rdEdtheta)
Calculate dE/dTheta and store it in rdEdtheta. dE/dTheta = <dE / dtemp_phi | dtemp_phi / dTheta> = <d...
Definition esolver_of_tool.cpp:180
double normdLdphi_last_
Definition esolver_of.h:80
virtual double cal_energy() override
Calculate the total energy. NOTE THIS FUNCTION SHOULD BE CALLEDD AFTER POTENTIAL HAS BEEN UPDATED.
Definition esolver_of.cpp:499
void get_step_length(double *dEdtheta, double **ptemp_phi, UnitCell &ucell)
[Interface to opt] Call line search to find the best step length
Definition esolver_of_interface.cpp:98
double normdLdphi_llast_
Definition esolver_of.h:79
std::vector< double > nelec_
Definition esolver_of.h:54
ModuleBase::Opt_CG * opt_cg_mag_
Definition esolver_of.h:42
std::vector< double * > pdirect_
Definition esolver_of.h:59
void cal_potential_wrapper(double *ptemp_phi, double *rdLdphi)
Definition esolver_of_interface.cpp:51
void resize_spin_arrays()
Definition esolver_of_tool.cpp:100
std::vector< double > pdirect_storage_
Definition esolver_of.h:58
ModuleBase::Opt_DCsrch * opt_dcsrch_
Definition esolver_of.h:41
void adjust_direction()
Rotate and renormalize the direction |d>, make it orthogonal to phi (<d|phi> = 0),...
Definition esolver_of_tool.cpp:228
void init_elecstate(UnitCell &ucell)
Initialize this->pelec, as well as this->pelec->pot.
Definition esolver_of_tool.cpp:22
int tn_spin_flag_
Definition esolver_of.h:69
double of_tole_
Definition esolver_of.h:48
virtual void runner(BaseCell &basecell, const int istep) override
run energy solver
Definition esolver_of.cpp:131
virtual void cal_force(BaseCell &basecell, ModuleBase::matrix &force) override
Calculate the force.
Definition esolver_of.cpp:522
std::vector< double > pdLdphi_storage_
Definition esolver_of.h:65
void update_rho()
Update the charge density and "wavefunction" (phi) after one step of optimization phi = cos(theta) * ...
Definition esolver_of.cpp:355
ModuleBase::Opt_CG * opt_cg_
Definition esolver_of.h:39
int iter_
Definition esolver_of.h:57
std::string of_kinetic_
Definition esolver_of.h:45
double energy_llast_
Definition esolver_of.h:76
double normdLdphi_
Definition esolver_of.h:81
bool conv_esolver
Definition esolver.h:46
Provide the basic information about unitcell.
Definition unitcell.h:16
The First-Principles (FP) Energy Solver Class.
Definition opt_test_tools.cpp:93