ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
#include <opt_test_tools.h>
Public Member Functions | |
ESolver_OF () | |
~ESolver_OF () | |
double | func (double *x) |
void | dfuncdx (double *x, double *gradient) |
double | dfuncdstp (double *x, double *p) |
ESolver_OF () | |
~ESolver_OF () | |
virtual void | before_all_runners (UnitCell &ucell, const Input_para &inp) override |
Initialize of the first-principels energy solver. | |
virtual void | runner (UnitCell &ucell, const int istep) override |
run energy solver | |
virtual void | after_all_runners (UnitCell &ucell) override |
Output the FINAL_ETOT. | |
virtual double | cal_energy () override |
Calculate the total energy. NOTE THIS FUNCTION SHOULD BE CALLEDD AFTER POTENTIAL HAS BEEN UPDATED. | |
virtual void | cal_force (UnitCell &ucell, ModuleBase::matrix &force) override |
Calculate the force. | |
virtual void | cal_stress (UnitCell &ucell, ModuleBase::matrix &stress) override |
Calculate the stress. | |
![]() | |
ESolver_FP () | |
Constructor. | |
virtual | ~ESolver_FP () |
Deconstructor. | |
![]() | |
ESolver () | |
virtual | ~ESolver () |
virtual void | others (UnitCell &ucell, const int istep) |
Public Attributes | |
double * | x |
![]() | |
bool | conv_esolver = true |
std::string | classname |
Private Member Functions | |
void | before_opt (const int istep, UnitCell &ucell) |
Prepare to optimize the charge density, update elecstate, kedf, and opts if needed calculate ewald energy, initialize the rho, phi, theta. | |
void | update_potential (UnitCell &ucell) |
Get dL/dphi = dL/drho * drho/dphi = (dE/drho - mu) * 2 * phi, as well as normdLdphi = sqrt{<dL/dphi|dL/dphi>}. | |
void | optimize (UnitCell &ucell) |
Get the optimization direction (this->pdirection_) and the step length (this->theta) | |
void | update_rho () |
Update the charge density and "wavefunction" (phi) after one step of optimization phi = cos(theta) * phi + sin(theta) * direction, rho = phi^2. | |
bool | check_exit (bool &conv_esolver) |
Check convergence, return ture if converge or iter >= max_iter_, and print the necessary information. | |
void | after_opt (const int istep, UnitCell &ucell, const bool conv_esolver) |
After optimization, output the charge density, effective potential, ..., if needed. | |
void | init_elecstate (UnitCell &ucell) |
Initialize this->pelec, as well as this->pelec->pot. | |
void | allocate_array () |
Allocate the arrays, as well as this->psi_ and this->ptemp_rho_. | |
void | cal_potential_wrapper (double *ptemp_phi, double *rdLdphi) |
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. | |
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> = <dE / dtemp_phi | - sin(theta) * phi + cos(theta) * direction> | |
double | cal_mu (double *pphi, double *pdEdphi, double nelec) |
Calculate the chemical potential mu. mu = <dE/dphi|phi> / (2 * nelec) | |
void | adjust_direction () |
Rotate and renormalize the direction |d>, make it orthogonal to phi (<d|phi> = 0), and <d|d> = nelec. | |
void | check_direction (double *dEdtheta, double **ptemp_phi, UnitCell &ucell) |
Make sure that dEdtheta<0 at theta = 0, preparing to call the line search. | |
void | test_direction (double *dEdtheta, double **ptemp_phi, UnitCell &ucell) |
ONLY used for test. Check the validity of KEDF. | |
void | print_info (const bool conv_esolver) |
Print nessecary information to the screen, and write the components of the total energy into running_log. | |
double | inner_product (double *pa, double *pb, int length, double dV=1) |
void | init_opt () |
[Interface to opt] Initialize the opts | |
void | get_direction (UnitCell &ucell) |
[Interface to opt] Call optimization methods to get the optimization direction | |
void | get_step_length (double *dEdtheta, double **ptemp_phi, UnitCell &ucell) |
[Interface to opt] Call line search to find the best step length | |
Private Attributes | |
KEDF_Manager * | kedf_manager_ = nullptr |
ModuleBase::Opt_CG * | opt_cg_ = nullptr |
ModuleBase::Opt_TN * | opt_tn_ = nullptr |
ModuleBase::Opt_DCsrch * | opt_dcsrch_ = nullptr |
ModuleBase::Opt_CG * | opt_cg_mag_ = nullptr |
std::string | of_kinetic_ = "wt" |
std::string | of_method_ = "tn" |
std::string | of_conv_ = "energy" |
double | of_tole_ = 2e-6 |
double | of_tolp_ = 1e-5 |
int | max_iter_ = 50 |
double | dV_ = 0 |
double * | nelec_ = nullptr |
int | iter_ = 0 |
double ** | pdirect_ = nullptr |
std::complex< double > ** | precip_dir_ = nullptr |
double * | theta_ = nullptr |
double ** | pdEdphi_ = nullptr |
double ** | pdLdphi_ = nullptr |
double ** | pphi_ = nullptr |
char * | task_ = nullptr |
int | tn_spin_flag_ = -1 |
int | max_dcsrch_ = 200 |
int | flag_ = -1 |
Charge * | ptemp_rho_ = nullptr |
psi::Psi< double > * | psi_ = nullptr |
double | energy_llast_ = 0 |
double | energy_last_ = 0 |
double | energy_current_ = 0 |
double | normdLdphi_llast_ = 100 |
double | normdLdphi_last_ = 100 |
double | normdLdphi_ = 100. |
std::function< void(double *, double *)> | bound_cal_potential_ |
Additional Inherited Members | |
![]() | |
virtual void | before_scf (UnitCell &ucell, const int istep) |
Something to do before SCF iterations. | |
virtual void | after_scf (UnitCell &ucell, const int istep, const bool conv_esolver) |
Something to do after SCF iterations when SCF is converged or comes to the max iter step. | |
virtual void | iter_finish (UnitCell &ucell, const int istep, int &iter, bool &conv_esolver) |
Something to do after hamilt2rho function in each iter loop. | |
![]() | |
elecstate::ElecState * | pelec = nullptr |
Electronic states. | |
K_Vectors | kv |
K points in Brillouin zone. | |
Charge | chr |
Electorn charge density. | |
ModulePW::PW_Basis * | pw_rho |
ModulePW::PW_Basis * | pw_rhod |
ModulePW::PW_Basis_Big * | pw_big |
dense grid for USPP | |
Parallel_Grid | Pgrid |
parallel for rho grid | |
Structure_Factor | sf |
Structure factors that used with plane-wave basis set. | |
pseudopot_cell_vl | locpp |
local pseudopotentials | |
Charge_Extra | CE |
charge extrapolation method | |
surchem | solvent |
solvent model | |
int | pw_rho_flag = false |
flag for pw_rho, 0: not initialized, 1: initialized | |
double | iter_time |
the start time of scf iteration | |
|
inline |
|
inline |
ModuleESolver::ESolver_OF::ESolver_OF | ( | ) |
ModuleESolver::ESolver_OF::~ESolver_OF | ( | ) |
|
private |
Rotate and renormalize the direction |d>, make it orthogonal to phi (<d|phi> = 0), and <d|d> = nelec.
|
overridevirtual |
Output the FINAL_ETOT.
Reimplemented from ModuleESolver::ESolver_FP.
|
private |
After optimization, output the charge density, effective potential, ..., if needed.
istep | |
ucell |
|
private |
Allocate the arrays, as well as this->psi_ and this->ptemp_rho_.
|
overridevirtual |
Initialize of the first-principels energy solver.
1) read pseudopotentials
2) initialie the plane wave basis for rho
3) initialize the double grid (for uspp) if necessary
4) print some information
5) initialize the charge extrapolation method if necessary
Reimplemented from ModuleESolver::ESolver_FP.
|
private |
Prepare to optimize the charge density, update elecstate, kedf, and opts if needed calculate ewald energy, initialize the rho, phi, theta.
istep | |
ucell |
1) call before_scf() of ESolver_FP
|
private |
Calculate dE/dTheta and store it in rdEdtheta. dE/dTheta = <dE / dtemp_phi | dtemp_phi / dTheta> = <dE / dtemp_phi | - sin(theta) * phi + cos(theta) * direction>
[in] | ptemp_phi | |
[in] | temp_rho | |
[in] | ucell | |
[in] | ptheta | |
[out] | rdEdtheta | dE/dTheta |
|
overridevirtual |
Calculate the total energy. NOTE THIS FUNCTION SHOULD BE CALLEDD AFTER POTENTIAL HAS BEEN UPDATED.
Implements ModuleESolver::ESolver.
|
overridevirtual |
Calculate the force.
[out] | force |
Implements ModuleESolver::ESolver.
|
private |
Calculate the chemical potential mu. mu = <dE/dphi|phi> / (2 * nelec)
pphi | |
pdEdphi | |
nelec |
|
private |
Get dL/dphi = dL/drho * drho/dphi = (dE/drho - mu) * 2 * ptemp_phi and store it in rdLdphi.
[in] | ptemp_phi | phi |
[out] | rdLdphi | dL/dphi |
|
private |
|
overridevirtual |
Calculate the stress.
[out] | stress |
Implements ModuleESolver::ESolver.
|
private |
Make sure that dEdtheta<0 at theta = 0, preparing to call the line search.
dEdtheta | |
ptemp_phi | |
ucell |
|
private |
Check convergence, return ture if converge or iter >= max_iter_, and print the necessary information.
double ModuleESolver::ESolver_OF::dfuncdstp | ( | double * | x, |
double * | p | ||
) |
void ModuleESolver::ESolver_OF::dfuncdx | ( | double * | x, |
double * | gradient | ||
) |
double ModuleESolver::ESolver_OF::func | ( | double * | x | ) |
|
private |
[Interface to opt] Call optimization methods to get the optimization direction
|
private |
[Interface to opt] Call line search to find the best step length
dEdtheta | d E / d theta |
ptemp_phi | |
ucell |
|
private |
Initialize this->pelec, as well as this->pelec->pot.
ucell |
|
private |
[Interface to opt] Initialize the opts
|
inlineprivate |
|
private |
Get the optimization direction (this->pdirection_) and the step length (this->theta)
ucell |
|
private |
Print nessecary information to the screen, and write the components of the total energy into running_log.
|
overridevirtual |
|
private |
ONLY used for test. Check the validity of KEDF.
dEdtheta | |
ptemp_phi | |
ucell |
|
private |
Get dL/dphi = dL/drho * drho/dphi = (dE/drho - mu) * 2 * phi, as well as normdLdphi = sqrt{<dL/dphi|dL/dphi>}.
ucell |
|
private |
Update the charge density and "wavefunction" (phi) after one step of optimization phi = cos(theta) * phi + sin(theta) * direction, rho = phi^2.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
double* ModuleESolver::ESolver_OF::x |