Skip to content

Commit 1c9557b

Browse files
authored
Merge branch 'develop' into fix/dftu-uom-mixing-stability
2 parents 89c64e3 + 3df3bb4 commit 1c9557b

150 files changed

Lines changed: 12069 additions & 9494 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ rules. Read the complete governance document before making or reviewing changes:
3434
is required.
3535
- Report the exact verification performed. Do not claim completion without
3636
fresh test or check output.
37+
- For multi-step refactors (e.g., splitting a large `.cpp` into several
38+
files), build and commit after each step rather than batching all changes
39+
before verification. This keeps the blast radius small when a step
40+
surfaces a missing include or instantiation error.
3741
- Prefer `std::vector` over raw `new`/`delete` for dynamic arrays; before
3842
converting class members, confirm no external code consumes them as raw
3943
pointers (e.g., `std::vector<bool>` has no `.data()`), and use
@@ -106,6 +110,8 @@ rules. Read the complete governance document before making or reviewing changes:
106110
python3 tools/03_code_analysis/agent_governance_check.py --staged
107111
python3 tools/03_code_analysis/agent_governance_check.py --base upstream/develop --head HEAD --format text
108112
pre-commit run abacus-agent-governance --all-files
113+
# Score changed C++ files for quality debt (pass line is 60):
114+
python3 tools/03_code_analysis/code_quality_score.py $(git diff --name-only upstream/develop...HEAD | grep -E '\.(cpp|h)$')
109115
```
110116

111117
The repository text files have been normalized to LF once. Day-to-day line

docs/advanced/acceleration/cuda.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The ABACUS program will automatically determine whether the current ELPA support
4444
## Run with the GPU support by editing the INPUT script:
4545

4646
In `INPUT` file we need to set the input parameter [device](../input_files/input-main.md#device) to `gpu`. If this parameter is not set, ABACUS will try to determine if there are available GPUs.
47-
- Set `ks_solver`: For the PW basis, CG, BPCG and Davidson methods are supported on GPU; set the input parameter [ks_solver](../input_files/input-main.md#ks_solver) to `cg`, `bpcg` or `dav`. For the LCAO basis, `cusolver`, `cusolvermp` and `elpa` is supported on GPU.
47+
- Set `ks_solver`: For the PW basis, CG, BPCG, Davidson, and Davidson subspace methods are supported on GPU; set the input parameter [ks_solver](../input_files/input-main.md#ks_solver) to `cg`, `bpcg`, `dav`, or `dav_subspace`. For the LCAO basis, `cusolver`, `cusolvermp`, and `elpa` are supported on GPU.
4848
- **single-card**: ABACUS allows for single-GPU acceleration. You can run ABACUS without any MPI process by command `abacus`, and `ks_solver cusolver` is recommended for the LCAO basis. *note: avoid using `mpirun -n 1 abacus`*.
4949
- **multi-cards**: ABACUS allows for multi-GPU acceleration. If you have multiple GPU cards, you can run ABACUS with several MPI processes, and each process will utilize one GPU card. For example, the command `mpirun -n 2 abacus` will by default launch two GPUs for computation. If you only have one card, this command will only start one GPU. *note: the number of MPI processes SHOULD be equal to the number of GPU cards, unless you are using MPS in your computer.*
5050

@@ -58,4 +58,4 @@ PW basis:
5858

5959
LCAO basis:
6060
- Unless there is a specific reason, avoid using multiple GPUs, as it can be slower than using a single GPU. This is because the generalized eigenvalue solution of the LCAO basis set will incur additional communication overhead when calculated on multiple cards. When the memory limit of a GPU card makes it insufficient to complete the task, it is recommended to use multiple cards for calculation.
61-
- When using elpa on GPUs, some ELPA internal logs will be output.
61+
- When using elpa on GPUs, some ELPA internal logs will be output.

docs/advanced/input_files/input-main.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [System variables](#system-variables)
99
- [suffix](#suffix)
1010
- [ntype](#ntype)
11+
- [cell\_replica](#cell_replica)
1112
- [calculation](#calculation)
1213
- [esolver\_type](#esolver_type)
1314
- [symmetry](#symmetry)
@@ -356,6 +357,8 @@
356357
- [md\_restart](#md_restart)
357358
- [md\_restartfreq](#md_restartfreq)
358359
- [md\_dumpfreq](#md_dumpfreq)
360+
- [md\_neighbor\_skin](#md_neighbor_skin)
361+
- [md\_out\_force](#md_out_force)
359362
- [dump\_force](#dump_force)
360363
- [dump\_vel](#dump_vel)
361364
- [dump\_virial](#dump_virial)
@@ -601,6 +604,12 @@
601604
- **Description**: Number of different atom species in the calculation.
602605
- **Default**: 0
603606

607+
### cell_replica
608+
609+
- **Type**: Three Integers
610+
- **Description**: Replicate the input STRU by Na, Nb, and Nc along its lattice vectors for distributed MDCell workflows. This parameter is only used for classical potentials or machine-learned interatomic potentials. The default is 1 1 1, which preserves the input structure.
611+
- **Default**: 1 1 1
612+
604613
### calculation
605614

606615
- **Type**: String
@@ -3504,15 +3513,28 @@
35043513
### md_restartfreq
35053514

35063515
- **Type**: Integer
3507-
- **Description**: The output frequency of OUT.{suffix}/STRIU/, which are used to restart molecular dynamics calculations, see md_restart in detail.
3516+
- **Description**: The output frequency of OUT.{suffix}/STRU_MD_*, which are used to restart molecular dynamics calculations, see md_restart in detail. Set to 0 to disable MD restart output.
35083517
- **Default**: 5
35093518

35103519
### md_dumpfreq
35113520

35123521
- **Type**: Integer
3513-
- **Description**: The output frequency of OUT.${suffix}/MD_dump in molecular dynamics calculations, which including the information of lattices and atoms.
3522+
- **Description**: The output frequency of OUT.${suffix}/MD_dump in molecular dynamics calculations, which includes lattice and atomic information. Set to 0 to disable MD_dump output.
35143523
- **Default**: 1
35153524

3525+
### md_neighbor_skin
3526+
3527+
- **Type**: Real
3528+
- **Description**: The extra neighbor-list radius in Angstrom for MDCell molecular dynamics. This parameter is only used for classical potentials or machine-learned interatomic potentials. A positive value reuses the cutoff-plus-skin candidate list until an atom has moved by half this distance; 0 rebuilds the list every force evaluation.
3529+
- **Default**: 0.0
3530+
- **Unit**: Angstrom
3531+
3532+
### md_out_force
3533+
3534+
- **Type**: Boolean
3535+
- **Description**: Whether to output the TOTAL-FORCE table in OUT.${suffix}/running_md.log for MDCell molecular dynamics. This does not affect force calculation or molecular dynamics integration.
3536+
- **Default**: True
3537+
35163538
### dump_force
35173539

35183540
- **Type**: Boolean
@@ -3535,8 +3557,8 @@
35353557

35363558
- **Type**: Integer
35373559
- **Description**: The random seed to initialize random numbers used in molecular dynamics calculations.
3538-
- &lt; 0: No srand() function is called.
3539-
- &gt;= 0: The function srand(md_seed) is called.
3560+
- &lt; 0: Each MPI rank uses the default seed 1 plus its rank.
3561+
- &gt;= 0: Each MPI rank uses md_seed plus its rank.
35403562
- **Default**: -1
35413563

35423564
### md_tfreq

docs/parameters.yaml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ parameters:
1717
default_value: "0"
1818
unit: ""
1919
availability: ""
20+
- name: cell_replica
21+
category: System variables
22+
type: Three Integers
23+
description: |
24+
Replicate the input STRU by Na, Nb, and Nc along its lattice vectors for distributed MDCell workflows. This parameter is only used for classical potentials or machine-learned interatomic potentials. The default is 1 1 1, which preserves the input structure.
25+
default_value: 1 1 1
26+
unit: ""
27+
availability: ""
2028
- name: calculation
2129
category: System variables
2230
type: String
@@ -1449,18 +1457,34 @@ parameters:
14491457
category: Molecular dynamics
14501458
type: Integer
14511459
description: |
1452-
The output frequency of OUT.{suffix}/STRIU/, which are used to restart molecular dynamics calculations, see md_restart in detail.
1460+
The output frequency of OUT.{suffix}/STRU_MD_*, which are used to restart molecular dynamics calculations, see md_restart in detail. Set to 0 to disable MD restart output.
14531461
default_value: "5"
14541462
unit: ""
14551463
availability: ""
14561464
- name: md_dumpfreq
14571465
category: Molecular dynamics
14581466
type: Integer
14591467
description: |
1460-
The output frequency of OUT.${suffix}/MD_dump in molecular dynamics calculations, which including the information of lattices and atoms.
1468+
The output frequency of OUT.${suffix}/MD_dump in molecular dynamics calculations, which includes lattice and atomic information. Set to 0 to disable MD_dump output.
14611469
default_value: "1"
14621470
unit: ""
14631471
availability: ""
1472+
- name: md_neighbor_skin
1473+
category: Molecular dynamics
1474+
type: Real
1475+
description: |
1476+
The extra neighbor-list radius in Angstrom for MDCell molecular dynamics. This parameter is only used for classical potentials or machine-learned interatomic potentials. A positive value reuses the cutoff-plus-skin candidate list until an atom has moved by half this distance; 0 rebuilds the list every force evaluation.
1477+
default_value: "0.0"
1478+
unit: Angstrom
1479+
availability: ""
1480+
- name: md_out_force
1481+
category: Molecular dynamics
1482+
type: Boolean
1483+
description: |
1484+
Whether to output the TOTAL-FORCE table in OUT.${suffix}/running_md.log for MDCell molecular dynamics. This does not affect force calculation or molecular dynamics integration.
1485+
default_value: "True"
1486+
unit: ""
1487+
availability: ""
14641488
- name: dump_force
14651489
category: Molecular dynamics
14661490
type: Boolean
@@ -1490,8 +1514,8 @@ parameters:
14901514
type: Integer
14911515
description: |
14921516
The random seed to initialize random numbers used in molecular dynamics calculations.
1493-
* < 0: No srand() function is called.
1494-
* >= 0: The function srand(md_seed) is called.
1517+
* < 0: Each MPI rank uses the default seed 1 plus its rank.
1518+
* >= 0: Each MPI rank uses md_seed plus its rank.
14951519
default_value: "-1"
14961520
unit: ""
14971521
availability: ""

generate_build_info.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ if [ "${USE_CUDA}" == "ON" ]; then
257257
fi
258258
# --- Final File Generation ---
259259

260-
INPUT_FILE="source_io/build_info.h.in"
260+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
261+
INPUT_FILE="${SCRIPT_DIR}/source/source_io/build_info.h.in"
261262

262263
# Use sed to replace all placeholders with detected values
263264
# Note the use of different delimiters (#) for paths to avoid conflicts with /

python/pyabacus/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ To contribute to the `pyabacus` project, follow these steps:
375375

376376
@staticmethod
377377
def sphbes_zeros(l: int, n: int, zeros: NDArray[np.float64]) -> None:
378-
super().sphbes_zeros(l, n, zeros)
378+
_Sphbes.sphbes_zeros(l, n, zeros)
379379
```
380380

