Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a1721e4
add a python script to check the code quality
Aug 20, 2026
c15fa10
update
Aug 20, 2026
c0b9ce7
Add cyclomatic complexity rule; raise file_too_long weight to 2
Aug 20, 2026
e75318f
Add post-C++11 rule (-80); expand test dirs; fix string-literal false…
Aug 20, 2026
c961e69
use code quality tool to fix issues in wavefunc_in_pw files
Aug 20, 2026
5425080
Merge branch 'develop' into 2026-08-20
mohanchen Aug 21, 2026
ef5576a
Merge branch 'develop' into 2026-08-20
Aug 23, 2026
c657f47
update code_quality_score
Aug 23, 2026
b5455f7
update code_quality_score
Aug 23, 2026
763b761
remove C++14 code in diago_pexsi.cpp
Aug 23, 2026
6a22c8c
update
Aug 23, 2026
e747810
update
Aug 23, 2026
2352078
update
Aug 23, 2026
e5bd52d
delete wavefunc_in_pw because they have not been used
Aug 23, 2026
a3ed9ba
update makefile
Aug 23, 2026
d472cce
remove C++14 codes in tests
Aug 23, 2026
1cbf76b
remove using namespace std in psi_base.h
Aug 24, 2026
be3bc28
remove Chinese notes
Aug 24, 2026
08c9aa4
remove one duplicate name of variables
Aug 24, 2026
375ab58
fix(code_quality): exclude template type params and enum class in fin…
Aug 24, 2026
d4b53d3
fix(code_quality): handle trailing return type and ctor init list in …
Aug 24, 2026
8df1306
fix(code_quality): blank string literals before cyclomatic complexity…
Aug 24, 2026
ecc3777
fix(code_quality): distinguish C++14 digit separators from char literals
Aug 24, 2026
2d87d80
fix(code_quality): distinguish declarations from call sites in param-…
Aug 25, 2026
ecc258c
fix(code_quality): cancel smart-pointer owned new in unpaired_new heu…
Aug 25, 2026
d1fd9fb
fix(code_quality): skip multi-line using/typedef continuations in mem…
Aug 25, 2026
7f237b2
fix(code_quality): exclude arrow member access from uppercase constan…
Aug 25, 2026
e1394a6
fix(code_quality): do not deduct for public members in struct bodies
Aug 25, 2026
437e013
refactor(hsolver_test): replace unique_ptr heap alloc with stack vars…
Aug 25, 2026
7798fae
Merge branch 'develop' into 2026-08-20
mohanchen Aug 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ OBJS_PSI_INITIALIZER=psi_base.o\
psi_init_atomic.o\
psi_init_atom_rand.o\
psi_init_nao.o\
psi_init_nao_random.o\
psi_init_nao_random.o

OBJS_PW=fft_bundle.o\
fft_cpu.o\
Expand Down Expand Up @@ -691,7 +691,6 @@ OBJS_LCAO=evolve_elec.o\
center2orb_orb21.o\
center2orb_orb22.o\
record_adj.o\
wavefunc_in_pw.o\

