Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions source/module_basis/module_ao/ORB_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
//==============================
/// PLEASE avoid using 'ORB' as global variable
// mohan note 2021-03-23
namespace GlobalC
{
LCAO_Orbitals ORB;
}

LCAO_Orbitals::LCAO_Orbitals()
{
Expand All @@ -41,11 +37,6 @@ LCAO_Orbitals::~LCAO_Orbitals()
delete[] Alpha;
}

const LCAO_Orbitals& LCAO_Orbitals::get_const_instance()
{
return GlobalC::ORB;
}

std::vector<double> LCAO_Orbitals::cutoffs() const {
std::vector<double> cutoffs(ntype);
for (int it = 0; it < ntype; ++it) {
Expand Down
10 changes: 0 additions & 10 deletions source/module_basis/module_ao/ORB_read.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ class LCAO_Orbitals
LCAO_Orbitals();
~LCAO_Orbitals();

// static function to get global instance
static const LCAO_Orbitals& get_const_instance();

void init(
std::ofstream& ofs_in,
const int& ntype,
Expand Down Expand Up @@ -134,11 +131,4 @@ class LCAO_Orbitals
friend class TwoCenterBundle; // for the sake of TwoCenterBundle::to_LCAO_Orbitals
};

/// PLEASE avoid using 'ORB' as global variable
///
///mohan note 2021 - 03 - 23
namespace GlobalC
{
extern LCAO_Orbitals ORB;
}
#endif
14 changes: 9 additions & 5 deletions source/module_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace ModuleESolver
//! mohan add 2024-05-11
//------------------------------------------------------------------------------
template <typename TK, typename TR>
ESolver_KS_LCAO<TK, TR>::ESolver_KS_LCAO(): orb_(GlobalC::ORB)
ESolver_KS_LCAO<TK, TR>::ESolver_KS_LCAO()
{
this->classname = "ESolver_KS_LCAO";
this->basisname = "LCAO";
Expand Down Expand Up @@ -204,8 +204,8 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(const Input_para& inp, UnitCell
{
XC_Functional::set_xc_first_loop(ucell);
// initialize 2-center radial tables for EXX-LRI
if (GlobalC::exx_info.info_ri.real_number) { this->exx_lri_double->init(MPI_COMM_WORLD, this->kv); }
else { this->exx_lri_complex->init(MPI_COMM_WORLD, this->kv); }
if (GlobalC::exx_info.info_ri.real_number) { this->exx_lri_double->init(MPI_COMM_WORLD, this->kv, orb_); }
else { this->exx_lri_complex->init(MPI_COMM_WORLD, this->kv, orb_); }
}
}
#endif
Expand Down Expand Up @@ -463,6 +463,7 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners()
this->GG,
this->GK,
this->kv,
orb_.cutoffs(),
this->pelec->wg,
GlobalC::GridD
#ifdef __EXX
Expand Down Expand Up @@ -490,6 +491,7 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners()
this->kv,
this->pelec->wg,
GlobalC::GridD,
orb_.cutoffs(),
this->two_center_bundle_
#ifdef __EXX
, this->exx_lri_double ? &this->exx_lri_double->Hexxs : nullptr
Expand Down Expand Up @@ -1175,8 +1177,9 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
RPA_LRI<TK, double> rpa_lri_double(GlobalC::exx_info.info_ri);
rpa_lri_double.cal_postSCF_exx(*dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM(),
MPI_COMM_WORLD,
this->kv);
rpa_lri_double.init(MPI_COMM_WORLD, this->kv);
this->kv,
orb_);
rpa_lri_double.init(MPI_COMM_WORLD, this->kv, orb_.cutoffs());
rpa_lri_double.out_for_RPA(this->pv, *(this->psi), this->pelec);
}
#endif
Expand Down Expand Up @@ -1265,6 +1268,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
this->kv.kvec_d,
&hR,
&GlobalC::ucell,
orb_.cutoffs(),
&GlobalC::GridD,
two_center_bundle_.kinetic_orb.get());

Expand Down
2 changes: 1 addition & 1 deletion source/module_esolver/esolver_ks_lcao.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ESolver_KS_LCAO : public ESolver_KS<TK> {
TwoCenterBundle two_center_bundle_;

// temporary introduced during removing GlobalC::ORB
LCAO_Orbitals& orb_;
LCAO_Orbitals orb_;

// Temporarily store the stress to unify the interface with PW,
// because it's hard to seperate force and stress calculation in LCAO.
Expand Down
1 change: 1 addition & 0 deletions source/module_esolver/esolver_ks_lcao_tddft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ void ESolver_KS_LCAO_TDDFT::after_scf(const int istep)
kv,
two_center_bundle_.overlap_orb.get(),
tmp_DM->get_paraV_pointer(),
orb_,
this->RA);
}
ESolver_KS_LCAO<std::complex<double>, double>::after_scf(istep);
Expand Down
4 changes: 2 additions & 2 deletions source/module_esolver/lcao_before_scf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(const int istep)
#ifdef __EXX // set xc type before the first cal of xc in pelec->init_scf
if (GlobalC::exx_info.info_ri.real_number)
{
this->exd->exx_beforescf(this->kv, *this->p_chgmix, GlobalC::ucell, this->pv);
this->exd->exx_beforescf(this->kv, *this->p_chgmix, GlobalC::ucell, this->pv, orb_);
}
else
{
this->exc->exx_beforescf(this->kv, *this->p_chgmix, GlobalC::ucell, this->pv);
this->exc->exx_beforescf(this->kv, *this->p_chgmix, GlobalC::ucell, this->pv, orb_);
}
#endif // __EXX

