Skip to content

Commit e99a7ac

Browse files
authored
Merge branch 'develop' into develop
2 parents 312393a + 370e024 commit e99a7ac

151 files changed

Lines changed: 7226 additions & 6766 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/cuda.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,30 @@ jobs:
7373
cd tests/13_NAO_multik_GPU
7474
bash ../integrate/Autotest.sh -n 2 -f CASES_GPU.txt
7575
76+
- name: Test 02_NAO_Gamma on GPU
77+
run: |
78+
cd tests/02_NAO_Gamma
79+
find . -name INPUT | while read f; do
80+
if grep -qE '^[[:space:]]*device[[:space:]]+' "$f"; then
81+
sed -i -E 's/^[[:space:]]*device[[:space:]]+.*/device gpu/' "$f"
82+
else
83+
echo "device gpu" >> "$f"
84+
fi
85+
done
86+
bash ../integrate/Autotest.sh -n 2 -f CASES_GPU.txt
87+
88+
- name: Test 03_NAO_multik on GPU
89+
run: |
90+
cd tests/03_NAO_multik
91+
find . -name INPUT | while read f; do
92+
if grep -qE '^[[:space:]]*device[[:space:]]+' "$f"; then
93+
sed -i -E 's/^[[:space:]]*device[[:space:]]+.*/device gpu/' "$f"
94+
else
95+
echo "device gpu" >> "$f"
96+
fi
97+
done
98+
bash ../integrate/Autotest.sh -n 2 -f CASES_GPU.txt
99+
76100
- name: Test 15_rtTDDFT_GPU
77101
run: |
78102
cd tests/15_rtTDDFT_GPU

AGENTS.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ rules. Read the complete governance document before making or reviewing changes:
88

99
## Required Baseline
1010

11-
- Follow the seven ABACUS coding rules summarized from the project governance:
11+
- Follow the nine ABACUS coding rules summarized from the project governance:
1212
1. Do not increase cross-layer control through `GlobalV`, `GlobalC`, or
1313
`PARAM`; pass dependencies explicitly where practical. Migration-neutral
1414
moves must keep the PR-level global dependency budget non-increasing and
@@ -23,6 +23,9 @@ rules. Read the complete governance document before making or reviewing changes:
2323
6. Add focused tests for key features, bug fixes, INPUT behavior changes,
2424
heterogeneous kernels, and core-module refactors.
2525
7. Keep code compatible with the repository C++11 baseline.
26+
8. Declare one variable per line; do not use comma-separated declarations.
27+
9. Do not call MPI routines directly; use the internally-guarded wrappers
28+
(e.g., `Parallel_Reduce::reduce_*`, `Parallel_Common::bcast_*`) instead.
2629
- Use LF line endings for text files. Only `.bat` and `.cmd` files may use CRLF.
2730
- Keep source file additions deterministic: update the relevant `CMakeLists.txt`
2831
or explain why the file is generated or included indirectly.
@@ -31,6 +34,10 @@ rules. Read the complete governance document before making or reviewing changes:
3134
is required.
3235
- Report the exact verification performed. Do not claim completion without
3336
fresh test or check output.
37+
- Prefer `std::vector` over raw `new`/`delete` for dynamic arrays; before
38+
converting class members, confirm no external code consumes them as raw
39+
pointers (e.g., `std::vector<bool>` has no `.data()`), and use
40+
`std::fill`/`std::copy` instead of `ZEROS`/`COPYARRAY` on vector buffers.
3441

3542
## Repository Map
3643

@@ -83,6 +90,15 @@ rules. Read the complete governance document before making or reviewing changes:
8390
test sufficiency, and exception approval require human review.
8491
- Exceptions must be recorded in the PR with reason, scope, risk, and a follow-up
8592
cleanup plan.
93+
- After a refactor, propose brief lessons worth recording in this file, then
94+
ask the developer whether to write them in; be cautious and skip unclear
95+
or unverified lessons.
96+
97+
## Refactoring Patterns
98+
99+
- Member -> free function: inventory `this->` reads; pass as params (const
100+
for config, ref for mutable state); move only when body is `this`-free;
101+
keep thin wrapper; compile each step.
86102

87103
## Local Commands
88104

docs/advanced/elec_properties/wfc.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@ ABACUS is able to output electron wave functions in both PW and LCAO basis calcu
44

55
## Wave Function in G-Space
66

