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
2 changes: 2 additions & 0 deletions source/module_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,12 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(const Input_para& inp, UnitCell
if (GlobalC::exx_info.info_ri.real_number)
{
this->exx_lri_double->init(MPI_COMM_WORLD, this->kv, orb_);
this->exd->exx_before_all_runners(this->kv, GlobalC::ucell, this->pv);
}
else
{
this->exx_lri_complex->init(MPI_COMM_WORLD, this->kv, orb_);
this->exc->exx_before_all_runners(this->kv, GlobalC::ucell, this->pv);
}
}
}
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, orb_);
this->exd->exx_beforescf(this->kv, *this->p_chgmix, GlobalC::ucell, orb_);
}
else
{
this->exc->exx_beforescf(this->kv, *this->p_chgmix, GlobalC::ucell, this->pv, orb_);
this->exc->exx_beforescf(this->kv, *this->p_chgmix, GlobalC::ucell, orb_);
}
#endif // __EXX

Expand Down
7 changes: 6 additions & 1 deletion source/module_ri/Exx_LRI_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ class Exx_LRI_Interface
double& get_Eexx() const { return this->exx_ptr->Eexx; }

// Processes in ESolver_KS_LCAO
/// @brief in before_all_runners: set symmetry according to irreducible k-points
/// since k-points are not reduced again after the variation of the cell and exx-symmetry must be consistent with k-points.
/// In the future, we will reduce k-points again during cell-relax, then this setting can be moved to `exx_beforescf`.
void exx_before_all_runners(const K_Vectors& kv, const UnitCell& ucell, const Parallel_2D& pv);

/// @brief in beforescf: set xc type, opt_orb, do DM mixing
void exx_beforescf(const K_Vectors& kv, const Charge_Mixing& chgmix, const UnitCell& ucell, const Parallel_2D& pv, const LCAO_Orbitals& orb);
void exx_beforescf(const K_Vectors& kv, const Charge_Mixing& chgmix, const UnitCell& ucell, const LCAO_Orbitals& orb);

/// @brief in eachiterinit: do DM mixing and calculate Hexx when entering 2nd SCF
void exx_eachiterinit(const elecstate::DensityMatrix<T, double>& dm/**< double should be Tdata if complex-PBE-DM is supported*/,
Expand Down
28 changes: 16 additions & 12 deletions source/module_ri/Exx_LRI_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,22 @@ void Exx_LRI_Interface<T, Tdata>::read_Hexxs_cereal(const std::string& file_name
}

template<typename T, typename Tdata>
void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const K_Vectors& kv, const Charge_Mixing& chgmix, const UnitCell& ucell, const Parallel_2D& pv, const LCAO_Orbitals& orb)
void Exx_LRI_Interface<T, Tdata>::exx_before_all_runners(const K_Vectors& kv, const UnitCell& ucell, const Parallel_2D& pv)
{
// initialize the rotation matrix in AO representation
this->exx_spacegroup_symmetry = (PARAM.inp.nspin < 4 && ModuleSymmetry::Symmetry::symm_flag == 1);
if (this->exx_spacegroup_symmetry)
{
const std::array<int, 3>& period = RI_Util::get_Born_vonKarmen_period(kv);
this->symrot_.find_irreducible_sector(ucell.symm, ucell.atoms, ucell.st,
RI_Util::get_Born_von_Karmen_cells(period), period, ucell.lat);
// this->symrot_.set_Cs_rotation(this->exx_ptr->get_abfs_nchis());
this->symrot_.cal_Ms(kv, ucell, pv);
}
}

template<typename T, typename Tdata>
void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const K_Vectors& kv, const Charge_Mixing& chgmix, const UnitCell& ucell, const LCAO_Orbitals& orb)
{
#ifdef __MPI
if (GlobalC::exx_info.info_global.cal_exx)
Expand All @@ -54,17 +69,6 @@ void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const K_Vectors& kv, const Charg
XC_Functional::set_xc_type("scan");
}
}
// initialize the rotation matrix in AO representation
this->exx_spacegroup_symmetry = (PARAM.inp.nspin < 4 && ModuleSymmetry::Symmetry::symm_flag == 1);
if (this->exx_spacegroup_symmetry)
{
const std::array<int, 3>& period = RI_Util::get_Born_vonKarmen_period(kv);
this->symrot_.find_irreducible_sector(ucell.symm, ucell.atoms, ucell.st,
RI_Util::get_Born_von_Karmen_cells(period), period, ucell.lat);
// this->symrot_.set_Cs_rotation(this->exx_ptr->get_abfs_nchis());
this->symrot_.cal_Ms(kv, ucell, pv);
}

this->exx_ptr->cal_exx_ions(PARAM.inp.out_ri_cv);
}

