17template <
typename T,
typename Tdata>
22 this->mpi_comm = mpi_comm_in;
23 this->orb_cutoff_ = orb_cutoff;
32template <
typename T,
typename Tdata>
35 std::vector<TA> atoms(ucell.
nat);
36 for (
int iat = 0; iat < ucell.
nat; ++iat)
40 const std::array<Tcell, Ndim> period = {p_kv->nmp[0], p_kv->nmp[1], p_kv->nmp[2]};
42 const std::array<Tcell, Ndim> period_Vs = LRI_CV_Tools::cal_latvec_range<Tcell>(1 + this->info.ccp_rmesh_times, ucell,orb_cutoff_);
43 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, std::array<Tcell, Ndim>>>>> list_As_Vs
44 = RI::Distribute_Equally::distribute_atoms(this->mpi_comm, atoms, period_Vs, 2,
false);
50 {
"writable_Vws", true}
52 this->Vs_period = RI::RI_Tools::cal_period(Vs, period);
54 const std::array<Tcell, Ndim> period_Cs = LRI_CV_Tools::cal_latvec_range<Tcell>(2, ucell,orb_cutoff_);
55 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, std::array<Tcell, Ndim>>>>> list_As_Cs
56 = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Cs, 2,
false);
58 std::pair<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>,
59 std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>>>
65 {
"writable_Cws", true },
66 {
"writable_dCws", true },
67 {
"writable_Vws", false},
68 {
"writable_dVws", false}
70 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>& Cs = std::get<0>(Cs_dCs);
71 this->Cs_period = RI::RI_Tools::cal_period(Cs, period);
72 this->Cs_period =
exx_lri_rpa.exx_lri.post_2D.set_tensors_map2(this->Cs_period);
75template <
typename T,
typename Tdata>
77 const MPI_Comm& mpi_comm_in,
84 if (exx_spacegroup_symmetry)
91 if (exx_spacegroup_symmetry)
96 Rs, period, ucell.
lat);
107 const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>
119 {
"singularity_correction",
"spencer"} }};
132template <
typename T,
typename Tdata>
139 this->out_bands(pelec);
140 this->out_eigen_vector(parav,
psi);
141 this->out_struc(ucell);
143 this->cal_rpa_cv(ucell);
144 std::cout <<
"rpa_pca_threshold: " << this->info.pca_threshold << std::endl;
145 std::cout <<
"rpa_ccp_rmesh_times: " << this->info.ccp_rmesh_times << std::endl;
146 std::cout <<
"rpa_lcao_exx(Ha): " << std::fixed << std::setprecision(15) <<
exx_lri_rpa.Eexx / 2.0 << std::endl;
148 this->out_coulomb_k(ucell);
150 std::cout <<
"etxc(Ha): " << std::fixed << std::setprecision(15) << pelec->
f_en.
etxc / 2.0 << std::endl;
151 std::cout <<
"etot(Ha): " << std::fixed << std::setprecision(15) << pelec->
f_en.
etot / 2.0 << std::endl;
152 std::cout <<
"Etot_without_rpa(Ha): " << std::fixed << std::setprecision(15)
158template <
typename T,
typename Tdata>
164 const int nks_tot =
PARAM.
inp.
nspin == 2 ? p_kv->get_nks() / 2 : p_kv->get_nks();
166 const std::complex<double>
zero(0.0, 0.0);
168 for (
int ik = 0; ik < nks_tot; ik++)
170 std::stringstream ss;
171 ss <<
"KS_eigenvector_" << ik <<
".dat";
176 ofs.open(ss.str().c_str(), std::ios::out);
178 std::vector<ModuleBase::ComplexMatrix> is_wfc_ib_iw(npsin_tmp);
179 for (
int is = 0; is < npsin_tmp; is++)
182 for (
int ib_global = 0; ib_global <
PARAM.
inp.
nbands; ++ib_global)
190 for (
int ir = 0; ir <
psi.get_nbasis(); ir++)
196 std::vector<std::complex<double>> tmp = wfc_iks;
198 MPI_Allreduce(&tmp[0], &wfc_iks[0],
PARAM.
globalv.
nlocal, MPI_DOUBLE_COMPLEX, MPI_SUM, MPI_COMM_WORLD);
202 is_wfc_ib_iw[is](ib_global, iw) = wfc_iks[iw];
206 ofs << ik + 1 << std::endl;
211 for (
int is = 0; is < npsin_tmp; is++)
213 ofs << std::setw(21) << std::fixed << std::setprecision(15) << is_wfc_ib_iw[is](ib, iw).real()
214 << std::setw(21) << std::fixed << std::setprecision(15) << is_wfc_ib_iw[is](ib, iw).imag()
224template <
typename T,
typename Tdata>
233 const int nks_tot =
PARAM.
inp.
nspin == 2 ? (int)p_kv->get_nkstot() / 2 : p_kv->get_nkstot();
234 const int nks_tot_full = p_kv->get_nkstot_full();
235 const int natom = ucell.
nat;
238 std::stringstream ss;
241 ofs.open(ss.str().c_str(), std::ios::out);
242 ofs << std::fixed << std::setprecision(9) << lat.
e11 << std::setw(15) << lat.
e12 << std::setw(15) << lat.
e13 << std::endl;
243 ofs << lat.
e21 << std::setw(15) << lat.
e22 << std::setw(15) << lat.
e23 << std::endl;
244 ofs << lat.
e31 << std::setw(15) << lat.
e32 << std::setw(15) << lat.
e33 << std::endl;
246 ofs << G_RPA.
e11 << std::setw(15) << G_RPA.
e12 << std::setw(15) << G_RPA.
e13 << std::endl;
247 ofs << G_RPA.
e21 << std::setw(15) << G_RPA.
e22 << std::setw(15) << G_RPA.
e23 << std::endl;
248 ofs << G_RPA.
e31 << std::setw(15) << G_RPA.
e32 << std::setw(15) << G_RPA.
e33 << std::endl;
250 ofs << natom << std::endl;
251 for(
int iat=0; iat < natom; ++iat) {
252 int it = ucell.
iat2it[iat];
254 ofs << atom_pos.
x << std::setw(15) << atom_pos.
y << std::setw(15) << atom_pos.
z << std::setw(15) << (it + 1) << std::endl;
257 ofs << p_kv->nmp[0] << std::setw(6) << p_kv->nmp[1] << std::setw(6) << p_kv->nmp[2] << std::setw(6) << std::endl;
259 for (
int ik = 0; ik != nks_tot; ik++)
261 ofs << std::setw(15) << p_kv->kvec_c[ik].x * TWOPI_Bohr2A << std::setw(15)
262 << p_kv->kvec_c[ik].y * TWOPI_Bohr2A << std::setw(15) << p_kv->kvec_c[ik].z * TWOPI_Bohr2A << std::endl;
265 for (
int ik = 0; ik != nks_tot_full; ++ik){
266 ofs << (p_kv->ibz_index[ik] + 1) << std::endl;
273template <
typename T,
typename Tdata>
281 const int nks_tot =
PARAM.
inp.
nspin == 2 ? (int)p_kv->get_nks() / 2 : p_kv->get_nks();
283 std::stringstream ss;
286 ofs.open(ss.str().c_str(), std::ios::out);
287 ofs << nks_tot << std::endl;
291 ofs << (pelec->
eferm.
ef / 2.0) << std::endl;
293 for (
int ik = 0; ik != nks_tot; ik++)
295 for (
int is = 0; is != nspin_tmp; is++)
297 ofs << std::setw(6) << ik + 1 << std::setw(6) << is + 1 << std::endl;
300 ofs << std::setw(5) << ib + 1 <<
" " << std::setw(8) << pelec->
wg(ik + is * nks_tot, ib) * nks_tot
301 << std::setw(18) << std::fixed << std::setprecision(8) << pelec->
ekb(ik + is * nks_tot, ib) / 2.0
302 << std::setw(18) << std::fixed << std::setprecision(8)
311template <
typename T,
typename Tdata>
314 std::stringstream ss;
317 ofs.open(ss.str().c_str(), std::ios::out);
318 ofs << ucell.
nat <<
" " << 0 << std::endl;
319 for (
auto& Ip: this->Cs_period)
323 for (
auto& JPp: Ip.second)
325 size_t J = JPp.first.first;
326 auto R = JPp.first.second;
327 auto& tmp_Cs = JPp.second;
330 ofs << I + 1 <<
" " << J + 1 <<
" " << R[0] <<
" " << R[1] <<
" " << R[2] <<
" " << i_num
332 ofs << j_num <<
" " << tmp_Cs.shape[0] << std::endl;
333 for (
int i = 0; i != i_num; i++)
335 for (
int j = 0; j != j_num; j++)
337 for (
int mu = 0; mu != tmp_Cs.shape[0]; mu++)
339 ofs << std::setw(15) << std::fixed << std::setprecision(9) << tmp_Cs(mu, i, j) << std::endl;
349template <
typename T,
typename Tdata>
353 vector<int> mu_shift(ucell.
nat);
354 for (
int I = 0; I != ucell.
nat; I++)
356 mu_shift[I] = all_mu;
359 const int nks_tot =
PARAM.
inp.
nspin == 2 ? (int)p_kv->get_nks() / 2 : p_kv->get_nks();
360 std::stringstream ss;
364 ofs.open(ss.str().c_str(), std::ios::out);
366 ofs << nks_tot << std::endl;
367 for (
auto& Ip: this->Vs_period)
372 for (
int ik = 0; ik != nks_tot; ik++)
374 std::map<size_t, RI::Tensor<std::complex<double>>> Vq_k_IJ;
375 for (
auto& JPp: Ip.second)
377 auto J = JPp.first.first;
379 auto R = JPp.first.second;
384 RI::Tensor<std::complex<double>> tmp_VR = RI::Global_Func::convert<std::complex<double>>(JPp.second);
388 const std::complex<double> kphase = std::complex<double>(cos(arg), sin(arg));
389 if (Vq_k_IJ[J].empty())
391 Vq_k_IJ[J] = RI::Tensor<std::complex<double>>({tmp_VR.shape[0], tmp_VR.shape[1]});
393 Vq_k_IJ[J] = Vq_k_IJ[J] + tmp_VR * kphase;
395 for (
auto& vq_Jp: Vq_k_IJ)
397 auto iJ = vq_Jp.first;
398 auto& vq_J = vq_Jp.second;
400 ofs << all_mu <<
" " << mu_shift[I] + 1 <<
" " << mu_shift[I] + mu_num <<
" " << mu_shift[iJ] + 1
401 <<
" " << mu_shift[iJ] + nu_num << std::endl;
402 ofs << ik + 1 <<
" " << std::fixed << std::setprecision(12) << p_kv->wk[ik] / 2.0 *
PARAM.
inp.
nspin << std::endl;
403 for (
int i = 0; i != vq_J.data->size(); i++)
405 ofs << std::setw(21) << (*vq_J.data)[i].real()
406 << std::setw(21) << (*vq_J.data)[i].imag() << std::endl;
Exx_LRI< double > exx_lri_rpa(GlobalC::exx_info.info_ri)
int nw
Definition atom_spec.h:23
std::vector< ModuleBase::Vector3< double > > tau
Definition atom_spec.h:36
int get_nkstot_full() const
Definition klist.h:78
int get_nks() const
Definition klist.h:68
Definition Mix_DMk_2D.h:17
std::vector< const std::vector< std::complex< double > > * > get_DMk_k_out() const
Returns the complex density matrix.
Definition Mix_DMk_2D.cpp:66
Mix_DMk_2D & set_mixing(Base_Mixing::Mixing *mixing_in)
Sets the mixing mode.
Definition Mix_DMk_2D.cpp:20
void mix(const std::vector< std::vector< double > > &dm, const bool flag_restart)
Mixes the double density matrix.
Definition Mix_DMk_2D.cpp:44
std::vector< const std::vector< double > * > get_DMk_gamma_out() const
Returns the double density matrix.
Definition Mix_DMk_2D.cpp:59
Mix_DMk_2D & set_nks(const int nks, const bool gamma_only_in)
Sets the number of k-points and gamma_only flag.
Definition Mix_DMk_2D.cpp:9
3x3 matrix and related mathamatical operations
Definition matrix3.h:19
double e13
Definition matrix3.h:26
double e31
Definition matrix3.h:26
double e11
element e_ij: i_row, j_column
Definition matrix3.h:26
double e33
Definition matrix3.h:26
double e32
Definition matrix3.h:26
double e21
Definition matrix3.h:26
double e12
Definition matrix3.h:26
double e23
Definition matrix3.h:26
double e22
Definition matrix3.h:26
3 elements vector
Definition vector3.h:22
T x
Definition vector3.h:24
T y
Definition vector3.h:25
T z
Definition vector3.h:26
static void tick(const std::string &class_name_in, const std::string &name_in)
Use twice at a time: the first time, set start_flag to false; the second time, calculate the time dur...
Definition timer.cpp:57
Definition symmetry_rotation.h:16
void set_abfs_Lmax(const int l)
Definition symmetry_rotation.h:44
std::vector< std::vector< std::complex< double > > > restore_dm(const K_Vectors &kv, const std::vector< std::vector< std::complex< double > > > &dm_k_ibz, const Parallel_2D &pv) const
Definition symmetry_rotation.cpp:80
void cal_Ms(const K_Vectors &kv, const UnitCell &ucell, const Parallel_2D &pv)
functions to contruct rotation matrix in AO-representation
Definition symmetry_rotation.cpp:21
void find_irreducible_sector(const Symmetry &symm, const Atom *atoms, const Statistics &st, const std::vector< TC > &Rs, const TC &period, const Lattice &lat)
Definition symmetry_rotation.h:39
static int symm_flag
Definition symmetry.h:30
int local2global_row(const int ilr) const
get the global index of a local index (row)
Definition parallel_2d.h:57
int global2local_col(const int igc) const
get the local index of a global index (col)
Definition parallel_2d.h:51
Definition parallel_orbitals.h:9
const Input_para & inp
Definition parameter.h:26
const System_para & globalv
Definition parameter.h:30
void cal_postSCF_exx(const elecstate::DensityMatrix< T, Tdata > &dm, const MPI_Comm &mpi_comm_in, const UnitCell &ucell, const K_Vectors &kv, const LCAO_Orbitals &orb)
Definition RPA_LRI.hpp:76
void out_coulomb_k(const UnitCell &ucell)
Definition RPA_LRI.hpp:350
void out_Cs(const UnitCell &ucell)
Definition RPA_LRI.hpp:312
void out_bands(const elecstate::ElecState *pelec)
Definition RPA_LRI.hpp:274
void out_struc(const UnitCell &ucell)
Definition RPA_LRI.hpp:225
void out_for_RPA(const UnitCell &ucell, const Parallel_Orbitals ¶v, const psi::Psi< T > &psi, const elecstate::ElecState *pelec)
Definition RPA_LRI.hpp:133
void cal_rpa_cv(const UnitCell &ucell)
Definition RPA_LRI.hpp:33
void out_eigen_vector(const Parallel_Orbitals ¶v, const psi::Psi< T > &psi)
Definition RPA_LRI.hpp:159
void init(const MPI_Comm &mpi_comm_in, const K_Vectors &kv_in, const std::vector< double > &orb_cutoff)
Definition RPA_LRI.hpp:18
int *& iat2it
Definition unitcell.h:47
Atom * atoms
Definition unitcell.h:18
ModuleBase::Matrix3 & latvec
Definition unitcell.h:35
Lattice lat
Definition unitcell.h:25
int lmax
Definition unitcell.h:185
ModuleSymmetry::Symmetry symm
Definition unitcell.h:55
int & nat
Definition unitcell.h:46
int *& iat2ia
Definition unitcell.h:48
Statistics st
Definition unitcell.h:44
ModuleBase::Matrix3 & G
Definition unitcell.h:39
Definition density_matrix.h:36
const std::vector< std::vector< TK > > & get_DMK_vector() const
get pointer vector of DMK
Definition density_matrix.h:161
const Parallel_Orbitals * get_paraV_pointer() const
get pointer of paraV
Definition density_matrix.h:173
Definition elecstate.h:15
fenergy f_en
energies contribute to the total free energy
Definition elecstate.h:157
ModuleBase::matrix wg
occupation weight for each k-point and band
Definition elecstate.h:167
efermi eferm
fermi energies
Definition elecstate.h:158
ModuleBase::matrix ekb
band energy at each k point, each band.
Definition elecstate.h:166
Exx_Info exx_info
Definition test_xc.cpp:29
int MY_RANK
global index of process
Definition global_variable.cpp:21
const double TWO_PI
Definition constants.h:21
const double BOHR_TO_A
Definition constants.h:55
const double Ry_to_eV
Definition constants.h:81
void TITLE(const std::string &class_name, const std::string &function_name, const bool disable)
Definition tool_title.cpp:18
void print_symrot_info_k(const ModuleSymmetry::Symmetry_rotation &symrot, const K_Vectors &kv, const UnitCell &ucell)
Definition symmetry_rotation_output.cpp:54
void print_symrot_info_R(const Symmetry_rotation &symrot, const Symmetry &symm, const int lmax_ao, const std::vector< TC > &Rs)
Definition symmetry_rotation_output.cpp:14
std::array< int, 3 > get_Born_vonKarmen_period(const K_Vectors &kv)
Definition RI_Util.hpp:16
std::vector< std::array< Tcell, Ndim > > get_Born_von_Karmen_cells(const std::array< Tcell, Ndim > &Born_von_Karman_period)
Definition RI_Util.hpp:34
ModuleBase::Vector3< Tcell > array3_to_Vector3(const std::array< Tcell, 3 > &v)
Definition RI_Util.h:38
Parameter PARAM
Definition parameter.cpp:3
std::map< Conv_Coulomb_Pot_K::Coulomb_Type, std::vector< std::map< std::string, std::string > > > coulomb_param
Definition exx_info.h:17
double hybrid_alpha
Definition exx_info.h:31
Conv_Coulomb_Pot_K::Ccp_Type ccp_type
Definition exx_info.h:30
double ccp_rmesh_times
Definition exx_info.h:67
Exx_Info_Global info_global
Definition exx_info.h:38
Exx_Info_RI info_ri
Definition exx_info.h:78
int nlocal
total number of local basis.
Definition system_parameter.h:23
bool gamma_only_local
Definition system_parameter.h:38
double ef
Fermi energy.
Definition fp_energy.h:64
double etot
the total free energy
Definition fp_energy.h:18
double etxc
E_xc[n(r)] exchange and correlation energy.
Definition fp_energy.h:24
const std::map< std::string, std::vector< double > > zero
Definition vdwd3_autoset_xcparam.cpp:323