Skip to content

Commit 641255a

Browse files
[pre-commit.ci lite] apply automatic fixes
1 parent e74aa2b commit 641255a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

source/module_base/opt_TN.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ class Opt_TN
5454
void refresh(int nx_new = 0)
5555
{
5656
this->iter_ = 0;
57-
if (nx_new != 0)
57+
if (nx_new != 0) {
5858
this->nx_ = nx_new;
59+
}
5960
this->cg_.refresh(nx_new);
6061
}
6162

@@ -169,18 +170,21 @@ void Opt_TN::next_direct(double* px,
169170
// Hcgd = (df(temp_x)/dx - df(x)/x) / epsilon, where temp_x = x + step * cg_direct
170171
epsilon = this->get_epsilon(px, cg_direct);
171172
// epsilon = 1e-9;
172-
for (int i = 0; i < this->nx_; ++i)
173+
for (int i = 0; i < this->nx_; ++i) {
173174
temp_x[i] = px[i] + epsilon * cg_direct[i];
175+
}
174176
(t->*p_calGradient)(temp_x, temp_gradient, ucell);
175-
for (int i = 0; i < this->nx_; ++i)
177+
for (int i = 0; i < this->nx_; ++i) {
176178
temp_Hcgd[i] = (temp_gradient[i] - pgradient[i]) / epsilon;
179+
}
177180

178181
// get CG step length and update rdirect
179182
cg_alpha = cg_.step_length(temp_Hcgd, cg_direct, cg_ifPD);
180183
if (cg_ifPD == -1) // Hessian is not positive definite, and cgiter = 1.
181184
{
182-
for (int i = 0; i < this->nx_; ++i)
185+
for (int i = 0; i < this->nx_; ++i) {
183186
rdirect[i] += cg_alpha * cg_direct[i];
187+
}
184188
flag = -1;
185189
break;
186190
}
@@ -190,15 +194,17 @@ void Opt_TN::next_direct(double* px,
190194
break;
191195
}
192196

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

196201
// store residuals used in truncated conditions
197202
last_residual = curr_residual;
198203
curr_residual = cg_.get_residual();
199204
cg_iter = cg_.get_iter();
200-
if (cg_iter == 1)
205+
if (cg_iter == 1) {
201206
init_residual = curr_residual;
207+
}
202208

203209
// check truncated conditions
204210
// if (curr_residual < 1e-12)

source/module_esolver/esolver_ks_lcaopw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ namespace ModuleESolver
9090
|| PARAM.inp.calculation == "md") {
9191
if (GlobalC::exx_info.info_global.cal_exx)
9292
{
93-
XC_Functional::set_xc_first_loop(cell);
93+
XC_Functional::set_xc_first_loop(ucell);
9494
this->exx_lip = std::unique_ptr<Exx_Lip<T>>(new Exx_Lip<T>(GlobalC::exx_info.info_lip,
9595
cell.symm, &this->kv, this->p_wf_init, this->kspw_psi, this->pw_wfc, this->pw_rho, this->sf, &cell, this->pelec));
9696
// 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);

0 commit comments

Comments
 (0)