diff --git a/include/RI/physics/GW.h b/include/RI/physics/GW.h new file mode 100644 index 0000000..00643e7 --- /dev/null +++ b/include/RI/physics/GW.h @@ -0,0 +1,69 @@ +// =================== +// Author: Minye Zhang, almost completely copied from Exx.h +// date: 2022.12.18 +// =================== + +#pragma once + +// #include "Exx_Post_2D.h" +#include "../global/Global_Func-2.h" +#include "../global/Tensor.h" +#include "../ri/LRI.h" + +#include +#include +#include + +namespace RI +{ + +//! class to compute the correlation self-energy in G0W0 approximation by space-time method +template +class G0W0 +{ +public: + using TC = std::array; + using TAC = std::pair; + using Tdata_real = Global_Func::To_Real_t; + constexpr static std::size_t Npos = Ndim; // tmp + using Tatom_pos = std::array; // tmp + + void set_parallel( + const MPI_Comm &mpi_comm, + const std::map &atoms_pos, + const std::array &latvec, + const std::array &period); + + void set_Cs( + const std::map>> &Cs, + const Tdata_real &threshold_C); + void set_csm_threshold( + const Tdata_real &threshold) { this->lri.csm.set_threshold(threshold); } + + void cal_Sigc( + const std::map>> gf_tau, + const Tdata_real &threshold_G, + const std::map>> Wc_tau, + const Tdata_real &threshold_W); + + std::map>> Sigc_tau; + +public: + LRI lri; + + struct Flag_Finish + { + bool stru=false; + bool C=false; + }; + Flag_Finish flag_finish; + + MPI_Comm mpi_comm; + std::map atoms_pos; + std::array latvec; + std::array period; +}; + +} + +#include "GW.hpp" \ No newline at end of file diff --git a/include/RI/physics/GW.hpp b/include/RI/physics/GW.hpp new file mode 100644 index 0000000..1d6cac9 --- /dev/null +++ b/include/RI/physics/GW.hpp @@ -0,0 +1,71 @@ +// =================== +// Author: Minye Zhang, almost completely copied from Exx.hpp +// date: 2022.12.18 +// =================== +#pragma once + +#include "GW.h" +#include "../ri/Label.h" + +namespace RI +{ + +template +void G0W0::set_parallel( + const MPI_Comm &mpi_comm_in, + const std::map &atoms_pos_in, + const std::array &latvec_in, + const std::array &period_in) +{ + this->mpi_comm = mpi_comm_in; + this->atoms_pos = atoms_pos_in; + this->latvec = latvec_in; + this->period = period_in; + + this->lri.set_parallel(this->mpi_comm, this->atoms_pos, this->latvec, this->period); + this->flag_finish.stru = true; + //if() + // this->post_2D.set_parallel(this->mpi_comm, this->atoms_pos, this->period); +} + +template +void G0W0::set_Cs( + const std::map>> &Cs, + const Tdata_real &threshold_C) +{ + this->lri.set_tensors_map2( Cs, Label::ab::a, threshold_C ); + this->lri.set_tensors_map2( Cs, Label::ab::b, threshold_C ); + this->flag_finish.C = true; +} + + +template +void G0W0::cal_Sigc( + const std::map>> gf_tau, + const Tdata_real &threshold_G, + const std::map>> Wc_tau, + const Tdata_real &threshold_W) +{ + assert(this->flag_finish.stru); + assert(this->flag_finish.C); + // setup Green's function + this->lri.set_tensors_map2( gf_tau, Label::ab::a1b1, threshold_G ); + this->lri.set_tensors_map2( gf_tau, Label::ab::a1b2, threshold_G ); + this->lri.set_tensors_map2( gf_tau, Label::ab::a2b1, threshold_G ); + this->lri.set_tensors_map2( gf_tau, Label::ab::a2b2, threshold_G ); + + // setup screened Coulomb interaction + this->lri.set_tensors_map2( Wc_tau, Label::ab::a0b0, threshold_W ); + + std::vector>>> Sigc_vec(1); + this->lri.coefficients = {nullptr}; + this->lri.cal( + {Label::ab_ab::a0b0_a1b1, + Label::ab_ab::a0b0_a1b2, + Label::ab_ab::a0b0_a2b1, + Label::ab_ab::a0b0_a2b2}, + Sigc_vec); + this->Sigc_tau = std::move(Sigc_vec[0]); +} + +} // namespace RI \ No newline at end of file diff --git a/unittests/physics/GW-test.hpp b/unittests/physics/GW-test.hpp new file mode 100644 index 0000000..336ce8a --- /dev/null +++ b/unittests/physics/GW-test.hpp @@ -0,0 +1,27 @@ +// =================== +// Author: Minye Zhang, almost copied from Exx-test.hpp +// date: 2022.06.02 +// =================== + +#pragma once + +#include "RI/physics/GW.h" +// #include + +namespace GW_Test +{ + template + void main(int argc, char *argv[]) + { + int mpi_init_provide; + MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &mpi_init_provide); + + RI::G0W0 g0w0; + g0w0.set_parallel(MPI_COMM_WORLD, {{1,{0}},{2,{4}}}, {}, {1}); + g0w0.set_csm_threshold(1E-4); + g0w0.set_Cs({}, 1E-4); + g0w0.cal_Sigc({}, 1E-4, {}, 1E-4); + + MPI_Finalize(); + } +} \ No newline at end of file