OBJS_MODULE_RI=conv_coulomb_pot_k.o\
exx_abfs-abfs_index.o\
Expand Down
2 changes: 1 addition & 1 deletion source/source_basis/module_ao/test/orb_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void test_orb::set_single_c2o(int TA, int TB, int LA, int NA, int LB, int NB)
{
this->test_center2_orb11[TA][TB][LA][NA][LB].insert(std::make_pair(
NB,
std::make_unique<c2o>(ORB.Phi[TA].PhiLN(LA, NA), ORB.Phi[TB].PhiLN(LB, NB), OGT.MOT.pSB, Center2_MGT)));
std::unique_ptr<c2o>(new c2o(ORB.Phi[TA].PhiLN(LA, NA), ORB.Phi[TB].PhiLN(LB, NB), OGT.MOT.pSB, Center2_MGT))));
}
double test_orb::randr(double Rmax)
{
Expand Down
2 changes: 1 addition & 1 deletion source/source_hsolver/diago_pexsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ DiagoPexsi<T>::DiagoPexsi(const Parallel_Orbitals* ParaV_in,
}

this->ParaV = ParaV_in;
this->ps = std::make_unique<pexsi::PEXSI_Solver>();
this->ps.reset(new pexsi::PEXSI_Solver());

this->DM.resize(this->nspin_dm);
this->EDM.resize(this->nspin_dm);
Expand Down
2 changes: 1 addition & 1 deletion source/source_hsolver/kernels/cuda/diag_cusolvermp.cu
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Diag_CusolverMP_gvd<inputT>::Diag_CusolverMP_gvd(const MPI_Comm mpi_comm,
const int nacols,
const int* desc)
{
// 构造函数的实现
/// constructor implementation
this->cblacs_ctxt = desc[1];
this->nFull = desc[2];

Expand Down
4 changes: 2 additions & 2 deletions source/source_hsolver/test/diago_bpcg_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class DiagoBPCGPrepare
const std::vector<T> &h_mat = DIAGOTEST::hmatrix_local;
auto hpsi_func = [h_mat, dim](T *psi_in, T *hpsi_out,
const int ld_psi, const int nvec) {
auto one = std::make_unique<T>(1.0);
auto zero = std::make_unique<T>(0.0);
std::unique_ptr<T> one(new T(1.0));
std::unique_ptr<T> zero(new T(0.0));
const T *one_ = one.get();
const T *zero_ = zero.get();
Comment thread
mohanchen marked this conversation as resolved.
Outdated

Expand Down
2 changes: 1 addition & 1 deletion source/source_hsolver/test/diago_pexsi_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class PexsiPrepare
std::cout << "nrow: " << hmtest.nrow << ", ncol: " << hmtest.ncol << ", nb: " << nb2d << std::endl;
}

dh = std::make_unique<hsolver::DiagoPexsi<T>>(&po, PARAM.input.nspin, nlocal, PARAM.input.nelec);
dh.reset(new hsolver::DiagoPexsi<T>(&po, PARAM.input.nspin, nlocal, PARAM.input.nelec));
}

void distribute_data()
Expand Down
4 changes: 2 additions & 2 deletions source/source_io/module_unk/berryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void berryphase::set_kpoints(const K_Vectors& kv, const int direction)

nppstr = mp_x + 1;
}
else if (direction == 2) // 计算y方向
else if (direction == 2) /// compute the y direction
{
const int num_string = mp_x * mp_z;

Expand Down Expand Up @@ -163,7 +163,7 @@ void berryphase::set_kpoints(const K_Vectors& kv, const int direction)

nppstr = mp_y + 1;
}
else if (direction == 3) // 计算z方向
else if (direction == 3) /// compute the z direction
{
const int num_string = mp_x * mp_y;

Expand Down
2 changes: 1 addition & 1 deletion source/source_io/module_wannier/to_wannier90_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "source_base/matrix.h"
#include "source_base/matrix3.h"
#include "source_cell/klist.h"
#include "source_lcao/wavefunc_in_pw.h"
#include "source_basis/module_pw/pw_basis_k.h"
#include "source_psi/psi.h"

class toWannier90_PW : public toWannier90
Expand Down
1 change: 0 additions & 1 deletion source/source_lcao/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ if(ENABLE_LCAO)
center2orb_orb11.cpp
center2orb_orb21.cpp
center2orb_orb22.cpp
wavefunc_in_pw.cpp
)

