Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
a001659
Feature(dftu-pw): add DeltaSpin strategy input parameters and relax D…
dyzheng May 1, 2026
7f22e9b
Feature(dftu-pw): add DFT+U occupation matrix mixing in Charge_Mixing
dyzheng May 1, 2026
8739c88
Feature(dftu-pw): encapsulate Plus_U accessors and rewrite cal_occ_pw…
dyzheng May 1, 2026
916fb90
Feature(deltaspin-pw): add npol support, lambda strategies, PW subspa…
dyzheng May 1, 2026
285498a
Fix(dftu-pw): add npol=1 code paths for PW force/stress/onsite kernels
dyzheng May 1, 2026
4ab80fc
Feature(dftu-pw): extend onsite projector and PW DFT+U/DeltaSpin for …
dyzheng May 1, 2026
e6dc14d
Feature(dftu-pw): wire LCAO operators and ESolver for DFT+U/DeltaSpin…
dyzheng May 1, 2026
8a07ea6
Refactor: vnl_pw simplification, remove TD_MovingGauge, minor module …
dyzheng May 1, 2026
d325791
Test(dftu-pw): add 17_DS_DFTU integration test suite
dyzheng May 1, 2026
82bbb59
Fix(tests): correct CASES_CPU.txt directory names and regenerate resu…
dyzheng May 1, 2026
73666a0
Fix: remove stale use_paw parameter from HSolverPW/DiagoDavid calls
dyzheng May 1, 2026
9b72452
Docs: add DeltaSpin guide, sc_lambda_strategy/sc_direction_only param…
dyzheng May 1, 2026
e86f875
Fix CI build: eliminate RI_2D_Comm.hpp redefinition errors, complete …
dyzheng May 2, 2026
19fc9be
Fix(tests): make 50/51 FeO atom-order tests use identical atomic posi…
dyzheng May 2, 2026
e6b3628
Fix(test): correct MODULE_LCAO_operator_dftu_test CMakeLists and add …
dyzheng May 2, 2026
5569061
Fix(test): implement proper stubs for get_locale_flat and set_locale_…
dyzheng May 2, 2026
5837a65
Fix(test): correct stress parsing in catch_properties.sh
dyzheng May 3, 2026
d644491
Fix(PW): restore correct force/stress formula for npol=2
dyzheng May 3, 2026
eaad950
Fix(PW): correct all nonlocal force/stress formulas for nspin=4/SOC
dyzheng May 3, 2026
f7ce7d0
Fix(PW): revert nonlocal force/stress formula to match develop
dyzheng May 3, 2026
37dcdf9
Fix(test): correct stress extraction in catch_properties.sh
dyzheng May 5, 2026
3ef7ff5
Fix(test): redesign 50/51 FeO tests for fast convergence
dyzheng May 5, 2026
645aae3
Merge branch 'feat/dftu-pw-port-v2' of github.com:dyzheng/abacus-deve…
dyzheng May 5, 2026
b566110
Fix(test): correct column-major indexing in DeltaHcc_GemmContribution…
dyzheng May 5, 2026
6a18e27
Merge develop into feat/dftu-pw-port-v2
dyzheng May 5, 2026
d6cf86f
Merge develop into feat/dftu-pw-port-v2
dyzheng May 5, 2026
25d687d
Fix(test): improve DeltaSpin LCAO tests convergence
dyzheng May 5, 2026
42517c2
Merge remote-tracking branch 'zdy/feat/dftu-pw-port-v2' into feat/dft…
dyzheng May 5, 2026
41332ba
Fix(build): restore develop's DeepKS files to fix LIBRI compilation
dyzheng May 5, 2026
6abc8b6
Fix(test): sync pw_basis_k.cpp warning message with develop
dyzheng May 5, 2026
437bc66
Fix(GPU): sync CUDA kernels force/stress formula with develop
dyzheng May 5, 2026
2d90a6e
Fix(PW): sync CPU kernels force/stress/onsite formulas with develop
dyzheng May 5, 2026
ad84b16
Fix(CUDA): remove erroneous npol parameters from force/stress operato…
dyzheng May 5, 2026
1f49ed5
Fix(PW): restore npol parameters and correct formula order for DFT+U/…
dyzheng May 6, 2026
7c09c7e
Fix(CUDA): use vkbnc instead of vkb.nc for GPU path leading dimension
dyzheng May 6, 2026
c56b8bb
Fix(SDFT-GPU): restore lazy-allocation guard for vkb in getgradq_vnl
dyzheng May 6, 2026
d0193eb
Fix(force/stress): correct nonlocal formula order for SOC/DFT+U/Delta…
dyzheng May 6, 2026
c035a11
Fix(onsite_op): restore npol==1/2 branches to fix nspin=2 DFT+U/Delta…
dyzheng May 7, 2026
87dfd9a
CI: re-trigger CI tests after force push fix
dyzheng May 7, 2026
cebdd5f
Merge remote-tracking branch 'origin/develop' into feat/dftu-pw-port-v2
dyzheng May 7, 2026
4c302dc
Fix(tests): correct result.ref for 11 and 18 to match 4-MPI-process C…
dyzheng May 7, 2026
a761c3a
Fix(tests): update test 11 result.ref to correct DFT+U energy -6364.2…
dyzheng May 7, 2026
bc04795
Fix(tests): disable test 18 (DFT+U+DeltaSpin+PW crashes) in CASES_CPU…
dyzheng May 7, 2026
e3f10f5
Fix(dftu-pw): use isk[ik] instead of ik >= nk/2 for spin channel sele…
dyzheng May 8, 2026
73163aa
Fix DFT+U locale double-counting with kpar>1
dyzheng May 8, 2026
4d567a4
Fix DeltaSpin reduce_double_allpool using GlobalV::NPROC_IN_POOL
dyzheng May 8, 2026
15459c6
Update test references for kpar>1 fix
dyzheng May 8, 2026
61f044c
Update nspin=4 test references after nproc_in_pool fix
dyzheng May 8, 2026
ab18634
Remove deprecated sc_scf_nmin parameter
dyzheng May 8, 2026
925a1b0
Translate README.md comments from Chinese to English
dyzheng May 8, 2026
5f220d3
Translate Chinese comments to English across source files and test IN…
dyzheng May 8, 2026
3a19280
refactor(deltaspin): remove LCAO-specific lambda loop path and Lambda…
dyzheng May 11, 2026
47b37f1
fix(deltaspin): resolve SCF crash and charge density sync issues in L…
dyzheng May 11, 2026
39d2a44
feat(deltaspin): add full/incremental lambda update strategy for PW a…
dyzheng May 11, 2026
07cc23b
test: regenerate result.ref files for DeltaSpin test cases
dyzheng May 12, 2026
e771f70
test: regenerate DeltaSpin result.ref files with CPU build (abacus_ba…
dyzheng May 12, 2026
4eb61da
fix(deltaspin): guard BFGS and linear scan functions with __LCAO for …
dyzheng May 12, 2026
83571b6
refactor(deltaspin): remove experimental BFGS v2, encapsulate LCAO-sp…
dyzheng May 12, 2026
795454a
test: add new DeltaSpin/DFT+U test cases for magmom, lambda, NSCF, an…
dyzheng May 12, 2026
024a833
feat(deltaspin): add nspin=1 support for PW DeltaSpin and fix colline…
dyzheng May 12, 2026
0c42d43
docs(deltaspin): add comprehensive English comments to module_deltaspin
dyzheng May 12, 2026
446baa4
feat(deltaspin): enable linear_scan strategy for PW basis set
dyzheng May 12, 2026
776c120
test(deltaspin): update result.ref for 11 failed cases and disable 55…
dyzheng May 12, 2026
7b03c4e
test: unify sc_scf_thr to 10 for PW DS cases and add missing sc field…
dyzheng May 13, 2026
85e4e49
test: reduce 17_DS_DFTU test suite from 39 to 24 active cases
dyzheng May 13, 2026
4f6abba
test: fix 17_DS_DFTU CI order and clean unregistered directories
dyzheng May 13, 2026
149b911
test: restructure 17_DS_DFTU test suite with proper registration
dyzheng May 13, 2026
2fe4692
chore: remove debug docs and log files from test suite
dyzheng May 13, 2026
75ee910
test: update CASES_CPU.txt with NSCF documentation and cleanup
dyzheng May 13, 2026
2d2b94d
test: add DFT+U NSCF test cases (60, 62, 63, 64) with charge and onsi…
dyzheng May 13, 2026
05241d6
test: complete 60-64 NSCF test cases with missing charge density, STR…
dyzheng May 13, 2026
02e91a5
fix: add missing onsite.dm to PW NSCF test cases (60, 64)
dyzheng May 13, 2026
305a5fa
fix: resolve segfault at MPI_Finalize and LCAO DFT+U NSCF assertion f…
dyzheng May 13, 2026
95475a0
chore: remove test.sum temp file from 17_DS_DFTU test suite
dyzheng May 13, 2026
01f8e71
fix: restore proper MPI/FFTW cleanup order to fix CI test failures
dyzheng May 14, 2026
3ad26c4
fix(test): update result.ref for CI and shield unstable LCAO S4 cases
dyzheng May 14, 2026
2fadb46
refactor: add detailed English comments and OpenMP critical section f…
dyzheng May 14, 2026
d3ab6d8
feat: add debug output for DFT+U HR/HK comparison between single/mult…
dyzheng May 14, 2026
753e6ee
chore: remove __DFTU_DEBUG_OUTPUT test code and clean up includes
dyzheng May 14, 2026
ef78f14
fix(test): shield LCAO DFT+U NSCF cases 62/63 and remove debug output
dyzheng May 14, 2026
e2b66ef
test(17_DS_DFTU): shield 10 unstable cases in CI and overhaul README
dyzheng May 15, 2026
9ae17b7
feat(deltaspin): add constraint SCF annealing for direction_only mode
dyzheng May 15, 2026
b35022d
fix(deltaspin): direction_only two-phase BFGS + lambda decay
dyzheng May 17, 2026
953632f
docs(deltaspin): add comprehensive code comments for nspin=2/4 paths …
dyzheng May 17, 2026
1aa6b2b
docs(deltaspin): add parameter unification design spec
dyzheng May 17, 2026
ac43072
docs(deltaspin): add parameter unification implementation plan
dyzheng May 17, 2026
44106c8
chore(deltaspin): delete unfinished lambda strategy code
dyzheng May 17, 2026
8dc9648
fix(deltaspin): correct sc_scf_thr default value and comment
dyzheng May 17, 2026
a94b800
fix(deltaspin): update test INPUT files from removed linear_response …
dyzheng May 17, 2026
b79f6a8
feat(deltaspin): add sc_scf_thr_mode parameter
dyzheng May 17, 2026
822792e
feat(deltaspin): add sc_dir_phase1_steps parameter
dyzheng May 17, 2026
caf0877
fix(deltaspin): move sc_dir_phase1_steps to correct position
dyzheng May 17, 2026
88fae09
fix(deltaspin): rewrite mixing_restart auto-setting logic
dyzheng May 17, 2026
b2a18cf
refactor(deltaspin): restructure esolver control flow
dyzheng May 17, 2026
e614ff5
refactor(deltaspin): update PW path for sc_scf_thr_mode
dyzheng May 17, 2026
0446eda
docs(deltaspin): update comments for unified parameter scheme
dyzheng May 17, 2026
403fff4
test(deltaspin): add tests for sc_scf_thr_mode and sc_dir_phase1_steps
dyzheng May 17, 2026
968619a
docs(deltaspin): update parameters.yaml for unified parameter scheme
dyzheng May 17, 2026
8554f70
test(deltaspin): add nspin=2+direction_only test case and update refe…
dyzheng May 17, 2026
8a72647
test(deltaspin): replace sc_scf_thr=10 with sc_scf_thr_mode=immediate
dyzheng May 17, 2026
9c36c5b
fix(deltaspin): correct run_lambda_loop iter indexing in PW path
dyzheng May 17, 2026
5bb1664
Revert "test(deltaspin): replace sc_scf_thr=10 with sc_scf_thr_mode=i…
dyzheng May 17, 2026
561aada
Revert "test(deltaspin): add nspin=2+direction_only test case and upd…
dyzheng May 17, 2026
0438bd6
test(deltaspin): add nspin=2+direction_only LCAO test case
dyzheng May 17, 2026
445865e
fix(deltaspin): correct test INPUT parameters and remove tracked log/…
dyzheng May 18, 2026
f902349
refactor(deltaspin): replace sc_scf_thr=10 with sc_scf_thr_mode=immed…
dyzheng May 18, 2026
a39b0d6
feat(deltaspin): add sc_scf_thr_mode "off" and replace sc_scf_thr=1e-…
dyzheng May 18, 2026
638460c
docs(deltaspin): add nspin=2 magnetic constraint schemes documentation
dyzheng May 18, 2026
e8297dc
docs(deltaspin): rewrite nspin=2 constraint scheme evaluation
dyzheng May 18, 2026
aeda83c
docs(deltaspin): rewrite nspin=2 constraint evaluation for data sampling
dyzheng May 18, 2026
3706309
docs(deltaspin): rewrite nspin=2 constraint evaluation with physics
dyzheng May 18, 2026
9c49503
feat(deltaspin): opt-in subspace acceleration for LCAO spin-constrain…
dyzheng May 22, 2026
b2c9d04
fix(deltaspin): fix LCAO subspace acceleration bugs and add diagnostic
dyzheng May 26, 2026
e61fc8f
fix(deltaspin): replace cal_PI_sub with calculate_PI_sub_from_hr for …
dyzheng May 26, 2026
5735ea6
feat(deltaspin): simplify execution strategy with sc_strategy parameter
dyzheng May 27, 2026
a03890e
docs(deltaspin): add subspace acceleration usage guide
dyzheng May 27, 2026
c9f3ff8
feat(deltaspin): implement LCAO subspace mixed-precision GEMM optimiz…
dyzheng May 27, 2026
bb0c319
chore(deltaspin): add missing diagonalization_engine.h to source tree
dyzheng May 27, 2026
02fcbec
fix(deltaspin): use C++11-compatible is_same and unique_ptr::reset
dyzheng May 27, 2026
9f46cac
fix(deltaspin): replace make_unique with explicit new for C++11 compa…
dyzheng May 27, 2026
eb9a0e4
Fix(deltaspin): use global NLOCAL instead of local nrow in pzgemm cal…
May 28, 2026
eb1a8b6
Fix(deltaspin): correct E_lambda formula from -sum(lambda*Mi) to -sum…
May 28, 2026
de96b27
Fix(deltaspin): unify lambda sign convention to E_prime=E+lambda*(M-M…
May 29, 2026
52c6545
Fix(deltaspin): add empty-check guard in cal_escon() to prevent segfault
May 29, 2026
f4548f4
Perf(deltaspin): eliminate gather redundancy in lcao_PI_sub_save_ and…
May 30, 2026
a04393e
Feat(xc): implement gga_grad parameter for noncollinear GGA gradient …
Jul 24, 2026
a263eb8
Feat(psi): add PsiStorageMode and device_memory_mode for GPU paging
Jul 24, 2026
4dfc525
Feat(deltaspin): nspin=4 LCAO subspace, Pauli sign fixes, gint_precision
Jul 24, 2026
d57aa19
Feat(xc/psi): libxc gga_grad=3 SF, PAGED_GPU to_range/fix_k fixes
Jul 24, 2026
702141e
Feat(psi/hsolver): integrate k-point paging into HSolverPW solve loop
Jul 24, 2026
66696b6
Fix(deltaspin): enable final diag after subspace for nspin=4
Jul 24, 2026
08bd7fa
Feat(deltaspin): enable first_order acceleration for nspin=4
Jul 24, 2026
6af97d7
Fix(xc): align PW DeltaSpin sigma_y sign with LCAO path
Jul 24, 2026
9ba3829
Feat(psi): add GPU memory mode log in setup_psi_pw
Jul 24, 2026
e7ba46c
Revert: erroneous PW sigma_y sign fix was wrong
Jul 24, 2026
7b07f9f
Revert PW sigma_y sign fix + doc test analysis
Jul 24, 2026
e14b77d
Fix(xc): disable SF builtin dispatch for gga_grad=3
Jul 24, 2026
e298c81
Feature(xc): implement gga_grad=3 via SF builtin for noncollinear GGA
Jul 24, 2026
9244c47
Fix GPU memory MPI communication bugs for DeltaSpin/DFT+U
dyzheng Jul 24, 2026
1f02f16
Merge branch 'fix/gpu-deltaspin-dftu-mpi-reduce' from dyzheng
Jul 25, 2026
f802202
Fix(deltaspin,psi): disable subspace for nspin=4 and fix PAGED_GPU me…
Jul 25, 2026
edbf29c
Fix(paged): add load_k_to_gpu before k-point loops accessing psi in P…
Jul 25, 2026
9196c54
Merge accel into develop-based branch (automatic resolution with -X t…
Jul 26, 2026
2199af1
Fix(XC,tests): restore develop's XC CMakeLists and fix duplicate add_…
Jul 26, 2026
3a56c4e
Restore critical source files from accel branch
Jul 26, 2026
3eded22
Fix: resolve merge conflicts and compilation errors
Jul 26, 2026
236f9fb
Cleanup: remove test artifacts and add gga_grad documentation for non…
Jul 26, 2026
dd825f1
Cleanup: remove unrelated debug logs, examples, and revert comment tr…
Jul 26, 2026
b72a498
Cleanup: remove duplicate test reference files
Jul 26, 2026
fea1c7b
Cleanup: remove unrelated files not part of DeltaSpin acceleration PR
Jul 26, 2026
1f817bd
Fix(CUDA): add missing isk parameter to DeltaSpin force kernel GPU ve…
Jul 26, 2026
2d3cbae
Cleanup: remove files refactored in develop branch
Jul 26, 2026
2b0b921
Fix(build): remove memory.h dependency from psi.cpp
Jul 26, 2026
d3ad308
Fix(deltaspin): fix memory leak in DeltaSpin cal_pre_HR() when reinit…
Jul 27, 2026
ca65a72
Fix(PW DFT+U): add missing member variable assignments in init()
Jul 27, 2026
c925ec6
Fix(GPU): fix compilation errors for GPU build with CUDA
dyzheng Jul 27, 2026
8557d68
Merge remote-tracking branch 'origin/develop' into accel
dyzheng Jul 27, 2026
605f64e
Fix(build): add #ifdef __LCAO guards for LCAO-only code in DeltaSpin
dyzheng Jul 27, 2026
2974609
Fix(CI): fix pyabacus link error and CMake CMP0177 policy
dyzheng Jul 27, 2026
8c838a2
Fix(deltaspin): propagate current_spin through operator chain in init()
Jul 28, 2026
e94e740
Fix(paged_gpu): fix compilation and PAGED_GPU runtime crash
Jul 28, 2026
a0c6474
Refactor: cache frequently-used PARAM.inp values in local variables
dyzheng Jul 28, 2026
8791665
Merge branch 'accel' of github.com:dyzheng/abacus-develop into accel
dyzheng Jul 28, 2026
a9a13de
Fix(build): resolve merge conflicts and fix GPU compilation
dyzheng Jul 28, 2026
d012013
Refactor: use cached member variables instead of PARAM.inp in SpinCon…
dyzheng Jul 28, 2026
54ab2bd
Refactor: add SpinConstrain getters for basis_type/ks_solver/nbands
dyzheng Jul 28, 2026
59ce37b
Fix(lcao): fix uninitialized local variables in hamilt2rho_single
Jul 28, 2026
2de77d2
Fix(tests): restore O.upf pseudopotential deleted in cleanup commit 2…
Jul 28, 2026
c996775
Fix(paged): resolve Psi PAGED_GPU mode issues with psi_prepare, opera…
dyzheng Jul 28, 2026
aaab6dd
Fix(paged): fix PAGED_GPU buffer overflow, invalid D2H copy, and psi_…
Jul 28, 2026
613a4ff
Fix(paged): fix PAGED_GPU dav_subspace issues: to_range() type-punnin…
dyzheng Jul 29, 2026
6c1bb6a
Fix(hsolver): sync d_eigenvalue before GPU refresh in Diago_DavSubspace
dyzheng Jul 31, 2026
0299ee9
Fix(force): load k-point wavefunction before onsite force/stress in P…
dyzheng Jul 31, 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
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,14 @@ jobs:
OMP_NUM_THREADS: '2'
run: |
ctest --test-dir build -V --timeout 1700 -R 10_others

# - name: 17_DS_DFTU Test
# env:
# GTEST_COLOR: 'yes'
# OMP_NUM_THREADS: '2'
# run: |
# ctest --test-dir build -V --timeout 1700 -R 17_DS_DFTU

- name: 17_DS_DFTU Test
env:
GTEST_COLOR: 'yes'
OMP_NUM_THREADS: '2'
run: |
ctest --test-dir build -V --timeout 1700 -R 17_DS_DFTU
- name: Other Unittests
env:
GTEST_COLOR: 'yes'
Expand Down
339 changes: 239 additions & 100 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,106 +1,245 @@
# ABACUS Agent Instructions

This file is the entry point for AI agents, automated review tools, and human
contributors who want the short operational version of the ABACUS development
rules. Read the complete governance document before making or reviewing changes:

- `docs/developers_guide/agent_governance.md`

## Required Baseline

- Follow the seven ABACUS coding rules summarized from the project governance:
1. Do not increase cross-layer control through `GlobalV`, `GlobalC`, or
`PARAM`; pass dependencies explicitly where practical. Migration-neutral
moves must keep the PR-level global dependency budget non-increasing and
explain the remaining global usage.
2. Do not hide workflow switches in mutable member variables that can be
changed from multiple places.
3. Keep header dependencies minimal.
4. Avoid adding `.hpp` implementation headers or propagating them through
other headers unless there is a narrow reason.
5. Do not add default arguments to existing interfaces; update call sites or
design a clearer extension.
6. Add focused tests for key features, bug fixes, INPUT behavior changes,
heterogeneous kernels, and core-module refactors.
7. Keep code compatible with the repository C++11 baseline.
- Use LF line endings for text files. Only `.bat` and `.cmd` files may use CRLF.
- Keep source file additions deterministic: update the relevant `CMakeLists.txt`
or explain why the file is generated or included indirectly.
- INPUT parameter behavior changes must update `docs/parameters.yaml` and
`docs/advanced/input_files/input-main.md`, or the PR must state why no update
is required.
- Report the exact verification performed. Do not claim completion without
fresh test or check output.

## Repository Map

- Core C++ implementation lives under `source/`; source additions must be wired
through the relevant `CMakeLists.txt`.
- INPUT parsing and help metadata live under `source/source_io/`; user-facing
INPUT docs live in `docs/parameters.yaml` and
`docs/advanced/input_files/input-main.md`.
- Unit tests are colocated under module `test/` directories such as
`source/source_md/test/`; integration and workflow tests are selected through
CTest labels and patterns.
- Developer and user build/install references live in `docs/quick_start/`,
`docs/advanced/`, `toolchain/`, `Dockerfile.gnu`, `Dockerfile.intel`, and
`Dockerfile.cuda`.

## Build And Test Entry Points

- Prefer the repository CMake/CTest flow already used by CI. For focused local
checks, use commands such as `ctest --test-dir build -V -R MODULE_MD` after a
usable build exists.
- For INPUT-related changes, verify both documentation and CLI behavior when an
executable is available: `./build/abacus -h <parameter>` and
`./build/abacus --check-input` from a valid case directory.
- For executable identity, record `./build/abacus --version` or the equivalent
installed `abacus --version` command used during verification.
- Reuse existing Docker and toolchain assets. Do not add a new container,
compiler setup, or calculation-task skill unless the PR explicitly requires
and justifies it.

## Local Runtime Testing

- Set `OMP_NUM_THREADS=1` for ABACUS runtime, integration, and MPI tests unless
a test explicitly requires another value.
- Run MPI/runtime tests outside restricted sandboxes when process visibility,
sockets, or MPI launch behavior matters.
- Treat OpenMPI `opal_ifinit: socket() failed errno=1` warnings from sandboxed
MPI-linked builds or runs as expected sandbox artifacts; rerun outside the
sandbox before treating them as ABACUS failures.
- Do not relax existing tests or references merely to make a failure pass.
Update references only when the intended behavior changed and the PR explains
why.

## Review And Exception Flow

- Mechanical blockers are enforced by hook and CI only for new files, changed
files, or diff-added lines. Historical untouched code is not a default blocker.
- Warnings from CI or AI review require reviewer attention but do not block by
themselves.
- Semantic questions such as module ownership, member-variable workflow state,
test sufficiency, and exception approval require human review.
- Exceptions must be recorded in the PR with reason, scope, risk, and a follow-up
cleanup plan.

## Local Commands
# AGENTS.md

This file provides guidance to agentic coding agents working with the ABACUS codebase.

## Build System

ABACUS uses CMake as its build system. The main build configuration is in `CMakeLists.txt` at the root.

### Basic Build Commands

```bash
python3 tools/03_code_analysis/agent_governance_check.py --staged
python3 tools/03_code_analysis/agent_governance_check.py --base upstream/develop --head HEAD --format text
pre-commit run abacus-agent-governance --all-files
# Configure with default options (LCAO enabled, MPI enabled)
cmake -B build

# Build with specific number of processors
cmake --build build -j${number_of_processors}

# Install (required before running tests)
cmake --install build
```

The repository text files have been normalized to LF once. Day-to-day line
ending enforcement should rely on staged/changed-file hooks and CI; rerun the
full mixed-line-ending hook only for intentional repository-wide normalization.
### Common Build Options

- `-DBUILD_TESTING=ON` - Enable unit tests (required for testing)
- `-DENABLE_LCAO=ON/OFF` - Enable/disable LCAO calculations (default: ON)
- `-DUSE_CUDA=ON` - Enable CUDA support
- `-DUSE_ROCM=ON` - Enable ROCm/HIP support
- `-DUSE_OPENMP=ON/OFF` - Enable OpenMP (default: ON)
- `-DENABLE_COVERAGE=ON` - Enable code coverage (sets Debug build)
- `-DENABLE_ASAN=ON` - Enable AddressSanitizer (sets RelWithDebInfo build)
- `-DCMAKE_BUILD_TYPE=Debug/Release/RelWithDebInfo` - Build type
- `-DENABLE_DEEPKS=ON` - Enable DeePKS functionality
- `-DENABLE_LIBXC=ON` - Enable LibXC functionality
- `-DUSE_ELPA=ON/OFF` - Enable ELPA diagonalization (default: ON)
- `-DENABLE_LIBRI=ON` - Enable EXX with LibRI
- `-DENABLE_PAW=ON` - Enable PAW calculations
- `-DMKLROOT=$MKLROOT` - Use Intel MKL for math libraries

### Build Variants

The executable name depends on build configuration:
- `abacus` - LCAO enabled, MPI enabled (default)
- `abacus_pw` - LCAO disabled, MPI enabled
- `abacus_serial` - LCAO enabled, MPI disabled
- `abacus_pw_serial` - LCAO disabled, MPI disabled

## Testing

### Unit Tests

Unit tests use GoogleTest framework and are located in `source/*/test` directories.

```bash
# Build with unit tests enabled
cmake -B build -DBUILD_TESTING=ON
cmake --build build -j${nproc}
cmake --install build # REQUIRED before running tests

# Run all tests
cd build
ctest -V

# Run specific test by name
ctest -R <test-name>

# Run tests matching pattern
ctest -R <pattern>

# Build specific unit test
cmake --build build -j${nproc} --target ${unit_test_name}
```

Unit test executables are located in `build/source/${module_name}/test` (or `test_parallel`, `test_pw` for specialized tests).

### Integration Tests

Integration tests are in `tests/integrate/` directory. Each test case is a subdirectory with input files (INPUT, STRU, KPT) and reference results (result.ref).

```bash
# Run all integration tests
cd tests/integrate
bash Autotest.sh

# Run specific test case
cd tests/integrate/<test_case_name>
bash ../Single_job.sh

# Run with custom parameters
bash Autotest.sh -a /path/to/abacus -n 4 -t 0.0000001

# Generate reference results for new test
bash Autotest.sh -g -r <test_case_name>
```

Key Autotest.sh options:
- `-a <path>` - ABACUS executable path (default: abacus)
- `-n <num>` - Number of MPI processes (default: 4)
- `-t <threshold>` - Energy threshold in eV (default: 0.0000001)
- `-c <accuracy>` - Check accuracy (default: 8)
- `-g` - Generate reference results
- `-r <regex>` - Test case name regex filter
- `-f <file>` - Test cases file (default: CASES_CPU.txt)

## Code Style and Formatting

### Formatting

- Use `clang-format` with the `.clang-format` file in root directory
- Based on Microsoft style with customizations
- 4-space indentation, no tabs
- Left-aligned pointers (`int* ptr` not `int *ptr`)
- Sort includes and using declarations

### Documentation

- Doxygen comments for documentation (Javadoc style preferred)
- Comment only in `.h` files for Doxygen visibility
- Use `@param` for parameters, `\f$...\f$` for inline formulas

### Code Conventions

**Naming:**
- Classes: PascalCase (e.g., `HSolver`, `Matrix`)
- Functions: snake_case (e.g., `solve_hamiltonian`, `calculate_energy`)
- Variables: snake_case (e.g., `num_bands`, `ecutwfc`)
- Constants: UPPER_SNAKE_CASE (e.g., `MAX_ITERATIONS`)
- Private members: trailing underscore (e.g., `num_bands_`)

**Imports and Includes:**
- System headers first, then project headers
- Use angle brackets for system headers, quotes for project headers
- Group includes: C standard library, C++ standard library, external libraries, internal headers
- Sort includes alphabetically within groups

**Types:**
- Use `double` for floating-point by default, `float` only when memory is critical
- Use `std::complex<double>` for complex numbers
- Prefer `std::vector` over C-style arrays
- Use `size_t` for sizes and indices
- Use `const` and references where appropriate

**Error Handling:**
- Use assertions (`assert()`) for internal invariants
- Return error codes or use exceptions for recoverable errors
- Log errors using the existing logging infrastructure
- Validate input parameters at function boundaries

**Templates:**
- Use templates for generic algorithms and data structures
- Provide explicit instantiations for common types
- Use `template <>` for specializations

**Memory Management:**
- Use RAII principles with smart pointers (`std::unique_ptr`, `std::shared_ptr`)
- Avoid raw `new`/`delete` when possible
- Follow the Rule of Three/Five for classes managing resources

**Parallelization:**
- Use MPI for distributed memory parallelization
- Use OpenMP for shared memory parallelization
- Follow existing patterns for communicator splitting
- Be careful with global variables in parallel contexts

### Module Structure

The source code is organized into modules under `source/`:

**Core Infrastructure:**
- `module_base/` - Mathematical library interfaces, data structures, parallelization, utilities
- `module_container/` - Container module for data storage and operations
- `module_parameter/` - Input parameters and global variables

**Basis Sets:**
- `module_basis/module_pw/` - Plane wave basis
- `module_basis/module_nao/` - Numerical atomic orbital basis
- `module_basis/module_ao/` - Legacy atomic orbital basis

**Cell and Structure:**
- `module_cell/` - Unit cell definition and operations
- `module_cell/module_neighbor/` - Neighbor finding
- `module_cell/module_symmetry/` - Symmetry operations

**Electronic Structure:**
- `module_elecstate/` - Electronic state definition and operations
- `module_elecstate/module_charge/` - Charge density calculation and mixing
- `module_elecstate/potentials/` - Potential calculations
- `module_psi/` - Wave function definition and operations

**Hamiltonians:**
- `module_hamilt_general/` - General Hamiltonian components
- `module_hamilt_pw/` - PW-specific Hamiltonians
- `module_hamilt_lcao/` - LCAO-specific Hamiltonians

**Solvers and Drivers:**
- `module_hsolver/` - Hamiltonian diagonalization methods
- `module_esolver/` - Task-specific workflow drivers
- `module_md/` - Molecular dynamics
- `module_relax/` - Structural optimization

**I/O:**
- `module_io/` - INPUT file reading and property output

## Development Workflow

### Adding New Features

1. Read relevant source files first before proposing changes
2. Follow existing code patterns in the module
3. Add unit tests in `source/${module}/test/` using GoogleTest
4. Add integration tests in `tests/integrate/` if needed
5. Update CMakeLists.txt if adding new source files or tests
6. Ensure code follows clang-format style

### Important Notes

- Always run `cmake --install build` after building and before running tests
- For PW calculations, set `pw_seed 1` in INPUT file for reproducible tests
- Integration tests should run in < 20 seconds (reduce atoms, k-points, ecutwfc, steps)
- Pseudopotential and orbital files go in `tests/PP_ORB/`
- Use relative paths in INPUT for `pseudo_dir` and `orb_dir`
- The main development branch is `develop`, not `main` or `master`

### Commit Message Format

Follow Conventional Commits specification:

```
<type>[optional scope]: <description>

[optional body]

[optional footer]
```

Types: `Feature`, `Fix`, `Docs`, `Style`, `Refactor`, `Perf`, `Test`, `Build`, `CI`, `Revert`

Example:
```
Fix(lcao): use correct scalapack interface

## PR Self-Check
`pzgemv_` and `pzgemm_` used `double*` for alpha and beta parameters
but not `complex*`, this would cause error in GNU compiler.

- Confirm the PR body states exact commands run, whether they passed or failed,
and why any expected check could not be run.
- Keep warning rationales concrete. For example, a header include warning can be
acceptable when the header owns a value member that requires the complete type.
- Keep historical-debt notes separate from new deterministic errors introduced
by the PR.
Fix #753.
```
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 3.16)

if(POLICY CMP0177)
cmake_policy(SET CMP0177 OLD)
endif()

# Require out-of-source builds
file(TO_CMAKE_PATH "${CMAKE_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
if(EXISTS "${LOC_PATH}")
Expand Down
Loading