Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ if(ENABLE_LIBRI)
else()
message(FATAL_ERROR "Must provide LIBRI_DIR for RI related features.")
endif()
target_link_libraries(${ABACUS_BIN_NAME} ri)
target_link_libraries(${ABACUS_BIN_NAME} ri exx_symmetry)
add_compile_definitions(__EXX EXX_DM=3 EXX_H_COMM=2 TEST_EXX_LCAO=0
TEST_EXX_RADIAL=1)
endif()
Expand Down
2 changes: 1 addition & 1 deletion deps/LibRI
Submodule LibRI updated 74 files
+41 −0 include/RI/comm/example/Communicate_Map_Combine.h
+39 −1 include/RI/comm/mix/Communicate_Tensors_Map_Judge.h
+17 −1 include/RI/distribute/Distribute_Equally.h
+35 −0 include/RI/distribute/Distribute_Equally.hpp
+23 −10 include/RI/distribute/Divide_Atoms.hpp
+2 −2 include/RI/distribute/Split_Processes.hpp
+2 −1 include/RI/global/Cereal_Types.h
+56 −0 include/RI/global/Map_Operator.h
+2 −1 include/RI/global/Tensor.h
+8 −2 include/RI/global/Tensor.hpp
+51 −0 include/RI/global/Tensor_Multiply-23.hpp
+85 −0 include/RI/global/Tensor_Multiply-32.hpp
+68 −0 include/RI/global/Tensor_Multiply-33.hpp
+13 −0 include/RI/global/Tensor_Multiply.h
+17 −3 include/RI/parallel/Parallel_LRI.h
+18 −8 include/RI/parallel/Parallel_LRI_Equally.h
+121 −6 include/RI/parallel/Parallel_LRI_Equally.hpp
+17 −4 include/RI/physics/Exx.h
+185 −169 include/RI/physics/Exx.hpp
+1 −3 include/RI/physics/GW.h
+18 −13 include/RI/physics/GW.hpp
+0 −1 include/RI/physics/RPA.h
+20 −15 include/RI/physics/RPA.hpp
+0 −59 include/RI/ri/CS_Matrix-set.hpp
+1 −1 include/RI/ri/Cell_Nearest.h
+2 −2 include/RI/ri/Cell_Nearest.hpp
+46 −0 include/RI/ri/Data_Pack.h
+1,213 −0 include/RI/ri/LRI-cal_loop3.hpp
+36 −57 include/RI/ri/LRI-set.hpp
+22 −26 include/RI/ri/LRI.h
+7 −11 include/RI/ri/LRI.hpp
+181 −16 include/RI/ri/LRI_Cal_Aux.h
+26 −24 include/RI/ri/LRI_Cal_Tools.h
+33 −64 include/RI/ri/Label.h
+209 −0 include/RI/ri/Label_Tools.h
+5 −0 include/RI/ri/RI_Tools.h
+29 −0 include/RI/ri/RI_Tools.hpp
+0 −56 include/RI/ri/Save_Load.h
+0 −102 include/RI/ri/Save_Load.hpp
+0 −0 include/RI/ri/bak_LRI-cal-loop4_1/bak-LRI-cal.hpp
+15 −16 include/RI/ri/bak_LRI-cal-loop4_2/CS_Matrix-filter.hpp
+81 −0 include/RI/ri/bak_LRI-cal-loop4_2/CS_Matrix-set.hpp
+14 −9 include/RI/ri/bak_LRI-cal-loop4_2/CS_Matrix.h
+0 −0 include/RI/ri/bak_LRI-cal-loop4_2/CS_Matrix_Tools.h
+1 −1 include/RI/ri/bak_LRI-cal-loop4_2/CS_Matrix_Tools.hpp
+48 −0 include/RI/ri/bak_LRI-cal-loop4_2/Data_Pack.h
+460 −0 include/RI/ri/bak_LRI-cal-loop4_2/Exx.hpp
+4 −1 include/RI/ri/bak_LRI-cal-loop4_2/LRI-cal-loop4-b01.hpp
+4 −1 include/RI/ri/bak_LRI-cal-loop4_2/LRI-cal-loop4-bx2.hpp
+3 −5 include/RI/ri/bak_LRI-cal-loop4_2/LRI-cal-loop4.hpp
+165 −0 include/RI/ri/bak_LRI-cal-loop4_2/LRI-set.hpp
+113 −0 include/RI/ri/bak_LRI-cal-loop4_2/LRI.h
+24 −6 unittests/Test_All.hpp
+9 −9 unittests/comm/mix/Communicate_Tensors-test.hpp
+72 −30 unittests/distribute/Distribute_Equally-test.hpp
+3 −3 unittests/distribute/Divide_Atoms-test.hpp
+6 −6 unittests/distribute/Split_Processes-test.hpp
+2 −2 unittests/global/Blas-test.hpp
+7 −7 unittests/global/Map_Operator-test.hpp
+1 −1 unittests/global/Tensor-test-4.hpp
+0 −1 unittests/global/Tensor-test.h
+54 −0 unittests/global/Tensor_Multiply-23-test.hpp
+92 −0 unittests/global/Tensor_Multiply-32-test.hpp
+73 −0 unittests/global/Tensor_Multiply-33-test.hpp
+42 −0 unittests/global/Tensor_Multiply-test.hpp
+2 −1 unittests/physics/Exx-test.hpp
+0 −1 unittests/physics/GW-test.hpp
+15 −0 unittests/print_stl.h
+3 −15 unittests/ri/CS_Matrix-test.hpp
+1 −1 unittests/ri/Cell_Nearest-test.hpp
+401 −0 unittests/ri/LRI-loop3-test.hpp
+38 −26 unittests/ri/LRI-loop4-test.hpp
+7 −7 unittests/ri/LRI-speed-test.hpp
+0 −58 unittests/ri/Label-test.h
10 changes: 10 additions & 0 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
- [exx\_opt\_orb\_ecut](#exx_opt_orb_ecut)
- [exx\_opt\_orb\_tolerence](#exx_opt_orb_tolerence)
- [exx\_real\_number](#exx_real_number)
- [exx\_symmetry\_realspace](#exx_symmetry_realspace)
- [rpa\_ccp\_rmesh\_times](#rpa_ccp_rmesh_times)
- [Molecular dynamics](#molecular-dynamics)
- [md\_type](#md_type)
Expand Down Expand Up @@ -2402,6 +2403,15 @@ These variables are relevant when using hybrid functionals.
- **Description**: How many times larger the radial mesh required is to that of atomic orbitals in the postprocess calculation of the **bare** Coulomb matrix for RPA, GW, etc.
- **Default**: 10

### exx_symmetry_realspace

- **Type**: Boolean
- **Availability**: *[symmetry](#symmetry)==1* and exx calculation (*[dft_fuctional](#dft_functional)==hse/hf/pbe0/scan0/opt_orb* or *[rpa](#rpa)==True*)
- **Description**:
- False: only rotate k-space density matrix D(k) from irreducible k-points to accelerate diagonalization
- True: rotate both D(k) and Hexx(R) to accelerate both diagonalization and EXX calculation
- **Default**: True

[back to top](#full-list-of-input-keywords)

## Molecular dynamics
Expand Down
2 changes: 1 addition & 1 deletion examples/hse/lcao_Si2/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ecutwfc 100
scf_thr 1e-8
scf_nmax 100
gamma_only 0
symmetry -1
symmetry 1
smearing_method gauss
mixing_type broyden
mixing_beta 0.4
Expand Down
2 changes: 2 additions & 0 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ OBJS_MODULE_RI=conv_coulomb_pot_k.o\
RI_2D_Comm.o\
Mix_DMk_2D.o\
Mix_Matrix.o\
symmetry_rotation.o\
symmetry_irreducible_sector.o\

OBJS_PARALLEL=parallel_common.o\
parallel_global.o\
Expand Down
2 changes: 1 addition & 1 deletion source/module_base/scalapack_connector.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class ScalapackConnector
B, &IB, &JB, DESCB, &beta, C, &IC, &JC, DESCC);
}

static inline
static inline
void getrf(
const int M, const int N,
std::complex<double> *A, const int IA, const int JA, const int *DESCA,
Expand Down
72 changes: 69 additions & 3 deletions source/module_cell/klist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,9 @@ void K_Vectors::ibz_kpoint(const ModuleSymmetry::Symmetry& symm,
// if really there is no equivalent k point in the list, then add it.
if (!already_exist)
{
// if it's a new ibz kpoint.
// nkstot_ibz indicate the index of ibz kpoint.
kvec_d_ibz[nkstot_ibz] = kvec_rot;
//if it's a new ibz kpoint.
//nkstot_ibz indicate the index of ibz kpoint.
kvec_d_ibz[nkstot_ibz] = kvec_d[i];
// output in kpoints file
ibz_index[i] = nkstot_ibz;

Expand Down Expand Up @@ -924,6 +924,38 @@ void K_Vectors::ibz_kpoint(const ModuleSymmetry::Symmetry& symm,
}

delete[] kkmatrix;

#ifdef __EXX
// setup kstars according to the final (max-norm) kvec_d_ibz
this->kstars.resize(nkstot_ibz);
if (ModuleSymmetry::Symmetry::symm_flag == 1)
{
for (int i = 0; i < nkstot; ++i)
{
int exist_number = -1;
int isym = 0;
for (int j = 0; j < nrotkm; ++j)
{
kvec_rot = kvec_d[i] * kgmatrix[j];
restrict_kpt(kvec_rot);
for (int k = 0; k < nkstot_ibz; ++k)
{
if (symm.equal(kvec_rot.x, kvec_d_ibz[k].x) &&
symm.equal(kvec_rot.y, kvec_d_ibz[k].y) &&
symm.equal(kvec_rot.z, kvec_d_ibz[k].z))
{
isym = j;
exist_number = k;
break;
}
}
if (exist_number != -1) break;
}
this->kstars[exist_number].insert(std::make_pair(isym, kvec_d[i]));
}
}
#endif

// output in kpoints file
std::stringstream ss;
ss << " " << std::setw(40) << "nkstot"
Expand Down Expand Up @@ -1196,6 +1228,40 @@ void K_Vectors::mpi_k()
wk[i] = wk_aux[k_index];
isk[i] = isk_aux[k_index];
}

#ifdef __EXX
if (ModuleSymmetry::Symmetry::symm_flag == 1)
{//bcast kstars
this->kstars.resize(nkstot);
for (int ikibz = 0;ikibz < nkstot;++ikibz)
{
int starsize = this->kstars[ikibz].size();
Parallel_Common::bcast_int(starsize);
GlobalV::ofs_running << "starsize: " << starsize << std::endl;
auto ks = this->kstars[ikibz].begin();
for (int ik = 0;ik < starsize;++ik)
{
int isym = 0;
ModuleBase::Vector3<double> ks_vec(0, 0, 0);
if (GlobalV::MY_RANK == 0)
{
isym = ks->first;
ks_vec = ks->second;
++ks;
}
Parallel_Common::bcast_int(isym);
Parallel_Common::bcast_double(ks_vec.x);
Parallel_Common::bcast_double(ks_vec.y);
Parallel_Common::bcast_double(ks_vec.z);
GlobalV::ofs_running << "isym: " << isym << " ks_vec: " << ks_vec.x << " " << ks_vec.y << " " << ks_vec.z << std::endl;
if (GlobalV::MY_RANK != 0)
{
kstars[ikibz].insert(std::make_pair(isym, ks_vec));
}
}
}
}
#endif
} // END SUBROUTINE
#endif

Expand Down
32 changes: 18 additions & 14 deletions source/module_cell/klist.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class K_Vectors
{
public:
public:
std::vector<ModuleBase::Vector3<double>> kvec_c; /// Cartesian coordinates of k points
std::vector<ModuleBase::Vector3<double>> kvec_d; /// Direct coordinates of k points

Expand All @@ -22,6 +22,10 @@ class K_Vectors
int nmp[3]; /// Number of Monhorst-Pack
std::vector<int> kl_segids; /// index of kline segment

/// @brief equal k points to each ibz-kpont, corresponding to a certain symmetry operations.
/// dim: [iks_ibz][(isym, kvec_d)]
std::vector<std::map<int, ModuleBase::Vector3<double>>> kstars;

K_Vectors();
~K_Vectors();
K_Vectors& operator=(const K_Vectors&) = default;
Expand All @@ -47,11 +51,11 @@ class K_Vectors
* @note Only available for nspin = 1 or 2 or 4.
*/
void set(const ModuleSymmetry::Symmetry& symm,
const std::string& k_file_name,
const int& nspin,
const ModuleBase::Matrix3& reciprocal_vec,
const ModuleBase::Matrix3& latvec,
std::ofstream& ofs);
const std::string& k_file_name,
const int& nspin,
const ModuleBase::Matrix3& reciprocal_vec,
const ModuleBase::Matrix3& latvec,
std::ofstream& ofs);

/**
* @brief Generates irreducible k-points in the Brillouin zone considering symmetry operations.
Expand All @@ -67,10 +71,10 @@ class K_Vectors
* @param match A boolean flag that indicates if the results matches the real condition.
*/
void ibz_kpoint(const ModuleSymmetry::Symmetry& symm,
bool use_symm,
std::string& skpt,
const UnitCell& ucell,
bool& match);
bool use_symm,
std::string& skpt,
const UnitCell& ucell,
bool& match);
// LiuXh add 20180515

/**
Expand Down Expand Up @@ -149,7 +153,7 @@ class K_Vectors
this->nkstot_full = value;
}

private:
private:
int nks; // number of symmetry-reduced k points in this pool(processor, up+dw)
int nkstot; /// number of symmetry-reduced k points in full k mesh
int nkstot_full; /// number of k points before symmetry reduction in full k mesh
Expand Down Expand Up @@ -278,8 +282,8 @@ class K_Vectors
* be recalculated.
*/
void update_use_ibz(const int& nkstot_ibz,
const std::vector<ModuleBase::Vector3<double>>& kvec_d_ibz,
const std::vector<double>& wk_ibz);
const std::vector<ModuleBase::Vector3<double>>& kvec_d_ibz,
const std::vector<double>& wk_ibz);

/**
* @brief Sets both the direct and Cartesian k-vectors.
Expand Down Expand Up @@ -400,4 +404,4 @@ inline int K_Vectors::getik_global(const int& ik) const
}
}

#endif // KVECT_H
#endif // KVECT_H
48 changes: 26 additions & 22 deletions source/module_cell/module_symmetry/symmetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ void Symmetry::analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms,
this->itmin_start = istart[it];
}
}
this->getgroup(nrot_out, nrotk_out, ofs_running, pos_spinup.data());
this->getgroup(nrot_out, nrotk_out, ofs_running, this->nop, this->symop, this->gmatrix, this->gtrans,
pos_spinup.data(), this->rotpos, this->index, this->itmin_type, this->itmin_start, this->istart, this->na);
// recover na and istart
for (int it = 0;it < ntype;++it)
{
Expand All @@ -164,11 +165,14 @@ void Symmetry::analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms,
}
// For AFM analysis End
//------------------------------------------------------------
} else {
}
else
{
// get the real symmetry operations according to the input structure
// nrot_out: the number of pure point group rotations
// nrotk_out: the number of all space group operations
this->getgroup(nrot_out, nrotk_out, ofs_running, this->newpos);
this->getgroup(nrot_out, nrotk_out, ofs_running, this->nop, this->symop, this->gmatrix, this->gtrans,
this->newpos, this->rotpos, this->index, this->itmin_type, this->itmin_start, this->istart, this->na);
}
};

Expand Down Expand Up @@ -287,16 +291,16 @@ void Symmetry::analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms,
// 3. output to running.log
//----------------------------------
// output the point group
this->pointgroup(this->nrot, this->pgnumber, this->pgname, this->gmatrix, ofs_running);
bool valid_group = this->pointgroup(this->nrot, this->pgnumber, this->pgname, this->gmatrix, ofs_running);
ModuleBase::GlobalFunc::OUT(ofs_running,"POINT GROUP", this->pgname);
// output the space group
this->pointgroup(this->nrotk, this->spgnumber, this->spgname, this->gmatrix, ofs_running);
valid_group = this->pointgroup(this->nrotk, this->spgnumber, this->spgname, this->gmatrix, ofs_running);
ModuleBase::GlobalFunc::OUT(ofs_running, "POINT GROUP IN SPACE GROUP", this->spgname);

//-----------------------------
// 4. For the case where point group is not complete due to symmetry_prec
//-----------------------------
if (!this->valid_group)
if (!valid_group)
{ // select the operations that have the inverse
std::vector<int>invmap(this->nrotk, -1);
this->gmatrix_invmap(this->gmatrix, this->nrotk, invmap.data());
Expand Down Expand Up @@ -881,7 +885,9 @@ void Symmetry::lattice_type(
}


void Symmetry::getgroup(int& nrot, int& nrotk, std::ofstream& ofs_running, double* pos)
void Symmetry::getgroup(int& nrot, int& nrotk, std::ofstream& ofs_running, const int& nop,
const ModuleBase::Matrix3* symop, ModuleBase::Matrix3* gmatrix, ModuleBase::Vector3<double>* gtrans,
double* pos, double* rotpos, int* index, const int itmin_type, const int itmin_start, int* istart, int* na)const
{
ModuleBase::TITLE("Symmetry", "getgroup");

Expand All @@ -905,9 +911,7 @@ void Symmetry::getgroup(int& nrot, int& nrotk, std::ofstream& ofs_running, doubl
//std::cout << "nop = " <<nop <<std::endl;
for (int i = 0; i < nop; ++i)
{
// std::cout << "symop = " << symop[i].e11 <<" "<< symop[i].e12 <<" "<< symop[i].e13 <<" "<< symop[i].e21 <<" "<< symop[i].e22 <<" "<< symop[i].e23 <<" "<< symop[i].e31 <<" "<< symop[i].e32 <<" "<< symop[i].e33 << std::endl;
this->checksym(this->symop[i], this->gtrans[i], pos);
// std::cout << "s_flag =" <<s_flag<<std::endl;
bool s_flag = this->checksym(symop[i], gtrans[i], pos, rotpos, index, itmin_type, itmin_start, istart, na);
if (s_flag == 1)
{
//------------------------------
Expand Down Expand Up @@ -985,7 +989,8 @@ void Symmetry::getgroup(int& nrot, int& nrotk, std::ofstream& ofs_running, doubl
return;
}

void Symmetry::checksym(ModuleBase::Matrix3 &s, ModuleBase::Vector3<double> &gtrans, double* pos)
bool Symmetry::checksym(const ModuleBase::Matrix3& s, ModuleBase::Vector3<double>& gtrans,
double* pos, double* rotpos, int* index, const int itmin_type, const int itmin_start, int* istart, int* na)const
{
//----------------------------------------------
// checks whether a point group symmetry element
Expand All @@ -994,7 +999,7 @@ void Symmetry::checksym(ModuleBase::Matrix3 &s, ModuleBase::Vector3<double> &gtr
// the start atom index.
bool no_diff = false;
ModuleBase::Vector3<double> trans(2.0, 2.0, 2.0);
s_flag = 0;
bool s_flag = 0;

for (int it = 0; it < ntype; it++)
{
Expand Down Expand Up @@ -1049,9 +1054,9 @@ void Symmetry::checksym(ModuleBase::Matrix3 &s, ModuleBase::Vector3<double> &gtr
//---------------------------------------------------------
// itmin_start = the start atom positions of species itmin
//---------------------------------------------------------
sptmin.x = rotpos[itmin_start*3];
sptmin.y = rotpos[itmin_start*3+1];
sptmin.z = rotpos[itmin_start*3+2];
// (s)tart (p)osition of atom (t)ype which has (min)inal number.
ModuleBase::Vector3<double> sptmin(rotpos[itmin_start * 3], rotpos[itmin_start * 3 + 1], rotpos[itmin_start * 3 + 2]);

for (int i = itmin_start; i < itmin_start + na[itmin_type]; ++i)
{
//set up the current test std::vector "gtrans"
Expand Down Expand Up @@ -1141,13 +1146,12 @@ void Symmetry::checksym(ModuleBase::Matrix3 &s, ModuleBase::Vector3<double> &gtr
gtrans.y = trans.y;
gtrans.z = trans.z;
}
return;
return s_flag;
}

void Symmetry::pricell(double* pos, const Atom* atoms)
{
bool no_diff = false;
s_flag = 0;
ptrans.clear();

for (int it = 0; it < ntype; it++)
Expand Down Expand Up @@ -1182,10 +1186,10 @@ void Symmetry::pricell(double* pos, const Atom* atoms)

//---------------------------------------------------------
// itmin_start = the start atom positions of species itmin
//---------------------------------------------------------
sptmin.x = pos[itmin_start*3];
sptmin.y = pos[itmin_start*3+1];
sptmin.z = pos[itmin_start*3+2];
//---------------------------------------------------------
// (s)tart (p)osition of atom (t)ype which has (min)inal number.
ModuleBase::Vector3<double> sptmin(pos[itmin_start * 3], pos[itmin_start * 3 + 1], pos[itmin_start * 3 + 2]);

for (int i = itmin_start; i < itmin_start + na[itmin_type]; ++i)
{
//set up the current test std::vector "gtrans"
Expand Down Expand Up @@ -1936,7 +1940,7 @@ void Symmetry::gtrans_convert(const ModuleBase::Vector3<double>* va, ModuleBase:
vb[i]=va[i]*a*bi;
}
}
void Symmetry::gmatrix_invmap(const ModuleBase::Matrix3* s, const int n, int* invmap)
void Symmetry::gmatrix_invmap(const ModuleBase::Matrix3* s, const int n, int* invmap) const
{
ModuleBase::Matrix3 eig(1, 0, 0, 0, 1, 0, 0, 0, 1);
ModuleBase::Matrix3 tmp;
Expand Down
Loading