add_library(
Expand Down
2 changes: 1 addition & 1 deletion source/source_lcao/module_deltaspin/spin_constrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ void SpinConstrain<TK>::print_Mi(std::ofstream& ofs_running)
* @par Typical values
* - Well-converged SCF: lambda ~ 0.01-1 eV/uB
* - Strongly constrained: lambda ~ 1-10 eV/uB
* - Diverging SCF: lambda growing without bound (check target_mag合理性)
* - Diverging SCF: lambda growing without bound (check target_mag validity)
*/
template <typename TK>
void SpinConstrain<TK>::print_Mag_Force(std::ofstream& ofs_running)
Expand Down
31 changes: 15 additions & 16 deletions source/source_lcao/module_ri/exx_lip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "source_base/global_function.h"
#include "source_base/vector3.h"
#include "source_cell/klist.h"
#include "source_lcao/wavefunc_in_pw.h"
#include "source_base/module_external/lapack_connector.h"
#include "source_base/parallel_global.h"
#include "source_io/module_parameter/parameter.h"
Expand Down Expand Up @@ -325,14 +324,14 @@ void Exx_Lip<T, Device>::qkg2_exp(const int ik, const int iq)
else
{ this->recip_qkg2[ig] = 1.0 / qkg2; }
this->sum2_factor += this->recip_qkg2[ig] * std::exp(-info.lambda * qkg2);
this->recip_qkg2[ig] = sqrt(this->recip_qkg2[ig]);
this->recip_qkg2[ig] = std::sqrt(this->recip_qkg2[ig]);
}
else if (Conv_Coulomb_Pot_K::Ccp_Type::Erfc == info.ccp_type)
{
if (std::abs(qkg2) < 1e-10)
{ this->recip_qkg2[ig] = 1.0 / (2 * info.hse_omega); }
else
{ this->recip_qkg2[ig] = sqrt((1 - std::exp(-qkg2 / (4 * info.hse_omega * info.hse_omega))) / qkg2); }
{ this->recip_qkg2[ig] = std::sqrt((1 - std::exp(-qkg2 / (4 * info.hse_omega * info.hse_omega))) / qkg2); }
}
else
{
Expand All @@ -348,13 +347,13 @@ void Exx_Lip<T, Device>::b_cal(const int ik, const int iq, const int ib)
ModuleBase::timer::start("Exx_Lip", "b_cal");
const ModuleBase::Vector3<double> q_minus_k = this->q_pack->kv_ptr->kvec_d[iq] - this->k_pack->kv_ptr->kvec_d[ik];
std::vector<T > mul_tmp(this->rho_basis->nrxx);
for( size_t ir=0,ix=0; ix<this->rho_basis->nx; ++ix)
for( std::size_t ir=0,ix=0; ix<this->rho_basis->nx; ++ix)
{
const Treal phase_x = q_minus_k.x * ix / this->rho_basis->nx;
for( size_t iy=0; iy<this->rho_basis->ny; ++iy)
for( std::size_t iy=0; iy<this->rho_basis->ny; ++iy)
{
const Treal phase_xy = phase_x + q_minus_k.y * iy / this->rho_basis->ny;
for( size_t iz=this->rho_basis->startz_current; iz<this->rho_basis->startz_current+this->rho_basis->nplane; ++iz)
for( std::size_t iz=this->rho_basis->startz_current; iz<this->rho_basis->startz_current+this->rho_basis->nplane; ++iz)
{
const Treal phase_xyz = phase_xy + q_minus_k.z * iz / this->rho_basis->nz;
mul_tmp[ir] = std::exp(-phase_xyz * this->two_pi_i);
Expand All @@ -365,12 +364,12 @@ void Exx_Lip<T, Device>::b_cal(const int ik, const int iq, const int ib)
}

std::vector<T> porter (this->rho_basis->nrxx);
for(size_t iw=0; iw< PARAM.globalv.nlocal; ++iw)
for(std::size_t iw=0; iw< PARAM.globalv.nlocal; ++iw)
{
auto& phi_w = this->phi[iw];
for( size_t ir=0; ir<this->rho_basis->nrxx; ++ir)
for( std::size_t ir=0; ir<this->rho_basis->nrxx; ++ir)
{
porter[ir] = conj(phi_w[ir]) * mul_tmp[ir] ;
porter[ir] = std::conj(phi_w[ir]) * mul_tmp[ir] ;
// porter[ir] = phi_w[ir] * psi_q_b[ir] *exp_tmp[ir] ;
}
T* const b_w = &this->b[iw * this->rho_basis->npw];
Expand All @@ -380,7 +379,7 @@ void Exx_Lip<T, Device>::b_cal(const int ik, const int iq, const int ib)
this->b0[iw] = b_w[this->rho_basis->ig_gge0];
} }

for (size_t ig = 0; ig < this->rho_basis->npw; ++ig)
for (std::size_t ig = 0; ig < this->rho_basis->npw; ++ig)
{ b_w[ig] *= this->recip_qkg2[ig]; }
}
ModuleBase::timer::end("Exx_Lip", "b_cal");
Expand All @@ -393,7 +392,7 @@ void Exx_Lip<T, Device>::sum3_cal(const int iq, const int ib)
if (gzero_rank_in_pool == GlobalV::RANK_IN_POOL) {
for (int iw_l = 0; iw_l < PARAM.globalv.nlocal; ++iw_l) {
for (int iw_r = 0; iw_r < PARAM.globalv.nlocal; ++iw_r) {
this->sum3[iw_l][iw_r] += this->b0[iw_l] * conj(this->b0[iw_r]) * (Treal)this->q_pack->wf_wg(iq, ib);
this->sum3[iw_l][iw_r] += this->b0[iw_l] * std::conj(this->b0[iw_r]) * (Treal)this->q_pack->wf_wg(iq, ib);
} } }
ModuleBase::timer::end("Exx_Lip", "sum3_cal");
}
Expand Down Expand Up @@ -426,9 +425,9 @@ void Exx_Lip<T, Device>::sum_all(const int ik)
if (Conv_Coulomb_Pot_K::Ccp_Type::Ccp == info.ccp_type || Conv_Coulomb_Pot_K::Ccp_Type::Hf == info.ccp_type)
{ MPI_Reduce(&this->sum2_factor, &sum2_factor_g, 1, MPI_DOUBLE, MPI_SUM, gzero_rank_in_pool, POOL_WORLD); }
#endif
for (size_t iw_l = 1; iw_l < PARAM.globalv.nlocal; ++iw_l) {
for (size_t iw_r = 0; iw_r < iw_l; ++iw_r) {
this->sum1[iw_l * PARAM.globalv.nlocal + iw_r] = conj(this->sum1[iw_r * PARAM.globalv.nlocal + iw_l]); // Peize Lin add conj 2019-04-14
for (std::size_t iw_l = 1; iw_l < PARAM.globalv.nlocal; ++iw_l) {
for (std::size_t iw_r = 0; iw_r < iw_l; ++iw_r) {
this->sum1[iw_l * PARAM.globalv.nlocal + iw_r] = std::conj(this->sum1[iw_r * PARAM.globalv.nlocal + iw_l]); // Peize Lin add conj 2019-04-14
} }

for (int iw_l = 0; iw_l < PARAM.globalv.nlocal; ++iw_l)
Expand All @@ -441,7 +440,7 @@ void Exx_Lip<T, Device>::sum_all(const int ik)
if (gzero_rank_in_pool == GlobalV::RANK_IN_POOL)
{
this->exx_matrix[ik][iw_l][iw_r] += spin_fac * (fourpi_div_omega * this->sum3[iw_l][iw_r] * sum2_factor_g);
this->exx_matrix[ik][iw_l][iw_r] += spin_fac * (-1 / (Treal)sqrt(info.lambda * ModuleBase::PI) * (Treal)(this->q_pack->kv_ptr->get_nks() / PARAM.inp.nspin) * this->sum3[iw_l][iw_r]);
this->exx_matrix[ik][iw_l][iw_r] += spin_fac * (-1 / (Treal)std::sqrt(info.lambda * ModuleBase::PI) * (Treal)(this->q_pack->kv_ptr->get_nks() / PARAM.inp.nspin) * this->sum3[iw_l][iw_r]);
}
}
}
Expand All @@ -461,7 +460,7 @@ void Exx_Lip<T, Device>::exx_energy_cal()
for( int iw_l=0; iw_l<PARAM.globalv.nlocal; ++iw_l) {
for( int iw_r=0; iw_r<PARAM.globalv.nlocal; ++iw_r) {
for( int ib=0; ib<PARAM.inp.nbands; ++ib) {
exx_energy_tmp += (this->exx_matrix[ik][iw_l][iw_r] * conj((*this->k_pack->hvec_array)(ik, ib, iw_l)) * (*this->k_pack->hvec_array)(ik, ib, iw_r)).real() * this->k_pack->wf_wg(ik, ib);
exx_energy_tmp += (this->exx_matrix[ik][iw_l][iw_r] * std::conj((*this->k_pack->hvec_array)(ik, ib, iw_l)) * (*this->k_pack->hvec_array)(ik, ib, iw_r)).real() * this->k_pack->wf_wg(ik, ib);
} } } }
#ifdef __MPI
MPI_Allreduce( &exx_energy_tmp, &this->exx_energy, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); // !!! k_point parallel incompleted. different pools have different kv.set_nks(>) deadlock
Expand Down
2 changes: 1 addition & 1 deletion source/source_lcao/module_ri/rpa_lri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ void RPA_LRI<T, Tdata>::out_velocity(const UnitCell &ucell,
// list_As_Vs.first, list_As_Vs.second[0],
// {{"writable_Vws",true}});

// // Vs[iat0][{iat1,cell1}] (iat0,iat1) 分进程,每个进程有所有 cell1
// // Vs[iat0][{iat1,cell1}] distributed across processes by (iat0,iat1); each process holds all cell1
// Vqs = FFT(Vs);
// out_Vs(Vqs);

Expand Down
2 changes: 1 addition & 1 deletion source/source_lcao/module_rt/solve_propagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void solve_propagation(const Parallel_Orbitals* pv,
const double dt,
const std::complex<double>* Stmp,
const std::complex<double>* Htmp,
const std::complex<double>* P_k, // <--- 接收 P_k
const std::complex<double>* P_k, ///< receives P_k
const std::complex<double>* psi_k_laststep,
std::complex<double>* psi_k)
{
Expand Down
Loading
Loading