Skip to content

Commit dbb8ebd

Browse files
authored
Merge branch 'develop' into refactor
2 parents 83df3b7 + 7baaab1 commit dbb8ebd

File tree

8 files changed

+271
-105
lines changed

8 files changed

+271
-105
lines changed

source/Makefile.Objects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ OBJS_LCAO=evolve_elec.o\
634634
spar_hsr.o\
635635
spar_st.o\
636636
spar_u.o\
637+
LCAO_set.o\
637638
LCAO_set_fs.o\
638639
LCAO_set_st.o\
639640
LCAO_nl_mu.o\

source/source_base/ylm.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,10 @@ void Ylm::get_ylm_real( const int &Lmax, const ModuleBase::Vector3<double> &vec,
324324
* *************************/
325325
void Ylm::rlylm
326326
(
327-
const int& Lmax, //max momentum of l + 1
328-
const double& x,
329-
const double& y,
330-
const double& z,
327+
const int Lmax, //max momentum of l + 1
328+
const double x,
329+
const double y,
330+
const double z,
331331
double rly[]
332332
)
333333
{
@@ -529,10 +529,10 @@ void Ylm::rlylm
529529
//return ylm, not rlylm
530530
void Ylm::sph_harm
531531
(
532-
const int& Lmax, //max momentum of l
533-
const double& xdr,
534-
const double& ydr,
535-
const double& zdr,
532+
const int Lmax, //max momentum of l
533+
const double xdr,
534+
const double ydr,
535+
const double zdr,
536536
std::vector<double> &rly
537537
)
538538
{
@@ -668,10 +668,10 @@ void Ylm::sph_harm
668668
// Peize Lin change rly 2016-08-26
669669
void Ylm::rl_sph_harm
670670
(
671-
const int& Lmax, //max momentum of L
672-
const double& x,
673-
const double& y,
674-
const double& z,
671+
const int Lmax, //max momentum of L
672+
const double x,
673+
const double y,
674+
const double z,
675675
std::vector<double>& rly
676676
)
677677
{
@@ -807,10 +807,10 @@ void Ylm::rl_sph_harm
807807

808808
void Ylm::grad_rl_sph_harm
809809
(
810-
const int& Lmax, //max momentum of L
811-
const double& x,
812-
const double& y,
813-
const double& z,
810+
const int Lmax, //max momentum of L
811+
const double x,
812+
const double y,
813+
const double z,
814814
double* rly,
815815
double** grly
816816
)
@@ -1097,10 +1097,10 @@ void Ylm::grad_rl_sph_harm
10971097

10981098
void Ylm::hes_rl_sph_harm
10991099
(
1100-
const int& Lmax, //max momentum of L
1101-
const double& x,
1102-
const double& y,
1103-
const double& z,
1100+
const int Lmax, //max momentum of L
1101+
const double x,
1102+
const double y,
1103+
const double z,
11041104
std::vector<std::vector<double>>& hrly
11051105
)
11061106
{
@@ -1394,10 +1394,10 @@ void Ylm::test2 (void)
13941394

13951395
void Ylm::rlylm
13961396
(
1397-
const int& Lmax, //max momentum of l + 1
1398-
const double& x,
1399-
const double& y,
1400-
const double& z,
1397+
const int Lmax, //max momentum of l + 1
1398+
const double x,
1399+
const double y,
1400+
const double z,
14011401
double rly[],
14021402
double grly[][3]
14031403
)

source/source_base/ylm.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ class Ylm
5353
* @param rly [in] calculated Ylm, Y00, Y10, Y11, Y1-1, Y20, Y21, Y2-1, Y22, Y2-2...
5454
*/
5555
static void rlylm(
56-
const int& Lmax,
57-
const double& x,
58-
const double& y,
59-
const double& z,
56+
const int Lmax,
57+
const double x,
58+
const double y,
59+
const double z,
6060
double rly[]);
6161

6262
/**
@@ -70,10 +70,10 @@ class Ylm
7070
* @param grly [out] gradient of Ylm, [dY00/dx, dY00/dy, dY00/dz], [dY10/dx, dY10/dy, dY10/dz], [dY11/dx, dY11/dy, dY11/dz],...
7171
*/
7272
static void rlylm(
73-
const int& Lmax,
74-
const double& x,
75-
const double& y,
76-
const double& z,
73+
const int Lmax,
74+
const double x,
75+
const double y,
76+
const double z,
7777
double rly[],
7878
double grly[][3]);
7979

@@ -87,10 +87,10 @@ class Ylm
8787
* @param rly [in] calculated Ylm, Y00, Y10, Y11, Y1-1, Y20, Y21, Y2-1, Y22, Y2-2...
8888
*/
8989
static void sph_harm(
90-
const int& Lmax,
91-
const double& xdr,
92-
const double& ydr,
93-
const double& zdr,
90+
const int Lmax,
91+
const double xdr,
92+
const double ydr,
93+
const double zdr,
9494
std::vector<double> &rly);
9595

9696
/**
@@ -105,10 +105,10 @@ class Ylm
105105
* @date 2016-08-26
106106
*/
107107
static void rl_sph_harm(
108-
const int& Lmax,
109-
const double& x,
110-
const double& y,
111-
const double& z,
108+
const int Lmax,
109+
const double x,
110+
const double y,
111+
const double z,
112112
std::vector<double>& rly);
113113

114114
/**
@@ -123,10 +123,10 @@ class Ylm
123123
* grly should be a memory-contiguous two-dimensional array for better performance.
124124
*/
125125
static void grad_rl_sph_harm(
126-
const int& Lmax,
127-
const double& x,
128-
const double& y,
129-
const double& z,
126+
const int Lmax,
127+
const double x,
128+
const double y,
129+
const double z,
130130
double* rly,
131131
double** grly);
132132

@@ -140,10 +140,10 @@ class Ylm
140140
* @param hrly [out] hessian of Ylm, [dY00/dx2, dY00/dxy, dY00/dxz, dY00/dyy, dY00/dyz, dY00/dzz] , ...
141141
*/
142142
static void hes_rl_sph_harm(
143-
const int& Lmax,
144-
const double& x,
145-
const double& y,
146-
const double& z,
143+
const int Lmax,
144+
const double x,
145+
const double y,
146+
const double z,
147147
std::vector<std::vector<double>>& hrly);
148148

149149
//calculate the coefficient of Ylm, ylmcoef.

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 15 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@
1717
#include "source_io/ctrl_runner_lcao.h" // use ctrl_runner_lcao()
1818
#include "source_io/ctrl_iter_lcao.h" // use ctrl_iter_lcao()
1919
#include "source_io/ctrl_scf_lcao.h" // use ctrl_scf_lcao()
20-
#include "source_psi/setup_psi.h" // mohan add 20251019
21-
#include "source_io/read_wfc_nao.h"
2220
#include "source_io/print_info.h"
2321
#include "source_lcao/rho_tau_lcao.h" // mohan add 20251024
22+
#include "source_lcao/LCAO_set.h" // mohan add 20251111
23+
24+
25+
// tmp
26+
#include "source_psi/setup_psi.h" // use Setup_Psi
27+
#include "source_io/read_wfc_nao.h" // use read_wfc_nao
28+
#include "source_estate/elecstate_tools.h" // use fixed_weights
29+
2430

2531
namespace ModuleESolver
2632
{
@@ -74,62 +80,17 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
7480
return;
7581
}
7682

77-
// 5) init electronic wave function psi
78-
Setup_Psi<TK>::allocate_psi(this->psi, this->kv, this->pv, inp);
79-
80-
//! read psi from file
81-
if (inp.init_wfc == "file" && inp.esolver_type != "tddft")
82-
{
83-
if (!ModuleIO::read_wfc_nao(PARAM.globalv.global_readin_dir,
84-
this->pv, *this->psi, this->pelec->ekb, this->pelec->wg, this->kv.ik2iktot,
85-
this->kv.get_nkstot(), inp.nspin))
86-
{
87-
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO", "read electronic wave functions failed");
88-
}
89-
}
90-
83+
LCAO_domain::set_psi_occ_dm_chg<TK>(this->kv, this->psi, this->pv, this->pelec,
84+
this->dmat, this->chr, inp);
9185

92-
// 7) init DMK, but DMR is constructed in before_scf()
93-
this->dmat.allocate_dm(&this->kv, &this->pv, inp.nspin);
86+
LCAO_domain::set_pot<TK>(ucell, this->kv, this->sf, *this->pw_rho, *this->pw_rhod,
87+
this->pelec, this->orb_, this->pv, this->locpp, this->dftu,
88+
this->solvent, this->exx_nao, this->deepks, inp);
9489

95-
// 8) init exact exchange calculations
96-
this->exx_nao.before_runner(ucell, this->kv, this->orb_, this->pv, inp);
97-
98-
// 9) initialize DFT+U
99-
if (inp.dft_plus_u)
100-
{
101-
this->dftu.init(ucell, &this->pv, this->kv.get_nks(), &orb_);
102-
}
103-
104-
// 10) init local pseudopotentials
105-
this->locpp.init_vloc(ucell, this->pw_rho);
106-
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
107-
108-
// 11) init charge density
109-
this->chr.allocate(inp.nspin);
110-
111-
// 12) init potentials
112-
if (this->pelec->pot == nullptr)
113-
{
114-
this->pelec->pot = new elecstate::Potential(this->pw_rhod, this->pw_rho,
115-
&ucell, &(this->locpp.vloc), &(this->sf), &(this->solvent),
116-
&(this->pelec->f_en.etxc), &(this->pelec->f_en.vtxc));
117-
}
118-
119-
// 13) init deepks
120-
this->deepks.before_runner(ucell, this->kv.get_nks(), this->orb_, this->pv, inp);
121-
122-
// 14) set occupations, tddft does not need to set occupations in the first scf
123-
if (inp.ocp && inp.esolver_type != "tddft")
124-
{
125-
elecstate::fixed_weights(inp.ocp_kb, inp.nbands, inp.nelec,
126-
this->pelec->klist, this->pelec->wg, this->pelec->skip_weights);
127-
}
128-
129-
// 15) if kpar is not divisible by nks, print a warning
90+
//! if kpar is not divisible by nks, print a warning
13091
ModuleIO::print_kpar(this->kv.get_nks(), PARAM.globalv.kpar_lcao);
13192

132-
// 16) init rdmft, added by jghan
93+
//! init rdmft, added by jghan
13394
if (inp.rdmft == true)
13495
{
13596
rdmft_solver.init(this->pv, ucell,
@@ -310,8 +271,6 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
310271

311272
ESolver_KS<TK>::after_all_runners(ucell);
312273

313-
const int nspin0 = (PARAM.inp.nspin == 2) ? 2 : 1;
314-
315274
auto* hamilt_lcao = dynamic_cast<hamilt::HamiltLCAO<TK, TR>*>(this->p_hamilt);
316275
if(!hamilt_lcao)
317276
{

source/source_io/ctrl_scf_lcao.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void ModuleIO::ctrl_scf_lcao(UnitCell& ucell,
278278
ModuleIO::AngularMomentumCalculator mylcalculator(
279279
inp.orbital_dir,
280280
ucell,
281-
inp.search_radius,
281+
orb.get_rcutmax_Phi(),
282282
inp.test_deconstructor,
283283
inp.test_grid,
284284
inp.test_atom_input,

source/source_lcao/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ if(ENABLE_LCAO)
3333
spar_hsr.cpp
3434
spar_st.cpp
3535
spar_u.cpp
36+
LCAO_set.cpp
3637
LCAO_set_fs.cpp
3738
LCAO_set_st.cpp
3839
LCAO_nl_mu.cpp

0 commit comments

Comments
 (0)