Expand Down
7 changes: 5 additions & 2 deletions source/module_esolver/lcao_gets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ void ESolver_KS_LCAO<std::complex<double>, double>::get_S(void)
this->p_hamilt = new hamilt::HamiltLCAO<std::complex<double>, double>(
&this->pv,
this->kv,
*(two_center_bundle_.overlap_orb));
*(two_center_bundle_.overlap_orb),
orb_.cutoffs());
dynamic_cast<hamilt::OperatorLCAO<std::complex<double>, double>*>(
this->p_hamilt->ops)
->contributeHR();
Expand Down Expand Up @@ -103,7 +104,9 @@ void ESolver_KS_LCAO<std::complex<double>, std::complex<double>>::get_S(void)
std::complex<double>>(
&this->pv,
this->kv,
*(two_center_bundle_.overlap_orb));
*(two_center_bundle_.overlap_orb),
orb_.cutoffs()
);
dynamic_cast<
hamilt::OperatorLCAO<std::complex<double>, std::complex<double>>*>(
this->p_hamilt->ops)
Expand Down
1 change: 1 addition & 0 deletions source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ void Force_Stress_LCAO<T>::getForceStress(const bool isforce,
GlobalC::ucell,
&GlobalC::GridD,
two_center_bundle.overlap_orb_onsite.get(),
orb.cutoffs(),
&GlobalC::dftu);

tmp_dftu.cal_force_stress(isforce, isstress, force_dftu, stress_dftu);
Expand Down
16 changes: 15 additions & 1 deletion source/module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "module_base/timer.h"
#include "module_hamilt_lcao/module_dftu/dftu.h"
#include "module_hamilt_pw/hamilt_pwdft/global.h"
#include <vector>

#ifdef __DEEPKS
#include "module_hamilt_lcao/module_deepks/LCAO_deepks.h"
Expand Down Expand Up @@ -41,7 +42,7 @@ namespace hamilt
{

template <typename TK, typename TR>
HamiltLCAO<TK, TR>::HamiltLCAO(const Parallel_Orbitals* paraV, const K_Vectors& kv_in, const TwoCenterIntegrator& intor_overlap_orb)
HamiltLCAO<TK, TR>::HamiltLCAO(const Parallel_Orbitals* paraV, const K_Vectors& kv_in, const TwoCenterIntegrator& intor_overlap_orb, const std::vector<double>& orb_cutoff)
{
this->classname = "HamiltLCAO";

Expand All @@ -57,6 +58,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(const Parallel_Orbitals* paraV, const K_Vectors&
this->hR,
this->sR,
&GlobalC::ucell,
orb_cutoff,
&GlobalC::GridD,
&intor_overlap_orb);
}
Expand Down Expand Up @@ -130,6 +132,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
this->hR,
this->sR,
&GlobalC::ucell,
orb.cutoffs(),
&GlobalC::GridD,
two_center_bundle.overlap_orb.get());