Expand Down
6 changes: 3 additions & 3 deletions source/module_ri/module_exx_symmetry/irreducible_sector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ namespace ModuleSymmetry
return TCdouble(std::round(return_lattice_double.x), std::round(return_lattice_double.y), std::round(return_lattice_double.z));
}

void Irreducible_Sector::get_return_lattice_all(const Symmetry& symm, const Atom* atoms, const Statistics& st)
void Irreducible_Sector::cal_return_lattice_all(const Symmetry& symm, const Atom* atoms, const Statistics& st)
{
ModuleBase::TITLE("Symmetry_rotation", "get_return_lattice_all");
ModuleBase::TITLE("Symmetry_rotation", "cal_return_lattice_all");
this->return_lattice_.resize(st.nat, std::vector<TCdouble>(symm.nrotk));
for (int iat1 = 0;iat1 < st.nat;++iat1)
{
Expand Down Expand Up @@ -163,7 +163,7 @@ namespace ModuleSymmetry
this->irreducible_sector_.clear();
this->sector_stars_.clear();

if (this->return_lattice_.empty()) this->get_return_lattice_all(symm, atoms, st);
if (this->return_lattice_.empty()) this->cal_return_lattice_all(symm, atoms, st);
// if (this->atompair_stars_.empty()) this->find_irreducible_atom_pairs(symm);

// contruct {atom pair, R} set
Expand Down
3 changes: 2 additions & 1 deletion source/module_ri/module_exx_symmetry/irreducible_sector.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ namespace ModuleSymmetry
TCdouble get_return_lattice(const Symmetry& symm,
const ModuleBase::Matrix3& gmatd, const TCdouble gtransd,
const TCdouble& posd_a1, const TCdouble& posd_a2)const;
void get_return_lattice_all(const Symmetry& symm, const Atom* atoms, const Statistics& st);

protected:
void cal_return_lattice_all(const Symmetry& symm, const Atom* atoms, const Statistics& st);

//--------------------------------------------------------------------------------
/// The sub functions to find irreducible sector: {abR}

Expand Down
6 changes: 2 additions & 4 deletions source/module_ri/module_exx_symmetry/symmetry_rotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ namespace ModuleSymmetry
auto vec_conj = [](const std::vector<std::complex<double>>& z, const double scal = 1.0) -> std::vector<std::complex<double>>
{
std::vector<std::complex<double>> z_conj(z.size());
for (int i = 0;i < z.size();++i) { z_conj[i] = std::conj(z[i]) * scal;
}
for (int i = 0;i < z.size();++i) { z_conj[i] = std::conj(z[i]) * scal; }
return z_conj;
};
std::vector<std::vector<std::complex<double>>> dm_k_full;
Expand All @@ -110,8 +109,7 @@ namespace ModuleSymmetry
{
double factor = 1.0 / static_cast<double>(kv.kstars[ik_ibz].size());
std::vector<std::complex<double>> dm_scaled(pv.get_local_size());
for (int i = 0;i < pv.get_local_size();++i) { dm_scaled[i] = factor * dm_k_ibz[ik_ibz + is * nk][i];
}
for (int i = 0;i < pv.get_local_size();++i) { dm_scaled[i] = factor * dm_k_ibz[ik_ibz + is * nk][i]; }
dm_k_full.push_back(dm_scaled);
}
else if (vec3_eq(isym_kvd.second, -kv.kvec_d[ik_ibz], this->eps_) && this->TRS_first_) {
Expand Down
10 changes: 5 additions & 5 deletions source/module_ri/module_exx_symmetry/symmetry_rotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ namespace ModuleSymmetry
//--------------------------------------------------------------------------------
// getters
const std::map<Tap, std::set<TC>>& get_irreducible_sector()const { return this->irs_.get_irreducible_sector(); }
void find_irreducible_sector(const Symmetry& symm, const Atom* atoms, const Statistics& st,
const std::vector<TC>& Rs, const TC& period, const Lattice& lat)
{
this->irs_.find_irreducible_sector(symm, atoms, st, Rs, period, lat);
}
TCdouble get_return_lattice(const Symmetry& symm,
const ModuleBase::Matrix3& gmatd, const TCdouble gtransd,
const TCdouble& posd_a1, const TCdouble& posd_a2)const
Expand All @@ -34,6 +29,11 @@ namespace ModuleSymmetry
}
//--------------------------------------------------------------------------------
// setters
void find_irreducible_sector(const Symmetry& symm, const Atom* atoms, const Statistics& st,
const std::vector<TC>& Rs, const TC& period, const Lattice& lat)
{
this->irs_.find_irreducible_sector(symm, atoms, st, Rs, period, lat);
}
void set_Cs_rotation(const std::vector<std::vector<int>>& abfs_l_nchi);
//--------------------------------------------------------------------------------
/// functions to contruct rotation matrix in AO-representation
Expand Down
Loading