Skip to content

Commit

Permalink
[pre-commit.ci lite] apply automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci-lite[bot] authored Nov 22, 2024
1 parent e74aa2b commit 641255a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions source/module_base/opt_TN.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ class Opt_TN
void refresh(int nx_new = 0)
{
this->iter_ = 0;
if (nx_new != 0)
if (nx_new != 0) {
this->nx_ = nx_new;
}
this->cg_.refresh(nx_new);
}

Expand Down Expand Up @@ -169,18 +170,21 @@ void Opt_TN::next_direct(double* px,
// Hcgd = (df(temp_x)/dx - df(x)/x) / epsilon, where temp_x = x + step * cg_direct
epsilon = this->get_epsilon(px, cg_direct);
// epsilon = 1e-9;
for (int i = 0; i < this->nx_; ++i)
for (int i = 0; i < this->nx_; ++i) {
temp_x[i] = px[i] + epsilon * cg_direct[i];
}
(t->*p_calGradient)(temp_x, temp_gradient, ucell);
for (int i = 0; i < this->nx_; ++i)
for (int i = 0; i < this->nx_; ++i) {
temp_Hcgd[i] = (temp_gradient[i] - pgradient[i]) / epsilon;
}

// get CG step length and update rdirect
cg_alpha = cg_.step_length(temp_Hcgd, cg_direct, cg_ifPD);
if (cg_ifPD == -1) // Hessian is not positive definite, and cgiter = 1.
{
for (int i = 0; i < this->nx_; ++i)
for (int i = 0; i < this->nx_; ++i) {
rdirect[i] += cg_alpha * cg_direct[i];
}
flag = -1;
break;
}
Expand All @@ -190,15 +194,17 @@ void Opt_TN::next_direct(double* px,
break;
}

for (int i = 0; i < this->nx_; ++i)
for (int i = 0; i < this->nx_; ++i) {
rdirect[i] += cg_alpha * cg_direct[i];
}

// store residuals used in truncated conditions
last_residual = curr_residual;
curr_residual = cg_.get_residual();
cg_iter = cg_.get_iter();
if (cg_iter == 1)
if (cg_iter == 1) {
init_residual = curr_residual;
}

// check truncated conditions
// if (curr_residual < 1e-12)
Expand Down
2 changes: 1 addition & 1 deletion source/module_esolver/esolver_ks_lcaopw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace ModuleESolver
|| PARAM.inp.calculation == "md") {
if (GlobalC::exx_info.info_global.cal_exx)
{
XC_Functional::set_xc_first_loop(cell);
XC_Functional::set_xc_first_loop(ucell);
this->exx_lip = std::unique_ptr<Exx_Lip<T>>(new Exx_Lip<T>(GlobalC::exx_info.info_lip,
cell.symm, &this->kv, this->p_wf_init, this->kspw_psi, this->pw_wfc, this->pw_rho, this->sf, &cell, this->pelec));
// this->exx_lip.init(GlobalC::exx_info.info_lip, cell.symm, &this->kv, this->p_wf_init, this->kspw_psi, this->pw_wfc, this->pw_rho, this->sf, &cell, this->pelec);
Expand Down

0 comments on commit 641255a

Please sign in to comment.