forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Calculate and output electron localization function (ELF) wi…
…th KSDFT and OFDFT (#5139) * Feature: Calculate and output electron localization function (ELF) with KSDFT in both PW and LCAO basis. * Feature: Calculate and output ELF with OFDFT * Test: Add three integrate tests for out_elf 119_PW_out_elf, 219_NO_out_elf, 919_OF_out_elf * Test: Update tools/catch_properties.sh * Feature: Support ELF in SPIN2 case. * Doc: Update the document of input parameters * Fix: Update Makefile.Objects * [pre-commit.ci lite] apply automatic fixes * Fix: Fix the bug caused by check_value * Fix: Update the name of several parameters, fix a memory leak * Feature: support user defined precision of elf * Doc: Update document of out_elf * Doc/Test: Update the doc and test * Test: Update unit test * Refactor: Remove GlobalV::NPSIN from source/module_hamilt_pw/hamilt_ofdft/ * [pre-commit.ci lite] apply automatic fixes * Fix: Add a small number (1e-5) onto the numerator of chi to suppress the numerical instability caused by LCAO basis, as suggested by 卢天, 陈飞武. 电子定域化函数的含义与函数形式[J]. 物理化学学报, 2011, 27(12): 2786-2792. * Test: Update 119_PW_out_elf and 919_OF_out_elf * Test: Correct the reference of 119_PW_out_elf * Test: Update 219_LCAO_out_elf * Refactor: Move cal_tau to new files. * [pre-commit.ci lite] apply automatic fixes * Test: Update abacus-develop/source/module_elecstate/test/CMakeLists.txt --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Mohan Chen <mohanchen@pku.edu.cn>
- Loading branch information
1 parent
1c7a509
commit d6657ec
Showing
55 changed files
with
1,551 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "elecstate_lcao.h" | ||
|
||
#include "module_base/timer.h" | ||
|
||
namespace elecstate | ||
{ | ||
|
||
// calculate the kinetic energy density tau, multi-k case | ||
template <> | ||
void ElecStateLCAO<std::complex<double>>::cal_tau(const psi::Psi<std::complex<double>>& psi) | ||
{ | ||
ModuleBase::timer::tick("ElecStateLCAO", "cal_tau"); | ||
|
||
for (int is = 0; is < PARAM.inp.nspin; is++) | ||
{ | ||
ModuleBase::GlobalFunc::ZEROS(this->charge->kin_r[is], this->charge->nrxx); | ||
} | ||
Gint_inout inout1(this->charge->kin_r, Gint_Tools::job_type::tau); | ||
this->gint_k->cal_gint(&inout1); | ||
|
||
ModuleBase::timer::tick("ElecStateLCAO", "cal_tau"); | ||
return; | ||
} | ||
|
||
// calculate the kinetic energy density tau, gamma-only case | ||
template <> | ||
void ElecStateLCAO<double>::cal_tau(const psi::Psi<double>& psi) | ||
{ | ||
ModuleBase::timer::tick("ElecStateLCAO", "cal_tau"); | ||
|
||
for (int is = 0; is < PARAM.inp.nspin; is++) | ||
{ | ||
ModuleBase::GlobalFunc::ZEROS(this->charge->kin_r[is], this->charge->nrxx); | ||
} | ||
Gint_inout inout1(this->charge->kin_r, Gint_Tools::job_type::tau); | ||
this->gint_gamma->cal_gint(&inout1); | ||
|
||
ModuleBase::timer::tick("ElecStateLCAO", "cal_tau"); | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "elecstate_pw.h" | ||
#include "elecstate_getters.h" | ||
|
||
namespace elecstate { | ||
|
||
template<typename T, typename Device> | ||
void ElecStatePW<T, Device>::cal_tau(const psi::Psi<T, Device>& psi) | ||
{ | ||
ModuleBase::TITLE("ElecStatePW", "cal_tau"); | ||
for(int is=0; is<PARAM.inp.nspin; is++) | ||
{ | ||
setmem_var_op()(this->ctx, this->kin_r[is], 0, this->charge->nrxx); | ||
} | ||
|
||
for (int ik = 0; ik < psi.get_nk(); ++ik) | ||
{ | ||
psi.fix_k(ik); | ||
int npw = psi.get_current_nbas(); | ||
int current_spin = 0; | ||
if (PARAM.inp.nspin == 2) | ||
{ | ||
current_spin = this->klist->isk[ik]; | ||
} | ||
int nbands = psi.get_nbands(); | ||
for (int ibnd = 0; ibnd < nbands; ibnd++) | ||
{ | ||
this->basis->recip_to_real(this->ctx, &psi(ibnd,0), this->wfcr, ik); | ||
|
||
const auto w1 = static_cast<Real>(this->wg(ik, ibnd) / get_ucell_omega()); | ||
|
||
// kinetic energy density | ||
for (int j = 0; j < 3; j++) | ||
{ | ||
setmem_complex_op()(this->ctx, this->wfcr, 0, this->charge->nrxx); | ||
|
||
meta_op()(this->ctx, | ||
ik, | ||
j, | ||
npw, | ||
this->basis->npwk_max, | ||
static_cast<Real>(get_ucell_tpiba()), | ||
this->basis->template get_gcar_data<Real>(), | ||
this->basis->template get_kvec_c_data<Real>(), | ||
&psi(ibnd, 0), | ||
this->wfcr); | ||
|
||
this->basis->recip_to_real(this->ctx, this->wfcr, this->wfcr, ik); | ||
|
||
elecstate_pw_op()(this->ctx, current_spin, this->charge->nrxx, w1, this->kin_r, this->wfcr); | ||
} | ||
} | ||
} | ||
if (GlobalV::device_flag == "gpu" || PARAM.inp.precision == "single") { | ||
for (int ii = 0; ii < PARAM.inp.nspin; ii++) { | ||
castmem_var_d2h_op()(cpu_ctx, this->ctx, this->charge->kin_r[ii], this->kin_r[ii], this->charge->nrxx); | ||
} | ||
} | ||
this->parallelK(); | ||
ModuleBase::TITLE("ElecStatePW", "cal_tau"); | ||
} | ||
|
||
template class ElecStatePW<std::complex<float>, base_device::DEVICE_CPU>; | ||
template class ElecStatePW<std::complex<double>, base_device::DEVICE_CPU>; | ||
#if ((defined __CUDA) || (defined __ROCM)) | ||
template class ElecStatePW<std::complex<float>, base_device::DEVICE_GPU>; | ||
template class ElecStatePW<std::complex<double>, base_device::DEVICE_GPU>; | ||
#endif | ||
} // namespace elecstate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.