Skip to content

Commit

Permalink
Merge branch 'develop' into lapack_unit_test_and_document
Browse files Browse the repository at this point in the history
  • Loading branch information
Critsium-xy authored Jul 11, 2024
2 parents f97ae9d + 3c58070 commit 7f8bffd
Show file tree
Hide file tree
Showing 31 changed files with 96 additions and 129 deletions.
6 changes: 2 additions & 4 deletions source/module_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,12 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners()

if (INPUT.out_proj_band) // Projeced band structure added by jiyy-2022-4-20
{
ModuleIO::write_proj_band_lcao(this->psi, this->LM, this->pelec, this->kv, GlobalC::ucell, this->p_hamilt);
ModuleIO::write_proj_band_lcao(this->psi, this->ParaV, this->pelec, this->kv, GlobalC::ucell, this->p_hamilt);
}

if (INPUT.out_dos)
{
ModuleIO::out_dos_nao(this->psi,
this->LM,
this->ParaV,
this->pelec->ekb,
this->pelec->wg,
Expand Down Expand Up @@ -1408,8 +1407,7 @@ void ESolver_KS_LCAO<TK, TR>::cal_mag(const int istep, const bool print)
GlobalC::ucell.get_atomCounts(),
GlobalC::ucell.get_lnchiCounts(),
GlobalV::NSPIN);
auto out_sk = ModuleIO::Output_Sk<TK>(&(this->LM),
this->p_hamilt,
auto out_sk = ModuleIO::Output_Sk<TK>(this->p_hamilt,
&(this->ParaV),
GlobalV::NSPIN,
this->kv.get_nks());
Expand Down
4 changes: 2 additions & 2 deletions source/module_esolver/esolver_ks_lcao_elec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ void ESolver_KS_LCAO<std::complex<double>, double>::get_S(void)

std::cout << " The file is saved in " << fn << std::endl;

ModuleIO::output_SR(ParaV, this->LM, GlobalC::GridD, this->p_hamilt, fn);
ModuleIO::output_SR(ParaV, GlobalC::GridD, this->p_hamilt, fn);

return;
}
Expand Down Expand Up @@ -601,7 +601,7 @@ void ESolver_KS_LCAO<std::complex<double>, std::complex<double>>::get_S(void)

std::cout << " The file is saved in " << fn << std::endl;

ModuleIO::output_SR(ParaV, this->LM, GlobalC::GridD, this->p_hamilt, fn);
ModuleIO::output_SR(ParaV, GlobalC::GridD, this->p_hamilt, fn);

return;
}
Expand Down
2 changes: 1 addition & 1 deletion source/module_hamilt_lcao/hamilt_lcaodft/LCAO_allocate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace LCAO_domain
{

void divide_HS_in_frag(const bool isGamma, Parallel_Orbitals& pv,const int& nks) {
ModuleBase::TITLE("LCAO_Matrix", "divide_HS_in_frag");
ModuleBase::TITLE("LCAO_domain", "divide_HS_in_frag");

//(1), (2): set up matrix division have been moved into ESolver_KS_LCAO::init_basis_lcao
// just pass `ParaV` as pointer is enough
Expand Down
8 changes: 3 additions & 5 deletions source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include "module_base/timer.h"
#include "module_hamilt_lcao/hamilt_lcaodft/spar_exx.h"
#include "module_ri/RI_2D_Comm.h"
// use LCAO_Matrix
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h"

#include <RI/global/Global_Func-2.h>
#include <RI/ri/Cell_Nearest.h>
Expand All @@ -26,7 +24,7 @@
// Peize Lin add 2022.09.13
template <typename Tdata>
void sparse_format::cal_HR_exx(
LCAO_Matrix& lm, // mohan add 2024-04-06
const Parallel_Orbitals& pv,
LCAO_HS_Arrays& HS_Arrays,
const int& current_spin,
const double& sparse_threshold,
Expand Down Expand Up @@ -84,15 +82,15 @@ void sparse_format::cal_HR_exx(

for (size_t iw0 = 0; iw0 < Hexx.shape[0]; ++iw0) {
const int iwt0 = RI_2D_Comm::get_iwt(iat0, iw0, is0_b);
const int iwt0_local = lm.ParaV->global2local_row(iwt0);
const int iwt0_local = pv.global2local_row(iwt0);

if (iwt0_local < 0) {
continue;
}

for (size_t iw1 = 0; iw1 < Hexx.shape[1]; ++iw1) {
const int iwt1 = RI_2D_Comm::get_iwt(iat1, iw1, is1_b);
const int iwt1_local = lm.ParaV->global2local_col(iwt1);
const int iwt1_local = pv.global2local_col(iwt1);

if (iwt1_local < 0) {
continue;
Expand Down
28 changes: 14 additions & 14 deletions source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h"

void sparse_format::cal_dH(LCAO_Matrix& lm,
void sparse_format::cal_dH(const Parallel_Orbitals& pv,
LCAO_HS_Arrays& HS_Arrays,
Grid_Driver& grid,
const TwoCenterBundle& two_center_bundle,
Expand All @@ -14,17 +14,17 @@ void sparse_format::cal_dH(LCAO_Matrix& lm,

sparse_format::set_R_range(HS_Arrays.all_R_coor, grid);

const int nnr = lm.ParaV->nnr;
const int nnr = pv.nnr;

ForceStressArrays fsr_dh;

fsr_dh.DHloc_fixedR_x = new double[nnr];
fsr_dh.DHloc_fixedR_y = new double[nnr];
fsr_dh.DHloc_fixedR_z = new double[nnr];

ModuleBase::GlobalFunc::ZEROS(fsr_dh.DHloc_fixedR_x, lm.ParaV->nloc);
ModuleBase::GlobalFunc::ZEROS(fsr_dh.DHloc_fixedR_y, lm.ParaV->nloc);
ModuleBase::GlobalFunc::ZEROS(fsr_dh.DHloc_fixedR_z, lm.ParaV->nloc);
ModuleBase::GlobalFunc::ZEROS(fsr_dh.DHloc_fixedR_x, pv.nloc);
ModuleBase::GlobalFunc::ZEROS(fsr_dh.DHloc_fixedR_y, pv.nloc);
ModuleBase::GlobalFunc::ZEROS(fsr_dh.DHloc_fixedR_z, pv.nloc);
// cal dT=<phi|kin|dphi> in LCAO
// cal T + VNL(P1) in LCAO basis
if (GlobalV::CAL_STRESS)
Expand All @@ -36,7 +36,7 @@ void sparse_format::cal_dH(LCAO_Matrix& lm,
true,
GlobalC::ucell,
GlobalC::ORB,
*lm.ParaV,
pv,
two_center_bundle,
&GlobalC::GridD,
nullptr); // delete unused parameter lm.Hloc_fixedR
Expand All @@ -50,13 +50,13 @@ void sparse_format::cal_dH(LCAO_Matrix& lm,
true,
GlobalC::ucell,
GlobalC::ORB,
*lm.ParaV,
pv,
two_center_bundle,
&GlobalC::GridD,
nullptr); // delete unused parameter lm.Hloc_fixedR
}

LCAO_domain::build_Nonlocal_mu_new(*lm.ParaV,
LCAO_domain::build_Nonlocal_mu_new(pv,
fsr_dh,
nullptr,
true,
Expand All @@ -65,14 +65,14 @@ void sparse_format::cal_dH(LCAO_Matrix& lm,
*(two_center_bundle.overlap_orb_beta),
&GlobalC::GridD);

sparse_format::cal_dSTN_R(lm, HS_Arrays, fsr_dh, grid, current_spin, sparse_thr);
sparse_format::cal_dSTN_R(pv, HS_Arrays, fsr_dh, grid, current_spin, sparse_thr);

delete[] fsr_dh.DHloc_fixedR_x;
delete[] fsr_dh.DHloc_fixedR_y;
delete[] fsr_dh.DHloc_fixedR_z;

gint_k
.cal_dvlocal_R_sparseMatrix(current_spin, sparse_thr, HS_Arrays, lm.ParaV, GlobalC::ucell, GlobalC::GridD);
.cal_dvlocal_R_sparseMatrix(current_spin, sparse_thr, HS_Arrays, &pv, GlobalC::ucell, GlobalC::GridD);

return;
}
Expand Down Expand Up @@ -102,7 +102,7 @@ void sparse_format::set_R_range(std::set<Abfs::Vector3_Order<int>>& all_R_coor,
return;
}

void sparse_format::cal_dSTN_R(LCAO_Matrix& lm,
void sparse_format::cal_dSTN_R(const Parallel_Orbitals& pv,
LCAO_HS_Arrays& HS_Arrays,
ForceStressArrays& fsr,
Grid_Driver& grid,
Expand Down Expand Up @@ -178,7 +178,7 @@ void sparse_format::cal_dSTN_R(LCAO_Matrix& lm,
for (int ii = 0; ii < atom1->nw * GlobalV::NPOL; ii++)
{
const int iw1_all = start + ii;
const int mu = lm.ParaV->global2local_row(iw1_all);
const int mu = pv.global2local_row(iw1_all);

if (mu < 0)
{
Expand All @@ -188,7 +188,7 @@ void sparse_format::cal_dSTN_R(LCAO_Matrix& lm,
for (int jj = 0; jj < atom2->nw * GlobalV::NPOL; jj++)
{
int iw2_all = start2 + jj;
const int nu = lm.ParaV->global2local_col(iw2_all);
const int nu = pv.global2local_col(iw2_all);

if (nu < 0)
{
Expand Down Expand Up @@ -230,7 +230,7 @@ void sparse_format::cal_dSTN_R(LCAO_Matrix& lm,

void sparse_format::destroy_dH_R_sparse(LCAO_HS_Arrays& HS_Arrays)
{
ModuleBase::TITLE("LCAO_Matrix", "destroy_dH_R_sparse");
ModuleBase::TITLE("LCAO_domain", "destroy_dH_R_sparse");

if (GlobalV::NSPIN != 4)
{
Expand Down
4 changes: 2 additions & 2 deletions source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace sparse_format
{
void cal_dH(LCAO_Matrix& lm,
void cal_dH(const Parallel_Orbitals& pv,
LCAO_HS_Arrays& HS_Arrays,
Grid_Driver& grid,
const TwoCenterBundle& two_center_bundle,
Expand All @@ -22,7 +22,7 @@ void cal_dH(LCAO_Matrix& lm,
void set_R_range(std::set<Abfs::Vector3_Order<int>>& all_R_coor, Grid_Driver& grid);

// be called by 'cal_dH_sparse'
void cal_dSTN_R(LCAO_Matrix& lm,
void cal_dSTN_R(const Parallel_Orbitals& pv,
LCAO_HS_Arrays& HS_Arrays,
ForceStressArrays& fsr, // mohan add 2024-06-16
Grid_Driver& grid,
Expand Down
5 changes: 2 additions & 3 deletions source/module_hamilt_lcao/hamilt_lcaodft/spar_exx.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
#include <map>
#include <vector>

// use LCAO_Matrix
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_HS_arrays.hpp"
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h"
#include "module_basis/module_ao/parallel_orbitals.h"

namespace sparse_format
{

template <typename Tdata>
void cal_HR_exx(
LCAO_Matrix& lm,
const Parallel_Orbitals& pv,
LCAO_HS_Arrays& HS_Arrays,
const int& current_spin,
const double& sparse_thr,
Expand Down
9 changes: 4 additions & 5 deletions source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ void sparse_format::cal_HSR(const Parallel_Orbitals& pv,
// if EXX is considered
if (GlobalC::exx_info.info_global.cal_exx) {
if (GlobalC::exx_info.info_ri.real_number) {
sparse_format::cal_HR_exx(lm,
sparse_format::cal_HR_exx(pv,
HS_Arrays,
current_spin,
sparse_thr,
nmp,
*lm.Hexxd);
} else {
sparse_format::cal_HR_exx(lm,
sparse_format::cal_HR_exx(pv,
HS_Arrays,
current_spin,
sparse_thr,
Expand All @@ -111,7 +111,7 @@ void sparse_format::cal_HSR(const Parallel_Orbitals& pv,
#endif // __MPI
#endif // __EXX

sparse_format::clear_zero_elements(lm, HS_Arrays, current_spin, sparse_thr);
sparse_format::clear_zero_elements(HS_Arrays, current_spin, sparse_thr);

return;
}
Expand Down Expand Up @@ -237,8 +237,7 @@ void sparse_format::cal_HContainer_td(
}

// in case there are elements smaller than the threshold
void sparse_format::clear_zero_elements(LCAO_Matrix& lm,
LCAO_HS_Arrays& HS_Arrays,
void sparse_format::clear_zero_elements(LCAO_HS_Arrays& HS_Arrays,
const int& current_spin,
const double& sparse_thr) {
ModuleBase::TITLE("sparse_format", "clear_zero_elements");
Expand Down
3 changes: 1 addition & 2 deletions source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ void cal_HContainer_td(
std::map<Abfs::Vector3_Order<int>,
std::map<size_t, std::map<size_t, std::complex<double>>>>& target);

void clear_zero_elements(LCAO_Matrix& lm,
LCAO_HS_Arrays& HS_Arrays,
void clear_zero_elements(LCAO_HS_Arrays& HS_Arrays,
const int& current_spin,
const double& sparse_thr);

Expand Down
6 changes: 2 additions & 4 deletions source/module_hamilt_lcao/hamilt_lcaodft/spar_st.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@ void sparse_format::cal_SR(

void sparse_format::cal_TR(const UnitCell& ucell,
const Parallel_Orbitals& pv,
LCAO_Matrix& lm,
LCAO_HS_Arrays& HS_Arrays,
Grid_Driver& grid,
const TwoCenterBundle& two_center_bundle,
const double& sparse_thr) {
ModuleBase::TITLE("sparse_format", "cal_TR");

// need to rebuild T(R)
HS_Arrays.Hloc_fixedR.resize(lm.ParaV->nnr);
HS_Arrays.Hloc_fixedR.resize(pv.nnr);

LCAO_domain::zeros_HSR('T', HS_Arrays);

Expand All @@ -82,14 +81,13 @@ void sparse_format::cal_TR(const UnitCell& ucell,

sparse_format::set_R_range(HS_Arrays.all_R_coor, grid);

sparse_format::cal_STN_R_for_T(ucell, pv, lm, HS_Arrays, grid, sparse_thr);
sparse_format::cal_STN_R_for_T(ucell, pv, HS_Arrays, grid, sparse_thr);

return;
}

void sparse_format::cal_STN_R_for_T(const UnitCell& ucell,
const Parallel_Orbitals& pv,
LCAO_Matrix& lm,
LCAO_HS_Arrays& HS_arrays,
Grid_Driver& grid,
const double& sparse_thr) {
Expand Down
3 changes: 0 additions & 3 deletions source/module_hamilt_lcao/hamilt_lcaodft/spar_st.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define SPARSE_FORMAT_ST_H

#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_HS_arrays.hpp"
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h"
#include "module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h"

namespace sparse_format {
Expand All @@ -21,7 +20,6 @@ void cal_SR(const Parallel_Orbitals& pv,
//! calculate kinetic matrix with lattice vector R
void cal_TR(const UnitCell& ucell,
const Parallel_Orbitals& pv,
LCAO_Matrix& lm,
LCAO_HS_Arrays& HS_arrays,
Grid_Driver& grid,
const TwoCenterBundle& two_center_bundle,
Expand All @@ -30,7 +28,6 @@ void cal_TR(const UnitCell& ucell,
//! cal_STN_R_for_T is only called by cal_TR
void cal_STN_R_for_T(const UnitCell& ucell,
const Parallel_Orbitals& pv,
LCAO_Matrix& lm,
LCAO_HS_Arrays& HS_arrays,
Grid_Driver& grid,
const double& sparse_thr);
Expand Down
6 changes: 3 additions & 3 deletions source/module_hamilt_lcao/module_gint/gint_k.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Gint_k : public Gint {
std::map<size_t, std::map<size_t, double>>>&
pvdpR_sparseMatrix,
LCAO_HS_Arrays& HS_Arrays,
Parallel_Orbitals* pv);
const Parallel_Orbitals* pv);

void distribute_pvdpR_soc_sparseMatrix(
const int dim,
Expand All @@ -93,12 +93,12 @@ class Gint_k : public Gint {
std::map<size_t, std::map<size_t, std::complex<double>>>>&
pvdpR_soc_sparseMatrix,
LCAO_HS_Arrays& HS_Arrays,
Parallel_Orbitals* pv);
const Parallel_Orbitals* pv);

void cal_dvlocal_R_sparseMatrix(const int& current_spin,
const double& sparse_threshold,
LCAO_HS_Arrays& HS_Arrays,
Parallel_Orbitals* pv,
const Parallel_Orbitals* pv,
UnitCell& ucell,
Grid_Driver& gdriver);

Expand Down
6 changes: 3 additions & 3 deletions source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void Gint_k::distribute_pvdpR_sparseMatrix(
const double& sparse_threshold,
const std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, double>>>& pvdpR_sparseMatrix,
LCAO_HS_Arrays& HS_Arrays,
Parallel_Orbitals* pv)
const Parallel_Orbitals* pv)
{
ModuleBase::TITLE("Gint_k", "distribute_pvdpR_sparseMatrix");

Expand Down Expand Up @@ -170,7 +170,7 @@ void Gint_k::distribute_pvdpR_soc_sparseMatrix(
const std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, std::complex<double>>>>&
pvdpR_soc_sparseMatrix,
LCAO_HS_Arrays& HS_Arrays,
Parallel_Orbitals* pv)
const Parallel_Orbitals* pv)
{
ModuleBase::TITLE("Gint_k", "distribute_pvdpR_soc_sparseMatrix");

Expand Down Expand Up @@ -320,7 +320,7 @@ void Gint_k::distribute_pvdpR_soc_sparseMatrix(
void Gint_k::cal_dvlocal_R_sparseMatrix(const int& current_spin,
const double& sparse_threshold,
LCAO_HS_Arrays& HS_Arrays,
Parallel_Orbitals* pv,
const Parallel_Orbitals* pv,
UnitCell& ucell,
Grid_Driver& gdriver)
{
Expand Down
Loading

0 comments on commit 7f8bffd

Please sign in to comment.