99#include " LRI_CV.h"
1010#include " LRI_CV_Tools.h"
1111#include " exx_abfs-abfs_index.h"
12+ #include " exx_abfs-construct_orbs.h"
1213#include " RI_Util.h"
1314#include " ../../source_base/tool_title.h"
1415#include " ../../source_base/timer.h"
@@ -43,16 +44,22 @@ void LRI_CV<Tdata>::set_orbitals(
4344 const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> &abfs_in,
4445 const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> &abfs_ccp_in,
4546 const double &kmesh_times,
46- const double &ccp_rmesh_times_in)
47+ ORB_gaunt_table& MGT,
48+ const bool & init_MGT,
49+ const bool & init_C)
4750{
4851 ModuleBase::TITLE (" LRI_CV" , " set_orbitals" );
4952 ModuleBase::timer::tick (" LRI_CV" , " set_orbitals" );
5053
51- this ->orb_cutoff_ = orb.cutoffs ();
5254 this ->lcaos = lcaos_in;
5355 this ->abfs = abfs_in;
5456 this ->abfs_ccp = abfs_ccp_in;
55- this ->ccp_rmesh_times = ccp_rmesh_times_in;
57+
58+ this ->lcaos_rcut = Exx_Abfs::Construct_Orbs::get_Rcut (this ->lcaos );
59+ this ->abfs_ccp_rcut = Exx_Abfs::Construct_Orbs::get_Rcut (this ->abfs_ccp );
60+ const double lcaos_rmax = Exx_Abfs::Construct_Orbs::get_Rmax (this ->lcaos );
61+ const double abfs_ccp_rmax
62+ = Exx_Abfs::Construct_Orbs::get_Rmax (this ->abfs_ccp );
5663
5764 const ModuleBase::Element_Basis_Index::Range
5865 range_lcaos = Exx_Abfs::Abfs_Index::construct_range ( lcaos );
@@ -62,27 +69,50 @@ void LRI_CV<Tdata>::set_orbitals(
6269 range_abfs = Exx_Abfs::Abfs_Index::construct_range ( abfs );
6370 this ->index_abfs = ModuleBase::Element_Basis_Index::construct_index ( range_abfs );
6471
65- this ->m_abfs_abfs .init ( 2 , ucell,orb, kmesh_times, (1 +this ->ccp_rmesh_times )/2.0 );
66- this ->m_abfs_abfs .init_radial ( this ->abfs_ccp , this ->abfs );
67- this ->m_abfs_abfs .init_radial_table ();
68-
69- this ->m_abfslcaos_lcaos .init ( 1 , ucell , orb, kmesh_times, 1 );
70- this ->m_abfslcaos_lcaos .init_radial ( this ->abfs_ccp , this ->lcaos , this ->lcaos );
71- this ->m_abfslcaos_lcaos .init_radial_table ();
72+ int Lmax_v = std::numeric_limits<double >::min ();
73+ this ->m_abfs_abfs .init (2 , ucell, orb, kmesh_times, lcaos_rmax + abfs_ccp_rmax, Lmax_v);
74+ int Lmax_c = std::numeric_limits<double >::min ();
75+ if (init_C)
76+ this ->m_abfslcaos_lcaos .init (1 , ucell, orb, kmesh_times, lcaos_rmax, Lmax_c);
77+ int Lmax = std::max (Lmax_v, Lmax_c);
78+
79+ if (init_MGT) {
80+ MGT.init_Gaunt_CH (Lmax);
81+ MGT.init_Gaunt (Lmax);
82+ }
83+
84+ this ->m_abfs_abfs .init_radial (this ->abfs_ccp , this ->abfs , MGT);
85+ this ->m_abfs_abfs .init_radial_table ();
86+ if (init_C) {
87+ this ->m_abfslcaos_lcaos .init_radial (this ->abfs_ccp ,
88+ this ->lcaos ,
89+ this ->lcaos ,
90+ MGT);
91+ this ->m_abfslcaos_lcaos .init_radial_table ();
92+ }
7293
7394 ModuleBase::timer::tick (" LRI_CV" , " set_orbitals" );
7495}
7596
97+ template <typename Tdata>
98+ double LRI_CV<Tdata>::cal_V_Rcut(const int it0, const int it1) {
99+ return this ->abfs_ccp_rcut [it0] + this ->lcaos_rcut [it1];
100+ }
76101
102+ template <typename Tdata>
103+ double LRI_CV<Tdata>::cal_C_Rcut(const int it0, const int it1) {
104+ return std::min (this ->abfs_ccp_rcut [it0], this ->lcaos_rcut [it0])
105+ + this ->lcaos_rcut [it1];
106+ }
77107
78108template <typename Tdata> template <typename Tresult>
79109auto LRI_CV<Tdata>::cal_datas(
80110 const UnitCell &ucell,
81- const std::vector<TA> & list_A0,
82- const std::vector<TAC> & list_A1,
83- const std::map<std::string,bool > & flags,
84- const double &rmesh_times ,
85- const T_func_DPcal_data<Tresult> & func_DPcal_data)
111+ const std::vector<TA>& list_A0,
112+ const std::vector<TAC>& list_A1,
113+ const std::map<std::string, bool >& flags,
114+ const T_func_cal_Rcut& func_cal_Rcut ,
115+ const T_func_DPcal_data<Tresult>& func_DPcal_data)
86116-> std::map<TA,std::map<TAC,Tresult>>
87117{
88118 ModuleBase::TITLE (" LRI_CV" ," cal_datas" );
@@ -104,9 +134,8 @@ auto LRI_CV<Tdata>::cal_datas(
104134 const int ia1 = ucell.iat2ia [iat1];
105135 const ModuleBase::Vector3<double > tau0 = ucell.atoms [it0].tau [ia0];
106136 const ModuleBase::Vector3<double > tau1 = ucell.atoms [it1].tau [ia1];
107- const double Rcut = std::min (
108- orb_cutoff_[it0] * rmesh_times + orb_cutoff_[it1],
109- orb_cutoff_[it1] * rmesh_times + orb_cutoff_[it0]);
137+ const double Rcut
138+ = std::min (func_cal_Rcut (it0, it1), func_cal_Rcut (it1, it0));
110139 const Abfs::Vector3_Order<double > R_delta = -tau0+tau1+(RI_Util::array3_to_Vector3 (cell1)*ucell.latvec );
111140 if ( R_delta.norm ()*ucell.lat0 < Rcut )
112141 {
@@ -137,7 +166,12 @@ auto LRI_CV<Tdata>::cal_Vs(
137166 func_DPcal_V = std::bind (
138167 &LRI_CV<Tdata>::DPcal_V, this ,
139168 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4);
140- return this ->cal_datas (ucell,list_A0, list_A1, flags, this ->ccp_rmesh_times , func_DPcal_V);
169+ const T_func_cal_Rcut func_cal_Rcut = std::bind (&LRI_CV<Tdata>::cal_V_Rcut,
170+ this ,
171+ std::placeholders::_1,
172+ std::placeholders::_2);
173+
174+ return this ->cal_datas (ucell,list_A0, list_A1, flags, func_cal_Rcut, func_DPcal_V);
141175}
142176
143177template <typename Tdata>
@@ -153,7 +187,13 @@ auto LRI_CV<Tdata>::cal_dVs(
153187 func_DPcal_dV = std::bind (
154188 &LRI_CV<Tdata>::DPcal_dV, this ,
155189 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4);
156- return this ->cal_datas (ucell,list_A0, list_A1, flags, this ->ccp_rmesh_times , func_DPcal_dV);
190+
191+ const T_func_cal_Rcut func_cal_Rcut = std::bind (&LRI_CV<Tdata>::cal_V_Rcut,
192+ this ,
193+ std::placeholders::_1,
194+ std::placeholders::_2);
195+
196+ return this ->cal_datas (ucell,list_A0, list_A1, flags, func_cal_Rcut, func_DPcal_dV);
157197}
158198
159199template <typename Tdata>
@@ -171,8 +211,13 @@ auto LRI_CV<Tdata>::cal_Cs_dCs(
171211 func_DPcal_C_dC = std::bind (
172212 &LRI_CV<Tdata>::DPcal_C_dC, this ,
173213 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4);
214+ const T_func_cal_Rcut func_cal_Rcut = std::bind (&LRI_CV<Tdata>::cal_C_Rcut,
215+ this ,
216+ std::placeholders::_1,
217+ std::placeholders::_2);
218+
174219 std::map<TA,std::map<TAC, std::pair<RI::Tensor<Tdata>, std::array<RI::Tensor<Tdata>,3 >>>>
175- Cs_dCs_tmp = this ->cal_datas (ucell,list_A0, list_A1, flags, std::min ( 1.0 , this -> ccp_rmesh_times ) , func_DPcal_C_dC);
220+ Cs_dCs_tmp = this ->cal_datas (ucell,list_A0, list_A1, flags, func_cal_Rcut , func_DPcal_C_dC);
176221
177222 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Cs;
178223 std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3 >>> dCs;
0 commit comments