Skip to content

Commit

Permalink
[pre-commit.ci lite] apply automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci-lite[bot] authored Sep 7, 2024
1 parent 1a9c20d commit 4ff8300
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 81 deletions.
43 changes: 26 additions & 17 deletions source/module_ri/Exx_LRI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ void Exx_LRI<Tdata>::init(const MPI_Comm &mpi_comm_in, const K_Vectors &kv_in)

const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>>
abfs_same_atom = Exx_Abfs::Construct_Orbs::abfs_same_atom( this->lcaos, this->info.kmesh_times, this->info.pca_threshold );
if(this->info.files_abfs.empty())
if(this->info.files_abfs.empty()) {
this->abfs = abfs_same_atom;
else
this->abfs = Exx_Abfs::IO::construct_abfs( abfs_same_atom, GlobalC::ORB, this->info.files_abfs, this->info.kmesh_times );
} else {
this->abfs = Exx_Abfs::IO::construct_abfs( abfs_same_atom, GlobalC::ORB, this->info.files_abfs, this->info.kmesh_times );
}
Exx_Abfs::Construct_Orbs::print_orbs_size(this->abfs, GlobalV::ofs_running);

auto get_ccp_parameter = [this]() -> std::map<std::string,double>
Expand All @@ -86,8 +87,9 @@ void Exx_LRI<Tdata>::init(const MPI_Comm &mpi_comm_in, const K_Vectors &kv_in)
this->abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp(this->abfs, this->info.ccp_type, get_ccp_parameter(), this->info.ccp_rmesh_times);


for( size_t T=0; T!=this->abfs.size(); ++T )
GlobalC::exx_info.info_ri.abfs_Lmax = std::max( GlobalC::exx_info.info_ri.abfs_Lmax, static_cast<int>(this->abfs[T].size())-1 );
for( size_t T=0; T!=this->abfs.size(); ++T ) {
GlobalC::exx_info.info_ri.abfs_Lmax = std::max( GlobalC::exx_info.info_ri.abfs_Lmax, static_cast<int>(this->abfs[T].size())-1 );
}

this->cv.set_orbitals(
this->lcaos, this->abfs, this->abfs_ccp,
Expand All @@ -108,11 +110,13 @@ void Exx_LRI<Tdata>::cal_exx_ions()
// this->m_abfslcaos_lcaos.init_radial_table(Rradial);

std::vector<TA> atoms(GlobalC::ucell.nat);
for(int iat=0; iat<GlobalC::ucell.nat; ++iat)
atoms[iat] = iat;
for(int iat=0; iat<GlobalC::ucell.nat; ++iat) {
atoms[iat] = iat;
}
std::map<TA,TatomR> atoms_pos;
for(int iat=0; iat<GlobalC::ucell.nat; ++iat)
atoms_pos[iat] = RI_Util::Vector3_to_array3( GlobalC::ucell.atoms[ GlobalC::ucell.iat2it[iat] ].tau[ GlobalC::ucell.iat2ia[iat] ] );
for(int iat=0; iat<GlobalC::ucell.nat; ++iat) {
atoms_pos[iat] = RI_Util::Vector3_to_array3( GlobalC::ucell.atoms[ GlobalC::ucell.iat2it[iat] ].tau[ GlobalC::ucell.iat2ia[iat] ] );
}
const std::array<TatomR,Ndim> latvec
= {RI_Util::Vector3_to_array3(GlobalC::ucell.a1),
RI_Util::Vector3_to_array3(GlobalC::ucell.a2),
Expand Down Expand Up @@ -269,9 +273,11 @@ void Exx_LRI<Tdata>::cal_exx_force()
for(int is=0; is<GlobalV::NSPIN; ++is)
{
this->exx_lri.cal_force({"","",std::to_string(is),"",""});
for(std::size_t idim=0; idim<Ndim; ++idim)
for(const auto &force_item : this->exx_lri.force[idim])
this->force_exx(force_item.first, idim) += std::real(force_item.second);
for(std::size_t idim=0; idim<Ndim; ++idim) {
for(const auto &force_item : this->exx_lri.force[idim]) {
this->force_exx(force_item.first, idim) += std::real(force_item.second);
}
}
}

const double SPIN_multiple = std::map<int,double>{{1,2}, {2,1}, {4,1}}.at(GlobalV::NSPIN); // why?
Expand All @@ -291,9 +297,11 @@ void Exx_LRI<Tdata>::cal_exx_stress()
for(int is=0; is<GlobalV::NSPIN; ++is)
{
this->exx_lri.cal_stress({"","",std::to_string(is),"",""});
for(std::size_t idim0=0; idim0<Ndim; ++idim0)
for(std::size_t idim1=0; idim1<Ndim; ++idim1)
this->stress_exx(idim0,idim1) += std::real(this->exx_lri.stress(idim0,idim1));
for(std::size_t idim0=0; idim0<Ndim; ++idim0) {
for(std::size_t idim1=0; idim1<Ndim; ++idim1) {
this->stress_exx(idim0,idim1) += std::real(this->exx_lri.stress(idim0,idim1));
}
}
}

const double SPIN_multiple = std::map<int,double>{{1,2}, {2,1}, {4,1}}.at(GlobalV::NSPIN); // why?
Expand All @@ -310,8 +318,9 @@ std::vector<std::vector<int>> Exx_LRI<Tdata>::get_abfs_nchis() const
for (const auto& abfs_T : this->abfs)
{
std::vector<int> abfs_nchi_T;
for (const auto& abfs_L : abfs_T)
abfs_nchi_T.push_back(abfs_L.size());
for (const auto& abfs_L : abfs_T) {
abfs_nchi_T.push_back(abfs_L.size());
}
abfs_nchis.push_back(abfs_nchi_T);
}
return abfs_nchis;
Expand Down
21 changes: 12 additions & 9 deletions source/module_ri/module_exx_symmetry/irreducible_sector.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@ namespace ModuleSymmetry
{
bool operator()(const Tap& lhs, const Tap& rhs) const
{
if (lhs.first < rhs.first)return true;
else if (lhs.first > rhs.first)return false;
else return lhs.second < rhs.second;
if (lhs.first < rhs.first) {return true;
} else if (lhs.first > rhs.first) {return false;
} else { return lhs.second < rhs.second;
}
}
};
struct apR_less_func
{
bool operator()(const TapR& lhs, const TapR& rhs) const
{
if (lhs.first < rhs.first)return true;
else if (lhs.first > rhs.first)return false;
else return lhs.second < rhs.second;
if (lhs.first < rhs.first) {return true;
} else if (lhs.first > rhs.first) {return false;
} else { return lhs.second < rhs.second;
}
}
};
struct len_less_func
Expand All @@ -44,9 +46,10 @@ namespace ModuleSymmetry
}
bool operator()(const TC& lhs, const TC& rhs) const
{
if (norm2(lhs) < norm2(rhs))return true;
else if (norm2(lhs) > norm2(rhs))return false;
else return lhs < rhs;
if (norm2(lhs) < norm2(rhs)) {return true;
} else if (norm2(lhs) > norm2(rhs)) {return false;
} else { return lhs < rhs;
}
}
};

