12class ESolver_OF :
public ESolver_FP
94 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:142
Definition kedf_manager.h:15
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:16
A class designed to deal with optimization problems with Truncated-Newton (TN) method....
Definition opt_TN.hpp:22
double ** pphi_
Definition esolver_of.h:60
virtual void after_all_runners(UnitCell &ucell) override
Output the FINAL_ETOT.
Definition esolver_of.cpp:540
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:430
Charge * ptemp_rho_
Definition esolver_of.h:65
void optimize(UnitCell &ucell)
Get the optimization direction (this->pdirection_) and the step length (this->theta)
Definition esolver_of.cpp:355
double energy_last_
Definition esolver_of.h:70
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:208
void test_direction(double *dEdtheta, double **ptemp_phi, UnitCell &ucell)
ONLY used for test. Check the validity of KEDF.
Definition esolver_of_tool.cpp:356
double inner_product(double *pa, double *pb, int length, double dV=1)
Definition esolver_of.h:105
int flag_
Definition esolver_of.h:64
int max_dcsrch_
Definition esolver_of.h:63
double ** pdLdphi_
Definition esolver_of.h:59
double energy_current_
Definition esolver_of.h:71
psi::Psi< double > * psi_
Definition esolver_of.h:66
int max_iter_
Definition esolver_of.h:47
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:310
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:119
virtual void before_all_runners(UnitCell &ucell, const Input_para &inp) override
Initialize of the first-principels energy solver.
Definition esolver_of.cpp:58
void allocate_array()
Allocate the arrays, as well as this->psi_ and this->ptemp_rho_.
Definition esolver_of_tool.cpp:71
std::string of_method_
Definition esolver_of.h:43
KEDF_Manager * kedf_manager_
Definition esolver_of.h:33
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:484
double dV_
Definition esolver_of.h:50
double of_tolp_
Definition esolver_of.h:46
void get_direction(UnitCell &ucell)
[Interface to opt] Call optimization methods to get the optimization direction
Definition esolver_of_interface.cpp:61
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:211
virtual void cal_force(UnitCell &ucell, ModuleBase::matrix &force) override
Calculate the force.
Definition esolver_of.cpp:575
double * nelec_
Definition esolver_of.h:51
void init_opt()
[Interface to opt] Initialize the opts
Definition esolver_of_interface.cpp:12
std::string of_conv_
Definition esolver_of.h:44
void print_info(const bool conv_esolver)
Print nessecary information to the screen, and write the components of the total energy into running_...
Definition esolver_of_tool.cpp:395
ModuleBase::Opt_TN * opt_tn_
Definition esolver_of.h:37
virtual void runner(UnitCell &ucell, const int istep) override
run energy solver
Definition esolver_of.cpp:153
virtual void cal_stress(UnitCell &ucell, ModuleBase::matrix &stress) override
Calculate the stress.
Definition esolver_of.cpp:586
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:304
std::complex< double > ** precip_dir_
Definition esolver_of.h:56
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:177
double normdLdphi_last_
Definition esolver_of.h:73
virtual double cal_energy() override
Calculate the total energy. NOTE THIS FUNCTION SHOULD BE CALLEDD AFTER POTENTIAL HAS BEEN UPDATED.
Definition esolver_of.cpp:551
char * task_
Definition esolver_of.h:61
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:102
double normdLdphi_llast_
Definition esolver_of.h:72
ModuleBase::Opt_CG * opt_cg_mag_
Definition esolver_of.h:39
void cal_potential_wrapper(double *ptemp_phi, double *rdLdphi)
Definition esolver_of_interface.cpp:52
ModuleBase::Opt_DCsrch * opt_dcsrch_
Definition esolver_of.h:38
void adjust_direction()
Rotate and renormalize the direction |d>, make it orthogonal to phi (<d|phi> = 0),...
Definition esolver_of_tool.cpp:223
void init_elecstate(UnitCell &ucell)
Initialize this->pelec, as well as this->pelec->pot.
Definition esolver_of_tool.cpp:18
int tn_spin_flag_
Definition esolver_of.h:62
double of_tole_
Definition esolver_of.h:45
void update_rho()
Update the charge density and "wavefunction" (phi) after one step of optimization phi = cos(theta) * ...
Definition esolver_of.cpp:397
ModuleBase::Opt_CG * opt_cg_
Definition esolver_of.h:36
int iter_
Definition esolver_of.h:54
double ** pdEdphi_
Definition esolver_of.h:58
std::string of_kinetic_
Definition esolver_of.h:42
double energy_llast_
Definition esolver_of.h:69
double ** pdirect_
Definition esolver_of.h:55
double normdLdphi_
Definition esolver_of.h:74
std::function< void(double *, double *)> bound_cal_potential_
Definition esolver_of.h:90
double * theta_
Definition esolver_of.h:57
bool conv_esolver
Definition esolver.h:44
plane wave basis
Definition opt_test_tools.cpp:93