Skip to content

Commit

Permalink
Update init_orb.cpp (#5551)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanchen authored Nov 22, 2024
1 parent e987240 commit 8af2923
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions source/module_hamilt_lcao/module_gint/init_orb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#include "module_base/memory.h"
#include "module_basis/module_ao/ORB_read.h"
#include "module_cell/unitcell.h"

namespace Gint_Tools{

void init_orb(double& dr_uniform,
std::vector<double>& rcuts,
UnitCell& ucell,
Expand All @@ -11,17 +13,23 @@ void init_orb(double& dr_uniform,
std::vector<std::vector<double>>& dpsi_u,
std::vector<std::vector<double>>& d2psi_u)
{
// set the grid parameters
//! set the grid parameters
dr_uniform=orb.dr_uniform;

assert(dr_uniform>0.0);

const int nwmax=ucell.nwmax;
const int ntype=ucell.ntype;

assert(nwmax>0);
assert(ntype>0);

rcuts=std::vector<double>(ntype);
ModuleBase::Memory::record("rcuts", sizeof(double)*ntype*3);
for(int T=0; T<ntype; T++)

for(int it=0; it<ntype; it++)
{
rcuts[T]=orb.Phi[T].getRcut();
rcuts[it]=orb.Phi[it].getRcut();
}

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

Atom* atomx;
const Numerical_Orbital_Lm* pointer;
Atom* atomx = nullptr;
const Numerical_Orbital_Lm* pointer = nullptr;

for (int i = 0; i < ntype; i++)
{
atomx = &ucell.atoms[i];
for (int j = 0; j < nwmax; j++)
{
const int k=i*nwmax+j;
if (j < atomx->nw)
{
pointer = &orb.Phi[i].PhiLN(atomx->iw2l[j],atomx->iw2n[j]);
psi_u[i*nwmax+j]=pointer->psi_uniform;
dpsi_u[i*nwmax+j]=pointer->dpsi_uniform;
d2psi_u[i*nwmax+j]=pointer->ddpsi_uniform;
psi_u[k]=pointer->psi_uniform;
dpsi_u[k]=pointer->dpsi_uniform;
d2psi_u[k]=pointer->ddpsi_uniform;
}
}
}
}
}// Gint_Tools
}// End of init_orb()

}// End of Gint_Tools

0 comments on commit 8af2923

Please sign in to comment.