Skip to content

Commit 152a0f0

Browse files
author
zxy.monado
committed
Merge upstream develop into hsolver refactor
2 parents c97342f + c2fa3ac commit 152a0f0

372 files changed

Lines changed: 32545 additions & 15504 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.

.github/workflows/build_test_cmake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- tag: gnu
2626
external_toolchain_args: ""
27-
build_args: "-DENABLE_LIBXC=ON -DENABLE_MLALGO=ON -DENABLE_LIBRI=ON -DENABLE_DFTD4=ON"
27+
build_args: "-DENABLE_LIBXC=ON -DENABLE_MLALGO=ON -DENABLE_LIBRI=ON -DENABLE_DFTD4=ON -DENABLE_PEXSI=ON"
2828
name: "Build extra components with GNU toolchain"
2929
- tag: intel
3030
external_toolchain_args: "--with-intel"

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
-DENABLE_RAPIDJSON=ON \
6868
-DENABLE_FLOAT_FFTW=ON \
6969
-DENABLE_DFTD4=ON \
70+
-DENABLE_PEXSI=ON \
7071
-Werror=dev
7172
7273
# Temporarily removed because no one maintains this now.

AGENTS.md

Lines changed: 9 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
@@ -99,13 +103,18 @@ rules. Read the complete governance document before making or reviewing changes:
99103
- Member -> free function: inventory `this->` reads; pass as params (const
100104
for config, ref for mutable state); move only when body is `this`-free;
101105
keep thin wrapper; compile each step.
106+
- Extract a base-class nested-vector member in three steps (hold + forward,
107+
switch writers, delete legacy) so no commit mixes old-storage writes with
108+
new-storage reads.
102109

103110
## Local Commands
104111

105112
```bash
106113
python3 tools/03_code_analysis/agent_governance_check.py --staged
107114
python3 tools/03_code_analysis/agent_governance_check.py --base upstream/develop --head HEAD --format text
108115
pre-commit run abacus-agent-governance --all-files
116+
# Score changed C++ files for quality debt (pass line is 60):
117+
python3 tools/03_code_analysis/code_quality_score.py $(git diff --name-only upstream/develop...HEAD | grep -E '\.(cpp|h)$')
109118
```
110119

