Skip to content

Remove useless and outdated write_psi_r_1 interface and improve related docs and examples #6345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 12 additions & 8 deletions docs/advanced/elec_properties/wfc.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Extracting Wave Functions

ABACUS is able to output electron wave functions in both PW and LCAO basis calculations. One can find the examples in [examples/wfc](https://github.com/deepmodeling/abacus-develop/tree/develop/examples/wfc).
ABACUS is able to output electron wave functions in both PW and LCAO basis calculations. One can find the examples in [examples/11_wfc](https://github.com/deepmodeling/abacus-develop/tree/develop/examples/11_wfc).

## wave function in G space
For the wave function in G space, one only needs to do a ground-state energy calculation with one additional keyword in the INPUT file: '***[out_wfc_pw](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#out-wfc-pw)***' for PW basis calculation, and '***[out_wfc_lcao](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#out-wfc-lcao)***' for LCAO basis calculation.
In the PW basis case, the wave function is output in a file called `WAVEFUNC${k}.txt`, where `${k}` is the index of K point. \
In the LCAO basis case, several `WFC_NAO_K${k}.dat` files will be output in multi-k calculation and `WFC_NAO_GAMMA1.dat` in gamma-only calculation.
## Wave Function in G-Space

## wave function in real space
To output wave functions in G-space, add one of the following keywords to the `INPUT` file while performing SCF calculation:
- **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.

One can also choose to output real-space wave function in PW basis calculation with the key word ***[out_wfc_norm](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#out-wfc-norm)***.
- **LCAO basis**: Set [`out_wfc_lcao`](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#out-wfc-lcao) to `1`.
- **Multi-k calculations**: Generates multiple files `wfs[spin]k[kpoint]_nao.txt`.
- **Gamma-only calculations**: `wfs[spin]_nao.txt` instead.

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/wfc/lcao_ienvelope_Si2](https://github.com/deepmodeling/abacus-develop/tree/develop/examples/wfc/lcao_ienvelope_Si2).
## Wave Function in Real Space

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).

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).
4 changes: 2 additions & 2 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ These variables are used to control the output of properties.

- **Type**: Boolean
- **Availability**: Numerical atomic orbital basis (multi-k points)
- **Description**: Whether to output the density matrix with Bravias lattice vector R index into files in the folder `OUT.${suffix}`. The files are named as `dmr{s}{spin index}{g}{geometry index}{_nao} + {".csr"}`. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and the sparse matrix format 'csr' is mentioned in [out_mat_hs2](#out_mat_hs2). Finally, if [out_app_flag](#out_app_flag) is set to false, the file name contains the optinal 'g' index for each ionic step that may have different geometries, and if [out_app_flag](#out_app_flag) is set to true, the density matrix with respect to Bravias lattice vector R accumulates during ionic steps:
- **Description**: Whether to output the density matrix with Bravias lattice vector R index into files in the folder `OUT.${suffix}`. The files are named as `dmr{s}{spin index}{g}{geometry index}{_nao} + {".csr"}`. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and the sparse matrix format 'csr' is mentioned in [out_mat_hs2](#out_mat_hs2). Finally, if [out_app_flag](#out_app_flag) is set to false, the file name contains the optional 'g' index for each ionic step that may have different geometries, and if [out_app_flag](#out_app_flag) is set to true, the density matrix with respect to Bravias lattice vector R accumulates during ionic steps:
- nspin = 1: `dmrs1_nao.csr`;
- nspin = 2: `dmrs1_nao.csr` and `dmrs2_nao.csr` for the two spin channels.
- **Default**: False
Expand All @@ -1726,7 +1726,7 @@ These variables are used to control the output of properties.

- **Type**: Integer
- **Availability**: Numerical atomic orbital basis
- **Description**: Whether to output the electronic wavefunction coefficients into files and store them in the folder `OUT.${suffix}`. The files are named as `wf{s}{spin index}{k(optinal)}{k-point index}{g(optional)}{geometry index1}{_nao} + {".txt"/".dat"}`. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and 's12' refer to spinor wave functions that contains both spin channels with spin-orbital coupling or noncollinear calculations enabled. In addition, if 'gamma_only' is set to 0, then the optinoal k-point sampling index appears with the k-point index attached to the electronic wave function file names. Finally, if [out_app_flag](#out_app_flag) is set to false, the file name contains the optinal 'g' index for each ionic step that may have different geometries, and if [out_app_flag](#out_app_flag) is set to true, the wave functions accumulate during ionic steps.
- **Description**: Whether to output the electronic wavefunction coefficients into files and store them in the folder `OUT.${suffix}`. The files are named as `wf{s}{spin index}{k(optional)}{k-point index}{g(optional)}{geometry index1}{_nao} + {".txt"/".dat"}`. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and 's12' refer to spinor wave functions that contains both spin channels with spin-orbital coupling or noncollinear calculations enabled. In addition, if 'gamma_only' is set to 0, then the optinoal k-point sampling index appears with the k-point index attached to the electronic wave function file names. Finally, if [out_app_flag](#out_app_flag) is set to false, the file name contains the optional 'g' index for each ionic step that may have different geometries, and if [out_app_flag](#out_app_flag) is set to true, the wave functions accumulate during ionic steps.
- 0: no output
- 1: (txt format)
- gamma-only: `wfs1_nao.txt` or `wfs2_nao.txt`, ...;
Expand Down
12 changes: 6 additions & 6 deletions examples/08_charge_density/lcao_nspin1_Si2/INPUT
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
INPUT_PARAMETERS
#Parameters (General)
#Parameters (General)
pseudo_dir ../../../tests/PP_ORB
orbital_dir ../../../tests/PP_ORB
calculation scf
calculation scf
nbands 8
#Parameters (Methos)
#Parameters (Methods)
basis_type lcao
symmetry 0
symmetry 0
#Parameters (Accuracy)
ecutwfc 60 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
ecutwfc 60 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
scf_thr 1.0e-7 // about iteration
scf_nmax 100
scf_nmax 100
#Parameters (File)
out_chg 1

Expand Down
14 changes: 7 additions & 7 deletions examples/08_charge_density/pw_nspin1_Al/INPUT
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
INPUT_PARAMETERS
#Parameters (General)
#Parameters (General)
pseudo_dir ../../../tests/PP_ORB
calculation scf
calculation scf
symmetry 0
#Parameters (Methos)
#Parameters (Methods)
basis_type pw
ecutwfc 60 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
ecutwfc 60 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
scf_thr 1.0e-8 // about iteration
scf_nmax 100
smearing_method gauss
smearing_sigma 0.01
scf_nmax 100
smearing_method gauss
smearing_sigma 0.01
#Parameters (File)
out_chg 1

Expand Down
14 changes: 7 additions & 7 deletions examples/09_density_matrix/lcao_nspin1_Si2/INPUT
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
INPUT_PARAMETERS
#Parameters (General)
#Parameters (General)
pseudo_dir ../../../tests/PP_ORB
orbital_dir ../../../tests/PP_ORB
calculation scf
calculation scf
nbands 16
#Parameters (Methos)
#Parameters (Methods)
basis_type lcao
symmetry 0
symmetry 0
#Parameters (Accuracy)
ecutwfc 60 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
ecutwfc 60 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
scf_thr 1.0e-7 // about iteration
scf_nmax 100
scf_nmax 100
#Parameters (File)
gamma_only 1
gamma_only 1
out_dmk 1


Expand Down
26 changes: 13 additions & 13 deletions examples/11_wfc/README
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
These examples show how to output the wavefunction in G space.
For PW basis:
- set 'out_wfc_pw' to '1'
The wave function is output in a file called 'WAVEFUNC1.txt'
These examples demonstrate how to output wave functions in G-space and real space.

For LCAO basis:
- set 'out_wfc_lcao' to '1'
Several `WFC_NAO_K#.txt` files will be output in multi-k calculation and
`WFC_NAO_GAMMA1.txt` in gamma-only calculation.
For Plane-Wave (PW) Basis:
- Set `out_wfc_pw = 1`.
The wave functions will be output to a series of files named `wfs[spin]k[kpoint]_pw.txt`.

For LCAO Basis:
- Set `out_wfc_lcao = 1`.
In multi-k calculations, multiple files named `wfs[spin]k[kpoint]_nao.txt` will be generated.
In gamma-only calculations, `wfs[spin]_nao.txt` instead.

For the wave functions in Real Space:
- set 'out_wfc_r' to '1'
The wave function is output in files OUT.${suffix}/wfc_realspace/wfc_realspace_$K_$B,
where $K and $B is the index of k point and band respectively.
Note, it is only used in planewave basis and get_wf calculation in localized orbitals set
For Wave Functions in Real Space:
- Set either `out_wfc_norm` or `out_wfc_re_im` to a space-separated string of 0s and 1s.
- E.g.: `1 0 0 0 0 1 1 1 1 1 0`, or `1 4*0 5*1 0` for short.
The wave functions will be output to files named `wfi[state]s[spin]k[kpoint][re/im].cube`.
Note, it is only supported for PW basis and `get_wf` calculation under LCAO basis.
8 changes: 4 additions & 4 deletions examples/11_wfc/lcao_ienvelope_Si2/INPUT1
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
INPUT_PARAMETERS
#Parameters (General)
#Parameters (General)
pseudo_dir ../../../tests/PP_ORB
orbital_dir ../../../tests/PP_ORB
calculation scf
ntype 1
nbands 8
#Parameters (Methos)
#Parameters (Methods)
basis_type lcao
symmetry 0
#Parameters (Accuracy)
ecutwfc 50
scf_thr 1.0e-7 // about iteration
scf_nmax 100
scf_nmax 100
#Parameters (File)
out_wfc_lcao 1
out_wfc_lcao 1
8 changes: 4 additions & 4 deletions examples/11_wfc/lcao_ienvelope_Si2/INPUT2
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
INPUT_PARAMETERS
#Parameters (General)
#Parameters (General)
pseudo_dir ../../../tests/PP_ORB
orbital_dir ../../../tests/PP_ORB
calculation get_wf
nbands 8
#Parameters (Methos)
#Parameters (Methods)
basis_type lcao
symmetry 0
#Parameters (Accuracy)
ecutwfc 50
#Parameters (File)
init_wfc file
out_wfc_r 1
init_wfc file
out_wfc_norm 4*1
4 changes: 2 additions & 2 deletions examples/11_wfc/lcao_ienvelope_Si2/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ if [[ ! -f scf.output ]] ||
[[ ! -f get_wf.output ]] ||
[[ ! -f OUT.ABACUS/running_scf.log ]] ||
[[ ! -f OUT.ABACUS/running_get_wf.log ]] ||
[[ ! -f OUT.ABACUS/WFC_NAO_K1.txt ]] ||
[[ ! -f OUT.ABACUS/WFC_NAO_K36.txt ]] ||
[[ ! -f OUT.ABACUS/wfs1k1_nao.txt ]] ||
[[ ! -f OUT.ABACUS/wfs1k36_nao.txt ]] ||
[[ ! ( "$(tail -1 OUT.ABACUS/running_scf.log)" == " Total Time :"* ) ]] ||
[[ ! ( "$(tail -1 OUT.ABACUS/running_get_wf.log)" == " Total Time :"* ) ]]
then
Expand Down
10 changes: 5 additions & 5 deletions examples/11_wfc/lcao_scf_Si2/INPUT
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
INPUT_PARAMETERS
#Parameters (General)
#Parameters (General)
pseudo_dir ../../../tests/PP_ORB
orbital_dir ../../../tests/PP_ORB
calculation scf
nbands 8
#Parameters (Methos)
#Parameters (Methods)
basis_type lcao
symmetry 0
#Parameters (Accuracy)
ecutwfc 60 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
ecutwfc 60 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
scf_thr 1.0e-7 // about iteration
scf_nmax 100
scf_nmax 100
#Parameters (File)
out_wfc_lcao 1
out_wfc_lcao 1


### [1] Energy cutoff determines the quality of numerical quadratures in your calculations.
Expand Down
4 changes: 2 additions & 2 deletions examples/11_wfc/lcao_scf_Si2/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ OMP_NUM_THREADS=${ABACUS_THREADS} mpirun -np ${ABACUS_NPROCS} ${ABACUS_PATH} | t

if [[ ! -f output ]] ||
[[ ! -f OUT.ABACUS/running_scf.log ]] ||
[[ ! -f OUT.ABACUS/WFC_NAO_K1.txt ]] ||
[[ ! -f OUT.ABACUS/WFC_NAO_K36.txt ]] ||
[[ ! -f OUT.ABACUS/wfs1k1_nao.txt ]] ||
[[ ! -f OUT.ABACUS/wfs1k36_nao.txt ]] ||
[[ ! ( "$(tail -1 OUT.ABACUS/running_scf.log)" == " Total Time :"* ) ]]
then
echo "job failed!"
Expand Down
16 changes: 8 additions & 8 deletions examples/11_wfc/pw_scf_Al/INPUT
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
INPUT_PARAMETERS
#Parameters (General)
#Parameters (General)
pseudo_dir ../../../tests/PP_ORB
calculation scf
symmetry 0
#Parameters (Methos)
#Parameters (Methods)
basis_type pw
ecutwfc 60 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
ecutwfc 60 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
scf_thr 1.0e-8 // about iteration
scf_nmax 100
smearing_method gauss
smearing_sigma 0.01
scf_nmax 100
smearing_method gauss
smearing_sigma 0.01
#Parameters (File)
out_wfc_pw 1
out_wfc_r 1
out_wfc_pw 1
out_wfc_norm 1*1


### [1] Energy cutoff determines the quality of numerical quadratures in your calculations.
Expand Down
10 changes: 5 additions & 5 deletions examples/12_band/lcao_Si2/INPUT1
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
INPUT_PARAMETERS
#Parameters (General)
#Parameters (General)
pseudo_dir ../../../tests/PP_ORB
orbital_dir ../../../tests/PP_ORB
calculation scf
ntype 1
ntype 1
nbands 8
#Parameters (Methos)
#Parameters (Methods)
basis_type lcao
symmetry 0
symmetry 0
#Parameters (Accuracy)
ecutwfc 50
scf_thr 1.0e-7 // about iteration
scf_nmax 100
scf_nmax 100
#Parameters (File)
out_chg 1
24 changes: 12 additions & 12 deletions examples/12_band/lcao_Si2/INPUT2
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
INPUT_PARAMETERS
#Parameters (General)
kpoint_file KLINES
pseudo_dir ../../../tests/PP_ORB
orbital_dir ../../../tests/PP_ORB
calculation nscf
ntype 1
nbands 8
symmetry 0
#Parameters (Methos)
basis_type lcao
kpoint_file KLINES
pseudo_dir ../../../tests/PP_ORB
orbital_dir ../../../tests/PP_ORB
calculation nscf
ntype 1
nbands 8
symmetry 0
#Parameters (Methods)
basis_type lcao
#Parameters (Accuracy)
ecutwfc 50
ecutwfc 50
#Parameters (File)
init_chg file
out_band 1
init_chg file
out_band 1
12 changes: 6 additions & 6 deletions examples/12_band/pw_Al/INPUT1
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
INPUT_PARAMETERS
#Parameters (General)
#Parameters (General)
pseudo_dir ../../../tests/PP_ORB
calculation scf
ntype 1
ntype 1
symmetry 0
#Parameters (Methos)
#Parameters (Methods)
basis_type pw
ecutwfc 50
scf_thr 1.0e-8 // about iteration
scf_nmax 100
smearing_method gauss
smearing_sigma 0.01
scf_nmax 100
smearing_method gauss
smearing_sigma 0.01
#Parameters (File)
out_chg 1
28 changes: 14 additions & 14 deletions examples/12_band/pw_Al/INPUT2
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
INPUT_PARAMETERS
#Parameters (General)
kpoint_file KLINES
pseudo_dir ../../../tests/PP_ORB
calculation nscf
ntype 1
symmetry 0
#Parameters (Methos)
ecutwfc 50
basis_type pw
pw_diag_thr 1e-10
pw_diag_nmax 100
kpoint_file KLINES
pseudo_dir ../../../tests/PP_ORB
calculation nscf
ntype 1
symmetry 0
#Parameters (Methods)
ecutwfc 50
basis_type pw
pw_diag_thr 1e-10
pw_diag_nmax 100
#Parameters (Accuracy)
smearing_method gauss
smearing_sigma 0.01
smearing_method gauss
smearing_sigma 0.01
#Parameters (File)
init_chg file
out_band 1
init_chg file
out_band 1
6 changes: 3 additions & 3 deletions examples/13_dos/lcao_Si2/INPUT1
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
INPUT_PARAMETERS
#Parameters (General)
#Parameters (General)
pseudo_dir ../../../tests/PP_ORB
orbital_dir ../../../tests/PP_ORB
calculation scf
ntype 1
nbands 8
#Parameters (Methos)
#Parameters (Methods)
basis_type lcao
symmetry 0
#Parameters (Accuracy)
ecutwfc 50
scf_thr 1.0e-7 // about iteration
scf_nmax 100
scf_nmax 100
#Parameters (File)
out_chg 1
Loading
Loading