381381
## Conclusion

python/pyabacus/src/pyabacus/ModuleBase/_module_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def dsphbesj(self, *args, **kwargs):
4848

4949
@staticmethod
5050
def sphbes_zeros(l: int, n: int, zeros: NDArray[np.float64]) -> None:
51-
super().sphbes_zeros(l, n, zeros)
51+
_Sphbes.sphbes_zeros(l, n, zeros)
5252

5353
class Integral(_Integral):
5454
def __init__(self) -> None:
@@ -81,7 +81,7 @@ def Simpson_Integral_0toall(
8181
rab: NDArray[np.float64],
8282
asum: NDArray[np.float64]
8383
) -> None:
84-
super().Simpson_Integral_0toall(mesh, func, rab, asum)
84+
_Integral.Simpson_Integral_0toall(mesh, func, rab, asum)
8585

8686
@staticmethod
8787
def Simpson_Integral_alltoinf(
@@ -90,7 +90,7 @@ def Simpson_Integral_alltoinf(
9090
rab: NDArray[np.float64],
9191
asum: NDArray[np.float64]
9292
) -> None:
93-
super().Simpson_Integral_alltoinf(mesh, func, rab, asum)
93+
_Integral.Simpson_Integral_alltoinf(mesh, func, rab, asum)
9494

9595
@overload
9696
@staticmethod

python/pyabacus/tests/test_base_math.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@ def test_sphbes():
1313
assert s.sphbesj(0, 0.0) == 1.0
1414
assert s.sphbesj(1, np.array([0.0]), 1, 1, np.zeros(1)) == None
1515

16+
def test_static_array_wrappers():
17+
zeros = np.zeros(2)
18+
base.Sphbes.sphbes_zeros(0, 2, zeros)
19+
np.testing.assert_allclose(zeros, [np.pi, 2 * np.pi])
20+
21+
mesh = 3
22+
func = np.ones(mesh)
23+
rab = np.ones(mesh)
24+
integral_from_zero = np.zeros(mesh)
25+
integral_to_infinity = np.zeros(mesh)
26+
27+
base.Integral.Simpson_Integral_0toall(mesh, func, rab, integral_from_zero)
28+
base.Integral.Simpson_Integral_alltoinf(mesh, func, rab, integral_to_infinity)
29+
30+
np.testing.assert_allclose(integral_from_zero, [0.0, 1.0, 2.0])
31+
np.testing.assert_allclose(integral_to_infinity, [2.0, 1.0, 0.0])
32+
1633
def test_sbt():
1734
sbt = base.SphericalBesselTransformer()
1835

source/Makefile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ OBJ_DIR = $(BUILD_DIR)/obj
66
BIN_DIR = $(BUILD_DIR)/bin
77
BUILD_INFO_DIR = $(BUILD_DIR)/source_io
88

9+
# The first rule in this file only generates build_info.h, so make would
10+
# stop after generating that header unless the default goal is set here.
11+
.DEFAULT_GOAL := abacus
12+
913
include $(ABACUS_ROOT)Makefile.vars
1014

1115
#==========================
@@ -252,18 +256,25 @@ ${OBJ_DIR}/parse_args.o: $(ABACUS_ROOT)source_io/parse_args.cpp $(BUILD_INFO_DIR
252256
@mkdir -p $(dir $@)
253257
${CXX} ${OPTS} ${OPTS_MPI} -c ${HONG} $< -o $@
254258

259+
# Explicit rule: source_cell/module_symmetry and source_estate/module_charge
260+
# both contain a symm_rho.cpp. VPATH resolves symm_rho.o to the source_cell
261+
# one (listed first), so the Symmetry_rho implementation needs an explicit
262+
# object name to be compiled from the correct source.
263+
${OBJ_DIR}/symm_rho_charge.o: $(ABACUS_ROOT)source_estate/module_charge/symm_rho.cpp
264+
@mkdir -p $(dir $@)
265+
${CXX} ${OPTS} ${OPTS_MPI} -c ${HONG} $< -o $@
266+
255267
###### END of ABACUS INFO PART ######
256268

257269
#==========================
258270
# MAKING OPTIONS
259271
#==========================
260272
abacus:
261-
@ if [ ! -d $(OBJ_DIR) ]; then mkdir $(OBJ_DIR); fi
262-
@ if [ ! -d $(BIN_DIR) ]; then mkdir $(BIN_DIR); fi
263-
@ $(MAKE) $(BIN_DIR)/${VERSION}.$(suffix)
273+
@ mkdir -p $(OBJ_DIR) $(BIN_DIR)
274+
@ $(MAKE) -f $(firstword $(MAKEFILE_LIST)) $(BIN_DIR)/${VERSION}.$(suffix)
264275

265276
test:
266-
@ $(MAKE) abacus
277+
@ $(MAKE) -f $(firstword $(MAKEFILE_LIST)) abacus
267278
@ cd $(ABACUS_ROOT)../tests/integrate/;sh Autotest.sh -a $(realpath $(BIN_DIR))/ABACUS.mpi -n $(TESTNP)
268279

269280
pw $(BIN_DIR)/${VERSION}-PW.x:
@@ -280,7 +291,8 @@ $(BIN_DIR)/${VERSION}.$(suffix) : ${FP_OBJS} ${PDIAG_OBJS} ${HEADERS}
280291
#==========================
281292
# Note: The specific rule for parse_args.o above is more precise.
282293
# This generic rule will apply to all other .cpp files.
283-
${OBJ_DIR}/%.o:$(realpath $(BIN_DIR))%.cpp
294+
${OBJ_DIR}/%.o:%.cpp
295+
@ mkdir -p $(dir $@)
284296
${CXX} ${OPTS} ${OPTS_MPI} -c ${HONG} $< -o $@
285297

286298
.PHONY:clean test

0 commit comments

Comments
 (0)