ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
dftu_nao_pots.h
Go to the documentation of this file.
1#ifndef DFTU_LCAO_POTS_H
2#define DFTU_LCAO_POTS_H
3
4#include <cmath>
5#include <complex>
6#include <vector>
7
8class Plus_U_Base;
9class UnitCell;
11
12namespace DFTU_LCAO {
13
27void cal_pot_onsite(const std::vector<double>& occ, const int m_size, const double u_value,
28 double* pot_onsite, double& eu);
29
40template <typename TR>
41void transfer_pot_onsite(const std::vector<double>& pot_onsite_tmp,
42 std::vector<TR>& pot_onsite)
43{
44 pot_onsite.resize(pot_onsite_tmp.size());
45 for (int i = 0; i < static_cast<int>(pot_onsite_tmp.size()); i++)
46 {
47 pot_onsite[i] = static_cast<TR>(pot_onsite_tmp[i]);
48 }
49}
50
51template <>
52inline void transfer_pot_onsite<std::complex<double>>(const std::vector<double>& pot_onsite_tmp,
53 std::vector<std::complex<double>>& pot_onsite)
54{
55 const int m_size = int(sqrt(pot_onsite_tmp.size()) / 2);
56 const int m_size2 = m_size * m_size;
57 pot_onsite.resize(pot_onsite_tmp.size());
58 for (int m1 = 0; m1 < m_size; m1++)
59 {
60 for (int m2 = 0; m2 < m_size; m2++)
61 {
62 int index[4];
63 index[0] = m1 * m_size + m2;
64 index[1] = m1 * m_size + m2 + m_size2;
65 index[2] = m2 * m_size + m1 + m_size2 * 2;
66 index[3] = m2 * m_size + m1 + m_size2 * 3;
67 pot_onsite[index[0]] = 0.5 * (pot_onsite_tmp[index[0]] + pot_onsite_tmp[index[3]]);
68 pot_onsite[index[3]] = 0.5 * (pot_onsite_tmp[index[0]] - pot_onsite_tmp[index[3]]);
69 pot_onsite[index[1]] = 0.5 * (pot_onsite_tmp[index[1]] - std::complex<double>(0.0, 1.0) * pot_onsite_tmp[index[2]]);
70 pot_onsite[index[2]] = 0.5 * (pot_onsite_tmp[index[1]] + std::complex<double>(0.0, 1.0) * pot_onsite_tmp[index[2]]);
71 }
72 }
73}
74
91double get_onsite_pot(const Plus_U_Base& dftu,
92 const int T,
93 const int iat,
94 const int L,
95 const int spin,
96 const int m0,
97 const int m1,
98 const bool new_occ_mat);
99
113template <typename T>
115 const UnitCell& ucell,
116 const Parallel_Orbitals* pv,
117 const int spin,
118 const bool new_occ_mat,
119 T* pot_onsite);
120
121// Explicit instantiations
122extern template void cal_pot_onsite<double>(const Plus_U_Base& dftu,
123 const UnitCell& ucell,
124 const Parallel_Orbitals* pv,
125 const int spin,
126 const bool new_occ_mat,
127 double* pot_onsite);
129 const UnitCell& ucell,
130 const Parallel_Orbitals* pv,
131 const int spin,
132 const bool new_occ_mat,
133 std::complex<double>* pot_onsite);
134
139
149template <typename T>
151 const UnitCell& ucell,
152 const Parallel_Orbitals* pv,
153 const int spin,
154 T* pot_uterm,
155 const T* sk);
156
157// Explicit instantiations
159 const UnitCell& ucell,
160 const Parallel_Orbitals* pv,
161 const int spin,
162 double* pot_uterm,
163 const double* sk);
165 const UnitCell& ucell,
166 const Parallel_Orbitals* pv,
167 const int spin,
168 std::complex<double>* pot_uterm,
169 const std::complex<double>* sk);
170
171} // namespace DFTU_LCAO
172
173#endif
Definition parallel_orbitals.h:16
Definition dftu_base.h:21
Provide the basic information about unitcell.
Definition unitcell.h:16
#define T
Definition exp.cpp:237
Definition dftu_nao_adj.cpp:14
template void cal_pot_onsite< double >(const Plus_U_Base &dftu, const UnitCell &ucell, const Parallel_Orbitals *pv, const int spin, const bool new_occ_mat, double *pot_onsite)
void cal_pot_uterm(Plus_U_Base &dftu, const UnitCell &ucell, const Parallel_Orbitals *pv, const int spin, T *pot_uterm, const T *sk)
Compute the LCAO-basis U-term effective potential matrix.
Definition dftu_nao_pots.cpp:138
void transfer_pot_onsite(const std::vector< double > &pot_onsite_tmp, std::vector< TR > &pot_onsite)
transfer pot_onsite format from Pauli matrix storage to the target matrix-element type used by the Ha...
Definition dftu_nao_pots.h:41
double get_onsite_pot(const Plus_U_Base &dftu, const int T, const int iat, const int L, const int spin, const int m0, const int m1, const bool new_occ_mat)
one-body effective onsite potential element for a given (m0,m1) pair.
Definition dftu_nao_pots.cpp:205
void cal_pot_onsite(const std::vector< double > &occ, const int m_size, const double u_value, double *pot_onsite, double &eu)
On-site potential and Hubbard energy for one correlated shell: pot_onsite(m,m') = U_eff * (0....
Definition dftu_nao_pots.cpp:16
template void cal_pot_uterm< double >(Plus_U_Base &dftu, const UnitCell &ucell, const Parallel_Orbitals *pv, const int spin, double *pot_uterm, const double *sk)
Plus_U_Base dftu
Definition test_dftu_nao_op.cpp:11