Skip to content

Commit dcbeb06

Browse files
authored
Feature: Support cube format real-space wave function output for Plane Wave basis set (#6217)
* Feature: Support cube format real-space wave function output for Plane Wave basis set * Keep out_wfc_r temporarily * Remove out_wfc_r from PW code * Remove out_wfc_r from LCAO code * Add out_wfc_re_im integrate test for LCAO * Remove the remaining out_wfc_r from ABACUS repo * Add integration tests for PW get_wf and get_pchg and some bug fixes * Remove sum_cube.exe from repo
1 parent 58a66d8 commit dcbeb06

File tree

30 files changed

+703
-384
lines changed

30 files changed

+703
-384
lines changed

docs/advanced/elec_properties/wfc.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ In the LCAO basis case, several `WFC_NAO_K${k}.dat` files will be output in mult
99

1010
## wave function in real space
1111

12-
One can also choose to output real-space wave function in PW basis calculation with the key word ***[out_wfc_r](https://abacus-rtd.readthedocs.io/en/latest/advanced/input_files/input-main.html#out_wfc_r)***.
13-
14-
After calculation, an additional directory named `wfc_realspace` will appear in the `OUT.${system}` directory.
12+
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)***.
1513

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

docs/advanced/input_files/input-main.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@
136136
- [out\_dm](#out_dm)
137137
- [out\_dm1](#out_dm1)
138138
- [out\_wfc\_pw](#out_wfc_pw)
139-
- [out\_wfc\_r](#out_wfc_r)
140139
- [out\_wfc\_lcao](#out_wfc_lcao)
141140
- [out\_dos](#out_dos)
142141
- [out\_ldos](#out_ldos)
@@ -1593,7 +1592,7 @@ These variables are used to control the output of properties.
15931592
### out_freq_elec
15941593

15951594
- **Type**: Integer
1596-
- **Description**: Output the charge density (only binary format, controlled by [out_chg](#out_chg)), wavefunction (controlled by [out_wfc_pw](#out_wfc_pw) or [out_wfc_r](#out_wfc_r)) per `out_freq_elec` electronic iterations. Note that they are always output when converged or reach the maximum iterations [scf_nmax](#scf_nmax).
1595+
- **Description**: Output the charge density (only binary format, controlled by [out_chg](#out_chg)), wavefunction (controlled by [out_wfc_pw](#out_wfc_pw)) per `out_freq_elec` electronic iterations. Note that they are always output when converged or reach the maximum iterations [scf_nmax](#scf_nmax).
15971596
- **Default**: [scf_nmax](#scf_nmax)
15981597

15991598
### out_chg
@@ -1670,13 +1669,6 @@ These variables are used to control the output of properties.
16701669
- 2: results are stored in binary files named `OUT.${suffix}/WAVEFUNC${K}.dat`.
16711670
- **Default**: 0
16721671

1673-
### out_wfc_r
1674-
1675-
- **Type**: Boolean
1676-
- **Availability**: Plane wave basis or get_wf calculation in numerical atomic orbital basis
1677-
- **Description**: Whether to output real-space wave functions into `OUT.suffix/wfc_realspace/wfc_realspace_${K}_${B}`, where `${K}` is the index of k points, `${B}` is the index of bands.
1678-
- **Default**: False
1679-
16801672
### out_wfc_lcao
16811673

16821674
- **Type**: Integer
@@ -1911,14 +1903,14 @@ The band (KS orbital) energy for each (k-point, spin, band) will be printed in t
19111903
### out_wfc_norm
19121904

19131905
- **Type**: String
1914-
- **Availability**: For LCAO, used when `calculation = get_wf`.
1906+
- **Availability**: For both PW and LCAO. When `basis_type = lcao`, used when `calculation = get_wf`.
19151907
- **Description**: Specifies the bands to calculate the real-space wave function modulus (norm, or known as the envelope function) $|\psi(r)|$. The syntax and band selection rules are identical to [`out_pchg`](#out_pchg), but the output is the norm of the wave function.
19161908
- **Default**: none
19171909

19181910
### out_wfc_re_im
19191911

19201912
- **Type**: String
1921-
- **Availability**: For LCAO, used when `calculation = get_wf`.
1913+
- **Availability**: For both PW and LCAO. When `basis_type = lcao`, used when `calculation = get_wf`.
19221914
- **Description**: Specifies the bands to calculate the real and imaginary parts of the wave function $\text{Re}(\psi(r))$ and $\text{Im}(\psi(r))$. The syntax and band selection rules are identical to [`out_pchg`](#out_pchg), but the output contains both the real and imaginary components of the wave function.
19231915
- **Default**: none
19241916

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "module_io/berryphase.h"
2525
#include "module_io/cal_ldos.h"
2626
#include "module_io/get_pchg_pw.h"
27+
#include "module_io/get_wf_pw.h"
2728
#include "module_io/numerical_basis.h"
2829
#include "module_io/numerical_descriptor.h"
2930
#include "module_io/to_wannier90_pw.h"
@@ -933,9 +934,41 @@ void ESolver_KS_PW<T, Device>::after_all_runners(UnitCell& ucell)
933934
//----------------------------------------------------------
934935
//! 5) Print out electronic wave functions in real space
935936
//----------------------------------------------------------
936-
if (PARAM.inp.out_wfc_r == 1) // Peize Lin add 2021.11.21
937+
938+
//----------------------------------------------------------
939+
//! The write_psi_r_1 interface will be removed in the very
940+
//! near future. Don't use it!
941+
//----------------------------------------------------------
942+
// if (PARAM.inp.out_wfc_r == 1) // Peize Lin add 2021.11.21
943+
// {
944+
// ModuleIO::write_psi_r_1(ucell, this->psi[0], this->pw_wfc, "wfc_realspace", true, this->kv);
945+
// }
946+
947+
const std::vector<int> out_wfc_norm = PARAM.inp.out_wfc_norm;
948+
const std::vector<int> out_wfc_re_im = PARAM.inp.out_wfc_re_im;
949+
if (out_wfc_norm.size() > 0 || out_wfc_re_im.size() > 0)
937950
{
938-
ModuleIO::write_psi_r_1(ucell, this->psi[0], this->pw_wfc, "wfc_realspace", true, this->kv);
951+
ModuleIO::get_wf_pw(out_wfc_norm,
952+
out_wfc_re_im,
953+
this->kspw_psi->get_nbands(),
954+
PARAM.inp.nspin,
955+
this->pw_rhod->nx,
956+
this->pw_rhod->ny,
957+
this->pw_rhod->nz,
958+
this->pw_rhod->nxyz,
959+
this->kv.get_nks(),
960+
this->kv.isk,
961+
this->kv.wk,
962+
this->pw_big->bz,
963+
this->pw_big->nbz,
964+
this->chr.ngmc,
965+
&ucell,
966+
this->psi,
967+
this->pw_rhod,
968+
this->pw_wfc,
969+
this->ctx,
970+
this->Pgrid,
971+
PARAM.globalv.global_out_dir);
939972
}
940973

941974
//----------------------------------------------------------

source/module_esolver/lcao_others.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@ void ESolver_KS_LCAO<TK, TR>::others(UnitCell& ucell, const int istep)
362362
this->pv,
363363
this->GG,
364364
PARAM.inp.out_wfc_pw,
365-
PARAM.inp.out_wfc_r,
366365
this->kv,
367366
PARAM.inp.nelec,
368367
PARAM.inp.nbands_istate,
@@ -384,7 +383,6 @@ void ESolver_KS_LCAO<TK, TR>::others(UnitCell& ucell, const int istep)
384383
this->pv,
385384
this->GK,
386385
PARAM.inp.out_wfc_pw,
387-
PARAM.inp.out_wfc_r,
388386
this->kv,
389387
PARAM.inp.nelec,
390388
PARAM.inp.nbands_istate,

0 commit comments

Comments
 (0)