Skip to content

Commit e3a7226

Browse files
authored
Update init_orb.cpp
1 parent a6d0ba1 commit e3a7226

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

source/module_hamilt_lcao/module_gint/init_orb.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#include "module_base/memory.h"
33
#include "module_basis/module_ao/ORB_read.h"
44
#include "module_cell/unitcell.h"
5+
56
namespace Gint_Tools{
7+
68
void init_orb(double& dr_uniform,
79
std::vector<double>& rcuts,
810
UnitCell& ucell,
@@ -11,17 +13,23 @@ void init_orb(double& dr_uniform,
1113
std::vector<std::vector<double>>& dpsi_u,
1214
std::vector<std::vector<double>>& d2psi_u)
1315
{
14-
// set the grid parameters
16+
//! set the grid parameters
1517
dr_uniform=orb.dr_uniform;
18+
19+
assert(dr_uniform>0.0);
1620

1721
const int nwmax=ucell.nwmax;
1822
const int ntype=ucell.ntype;
23+
24+
assert(nwmax>0);
25+
assert(ntype>0);
1926

2027
rcuts=std::vector<double>(ntype);
2128
ModuleBase::Memory::record("rcuts", sizeof(double)*ntype*3);
22-
for(int T=0; T<ntype; T++)
29+
30+
for(int it=0; it<ntype; it++)
2331
{
24-
rcuts[T]=orb.Phi[T].getRcut();
32+
rcuts[it]=orb.Phi[it].getRcut();
2533
}
2634

2735
const double max_cut = *std::max_element(rcuts.begin(), rcuts.end());
@@ -31,22 +39,24 @@ void init_orb(double& dr_uniform,
3139
d2psi_u=std::vector<std::vector<double>>(ntype * nwmax);
3240
ModuleBase::Memory::record("psi_u", sizeof(double)*nwmax*ntype*3);
3341

34-
Atom* atomx;
35-
const Numerical_Orbital_Lm* pointer;
42+
Atom* atomx = nullptr;
43+
const Numerical_Orbital_Lm* pointer = nullptr;
3644

3745
for (int i = 0; i < ntype; i++)
3846
{
3947
atomx = &ucell.atoms[i];
4048
for (int j = 0; j < nwmax; j++)
4149
{
50+
const int k=i*nwmax+j;
4251
if (j < atomx->nw)
4352
{
4453
pointer = &orb.Phi[i].PhiLN(atomx->iw2l[j],atomx->iw2n[j]);
45-
psi_u[i*nwmax+j]=pointer->psi_uniform;
46-
dpsi_u[i*nwmax+j]=pointer->dpsi_uniform;
47-
d2psi_u[i*nwmax+j]=pointer->ddpsi_uniform;
54+
psi_u[k]=pointer->psi_uniform;
55+
dpsi_u[k]=pointer->dpsi_uniform;
56+
d2psi_u[k]=pointer->ddpsi_uniform;
4857
}
4958
}
5059
}
51-
}
52-
}// Gint_Tools
60+
}// End of init_orb()
61+
62+
}// End of Gint_Tools

0 commit comments

Comments
 (0)