Skip to content

Commit a20ac97

Browse files
committed
replace pvpr with hcontainer in cal_dh
1 parent 7ab1a78 commit a20ac97

File tree

8 files changed

+265
-510
lines changed

8 files changed

+265
-510
lines changed

source/module_hamilt_lcao/module_gint/gint.h

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class Gint {
104104

105105
void gint_kernel_vlocal(Gint_inout* inout);
106106

107+
// calculate < phi_0 | vlocal | dphi_R >
107108
void gint_kernel_dvlocal(Gint_inout* inout);
108109

109110
void gint_kernel_vlocal_meta(Gint_inout* inout);
@@ -116,42 +117,6 @@ class Gint {
116117

117118
void gint_kernel_force_meta(Gint_inout* inout);
118119

119-
//------------------------------------------------------
120-
// in gint_vl.cpp
121-
//------------------------------------------------------
122-
// calculate the matrix elements of Hamiltonian matrix,
123-
// < phi_0 | Vl + Vh + Vxc | phi_R> or if the Vna is used,
124-
// < phi_0 | delta_Vh + Vxc | phi_R>.
125-
// void gint_kernel_vlocal(const int na_grid,
126-
// const int grid_index,
127-
// const double delta_r,
128-
// double* vldr3,
129-
// const int LD_pool,
130-
// double* pvpR_reduced,
131-
// const UnitCell& ucell,
132-
// hamilt::HContainer<double>* hR = nullptr);
133-
134-
// calculate < phi_0 | vlocal | dphi_R >
135-
void gint_kernel_dvlocal(const int na_grid,
136-
const int grid_index,
137-
const double delta_r,
138-
double* vldr3,
139-
const int LD_pool,
140-
double* pvdpRx_reduced,
141-
double* pvdpRy_reduced,
142-
double* pvdpRz_reduced,
143-
const UnitCell& ucell);
144-
145-
void gint_kernel_vlocal_meta(const int na_grid,
146-
const int grid_index,
147-
const double delta_r,
148-
double* vldr3,
149-
double* vkdr3,
150-
const int LD_pool,
151-
double* pvpR_reduced,
152-
const UnitCell& ucell,
153-
hamilt::HContainer<double>* hR = nullptr);
154-
155120
void cal_meshball_vlocal(
156121
const int na_grid, // how many atoms on this (i,j,k) grid
157122
const int LD_pool,
@@ -170,19 +135,6 @@ class Gint {
170135
hamilt::HContainer<double>* hR); // HContainer for storing the <phi_0 |
171136
// V | phi_R> matrix element.
172137

173-
void cal_meshball_vlocal_k(
174-
const int na_grid,
175-
const int LD_pool,
176-
const int grid_index,
177-
const int*const block_size,
178-
const int*const block_index,
179-
const int*const block_iw,
180-
const bool*const*const cal_flag,
181-
const double*const*const psir_ylm,
182-
const double*const*const psir_vlbr3,
183-
double*const pvpR,
184-
const UnitCell &ucell);
185-
186138
//------------------------------------------------------
187139
// in gint_fvl.cpp
188140
//------------------------------------------------------
@@ -271,8 +223,6 @@ class Gint {
271223

272224
// save the < phi_0i | V | phi_Rj > in sparse H matrix.
273225
bool pvpR_alloc_flag = false;
274-
double** pvpR_reduced
275-
= nullptr; // stores Hamiltonian in reduced format, for multi-l
276226
hamilt::HContainer<double>* hRGint
277227
= nullptr; // stores Hamiltonian in sparse format
278228
std::vector<hamilt::HContainer<double>*> hRGint_tmp; // size of vec is 4, only used when nspin = 4
@@ -282,9 +232,9 @@ class Gint {
282232
DMRGint; // stores DMR in sparse format
283233
hamilt::HContainer<double>* DMRGint_full
284234
= nullptr; // tmp tools used in transfer_DM2DtoGrid
285-
double** pvdpRx_reduced = nullptr;
286-
double** pvdpRy_reduced = nullptr;
287-
double** pvdpRz_reduced = nullptr;
235+
std::vector<hamilt::HContainer<double>> pvdpRx_reduced;
236+
std::vector<hamilt::HContainer<double>> pvdpRy_reduced;
237+
std::vector<hamilt::HContainer<double>> pvdpRz_reduced;
288238
};
289239

290240
#endif

source/module_hamilt_lcao/module_gint/gint_k_pvdpr.cpp

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,20 @@ void Gint_k::allocate_pvdpR(void)
2020

2121
//xiaohui modify 2015-05-30
2222
// the number of matrix element <phi_0 | V | dphi_R> is this->gridt->nnrg.
23-
this->pvdpRx_reduced = new double*[nspin];
24-
this->pvdpRy_reduced = new double*[nspin];
25-
this->pvdpRz_reduced = new double*[nspin];
2623
for(int is =0;is<nspin;is++)
2724
{
28-
this->pvdpRx_reduced[is] = new double[this->gridt->nnrg];
29-
ModuleBase::GlobalFunc::ZEROS( pvdpRx_reduced[is], this->gridt->nnrg);
30-
this->pvdpRy_reduced[is] = new double[this->gridt->nnrg];
31-
ModuleBase::GlobalFunc::ZEROS( pvdpRy_reduced[is], this->gridt->nnrg);
32-
this->pvdpRz_reduced[is] = new double[this->gridt->nnrg];
33-
ModuleBase::GlobalFunc::ZEROS( pvdpRz_reduced[is], this->gridt->nnrg);
25+
this->pvdpRx_reduced.push_back(hamilt::HContainer<double>(this->ucell->nat));
26+
pvdpRx_reduced[is].insert_ijrs(this->gridt->get_ijr_info(), *this->ucell);
27+
pvdpRx_reduced[is].allocate(nullptr, true);
28+
this->pvdpRy_reduced.push_back(hamilt::HContainer<double>(this->ucell->nat));
29+
pvdpRy_reduced[is].insert_ijrs(this->gridt->get_ijr_info(), *this->ucell);
30+
pvdpRy_reduced[is].allocate(nullptr, true);
31+
this->pvdpRz_reduced.push_back(hamilt::HContainer<double>(this->ucell->nat));
32+
pvdpRz_reduced[is].insert_ijrs(this->gridt->get_ijr_info(), *this->ucell);
33+
pvdpRz_reduced[is].allocate(nullptr, true);
3434
}
3535

36-
ModuleBase::Memory::record("pvdpR_reduced", 3 * sizeof(double) * this->gridt->nnrg * nspin);
37-
36+
ModuleBase::Memory::record("pvdpR_reduced", 3 * sizeof(double) * this->pvdpRx_reduced[0].get_nnr() * nspin);
3837
return;
3938
}
4039

@@ -44,24 +43,11 @@ void Gint_k::destroy_pvdpR(void)
4443

4544
const int nspin = PARAM.inp.nspin;
4645
assert(nspin>0);
47-
48-
for(int is =0;is<nspin;is++)
49-
{
50-
delete[] pvdpRx_reduced[is];
51-
}
52-
delete[] pvdpRx_reduced;
53-
54-
for(int is =0;is<nspin;is++)
55-
{
56-
delete[] pvdpRy_reduced[is];
57-
}
58-
delete[] pvdpRy_reduced;
59-
60-
for(int is =0;is<nspin;is++)
61-
{
62-
delete[] pvdpRz_reduced[is];
63-
}
64-
delete[] pvdpRz_reduced;
65-
46+
pvdpRx_reduced.clear();
47+
pvdpRy_reduced.clear();
48+
pvdpRz_reduced.clear();
49+
pvdpRx_reduced.shrink_to_fit();
50+
pvdpRy_reduced.shrink_to_fit();
51+
pvdpRz_reduced.shrink_to_fit();
6652
return;
6753
}

source/module_hamilt_lcao/module_gint/gint_k_pvpr.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@ void Gint_k::allocate_pvpR(void)
2323
ModuleBase::WARNING_QUIT("Gint_k::allocate_pvpR", "pvpR has been allocated!");
2424
}
2525

26-
// xiaohui modify 2015-05-30
27-
// the number of matrix element <phi_0 | V | phi_R> is nnrg.
28-
this->pvpR_reduced = new double*[PARAM.inp.nspin];
29-
for (int is = 0; is < PARAM.inp.nspin; is++)
30-
{
31-
this->pvpR_reduced[is] = new double[this->gridt->nnrg];
32-
ModuleBase::GlobalFunc::ZEROS(pvpR_reduced[is], this->gridt->nnrg);
33-
}
34-
35-
ModuleBase::Memory::record("pvpR_reduced", sizeof(double) * this->gridt->nnrg * PARAM.inp.nspin);
36-
3726
this->pvpR_alloc_flag = true;
3827
return;
3928
}
@@ -46,12 +35,6 @@ void Gint_k::destroy_pvpR(void)
4635
return;
4736
}
4837

49-
for (int is = 0; is < PARAM.inp.nspin; is++)
50-
{
51-
delete[] pvpR_reduced[is];
52-
}
53-
delete[] pvpR_reduced;
54-
5538
this->pvpR_alloc_flag = false;
5639
return;
5740
}

0 commit comments

Comments
 (0)