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