From 641255a35d11f284dc71a2d8416a95c85cc0f81d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 07:22:19 +0000 Subject: [PATCH] [pre-commit.ci lite] apply automatic fixes --- source/module_base/opt_TN.hpp | 18 ++++++++++++------ source/module_esolver/esolver_ks_lcaopw.cpp | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/source/module_base/opt_TN.hpp b/source/module_base/opt_TN.hpp index 07b603c158..310e5d226a 100644 --- a/source/module_base/opt_TN.hpp +++ b/source/module_base/opt_TN.hpp @@ -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); } @@ -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; } @@ -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) diff --git a/source/module_esolver/esolver_ks_lcaopw.cpp b/source/module_esolver/esolver_ks_lcaopw.cpp index d6cbaafd9c..b62b48e47c 100644 --- a/source/module_esolver/esolver_ks_lcaopw.cpp +++ b/source/module_esolver/esolver_ks_lcaopw.cpp @@ -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>(new Exx_Lip(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);