111120
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: 81 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)
@@ -586,6 +589,14 @@
586589
- [Reduced Density Matrix Functional Theory](#reduced-density-matrix-functional-theory)
587590
- [rdmft](#rdmft)
588591
- [rdmft\_power\_alpha](#rdmft_power_alpha)
592+
- [Density functional perturbation theory](#density-functional-perturbation-theory)
593+
- [dfpt\_qmesh](#dfpt_qmesh)
594+
- [dfpt\_qfile](#dfpt_qfile)
595+
- [dfpt\_compute\_q0](#dfpt_compute_q0)
596+
- [dfpt\_loto](#dfpt_loto)
597+
- [dfpt\_conv\_thr](#dfpt_conv_thr)
598+
- [dfpt\_max\_iter](#dfpt_max_iter)
599+
- [dfpt\_mix\_beta](#dfpt_mix_beta)
589600

590601
## System variables
591602

@@ -601,6 +612,12 @@
601612
- **Description**: Number of different atom species in the calculation.
602613
- **Default**: 0
603614

615+
### cell_replica
616+
617+
- **Type**: Three Integers
618+
- **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.
619+
- **Default**: 1 1 1
620+
604621
### calculation
605622

606623
- **Type**: String
@@ -634,6 +651,7 @@
634651
- nep: Neuroevolution Potential
635652
- ks-lr: Kohn-Sham density functional theory + LR-TDDFT (Under Development Feature)
636653
- lr: LR-TDDFT with given KS orbitals (Under Development Feature)
654+
- dfpt: density functional perturbation theory (Under Development Feature)
637655
- **Default**: ksdft
638656

639657
### symmetry
@@ -3504,15 +3522,28 @@
35043522
### md_restartfreq
35053523

35063524
- **Type**: Integer
3507-
- **Description**: The output frequency of OUT.{suffix}/STRIU/, which are used to restart molecular dynamics calculations, see md_restart in detail.
3525+
- **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.
35083526
- **Default**: 5
35093527

35103528
### md_dumpfreq
35113529

35123530
- **Type**: Integer
3513-
- **Description**: The output frequency of OUT.${suffix}/MD_dump in molecular dynamics calculations, which including the information of lattices and atoms.
3531+
- **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.
35143532
- **Default**: 1
35153533

3534+
### md_neighbor_skin
3535+
3536+
- **Type**: Real
3537+
- **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.
3538+
- **Default**: 0.0
3539+
- **Unit**: Angstrom
3540+
3541+
### md_out_force
3542+
3543+
- **Type**: Boolean
3544+
- **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.
3545+
- **Default**: True
3546+
35163547
### dump_force
35173548

35183549
- **Type**: Boolean
@@ -3535,8 +3566,8 @@
35353566

35363567
- **Type**: Integer
35373568
- **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.
3569+
- &lt; 0: Each MPI rank uses the default seed 1 plus its rank.
3570+
- &gt;= 0: Each MPI rank uses md_seed plus its rank.
35403571
- **Default**: -1
35413572

35423573
### md_tfreq
@@ -5170,3 +5201,49 @@
51705201
- **Default**: 0.656
51715202

51725203
[back to top](#full-list-of-input-keywords)
5204+
5205+
## Density functional perturbation theory
5206+
5207+
### dfpt_qmesh
5208+
5209+
- **Type**: Vector of Int (1 or 3 values)
5210+
- **Description**: Set the Monkhorst-Pack q mesh (gamma-centered) for DFPT phonon calculations. The q mesh must be commensurate with the ground-state k mesh: k + q must be a point of the k list (modulo a reciprocal lattice vector). For example, a 4x4x4 KPT mesh is commensurate with dfpt_qmesh values of 1, 2, or 4 along each direction. This parameter is ignored when dfpt_qfile is set.
5211+
- **Default**: 1 1 1
5212+
5213+
### dfpt_qfile
5214+
5215+
- **Type**: String
5216+
- **Description**: Set the file containing the q points for DFPT, in the same format as the KPT file (Q_POINTS card: Gamma/Monkhorst-Pack mesh, or an explicit Direct/Cartesian list; symmetry reduction is not applied to file q lists). When set, it overrides dfpt_qmesh. Each q point must still be commensurate with the ground-state k mesh.
5217+
- **Default**: ""
5218+
5219+
### dfpt_compute_q0
5220+
5221+
- **Type**: Boolean
5222+
- **Description**: Whether to compute the macroscopic dielectric tensor (epsilon_inf) and the Born effective charges at q = 0 within the same DFPT run. Requires a q point at Gamma (the default dfpt_qmesh 1 1 1).
5223+
- **Default**: false
5224+
5225+
### dfpt_loto
5226+
5227+
- **Type**: Boolean
5228+
- **Description**: Whether to apply the Lyddane-Sachs-Teller non-analytic correction to the Gamma-point dynamical matrix, which splits the longitudinal and transverse optical modes. Requires dfpt_compute_q0 to be true, since the correction is built from epsilon_inf and the Born effective charges.
5229+
- **Default**: false
5230+
5231+
### dfpt_conv_thr
5232+
5233+
- **Type**: Real
5234+
- **Description**: Set the convergence threshold of the self-consistent DFPT cycle: the iteration stops when the relative residual of the first-order density ||drho_out - drho_in|| / ||drho_out|| drops below this value for every displacement.
5235+
- **Default**: 1.0e-8
5236+
5237+
### dfpt_max_iter
5238+
5239+
- **Type**: Integer
5240+
- **Description**: Set the maximum number of self-consistent DFPT iterations for each atomic displacement.
5241+
- **Default**: 100
5242+
5243+
### dfpt_mix_beta
5244+
5245+
- **Type**: Real
5246+
- **Description**: Set the plain-mixing coefficient of the first-order density in the self-consistent DFPT cycle. The response Jacobian has strongly negative eigenvalues on the smallest-G shells (Coulomb stiffness), so beta must stay below 2 / (1 + |lambda_min|); the default 0.4 keeps margin up to |lambda_min| ~ 3. A larger value accelerates convergence for weakly screened systems but may diverge.
5247+
- **Default**: 0.4
5248+
5249+
[back to top](#full-list-of-input-keywords)

docs/parameters.yaml

Lines changed: 85 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
@@ -53,6 +61,7 @@ parameters:
5361
* nep: Neuroevolution Potential
5462
* ks-lr: Kohn-Sham density functional theory + LR-TDDFT (Under Development Feature)
5563
* lr: LR-TDDFT with given KS orbitals (Under Development Feature)
64+
* dfpt: density functional perturbation theory (Under Development Feature)
5665
default_value: ksdft
5766
unit: ""
5867
availability: ""
@@ -1449,18 +1458,34 @@ parameters:
14491458
category: Molecular dynamics
14501459
type: Integer
14511460
description: |
1452-
The output frequency of OUT.{suffix}/STRIU/, which are used to restart molecular dynamics calculations, see md_restart in detail.
1461+
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.
14531462
default_value: "5"
14541463
unit: ""
14551464
availability: ""
14561465
- name: md_dumpfreq
14571466
category: Molecular dynamics
14581467
type: Integer
14591468
description: |
1460-
The output frequency of OUT.${suffix}/MD_dump in molecular dynamics calculations, which including the information of lattices and atoms.
1469+
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.
14611470
default_value: "1"
14621471
unit: ""
14631472
availability: ""
1473+
- name: md_neighbor_skin
1474+
category: Molecular dynamics
1475+
type: Real
1476+
description: |
1477+
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.
1478+
default_value: "0.0"
1479+
unit: Angstrom
1480+
availability: ""
1481+
- name: md_out_force
1482+
category: Molecular dynamics
1483+
type: Boolean
1484+
description: |
1485+
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.
1486+
default_value: "True"
1487+
unit: ""
1488+
availability: ""
14641489
- name: dump_force
14651490
category: Molecular dynamics
14661491
type: Boolean
@@ -1490,8 +1515,8 @@ parameters:
14901515
type: Integer
14911516
description: |
14921517
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.
1518+
* < 0: Each MPI rank uses the default seed 1 plus its rank.
1519+
* >= 0: Each MPI rank uses md_seed plus its rank.
14951520
default_value: "-1"
14961521
unit: ""
14971522
availability: ""
@@ -3022,6 +3047,62 @@ parameters:
30223047
default_value: "-1 2 -1 2"
30233048
unit: primitive cells
30243049
availability: "lr_solver==plot and exciton_plot_format in [slice, both]"
3050+
- name: dfpt_qmesh
3051+
category: Density functional perturbation theory
3052+
type: Vector of Int (1 or 3 values)
3053+
description: |
3054+
Set the Monkhorst-Pack q mesh (gamma-centered) for DFPT phonon calculations. The q mesh must be commensurate with the ground-state k mesh: k + q must be a point of the k list (modulo a reciprocal lattice vector). For example, a 4x4x4 KPT mesh is commensurate with dfpt_qmesh values of 1, 2, or 4 along each direction. This parameter is ignored when dfpt_qfile is set.
3055+
default_value: 1 1 1
3056+
unit: ""
3057+
availability: ""
3058+
- name: dfpt_qfile
3059+
category: Density functional perturbation theory
3060+
type: String
3061+
description: |
3062+
Set the file containing the q points for DFPT, in the same format as the KPT file (Q_POINTS card: Gamma/Monkhorst-Pack mesh, or an explicit Direct/Cartesian list; symmetry reduction is not applied to file q lists). When set, it overrides dfpt_qmesh. Each q point must still be commensurate with the ground-state k mesh.
3063+
default_value: "\"\""
3064+
unit: ""
3065+
availability: ""
3066+
- name: dfpt_compute_q0
3067+
category: Density functional perturbation theory
3068+
type: Boolean
3069+
description: |
3070+
Whether to compute the macroscopic dielectric tensor (epsilon_inf) and the Born effective charges at q = 0 within the same DFPT run. Requires a q point at Gamma (the default dfpt_qmesh 1 1 1).
3071+
default_value: "false"
3072+
unit: ""
3073+
availability: ""
3074+
- name: dfpt_loto
3075+
category: Density functional perturbation theory
3076+
type: Boolean
3077+
description: |
3078+
Whether to apply the Lyddane-Sachs-Teller non-analytic correction to the Gamma-point dynamical matrix, which splits the longitudinal and transverse optical modes. Requires dfpt_compute_q0 to be true, since the correction is built from epsilon_inf and the Born effective charges.
3079+
default_value: "false"
3080+
unit: ""
3081+
availability: ""
3082+
- name: dfpt_conv_thr
3083+
category: Density functional perturbation theory
3084+
type: Real
3085+
description: |
3086+
Set the convergence threshold of the self-consistent DFPT cycle: the iteration stops when the relative residual of the first-order density ||drho_out - drho_in|| / ||drho_out|| drops below this value for every displacement.
3087+
default_value: "1.0e-8"
3088+
unit: ""
3089+
availability: ""
3090+
- name: dfpt_max_iter
3091+
category: Density functional perturbation theory
3092+
type: Integer
3093+
description: |
3094+
Set the maximum number of self-consistent DFPT iterations for each atomic displacement.
3095+
default_value: "100"
3096+
unit: ""
3097+
availability: ""
3098+
- name: dfpt_mix_beta
3099+
category: Density functional perturbation theory
3100+
type: Real
3101+
description: |
3102+
Set the plain-mixing coefficient of the first-order density in the self-consistent DFPT cycle. The response Jacobian has strongly negative eigenvalues on the smallest-G shells (Coulomb stiffness), so beta must stay below 2 / (1 + |lambda_min|); the default 0.4 keeps margin up to |lambda_min| ~ 3. A larger value accelerates convergence for weakly screened systems but may diverge.
3103+
default_value: "0.4"
3104+
unit: ""
3105+
availability: ""
30253106
- name: out_freq_ion
30263107
category: Output information
30273108
type: Integer

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

0 commit comments

Comments
 (0)