ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Matrix_Orbs11.hpp
Go to the documentation of this file.
1//=======================
2// AUTHOR : Peize Lin
3// DATE : 2022-08-17
4//=======================
5
6#ifndef MATRIX_ORB11_HPP
7#define MATRIX_ORB11_HPP
8
9#include "Matrix_Orbs11.h"
10#include "RI_Util.h"
11
12template<typename Tdata>
14 const size_t TA,
15 const size_t TB,
20 const Matrix_Order &matrix_order) const
21{
22 RI::Tensor<Tdata> m;
23 const double lat0 = *this->lat0;
24 const size_t sizeA = index_A[TA].count_size;
25 const size_t sizeB = index_B[TB].count_size;
26 switch(matrix_order)
27 {
28 case Matrix_Order::AB: m = RI::Tensor<Tdata>({sizeA, sizeB}); break;
29 case Matrix_Order::BA: m = RI::Tensor<Tdata>({sizeB, sizeA}); break;
30 default: throw std::invalid_argument(std::string(__FILE__)+" line "+std::to_string(__LINE__));
31 }
32
33 for( const auto &co3 : center2_orb11_s.at(TA).at(TB) )
34 {
35 const int LA = co3.first;
36 for( const auto &co4 : co3.second )
37 {
38 const size_t NA = co4.first;
39 for( size_t MA=0; MA!=2*LA+1; ++MA )
40 {
41 for( const auto &co5 : co4.second )
42 {
43 const int LB = co5.first;
44 for( const auto &co6 : co5.second )
45 {
46 const size_t NB = co6.first;
47 for( size_t MB=0; MB!=2*LB+1; ++MB )
48 {
49 const Tdata overlap = co6.second.cal_overlap( tauA*lat0, tauB*lat0, MA, MB );
50 const size_t iA = index_A[TA][LA][NA][MA];
51 const size_t iB = index_B[TB][LB][NB][MB];
52 switch(matrix_order)
53 {
54 case Matrix_Order::AB: m(iA,iB) = overlap; break;
55 case Matrix_Order::BA: m(iB,iA) = overlap; break;
56 default: throw std::invalid_argument(std::string(__FILE__)+" line "+std::to_string(__LINE__));
57 }
58 }
59 }
60 }
61 }
62 }
63 }
64 return m;
65}
66
67template<typename Tdata>
68std::array<RI::Tensor<Tdata>,3> Matrix_Orbs11::cal_grad_overlap_matrix(
69 const size_t TA,
70 const size_t TB,
75 const Matrix_Order &matrix_order) const
76{
77 std::array<RI::Tensor<Tdata>,3> m;
78 const double lat0 = *this->lat0;
79 const size_t sizeA = index_A[TA].count_size;
80 const size_t sizeB = index_B[TB].count_size;
81 for(int i=0; i<m.size(); ++i)
82 {
83 switch(matrix_order)
84 {
85 case Matrix_Order::AB: m[i] = RI::Tensor<Tdata>({sizeA, sizeB}); break;
86 case Matrix_Order::BA: m[i] = RI::Tensor<Tdata>({sizeB, sizeA}); break;
87 default: throw std::invalid_argument(std::string(__FILE__)+" line "+std::to_string(__LINE__));
88 }
89 }
90
91 for( const auto &co3 : center2_orb11_s.at(TA).at(TB) )
92 {
93 const int LA = co3.first;
94 for( const auto &co4 : co3.second )
95 {
96 const size_t NA = co4.first;
97 for( size_t MA=0; MA!=2*LA+1; ++MA )
98 {
99 for( const auto &co5 : co4.second )
100 {
101 const int LB = co5.first;
102 for( const auto &co6 : co5.second )
103 {
104 const size_t NB = co6.first;
105 for( size_t MB=0; MB!=2*LB+1; ++MB )
106 {
107 const std::array<double,3> grad_overlap = RI_Util::Vector3_to_array3(co6.second.cal_grad_overlap( tauA*lat0, tauB*lat0, MA, MB ));
108 const size_t iA = index_A[TA][LA][NA][MA];
109 const size_t iB = index_B[TB][LB][NB][MB];
110 for(size_t i=0; i<m.size(); ++i)
111 {
112 switch(matrix_order)
113 {
114 case Matrix_Order::AB: m[i](iA,iB) = grad_overlap[i]; break;
115 case Matrix_Order::BA: m[i](iB,iA) = grad_overlap[i]; break;
116 default: throw std::invalid_argument(std::string(__FILE__)+" line "+std::to_string(__LINE__));
117 }
118 }
119 }
120 }
121 }
122 }
123 }
124 }
125 return m;
126}
127
128template <typename Tdata>
129std::map<size_t,std::map<size_t,std::map<size_t,std::map<size_t,RI::Tensor<Tdata>>>>> Matrix_Orbs11::cal_overlap_matrix_all(
130 const UnitCell &ucell,
132 const ModuleBase::Element_Basis_Index::IndexLNM &index_c ) const
133{
134 ModuleBase::TITLE("Matrix_Orbs11","cal_overlap_matrix");
135
136 std::map<size_t,std::map<size_t,std::map<size_t,std::map<size_t,RI::Tensor<Tdata>>>>> matrixes;
137
138 for( const auto &co1 : center2_orb11_s )
139 {
140 const size_t TA = co1.first;
141 for (size_t IA=0; IA!=ucell.atoms[TA].na; ++IA)
142 {
143 const ModuleBase::Vector3<double> &tauA( ucell.atoms[TA].tau[IA] );
144
145 for( const auto &co2 : co1.second )
146 {
147 const size_t TB = co2.first;
148 for (size_t IB=0; IB!=ucell.atoms[TB].na; ++IB)
149 {
150 const ModuleBase::Vector3<double> &tauB( ucell.atoms[TB].tau[IB] );
151
152 matrixes[TA][IA][TB][IB] = cal_overlap_matrix<Tdata>( TA, TB, tauA, tauB, index_r, index_c, Matrix_Order::AB );
153 }
154 }
155 }
156 }
157 return matrixes;
158}
159
160#endif
const std::complex< double > i
Definition cal_pLpR.cpp:46
int na
Definition atom_spec.h:27
std::vector< ModuleBase::Vector3< double > > tau
Definition atom_spec.h:35
std::map< size_t, std::map< size_t, std::map< int, std::map< size_t, std::map< int, std::map< size_t, Center2_Orb::Orb11 > > > > > > center2_orb11_s
Definition Matrix_Orbs11.h:77
std::map< size_t, std::map< size_t, std::map< size_t, std::map< size_t, RI::Tensor< Tdata > > > > > cal_overlap_matrix_all(const UnitCell &ucell, const ModuleBase::Element_Basis_Index::IndexLNM &index_r, const ModuleBase::Element_Basis_Index::IndexLNM &index_c) const
Definition Matrix_Orbs11.hpp:129
RI::Tensor< Tdata > cal_overlap_matrix(const size_t TA, const size_t TB, const ModuleBase::Vector3< double > &tauA, const ModuleBase::Vector3< double > &tauB, const ModuleBase::Element_Basis_Index::IndexLNM &index_A, const ModuleBase::Element_Basis_Index::IndexLNM &index_B, const Matrix_Order &matrix_order) const
Definition Matrix_Orbs11.hpp:13
std::array< RI::Tensor< Tdata >, 3 > cal_grad_overlap_matrix(const size_t TA, const size_t TB, const ModuleBase::Vector3< double > &tauA, const ModuleBase::Vector3< double > &tauB, const ModuleBase::Element_Basis_Index::IndexLNM &index_A, const ModuleBase::Element_Basis_Index::IndexLNM &index_B, const Matrix_Order &matrix_order) const
Definition Matrix_Orbs11.hpp:68
double * lat0
Definition Matrix_Orbs11.h:69
Matrix_Order
Definition Matrix_Orbs11.h:35
3 elements vector
Definition vector3.h:24
Definition unitcell.h:15
Atom * atoms
Definition unitcell.h:45
std::vector< Index_T > IndexLNM
Definition element_basis_index.h:42
void TITLE(const std::string &class_name, const std::string &function_name, const bool disable)
Definition tool_title.cpp:18
std::array< Tcell, 3 > Vector3_to_array3(const ModuleBase::Vector3< Tcell > &v)
Definition RI_Util.h:32