Expand Down
20 changes: 13 additions & 7 deletions source/module_ri/module_exx_symmetry/irreducible_sector_bvk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ namespace ModuleSymmetry
{ //the BvK supercell has the same symmetry as the original cell
this->bvk_nsym_ = symm.nrotk;
this->isymbvk_to_isym_.resize(symm.nrotk);
for (int isym = 0;isym < symm.nrotk;++isym) this->isymbvk_to_isym_[isym] = isym;
for (int isym = 0;isym < symm.nrotk;++isym) { this->isymbvk_to_isym_[isym] = isym;
}
return;
}

Expand All @@ -59,7 +60,8 @@ namespace ModuleSymmetry
for (int it = 0;it < st.ntype;++it)
{
bvk_na[it] = atoms[it].na * bvk_min_period[0] * bvk_min_period[1] * bvk_min_period[2];
if (it > 0) bvk_istart[it] = bvk_istart[it - 1] + bvk_na[it - 1];
if (it > 0) { bvk_istart[it] = bvk_istart[it - 1] + bvk_na[it - 1];
}
if (bvk_na[it] < bvk_na[bvk_itmin_type])
{
bvk_itmin_type = it;
Expand All @@ -76,10 +78,10 @@ namespace ModuleSymmetry
s3 = a3 = lat.a3 * static_cast<double>(bvk_min_period[2]);
ModuleBase::Matrix3 bvk_min_lat = set_matrix3(s1, s2, s3);
int at = 0;
for (int it = 0; it < st.ntype; ++it)
for (int c1 = 0;c1 < bvk_min_period[0];++c1)
for (int c2 = 0;c2 < bvk_min_period[1];++c2)
for (int c3 = 0;c3 < bvk_min_period[2];++c3)
for (int it = 0; it < st.ntype; ++it) {
for (int c1 = 0;c1 < bvk_min_period[0];++c1) {
for (int c2 = 0;c2 < bvk_min_period[1];++c2) {
for (int c3 = 0;c3 < bvk_min_period[2];++c3) {
for (int ia = 0; ia < atoms[it].na; ++ia)
{
bvk_dpos[3 * at] = (static_cast<double> (c1) + atoms[it].taud[ia].x) / static_cast<double>(bvk_min_period[0]);
Expand All @@ -92,6 +94,10 @@ namespace ModuleSymmetry
}
++at;
}
}
}
}
}

// analyze bravis and generate optimized lattice for minimal BvK lattice
double cel_const[6], pre_const[6];
Expand Down Expand Up @@ -157,4 +163,4 @@ namespace ModuleSymmetry
// return in_plain;
// }

}
};
Loading

0 comments on commit 4ff8300

Please sign in to comment.