feat: add PPCG eigenvalue solver implementation#7414
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new plane-wave Kohn–Sham eigensolver ppcg to ABACUS. A new hsolver::DiagoPPCG<T, Device> class is implemented (header + source), the PW dispatcher in HSolverPW is extended to construct and invoke the solver with the same hpsi/spsi/subspace callback shape as DiagoCG, the new value ppcg is added to the list of accepted ks_solver strings for basis_type=pw, the build is updated, and a GoogleTest unit test is registered. The implementation closely mirrors DiagoCG (per-band Schmidt orthogonalization, preconditioned gradient, Polak–Ribiere update, 2D line minimization, and an outer retry/subspace loop) rather than a true block PPCG algorithm.
Changes:
- New
DiagoPPCGclass withdiag()callback API, retry loop, and complex CPU+GPU template instantiations. - PW solver dispatch and input validation extended to accept
"ppcg". - New GoogleTest target
MODULE_HSOLVER_ppcgand a single parametric eigenvalue-comparison test against LAPACK.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| source/source_hsolver/diago_ppcg.h | Declares DiagoPPCG class, callback typedefs, and helper methods. |
| source/source_hsolver/diago_ppcg.cpp | Implements PPCG diagonalization, including gradient/CG/line-minimization routines and template instantiations. |
| source/source_hsolver/hsolver_pw.cpp | Adds ppcg to the supported PW methods list and a dispatch branch constructing DiagoPPCG with subspace callback. |
| source/source_hsolver/CMakeLists.txt | Adds diago_ppcg.cpp to the hsolver object library. |
| source/source_hsolver/test/CMakeLists.txt | Registers the new MODULE_HSOLVER_ppcg test target under ENABLE_MPI. |
| source/source_hsolver/test/diago_ppcg_test.cpp | New unit test that compares PPCG eigenvalues against zheev_ on a random Hermitian matrix. |
| source/source_io/module_parameter/read_input_item_elec_stru.cpp | Adds "ppcg" to the validated PW ks_solver list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add missing includes (test_tool.h, mpi.h) to diago_ppcg_test.cpp to fix 'setupmpi' and 'divide_pools' not declared errors - Replace raw host loop with vector_mul_vector_op for GPU compatibility - Fix typo: DiagoPPGC -> DiagoPPCG in error message - Fix diag() return value: return avg_iter_ (cumulative) instead of avg to be consistent with DiagoCG behavior - Preserve constructor-provided convergence parameters, only fall back to DiagoIterAssist when defaults are unchanged
…test targets These test targets compile hsolver_pw.cpp which references DiagoPPCG, but the linker didn't have the PPCG object file, causing undefined reference errors.
- Update class docstring in diago_ppcg.h to clarify band-by-band PPCG variant - Fix en array allocation in test (npw -> nband) - Add more test configurations (varying nband, npw, sparsity) - Add ppcg to ks_solver annotations and documentation (read_input_item_elec_stru.cpp) - Add ppcg to hsolver.md, parameters.yaml, input-main.md docs - Merge latest develop branch
Reminder
Linked Issue
Fix #...
Unit Tests and/or Case Tests for my changes
What's changed?
Any changes of core modules? (ignore if not applicable)