Expand All @@ -140,6 +143,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
this->kv->kvec_d,
this->hR,
&GlobalC::ucell,
orb.cutoffs(),
&GlobalC::GridD,
two_center_bundle.kinetic_orb.get());
this->getOperator()->add(ekinetic);
Expand All @@ -153,6 +157,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
this->kv->kvec_d,
this->hR,
&GlobalC::ucell,
orb.cutoffs(),
&GlobalC::GridD,
two_center_bundle.overlap_orb_beta.get());
this->getOperator()->add(nonlocal);
Expand All @@ -174,6 +179,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
pot_in,
this->hR, // no explicit call yet
&GlobalC::ucell,
orb.cutoffs(),
&GlobalC::GridD
);
this->getOperator()->add(veff);
Expand Down Expand Up @@ -215,6 +221,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
GlobalC::ucell,
&GlobalC::GridD,
two_center_bundle.overlap_orb_onsite.get(),
orb.cutoffs(),
&GlobalC::dftu);
}
this->getOperator()->add(dftu);
Expand All @@ -240,6 +247,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
pot_in,
this->hR,
&GlobalC::ucell,
orb.cutoffs(),
&GlobalC::GridD);
// reset spin index and real space Hamiltonian matrix
int start_spin = -1;
Expand All @@ -256,6 +264,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
this->hR,
this->sR,
&GlobalC::ucell,
orb.cutoffs(),
&GlobalC::GridD,
two_center_bundle.overlap_orb.get());
if (this->getOperator() == nullptr)
Expand All @@ -275,6 +284,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
this->kv->kvec_d,
this->hR,
&GlobalC::ucell,
orb.cutoffs(),
&GlobalC::GridD,
two_center_bundle.kinetic_orb.get());
this->getOperator()->add(ekinetic);
Expand All @@ -288,6 +298,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
this->kv->kvec_d,
this->hR,
&GlobalC::ucell,
orb.cutoffs(),
&GlobalC::GridD,
two_center_bundle.overlap_orb_beta.get());
// TDDFT velocity gague will calculate full non-local potential including the original one and the
Expand Down Expand Up @@ -326,6 +337,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
this->hR,
kv,
&GlobalC::ucell,
orb.cutoffs(),
&GlobalC::GridD,
two_center_bundle.overlap_orb.get());
this->getOperator()->add(td_ekinetic);
Expand All @@ -334,6 +346,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
this->kv->kvec_d,
this->hR,
&GlobalC::ucell,
orb,
&GlobalC::GridD);
this->getOperator()->add(td_nonlocal);
}
Expand All @@ -355,6 +368,7 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
GlobalC::ucell,
&GlobalC::GridD,
two_center_bundle.overlap_orb_onsite.get(),
orb.cutoffs(),
&GlobalC::dftu);
}
this->getOperator()->add(dftu);
Expand Down
3 changes: 2 additions & 1 deletion source/module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "module_hamilt_lcao/module_gint/gint_k.h"
#include "module_hamilt_lcao/module_hcontainer/hcontainer.h"
#include "module_hamilt_lcao/hamilt_lcaodft/hs_matrix_k.hpp"
#include <vector>
#ifdef __EXX
#include "module_ri/Exx_LRI.h"
#endif
Expand Down Expand Up @@ -43,7 +44,7 @@ class HamiltLCAO : public Hamilt<TK>
/**
* @brief Constructor of vacuum Operators, only HR and SR will be initialed as empty HContainer
*/
HamiltLCAO(const Parallel_Orbitals* paraV, const K_Vectors& kv_in, const TwoCenterIntegrator& intor_overlap_orb);
HamiltLCAO(const Parallel_Orbitals* paraV, const K_Vectors& kv_in, const TwoCenterIntegrator& intor_overlap_orb, const std::vector<double>& orb_cutoff);

~HamiltLCAO()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::initialize_HR(Grid_Driver* Gr
const ModuleBase::Vector3<double>& tau1 = adjs.adjacent_tau[ad1];
const ModuleBase::Vector3<int>& R_index1 = adjs.box[ad1];
// choose the real adjacent atoms
const LCAO_Orbitals& orb = LCAO_Orbitals::get_const_instance();
// Note: the distance of atoms should less than the cutoff radius,
// When equal, the theoretical value of matrix element is zero,
// but the calculated value is not zero due to the numerical error, which would lead to result changes.
if (this->ucell->cal_dtau(iat0, iat1, R_index1).norm() * this->ucell->lat0
< orb.Phi[T1].getRcut() + orb.Alpha[0].getRcut())
< ptr_orb_->Phi[T1].getRcut() + ptr_orb_->Alpha[0].getRcut())
{
is_adj[ad1] = true;
}
Expand Down Expand Up @@ -310,8 +309,6 @@ void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::calculate_HR()
const Parallel_Orbitals* paraV = this->H_V_delta->get_paraV();
const int npol = this->ucell->get_npol();

const LCAO_Orbitals& orb = LCAO_Orbitals::get_const_instance();

// 1. calculate <psi|alpha> for each pair of atoms
for (int iat0 = 0; iat0 < this->ucell->nat; iat0++)
{
Expand All @@ -327,9 +324,9 @@ void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::calculate_HR()
if (!GlobalV::deepks_equiv)
{
int ib = 0;
for (int L0 = 0; L0 <= orb.Alpha[0].getLmax(); ++L0)
for (int L0 = 0; L0 <= ptr_orb_->Alpha[0].getLmax(); ++L0)
{
for (int N0 = 0; N0 < orb.Alpha[0].getNchi(L0); ++N0)
for (int N0 = 0; N0 < ptr_orb_->Alpha[0].getNchi(L0); ++N0)
{
const int inl = GlobalC::ld.get_inl(T0, I0, L0, N0);
const double* pgedm = GlobalC::ld.get_gedms(inl);
Expand All @@ -354,7 +351,7 @@ void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::calculate_HR()
int nproj = 0;
for (int il = 0; il < GlobalC::ld.get_lmaxd() + 1; il++)
{
nproj += (2 * il + 1) * orb.Alpha[0].getNchi(il);
nproj += (2 * il + 1) * ptr_orb_->Alpha[0].getNchi(il);
}
for (int iproj = 0; iproj < nproj; iproj++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ void DFTU<OperatorLCAO<TK, TR>>::cal_force_stress(const bool cal_force,
const ModuleBase::Vector3<double>& tau1 = adjs.adjacent_tau[ad];
const Atom* atom1 = &ucell->atoms[T1];

const LCAO_Orbitals& orb = LCAO_Orbitals::get_const_instance();
auto all_indexes = paraV->get_indexes_row(iat1);
auto col_indexes = paraV->get_indexes_col(iat1);
// insert col_indexes into all_indexes to get universal set with no repeat elements
Expand Down
Loading