1#ifndef ABACUS_SOURCE_LCAO_MODULE_LR_CAL_HS_GRAD_H
2#define ABACUS_SOURCE_LCAO_MODULE_LR_CAL_HS_GRAD_H
14 std::vector<bool> is_adj(adjs.
adj_num + 1,
false);
15 for (
int ad = 0;ad < adjs.
adj_num + 1;++ad)
17 const int it0 = ucell.
iat2it[iat0];
18 const int it1 = adjs.
ntype[ad];
19 const int ia1 = adjs.
natom[ad];
20 const int iat1 = ucell.
itia2iat(it1,ia1);
36 for (
int iat0 = 0;iat0 < ucell.
nat; ++iat0)
38 const int it0 = ucell.
iat2it[iat0];
39 const int ia0 = ucell.
iat2ia[iat0];
44 for (
int ad = 0;ad < adjs.
adj_num + 1;++ad)
46 const int it1 = adjs.
ntype[ad];
47 const int ia1 = adjs.
natom[ad];
48 const int iat1 = ucell.
itia2iat(it1, ia1);
61inline std::vector<hamilt::HContainer<double>>
cal_hs_grad(
const char job,
67 if(job !=
'S' && job !=
'T')
69 throw std::invalid_argument(
"job must be 'S' or 'T'");
75 std::vector<double> tmp_deriv(3);
78 for (
int ixyz = 0;ixyz < 3;++ixyz)
81 std::vector<int> ijr_info = dHS.at(ixyz).get_ijr_info();
83 std::vector<int>::iterator it = ijr_info.begin();
84 const int npairs = *it++;
86 while (it != ijr_info.end())
89 const int iat0 = *it++;
90 const int it0 = ucell.
iat2it[iat0];
95 const int iat1 = *it++;
96 const int it1 = ucell.
iat2it[iat1];
101 const int nR = *it++;
103 for (
int iR = 0;iR < nR;++iR)
108 const int Rx = *it++;
109 const int Ry = *it++;
110 const int Rz = *it++;
115 assert(dHS_block !=
nullptr);
118 for (
int lw0 = 0;lw0 < row_indexes.size();lw0 += npol)
120 const int gw0 = row_indexes[lw0] / npol;
121 const int l0 = atom0.
iw2l[gw0];
122 const int n0 = atom0.
iw2n[gw0];
123 const int m0 = atom0.
iw2m[gw0];
124 const int M0 = (m0 % 2 == 0) ? -m0 / 2 : (m0 + 1) / 2;
125 for (
int lw1 = 0;lw1 < col_indexes.size();lw1 += npol)
127 const int& gw1 = col_indexes[lw1] / npol;
128 const int l1 = atom1.
iw2l[gw1];
129 const int n1 = atom1.
iw2n[gw1];
130 const int m1 = atom1.
iw2m[gw1];
131 const int M1 = (m1 % 2 == 0) ? -m1 / 2 : (m1 + 1) / 2;
135 two_center_bundle.
overlap_orb->calculate(it0, l0, n0, M0, it1, l1, n1, M1,
136 relative_position,
nullptr, tmp_deriv.data());
139 two_center_bundle.
kinetic_orb->calculate(it0, l0, n0, M0, it1, l1, n1, M1,
140 relative_position,
nullptr, tmp_deriv.data());
143 dHS_block->
get_value(lw0, lw1) = tmp_deriv[ixyz];
148 assert(npairs == npairs_count);
std::vector< hamilt::HContainer< double > > cal_hs_grad(const char job, const UnitCell &ucell, const Parallel_Orbitals &pv, const Grid_Driver &gd, const TwoCenterBundle &two_center_bundle)
Calculate <dPhi|phi> or <dPhi|T|phi> by 2-center integration.
Definition cal_hs_grad.h:61
void filter_adjs_by_rcut(const UnitCell &ucell, const int iat0, AdjacentAtomInfo &adjs)
Definition cal_hs_grad.h:10
hamilt::HContainer< TR > build_hcontainer_local_op(const UnitCell &ucell, const Grid_Driver &gd, const Parallel_Orbitals &pv)
Return a local Hamiltonian operator in type HContainer. It can replace OverlapNew::initialize_SR() an...
Definition cal_hs_grad.h:33
Struct of array for packing the Adjacent atom information.
Definition sltk_grid_driver.h:21
int adj_num
number of adjacent atoms
Definition sltk_grid_driver.h:30
std::vector< ModuleBase::Vector3< int > > box
box indices of adjacent atoms
Definition sltk_grid_driver.h:34
std::vector< int > ntype
types of adjacent atoms
Definition sltk_grid_driver.h:31
std::vector< int > natom
indices of adjacent atoms
Definition sltk_grid_driver.h:32
Atom class for storing atom information.
Definition atom_spec.h:14
std::vector< int > iw2m
use iw to find m
Definition atom_spec.h:31
double Rcut
cut-off radius (pengfei Li 16-2-29)
Definition atom_spec.h:47
std::vector< int > iw2l
use iw to find L
Definition atom_spec.h:33
std::vector< int > iw2n
use iw to find n
Definition atom_spec.h:32
Grid_Driver class for neighbor search interface.
Definition sltk_grid_driver.h:63
void Find_atom(const UnitCell &ucell, const int ntype, const int nnumber, AdjacentAtomInfo *adjs=nullptr) const
Find adjacent atoms for a given atom.
Definition sltk_grid_driver.cpp:24
3 elements vector
Definition vector3.h:21
T x
Definition vector3.h:23
T norm(void) const
Get the norm of a Vector3.
Definition vector3.h:213
T y
Definition vector3.h:24
T z
Definition vector3.h:25
Definition parallel_orbitals.h:16
std::vector< int > get_indexes_col() const
Definition parallel_orbitals.cpp:151
int get_nrow_atom(int iat) const
Definition parallel_orbitals.cpp:110
int get_ncol_atom(int iat) const
dimension getters for 2D-block-cyclic division of Hamiltonian matrix ncloc() : total number of column...
Definition parallel_orbitals.cpp:87
std::vector< int > get_indexes_row() const
gather global indexes of orbitals in this processor get_indexes_row() : global indexes (~NLOCAL) of r...
Definition parallel_orbitals.cpp:137
Definition two_center_bundle.h:11
std::unique_ptr< TwoCenterIntegrator > kinetic_orb
Definition two_center_bundle.h:44
std::unique_ptr< TwoCenterIntegrator > overlap_orb
Definition two_center_bundle.h:45
Provide the basic information about unitcell.
Definition unitcell.h:16
Atom * atoms
Definition unitcell.h:165
const int & get_npol() const
Get npol.
Definition unitcell.h:66
const ModuleBase::Vector3< double > & get_tau(const int &iat) const
Get tau for atom iat.
Definition unitcell.h:104
double & lat0
Definition unitcell.h:135
ModuleBase::Matrix3 & latvec
Definition unitcell.h:142
std::vector< int > iat2ia
iat==>ia
Definition unitcell.h:157
ModuleBase::IntArray itia2iat
(it, ia)==>iat, the index in nat (add 2009-3-2 by mohan)
Definition unitcell.h:160
int nat
total number of atoms of all species in unitcell
Definition unitcell.h:155
std::vector< int > iat2it
iat==>it, distinguish a atom belong to which type
Definition unitcell.h:156
const ModuleBase::Vector3< double > cal_dtau(const int &iat1, const int &iat2, const ModuleBase::Vector3< int > &R) const
Calculate vector between two atoms with R cell.
Definition unitcell.h:110
Definition atom_pair.h:45
Definition base_matrix.h:20
T & get_value(const size_t &i_row, const size_t &j_col) const
get value from a whole matrix
Definition base_matrix.h:74
Definition hcontainer.h:147
void insert_pair(const AtomPair< T > &atom_ij)
a AtomPair object can be inserted into HContainer, two steps: 1, find AtomPair with atom index atom_i...
Definition hcontainer.cpp:880
void allocate(T *data_array=nullptr, bool if_zero=false)
allocate memory for all <IJR> matrix if data_array is not nullptr, use memory after data_array for ea...
Definition hcontainer.cpp:324
void filter_adjs(const std::vector< bool > &is_adj, AdjacentAtomInfo &adjs)
Filter adjacent atoms based on boolean mask.
Definition sltk_grid_driver.cpp:66
Grid_Driver class for neighbor search interface.