7-
To output wave functions in G-space, add one of the following keywords to the `INPUT` file while performing SCF calculation:
8-
- **PW basis**: Set [`out_wfc_pw`](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#out-wfc-pw) to `1`. Output file format: `wfs[spin]k[kpoint]_pw.txt`, where `[spin]` is the spin channel index, and `[kpoint]` the k-point index.
7+
For `basis_type=pw` and `esolver_type=ksdft`, [`out_wfc_pw`](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#out-wfc-pw) controls the output of plane-wave Kohn-Sham coefficients:
98

10-
- **LCAO basis**: Set [`out_wfc_lcao`](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#out-wfc-lcao) to `1`.
11-
- **Multi-k calculations**: Generates multiple files `wfs[spin]k[kpoint]_nao.txt`.
12-
- **Gamma-only calculations**: `wfs[spin]_nao.txt` instead.
9+
* `0`: Do not write wave-function coefficients.
10+
* `1`: Write text files with the `.txt` suffix.
11+
* `2`: Write binary files with the `.dat` suffix.
12+
13+
The files are stored in `OUT.${suffix}/`. Their pattern is `wfk{k}[s{spin}][g{geometry step}][e{electronic iteration}]_pw.txt` for `out_wfc_pw=1` and `wfk{k}[s{spin}][g{geometry step}][e{electronic iteration}]_pw.dat` for `out_wfc_pw=2`. The `s*` label is omitted for `nspin=1`, is `s1` or `s2` for `nspin=2`, and is `s4` for `nspin=4`. All PW files include the `k*` label, including Gamma-only calculations.
14+
15+
With `out_freq_ion=0`, files are written only when the electronic calculation converges or reaches `scf_nmax`, and the names contain neither `g*` nor `e*`. During structural relaxation or molecular dynamics, each later ionic step overwrites the same files. With `out_freq_ion>0`, output is restricted to the ionic steps selected by `out_freq_ion` and occurs at multiples of `out_freq_elec`, at convergence, or at `scf_nmax`; both `g*` and `e*` are included in the file names. A static `calculation=scf` or `calculation=nscf` run also receives `g1e*` indices when `out_freq_ion>0`.
16+
17+
The normal [`init_wfc=file`](../scf/initialization.md#wave-function) path reads only unindexed binary `wf*_pw.dat` files from `read_file_dir`. Generate directly reusable files with `out_wfc_pw=2` and normally `out_freq_ion=0`. Text `wf*_pw.txt` files and files containing `g*` or `e*` indices are not matched automatically.
18+
19+
For `basis_type=lcao`, set [`out_wfc_lcao=1`](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#out-wfc-lcao). Multi-k calculations generate `wfs{spin}k{k-point}_nao.txt`, while Gamma-only calculations generate `wfs{spin}_nao.txt`.
1320

1421
## Wave Function in Real Space
1522

1623
One can also choose to output real-space wave functions with the keyword [`out_wfc_norm`](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#out-wfc-norm) or [`out_wfc_re_im`](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#out-wfc-re-im).
1724

18-
Notice: When the [`basis_type`](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#basis-type) is `lcao`, only `get_wf` [`calculation`](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#calculation) is effective. An example is [examples/11_wfc/lcao_ienvelope_Si2](https://github.com/deepmodeling/abacus-develop/tree/develop/examples/11_wfc/lcao_ienvelope_Si2).
25+
Notice: When the [`basis_type`](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#basis-type) is `lcao`, only `get_wf` [`calculation`](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#calculation) is effective. An example is [examples/11_wfc/lcao_ienvelope_Si2](https://github.com/deepmodeling/abacus-develop/tree/develop/examples/11_wfc/lcao_ienvelope_Si2).

docs/advanced/input_files/input-main.md

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -731,18 +731,22 @@
731731
### init_wfc
732732

733733
- **Type**: String
734-
- **Description**: The type of the starting wave functions.
734+
- **Description**: The method used to initialize wavefunction coefficients. The available options and behavior depend on `basis_type`.
735735

736-
Available options are:
736+
For `basis_type=pw`, the available options are:
737+
738+
- `atomic`: Use atomic pseudo wavefunctions from `PP_PSWFC`. If no `PP_PSWFC` states are available, all bands are initialized randomly. If the number of atomic states is smaller than `nbands`, the remaining bands are initialized randomly.
739+
- `atomic+random`: If there are at least `nbands` atomic states, apply an approximately 5% multiplicative random perturbation to the atomic initialization. If there are fewer atomic states than `nbands`, use the atomic states and initialize the remaining bands randomly, as for `atomic`.
740+
- `random`: Initialize all bands with random coefficients.
741+
- `nao`: Use numerical atomic orbitals. If the number of NAO states is smaller than `nbands`, the remaining bands are initialized randomly.
742+
- `nao+random`: Apply an approximately 5% multiplicative random perturbation to the NAO initialization; any bands not covered by NAO states are first initialized randomly.
743+
- `file`: Read binary `wf*_pw.dat` files generated with `out_wfc_pw=2` from `read_file_dir`. The files must match the current k points, `nbands`, plane-wave layout, and lattice.
744+
745+
For `basis_type=lcao`, only `file` triggers reading existing wavefunctions. It reads text `wf*_nao.txt` files generated with `out_wfc_lcao=1` from `read_file_dir`; binary files generated with `out_wfc_lcao=2` are not supported. The files must use a compatible NAO basis, match the current k-point and spin setup, and contain enough bands. Normal `init_wfc=file` reading matches files written with the default `out_app_flag=true`, which have no geometry-step index. Files written under `WFC/` with a `g*` geometry-step index when `out_app_flag=false` are not matched automatically.
737746

738-
- atomic: from atomic pseudo wave functions. If they are not enough, other wave functions are initialized with random numbers.
739-
- atomic+random: add small random numbers on atomic pseudo-wavefunctions
740-
- file: from binary files wf*.dat, which are output by setting out_wfc_pw to 2.
741-
- random: random numbers
742-
- nao: from numerical atomic orbitals. If they are not enough, other wave functions are initialized with random numbers.
743-
- nao+random: add small random numbers on numerical atomic orbitals
747+
For `basis_type=lcao_in_pw`, `init_wfc` is automatically set to `nao`.
744748

745-
> Note: Only the file option is useful for the lcao basis set, which is mostly used when calculation is set to get_wf and get_pchg.
749+
> Note: For `calculation=get_wf` or `calculation=get_pchg`, `init_wfc` is automatically set to `file`. If `basis_type=lcao_in_pw` is also used, the final value is `nao`.
746750
- **Default**: atomic
747751

748752
### init_chg
@@ -1937,19 +1941,22 @@
19371941
### out_wfc_pw
19381942

19391943
- **Type**: Integer
1940-
- **Availability**: *[`basis_type`](#basis_type)==pw or ([`basis_type`](#basis_type)==lcao and [`calculation`](#calculation)==get_wf)*
1941-
- **Description**: Whether to output the electronic wavefunction coefficients into files and store them in the folder OUT.${suffix}. The files are named as wf{k}{k-point index}{s}{spin index}{g}{geometry index}{e}{electronic iteration index}{_pw} + {".txt"/".dat"}. Here, the s index refers to spin but the label will not show up for non-spin-polarized calculations, where s1 means spin up channel while s2 means spin down channel, and s4 refers to spinor wave functions that contains both spin channels with spin-orbital coupling or noncollinear calculations enabled. For scf or nscf calculations, g index will not appear, but the g index appears for geometry relaxation and molecular dynamics, where one can use the out_freq_ion command to control. To print out the electroinc wave functions every few SCF iterations, use the out_freq_elec command and the e index will appear in the file name.
1942-
- 0: no output
1943-
- 1: (txt format)
1944-
- non-gamma-only with nspin=1: wfk1_pw.txt, wfk2_pw.txt, ...;
1945-
- non-gamma-only with nspin=2: wfk1s1_pw.txt, wfk1s2_pw.txt, wfk2s1_pw.txt, wfk2s2_pw.txt, ...;
1946-
- non-gamma-only with nspin=4: wfk1s4_pw.txt, wfk2s4_pw.txt, ...;
1947-
- 2: (binary format)
1948-
- non-gamma-only with nspin=1: wfk1_pw.dat, wfk2_pw.dat, ...;
1949-
- non-gamma-only with nspin=2: wfk1s1_pw.dat, wfk1s2_pw.dat, wfk2s1_pw.dat, wfk2s2_pw.dat, ...;
1950-
- non-gamma-only with nspin=4: wfk1s4_pw.dat, wfk2s4_pw.dat, ...;
1944+
- **Availability**: *[`basis_type`](#basis_type)==pw and [`esolver_type`](#esolver_type)==ksdft*
1945+
- **Description**: Controls whether plane-wave Kohn-Sham wavefunction coefficients are written to `OUT.${suffix}/`.
1946+
1947+
Available values are:
1948+
1949+
- `0`: Do not write wavefunction coefficients.
1950+
- `1`: Write text files with the `.txt` suffix.
1951+
- `2`: Write binary files with the `.dat` suffix.
1952+
1953+
The file-name pattern is `wfk{k}[s{spin}][g{geometry step}][e{electronic iteration}]_pw.txt` for `out_wfc_pw=1` and `wfk{k}[s{spin}][g{geometry step}][e{electronic iteration}]_pw.dat` for `out_wfc_pw=2`. All PW output files include a `k*` label, including Gamma-only calculations. Without geometry-step or electronic-iteration indices, representative names are `wfk1_pw.txt` or `wfk1_pw.dat` for `nspin=1`, `wfk1s1_pw.txt` and `wfk1s2_pw.txt` or their `.dat` equivalents for `nspin=2`, and `wfk1s4_pw.txt` or `wfk1s4_pw.dat` for `nspin=4`.
1954+
1955+
With `out_freq_ion=0`, files are written only when the electronic calculation converges or reaches `scf_nmax`; no `g*` or `e*` index is added. During structural relaxation or molecular dynamics, later ionic steps overwrite the same unindexed files. With `out_freq_ion` &gt; 0, output is restricted to the ionic steps selected by `out_freq_ion` and is written when the electronic iteration is a multiple of `out_freq_elec`, when the calculation converges, or when it reaches `scf_nmax`. Both `g*` and `e*` indices are then added, including for a static `calculation=scf` or `calculation=nscf` run.
1956+
1957+
For `init_wfc=file`, ABACUS automatically reads only unindexed binary `wf*_pw.dat` files from `read_file_dir`. Such directly reusable files are normally generated with `out_wfc_pw=2` and `out_freq_ion=0`. Text `wf*_pw.txt` files and files containing `g*` or `e*` indices are not matched automatically.
19511958

1952-
> Note: In the 3.10-LTS version, the file names are WAVEFUNC1.dat, WAVEFUNC2.dat, etc.
1959+
> Note: In the 3.10-LTS version, the binary files are named `WAVEFUNC1.dat`, `WAVEFUNC2.dat`, etc.
19531960
- **Default**: 0
19541961

19551962
### out_wfc_lcao
@@ -2394,14 +2401,14 @@
23942401

23952402
- **Type**: String
23962403
- **Availability**: *[`basis_type`](#basis_type)==pw or ([`basis_type`](#basis_type)==lcao and [`calculation`](#calculation)==get_wf)*
2397-
- **Description**: Selects electronic states for real-space wavefunction-modulus output using the selection syntax and complete-state normalization of `out_pchg`. For `nspin=1`, `s1` contains the wavefunction modulus. For `nspin=2`, `s1` and `s2` contain the spin-up and spin-down wavefunction moduli, respectively. For `nspin=4`, `s1` contains the total spinor modulus. Files are named `wfi[state]s[spin]k[kpoint].cube`.
2404+
- **Description**: Selects electronic states for real-space wavefunction-modulus output using the selection syntax of `out_pchg`. Each wavefunction is normalized as a single-particle state and does not include SCF occupations or spin-degeneracy factors. For `nspin=1`, `s1` contains the wavefunction modulus. For `nspin=2`, `s1` and `s2` contain the spin-up and spin-down wavefunction moduli, respectively. For `nspin=4`, `s1` contains the total spinor modulus. Files are named `wfi[state]s[spin]k[kpoint].cube`.
23982405
- **Default**: none
23992406

24002407
### out_wfc_re_im
24012408

24022409
- **Type**: String
24032410
- **Availability**: *[`basis_type`](#basis_type)==pw or ([`basis_type`](#basis_type)==lcao and [`calculation`](#calculation)==get_wf)*
2404-
- **Description**: Selects electronic states for real-space wavefunction real- and imaginary-part output using the selection syntax and complete-state normalization of `out_pchg`. For `nspin=1`, `s1` contains the wavefunction. For `nspin=2`, `s1` and `s2` contain the spin-up and spin-down wavefunctions, respectively. For `nspin=4`, `s1` and `s2` contain the upper and lower spinor components, respectively. Files are named `wfi[state]s[spin]k[kpoint][re/im].cube`.
2411+
- **Description**: Selects electronic states for real-space wavefunction real- and imaginary-part output using the selection syntax of `out_pchg`. Each wavefunction is normalized as a single-particle state and does not include SCF occupations or spin-degeneracy factors. For `nspin=1`, `s1` contains the wavefunction. For `nspin=2`, `s1` and `s2` contain the spin-up and spin-down wavefunctions, respectively. For `nspin=4`, `s1` and `s2` contain the upper and lower spinor components, respectively. Files are named `wfi[state]s[spin]k[kpoint][re/im].cube`.
24052412
- **Default**: none
24062413

24072414
### if_separate_k

0 commit comments

Comments
 (0)