Skip to content

Commit 03ee34a

Browse files
authored
Merge branch 'develop' into fft15
2 parents 4f92fb9 + 2d6accb commit 03ee34a

File tree

214 files changed

+1654
-1314
lines changed

Some content is hidden

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

214 files changed

+1654
-1314
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ These variables are used to control general system parameters.
599599
- nao: from numerical atomic orbitals. If they are not enough, other wave functions are initialized with random numbers.
600600
- nao+random: add small random numbers on numerical atomic orbitals
601601

602-
> Only the `file` option is useful for the lcao basis set, which is mostly used when [calculation](#calculation) is set to `set_wf` and `get_pchg`. See more details in [out_wfc_lcao](#out_wfc_lcao).
602+
> Only the `file` option is useful for the lcao basis set, which is mostly used when [calculation](#calculation) is set to `get_wf` and `get_pchg`. See more details in [out_wfc_lcao](#out_wfc_lcao).
603603
- **Default**: atomic
604604

605605
### init_chg
@@ -608,7 +608,7 @@ These variables are used to control general system parameters.
608608
- **Description**: This variable is used for both plane wave set and localized orbitals set. It indicates the type of starting density.
609609

610610
- atomic: the density is starting from the summation of the atomic density of single atoms.
611-
- file: the density will be read in from a binary file `charge-density.dat` first. If it does not exist, the charge density will be read in from cube files. Besides, when you do `nspin=1` calculation, you only need the density file SPIN1_CHG.cube. However, if you do `nspin=2` calculation, you also need the density file SPIN2_CHG.cube. The density file should be output with these names if you set out_chg = 1 in INPUT file.
611+
- file: the density will be read in from a binary file `charge-density.dat` first. If it does not exist, the charge density will be read in from cube files. Besides, when you do `nspin=1` calculation, you only need the density file chgs1.cube. However, if you do `nspin=2` calculation, you also need the density file chgs2.cube. The density file should be output with these names if you set out_chg = 1 in INPUT file.
612612
- wfc: the density will be calculated by wavefunctions and occupations. Wavefunctions are read in from binary files `wf*.dat` (see [out_wfc_pw](#out_wfc_pw)) while occupations are read in from file `istate.info`.
613613
- auto: Abacus first attempts to read the density from a file; if not found, it defaults to using atomic density.
614614
- **Default**: atomic
@@ -742,7 +742,7 @@ These variables are used to control parameters related to input files.
742742
### read_file_dir
743743

744744
- **Type**: String
745-
- **Description**: Indicates the location of files, such as electron density (`SPIN1_CHG.cube`), required as a starting point.
745+
- **Description**: Location of files, such as the electron density (`chgs1.cube`), required as a starting point.
746746
- Example: './' implies the files to be read are located in the working directory.
747747
- **Default**: OUT.$suffix
748748

@@ -1602,24 +1602,26 @@ These variables are used to control the output of properties.
16021602
- **Description**:
16031603
The first integer controls whether to output the charge density on real space grids:
16041604
- 1: Output the charge density (in Bohr^-3) on real space grids into the density files in the folder `OUT.${suffix}`. The files are named as:
1605-
- nspin = 1: SPIN1_CHG.cube;
1606-
- nspin = 2: SPIN1_CHG.cube, and SPIN2_CHG.cube;
1607-
- nspin = 4: SPIN1_CHG.cube, SPIN2_CHG.cube, SPIN3_CHG.cube, and SPIN4_CHG.cube.
1608-
- 2: On top of 1, also output the initial charge density. The files are named as:
1609-
- nspin = 1: SPIN1_CHG_INI.cube
1610-
- nspin = 2: SPIN1_CHG_INI.cube, and SPIN2_CHG_INI.cube;
1611-
- nspin = 4: SPIN1_CHG_INI.cube, SPIN2_CHG_INI.cube, SPIN3_CHG_INI.cube, and SPIN4_CHG_INI.cube.
1605+
- nspin = 1: `chgs1.cube`;
1606+
- nspin = 2: `chgs1.cube`, and `chgs2.cube`;
1607+
- nspin = 4: `chgs1.cube`, `chgs2.cube`, `chgs3.cube`, and `chgs4.cube`;
1608+
Note that by using the Meta-GGA functional, additional files containing the kinetic energy density will be output with the following names:
1609+
- nspin = 1: `taus1.cube`;
1610+
- nspin = 2: `taus1.cube`, and `taus2.cube`;
1611+
- nspin = 4: `taus1.cube`, `taus2.cube`, `taus3.cube`, and `taus4.cube`;
1612+
- 2: On top of 1, also output the initial charge density files with a suffix name as '_ini', such as `taus1_ini.cube`, etc.
16121613
- -1: disable the charge density auto-back-up file `{suffix}-CHARGE-DENSITY.restart`, useful for large systems.
16131614

16141615
The second integer controls the precision of the charge density output, if not given, will use `3` as default. For purpose restarting from this file and other high-precision involved calculation, recommend to use `10`.
16151616

16161617
---
16171618
The circle order of the charge density on real space grids is: x is the outer loop, then y and finally z (z is moving fastest).
16181619

1619-
If EXX(exact exchange) is calculated, (i.e. *[dft_fuctional](#dft_functional)==hse/hf/pbe0/scan0/opt_orb* or *[rpa](#rpa)==True*), the Hexx(R) files will be output in the folder `OUT.${suffix}` too, which can be read in NSCF calculation.
1620+
In EXX(exact exchange) calculations, (i.e. *[dft_fuctional](#dft_functional)==hse/hf/pbe0/scan0/opt_orb* or *[rpa](#rpa)==True*), the Hexx(R) files will be output in the folder `OUT.${suffix}` too, which can be read in NSCF calculation.
16201621

1621-
In molecular dynamics calculations, the output frequency is controlled by [out_interval](#out_interval).
1622+
In molecular dynamics simulations, the output frequency is controlled by [out_interval](#out_interval).
16221623
- **Default**: 0 3
1624+
- **NOTE**: In the 3.10-LTS version, the file names are SPIN1_CHG.cube and SPIN1_CHG_INI.cube, etc.
16231625

16241626
### out_pot
16251627

@@ -1638,6 +1640,7 @@ These variables are used to control the output of properties.
16381640

16391641
In molecular dynamics calculations, the output frequency is controlled by [out_interval](#out_interval).
16401642
- **Default**: 0
1643+
- **NOTE**: In the 3.10-LTS version, the file names are SPIN1_POT.cube and SPIN1_POT_INI.cube, etc.
16411644

16421645
### out_dm
16431646

@@ -1651,6 +1654,7 @@ These variables are used to control the output of properties.
16511654
- nspin = 1: `dms1k1_nao.csr`, `dms1k2_nao.csr`, ...;
16521655
- nspin = 2: `dms1k1_nao.csr`... and `dms2k1_nao.csr`... for the two spin channels.
16531656
- **Default**: False
1657+
- **NOTE**: In the 3.10-LTS version, the file names are SPIN1_DM and SPIN2_DM, etc.
16541658

16551659
### out_dm1
16561660

@@ -1660,6 +1664,7 @@ These variables are used to control the output of properties.
16601664
- nspin = 1: `dmrs1_nao.csr`;
16611665
- nspin = 2: `dmrs1_nao.csr` and `dmrs2_nao.csr` for the two spin channels.
16621666
- **Default**: False
1667+
- **NOTE**: In the 3.10-LTS version, the file names are data-DMR-sparse_SPIN0.csr and data-DMR-sparse_SPIN1.csr, etc.
16631668

16641669
### out_wfc_pw
16651670

@@ -1672,6 +1677,7 @@ These variables are used to control the output of properties.
16721677
- 2: (binary format)
16731678
- non-gamma-only: `wfs1k1_pw.dat` or `wfs1k2_pw.dat`, ....
16741679
- **Default**: 0
1680+
- **NOTE**: In the 3.10-LTS version, the file names are OUT.${suffix}/WAVEFUNC${K}.dat, etc.
16751681

16761682
### out_wfc_lcao
16771683

@@ -1689,7 +1695,8 @@ These variables are used to control the output of properties.
16891695
The corresponding sequence of the orbitals can be seen in [Basis Set](../pp_orb.md#basis-set).
16901696

16911697
Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag).
1692-
- **Default**: Flase
1698+
- **Default**: False
1699+
- **NOTE**: In the 3.10-LTS version, the file names are WFC_NAO_GAMMA1_ION1.txt and WFC_NAO_K1_ION1.txt, etc.
16931700

16941701
### out_dos
16951702

@@ -1921,7 +1928,7 @@ The band (KS orbital) energy for each (k-point, spin, band) will be printed in t
19211928
### if_separate_k
19221929

19231930
- **Type**: Boolean
1924-
- **Availability**: Only for LCAO, used only when `calculation = get_pchg` and `gamma_only` is turned off.
1931+
- **Availability**: For both PW and LCAO. When `basis_type = pw`, used if `out_pchg` is set. When `basis_type = lcao`, used only when `calculation = get_pchg` and `gamma_only` is turned off.
19251932
- **Description**: Specifies whether to write the partial charge densities for all k-points to individual files or merge them. **Warning**: Enabling symmetry may produce incorrect results due to incorrect k-point weights. Therefore, when calculating partial charge densities, it is strongly recommended to set `symmetry = -1`.
19261933
- **Default**: false
19271934

source/module_elecstate/module_charge/charge_init.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
2828
{
2929
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "init_chg", PARAM.inp.init_chg);
3030

31+
const int nspin = PARAM.inp.nspin;
32+
assert(nspin>0);
33+
3134
std::cout << " START CHARGE : " << PARAM.inp.init_chg << std::endl;
32-
//here we need to set the omega for the charge density
35+
36+
// we need to set the omega for the charge density
3337
set_omega(&ucell.omega);
3438
this->pgrid = &pgrid;
3539

@@ -46,17 +50,17 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
4650
if (ModuleIO::read_rhog(binary.str(), rhopw, rhog))
4751
{
4852
GlobalV::ofs_running << " Read electron density from file: " << binary.str() << std::endl;
49-
for (int is = 0; is < PARAM.inp.nspin; ++is)
53+
for (int is = 0; is < nspin; ++is)
5054
{
5155
rhopw->recip2real(rhog[is], rho[is]);
5256
}
5357
}
5458
else
5559
{
56-
for (int is = 0; is < PARAM.inp.nspin; ++is)
60+
for (int is = 0; is < nspin; ++is)
5761
{
5862
std::stringstream ssc;
59-
ssc << PARAM.globalv.global_readin_dir << "SPIN" << is + 1 << "_CHG.cube";
63+
ssc << PARAM.globalv.global_readin_dir << "chgs" << is + 1 << ".cube";
6064
if (ModuleIO::read_vdata_palgrid(pgrid,
6165
(PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_BPGROUP : GlobalV::MY_RANK),
6266
GlobalV::ofs_running,
@@ -103,7 +107,7 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
103107
{
104108
const std::string warn_msg
105109
= " WARNING: \"init_chg\" is enabled but ABACUS failed to read\n charge density from file.\n"
106-
" Please check if there is SPINX_CHG.cube (X=1,...) or\n {suffix}-CHARGE-DENSITY.restart in the "
110+
" Please check if there is chgsx.cube (x=1,2,etc.) or\n {suffix}-CHARGE-DENSITY.restart in the "
107111
"directory.\n";
108112
std::cout << warn_msg;
109113
if (PARAM.inp.init_chg == "file")
@@ -121,9 +125,9 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
121125
{
122126
GlobalV::ofs_running << " try to read kinetic energy density from file" << std::endl;
123127
// try to read charge from binary file first, which is the same as QE
124-
std::vector<std::complex<double>> kin_g_space(PARAM.inp.nspin * this->ngmc, {0.0, 0.0});
128+
std::vector<std::complex<double>> kin_g_space(nspin * this->ngmc, {0.0, 0.0});
125129
std::vector<std::complex<double>*> kin_g;
126-
for (int is = 0; is < PARAM.inp.nspin; is++)
130+
for (int is = 0; is < nspin; is++)
127131
{
128132
kin_g.push_back(kin_g_space.data() + is * this->ngmc);
129133
}
@@ -133,14 +137,14 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
133137
if (ModuleIO::read_rhog(binary.str(), rhopw, kin_g.data()))
134138
{
135139
GlobalV::ofs_running << " Read in the kinetic energy density: " << binary.str() << std::endl;
136-
for (int is = 0; is < PARAM.inp.nspin; ++is)
140+
for (int is = 0; is < nspin; ++is)
137141
{
138142
rhopw->recip2real(kin_g[is], this->kin_r[is]);
139143
}
140144
}
141145
else
142146
{
143-
for (int is = 0; is < PARAM.inp.nspin; is++)
147+
for (int is = 0; is < nspin; is++)
144148
{
145149
std::stringstream ssc;
146150
ssc << PARAM.globalv.global_readin_dir << "SPIN" << is + 1 << "_TAU.cube";
@@ -175,16 +179,16 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
175179
}
176180
}
177181

178-
if (PARAM.inp.init_chg == "atomic" || read_error) // mohan add 2007-10-17
182+
if (PARAM.inp.init_chg == "atomic" || read_error)
179183
{
180184
if (read_error)
181185
{
182186
std::cout << " Charge::init_rho: use atomic initialization instead." << std::endl;
183187
}
184-
this->atomic_rho(PARAM.inp.nspin, ucell.omega, rho, strucFac, ucell);
188+
this->atomic_rho(nspin, ucell.omega, rho, strucFac, ucell);
185189
}
186190

187-
// wenfei 2021-7-29 : initial tau = 3/5 rho^2/3, Thomas-Fermi
191+
// initial tau = 3/5 rho^2/3, Thomas-Fermi
188192
if (XC_Functional::get_ked_flag())
189193
{
190194
if (PARAM.inp.init_chg == "atomic" || read_kin_error)
@@ -194,11 +198,11 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
194198
std::cout << " Charge::init_rho: init kinetic energy density from rho." << std::endl;
195199
}
196200
const double fact = (3.0 / 5.0) * pow(3.0 * ModuleBase::PI * ModuleBase::PI, 2.0 / 3.0);
197-
for (int is = 0; is < PARAM.inp.nspin; ++is)
201+
for (int is = 0; is < nspin; ++is)
198202
{
199203
for (int ir = 0; ir < this->rhopw->nrxx; ++ir)
200204
{
201-
kin_r[is][ir] = fact * pow(std::abs(rho[is][ir]) * PARAM.inp.nspin, 5.0 / 3.0) / PARAM.inp.nspin;
205+
kin_r[is][ir] = fact * pow(std::abs(rho[is][ir]) * nspin, 5.0 / 3.0) / nspin;
202206
}
203207
}
204208
}
@@ -207,7 +211,7 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
207211
// Peize Lin add 2020.04.04
208212
if (GlobalC::restart.info_load.load_charge && !GlobalC::restart.info_load.load_charge_finish)
209213
{
210-
for (int is = 0; is < PARAM.inp.nspin; ++is)
214+
for (int is = 0; is < nspin; ++is)
211215
{
212216
try
213217
{
@@ -217,20 +221,21 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
217221
{
218222
// try to load from the output of `out_chg`
219223
std::stringstream ssc;
220-
ssc << PARAM.globalv.global_readin_dir << "SPIN" << is + 1 << "_CHG.cube";
224+
ssc << PARAM.globalv.global_readin_dir << "chgs" << is + 1 << ".cube";
221225
if (ModuleIO::read_vdata_palgrid(pgrid,
222226
(PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_BPGROUP : GlobalV::MY_RANK),
223227
GlobalV::ofs_running,
224228
ssc.str(),
225229
this->rho[is],
226230
ucell.nat))
227231
{
228-
GlobalV::ofs_running << " Read in the electron density: " << ssc.str() << std::endl;
232+
GlobalV::ofs_running << " Read in electron density: " << ssc.str() << std::endl;
229233
}
230234
}
231235
}
232236
GlobalC::restart.info_load.load_charge_finish = true;
233237
}
238+
234239
#ifdef __MPI
235240
this->init_chgmpi();
236241
#endif
@@ -248,7 +253,7 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
248253
PARAM.globalv.global_readin_dir,
249254
GlobalV::KPAR, GlobalV::MY_POOL, GlobalV::MY_RANK,
250255
GlobalV::NPROC_IN_POOL, GlobalV::RANK_IN_POOL,
251-
PARAM.inp.nbands, PARAM.inp.nspin, PARAM.globalv.npol,
256+
PARAM.inp.nbands, nspin, PARAM.globalv.npol,
252257
kv->get_nkstot(),kv->ik2iktot,kv->isk,GlobalV::ofs_running);
253258
}
254259
}

source/module_elecstate/module_charge/symmetry_rho.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void Symmetry_rho::psymm(double* rho_part,
9797
rhotot.resize(rho_basis->nxyz);
9898
ModuleBase::GlobalFunc::ZEROS(rhotot.data(), rho_basis->nxyz);
9999
}
100-
Pgrid.reduce(rhotot.data(), rho_part);
100+
Pgrid.reduce(rhotot.data(), rho_part, false);
101101

102102
// (2)
103103
if (GlobalV::MY_RANK == 0)

source/module_esolver/esolver_fp.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void ESolver_FP::after_scf(UnitCell& ucell, const int istep, const bool conv_eso
165165
for (int is = 0; is < PARAM.inp.nspin; is++)
166166
{
167167
this->pw_rhod->real2recip(this->chr.rho_save[is], this->chr.rhog_save[is]);
168-
std::string fn =PARAM.globalv.global_out_dir + "/SPIN" + std::to_string(is + 1) + "_CHG.cube";
168+
std::string fn =PARAM.globalv.global_out_dir + "/chgs" + std::to_string(is + 1) + ".cube";
169169
ModuleIO::write_vdata_palgrid(Pgrid,
170170
this->chr.rho_save[is],
171171
is,
@@ -176,9 +176,10 @@ void ESolver_FP::after_scf(UnitCell& ucell, const int istep, const bool conv_eso
176176
&(ucell),
177177
PARAM.inp.out_chg[1],
178178
1);
179+
179180
if (XC_Functional::get_ked_flag())
180181
{
181-
fn =PARAM.globalv.global_out_dir + "/SPIN" + std::to_string(is + 1) + "_TAU.cube";
182+
fn =PARAM.globalv.global_out_dir + "/taus" + std::to_string(is + 1) + ".cube";
182183
ModuleIO::write_vdata_palgrid(Pgrid,
183184
this->chr.kin_r_save[is],
184185
is,
@@ -339,7 +340,7 @@ void ESolver_FP::before_scf(UnitCell& ucell, const int istep)
339340
for (int is = 0; is < PARAM.inp.nspin; is++)
340341
{
341342
std::stringstream ss;
342-
ss << PARAM.globalv.global_out_dir << "SPIN" << is + 1 << "_CHG_INI.cube";
343+
ss << PARAM.globalv.global_out_dir << "/chgs" << is + 1 << "_ini.cube";
343344
ModuleIO::write_vdata_palgrid(this->Pgrid,
344345
this->chr.rho[is],
345346
is,

source/module_esolver/esolver_fp.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#include "esolver.h"
55

6+
#ifndef __MPI
7+
#include <chrono>
8+
#endif
9+
610
//! plane wave basis
711
#include "module_basis/module_pw/pw_basis.h"
812

@@ -98,6 +102,12 @@ class ESolver_FP: public ESolver
98102

99103
int pw_rho_flag = false; ///< flag for pw_rho, 0: not initialized, 1: initialized
100104

105+
//! the start time of scf iteration
106+
#ifdef __MPI
107+
double iter_time;
108+
#else
109+
std::chrono::system_clock::time_point iter_time;
110+
#endif
101111
};
102112
} // namespace ModuleESolver
103113

source/module_esolver/esolver_ks.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
#ifndef ESOLVER_KS_H
22
#define ESOLVER_KS_H
33

4-
#ifdef __MPI
5-
#include <mpi.h>
6-
#else
7-
#include <chrono>
8-
#endif
9-
104
#include <cstring>
115
//#include <fstream>
126

@@ -79,13 +73,6 @@ class ESolver_KS : public ESolver_FP
7973
//! Electronic wavefunctions
8074
psi::Psi<T>* psi = nullptr;
8175

82-
//! the start time of scf iteration
83-
#ifdef __MPI
84-
double iter_time;
85-
#else
86-
std::chrono::system_clock::time_point iter_time;
87-
#endif
88-
8976
std::string basisname; //! esolver_ks_lcao.cpp
9077
double esolver_KS_ne = 0.0; //! number of electrons
9178
double diag_ethr; //! the threshold for diagonalization

0 commit comments

Comments
 (0)