Skip to content

Commit

Permalink
Merge branch 'develop' into elpa_gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
caic99 authored Aug 26, 2024
2 parents cbc4e5b + c61a66e commit 0253fee
Show file tree
Hide file tree
Showing 16 changed files with 465 additions and 127 deletions.
8 changes: 8 additions & 0 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
- [out\_level](#out_level)
- [out\_alllog](#out_alllog)
- [out\_mat\_hs](#out_mat_hs)
- [out\_mat\_tk](#out_mat_tk)
- [out\_mat\_r](#out_mat_r)
- [out\_mat\_hs2](#out_mat_hs2)
- [out\_mat\_t](#out_mat_t)
Expand Down Expand Up @@ -1667,6 +1668,13 @@ These variables are used to control the output of properties.
- **Description**: Whether to print the upper triangular part of the Hamiltonian matrices (in Ry) and overlap matrices for each k point into files in the directory `OUT.${suffix}`. The second number controls precision. For more information, please refer to [hs_matrix.md](../elec_properties/hs_matrix.md#out_mat_hs). Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag).
- **Default**: False 8

### out_mat_tk

- **Type**: Boolean \[Integer\](optional)
- **Availability**: Numerical atomic orbital basis
- **Description**: Whether to print the upper triangular part of the kinetic matrices (in Ry) for each k point into `OUT.${suffix}/data-i-T`, where i is the index of k points (see `OUT.${suffix}/kpoints`). One may optionally provide a second parameter to specify the precision.
- **Default**: False \[8\]

### out_mat_r

- **Type**: Boolean
Expand Down
2 changes: 1 addition & 1 deletion source/module_esolver/esolver_ks.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ESolver_KS : public ESolver_FP
virtual void iter_finish(int& iter);

//! Something to do after SCF iterations when SCF is converged or comes to the max iter step.
virtual void after_scf(const int istep);
virtual void after_scf(const int istep) override;

//! <Temporary> It should be replaced by a function in Hamilt Class
virtual void update_pot(const int istep, const int iter) {};
Expand Down
50 changes: 44 additions & 6 deletions source/module_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "module_elecstate/module_charge/symmetry_rho.h"
#include "module_elecstate/occupy.h"
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h" // need divide_HS_in_frag
#include "module_hamilt_lcao/hamilt_lcaodft/hs_matrix_k.hpp"
#include "module_hamilt_lcao/module_dftu/dftu.h"
#include "module_hamilt_pw/hamilt_pwdft/global.h"
#include "module_io/print_info.h"
Expand Down Expand Up @@ -994,15 +995,21 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(int& iter)
*this->p_hamilt,
*dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM(),
this->kv,
iter);
PARAM.inp.nspin,
iter,
this->pelec->f_en.etot,
this->scf_ene_thr);
}
else
{
this->conv_elec = this->exc->exx_after_converge(
*this->p_hamilt,
*dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM(),
this->kv,
iter);
PARAM.inp.nspin,
iter,
this->pelec->f_en.etot,
this->scf_ene_thr);
}
}
#endif
Expand Down Expand Up @@ -1130,11 +1137,10 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
}

#ifdef __EXX
// 4) write Exx matrix
if (GlobalC::exx_info.info_global.cal_exx) // Peize Lin add if 2022.11.14
// 4) write Hexx matrix for NSCF (see `out_chg` in docs/advanced/input_files/input-main.md)
if (GlobalC::exx_info.info_global.cal_exx && PARAM.inp.out_chg[0] && istep % PARAM.inp.out_interval == 0) // Peize Lin add if 2022.11.14
{
const std::string file_name_exx = GlobalV::global_out_dir + "HexxR"
+ std::to_string(GlobalV::MY_RANK);
const std::string file_name_exx = GlobalV::global_out_dir + "HexxR" + std::to_string(GlobalV::MY_RANK);
if (GlobalC::exx_info.info_ri.real_number) {
ModuleIO::write_Hexxs_csr(file_name_exx, GlobalC::ucell, this->exd->get_Hexxs());
} else {
Expand Down Expand Up @@ -1255,6 +1261,38 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
GlobalV::NPROC);
tqo.calculate();
}

if (PARAM.inp.out_mat_tk[0])
{
hamilt::HS_Matrix_K<TK> hsk(&pv, true);
hamilt::HContainer<TR> hR(&pv);
hamilt::Operator<TK>* ekinetic =
new hamilt::EkineticNew<hamilt::OperatorLCAO<TK, TR>>(&hsk,
this->kv.kvec_d,
&hR,
&GlobalC::ucell,
&GlobalC::GridD,
two_center_bundle_.kinetic_orb.get());

const int nspin_k = (GlobalV::NSPIN == 2 ? 2 : 1);
for (int ik = 0; ik < this->kv.get_nks() / nspin_k; ++ik)
{
ekinetic->init(ik);
ModuleIO::save_mat(0,
hsk.get_hk(),
GlobalV::NLOCAL,
false,
PARAM.inp.out_mat_tk[1],
1,
GlobalV::out_app_flag,
"T",
"data-" + std::to_string(ik),
this->pv,
GlobalV::DRANK);
}

delete ekinetic;
}
}

//------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ void Force_Stress_LCAO<T>::calForcePwPart(ModuleBase::matrix& fvl_dvl,
//--------------------------------------------------------
// force due to core correlation.
//--------------------------------------------------------
f_pw.cal_force_cc(fcc, rhopw, chr);
f_pw.cal_force_cc(fcc, rhopw, chr,GlobalC::ucell);
//--------------------------------------------------------
// force due to self-consistent charge.
//--------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion source/module_hamilt_pw/hamilt_pwdft/forces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void Forces<FPTYPE, Device>::cal_force(ModuleBase::matrix& force,
// not relevant for PAW
if (!GlobalV::use_paw)
{
Forces::cal_force_cc(forcecc, rho_basis, chr);
Forces::cal_force_cc(forcecc, rho_basis, chr,GlobalC::ucell);
}
else
{
Expand Down
5 changes: 3 additions & 2 deletions source/module_hamilt_pw/hamilt_pwdft/forces.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Forces

void cal_force_loc(ModuleBase::matrix& forcelc, ModulePW::PW_Basis* rho_basis, const Charge* const chr);
void cal_force_ew(ModuleBase::matrix& forceion, ModulePW::PW_Basis* rho_basis, const Structure_Factor* p_sf);
void cal_force_cc(ModuleBase::matrix& forcecc, ModulePW::PW_Basis* rho_basis, const Charge* const chr);
void cal_force_cc(ModuleBase::matrix& forcecc, ModulePW::PW_Basis* rho_basis, const Charge* const chr, UnitCell& ucell_in);
/**
* @brief This routine computes the atomic force of non-local pseudopotential
* F^{NL}_i = \sum_{n,k}f_{nk}\sum_I \sum_{lm,l'm'}D_{l,l'}^{I} [
Expand Down Expand Up @@ -86,7 +86,8 @@ class Forces
const FPTYPE* rhoc,
FPTYPE* drhocg,
ModulePW::PW_Basis* rho_basis,
int type); // used in nonlinear core correction stress
int type,
const UnitCell& ucell_in); // used in nonlinear core correction stress
void deriv_drhoc_scc(const bool& numeric,
const int mesh,
const FPTYPE* r,
Expand Down
Loading

0 comments on commit 0253fee

Please sign in to comment.