Skip to content

Commit 4918a08

Browse files
committed
add build_overlap in setup_deepks.h
1 parent 71bb08e commit 4918a08

File tree

5 files changed

+50
-53
lines changed

5 files changed

+50
-53
lines changed

source/source_basis/module_nao/two_center_bundle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_BASIS_MODULE_NAO_TWO_CENTER_BUNDLE_H
2-
#define W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_BASIS_MODULE_NAO_TWO_CENTER_BUNDLE_H
1+
#ifndef TWO_CENTER_BUNDLE_H
2+
#define TWO_CENTER_BUNDLE_H
33

44
#include "source_basis/module_ao/ORB_read.h"
55
#include "source_basis/module_nao/two_center_integrator.h"

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
#include "source_estate/module_charge/symmetry_rho.h"
88
#include "source_lcao/LCAO_domain.h" // need DeePKS_init
99
#include "source_lcao/module_dftu/dftu.h"
10-
#ifdef __MLALGO
11-
#include "source_lcao/module_deepks/LCAO_deepks.h"
12-
#include "source_lcao/module_deepks/LCAO_deepks_interface.h"
13-
#endif
1410
#include "source_lcao/FORCE_STRESS.h"
1511
#include "source_estate/elecstate_lcao.h"
1612
#include "source_lcao/hamilt_lcao.h"
@@ -336,43 +332,6 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
336332
}
337333
#endif
338334
elecstate::setup_dm<TK>(ucell, estate, this->psi, this->chr, iter, exx_two_level_step);
339-
340-
/*
341-
if (iter == 1 && exx_two_level_step == 0)
342-
{
343-
std::cout << " WAVEFUN -> CHARGE " << std::endl;
344-
345-
// calculate the density matrix using read in wave functions
346-
// and then calculate the charge density on grid.
347-
348-
estate->skip_weights = true;
349-
elecstate::calculate_weights(estate->ekb,
350-
estate->wg,
351-
estate->klist,
352-
estate->eferm,
353-
estate->f_en,
354-
estate->nelec_spin,
355-
estate->skip_weights);
356-
357-
elecstate::calEBand(estate->ekb, estate->wg, estate->f_en);
358-
elecstate::cal_dm_psi(estate->DM->get_paraV_pointer(), estate->wg, *this->psi, *(estate->DM));
359-
estate->DM->cal_DMR();
360-
361-
estate->psiToRho(*this->psi);
362-
estate->skip_weights = false;
363-
364-
elecstate::cal_ux(ucell);
365-
366-
//! update the potentials by using new electron charge density
367-
estate->pot->update_from_charge(&this->chr, &ucell);
368-
369-
//! compute the correction energy for metals
370-
estate->f_en.descf = estate->cal_delta_escf();
371-
}
372-
373-
*/
374-
375-
376335
}
377336

378337
#ifdef __EXX
@@ -409,11 +368,6 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
409368
{
410369
this->p_hamilt->refresh();
411370
}
412-
// if (iter == 1 && istep == 0)
413-
// {
414-
// // initialize DMR
415-
// this->deepks.ld.init_DMR(ucell, orb_, this->pv, this->gd);
416-
// }
417371
#endif
418372

419373
if (PARAM.inp.vl_in_h)

source/source_esolver/lcao_before_scf.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
#include "source_cell/module_neighbor/sltk_grid_driver.h"
77
#include "source_io/module_parameter/parameter.h"
88
#include "source_estate/elecstate_tools.h"
9-
#ifdef __MLALGO
10-
#include "source_lcao/module_deepks/LCAO_deepks.h"
11-
#endif
129
#include "source_estate/elecstate_lcao.h"
1310
#include "source_lcao/LCAO_domain.h"
1411
#include "source_lcao/module_operator_lcao/op_exx_lcao.h"
@@ -140,9 +137,13 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
140137
);
141138
}
142139

143-
#ifdef __MLALGO
140+
144141
// 9) for each ionic step, the overlap <phi|alpha> must be rebuilt
145142
// since it depends on ionic positions
143+
this->deepks.build_overlap(ucell, orb_, pv, gd, *(two_center_bundle_.overlap_orb_alpha), PARAM.inp);
144+
145+
/*
146+
#ifdef __MLALGO
146147
if (PARAM.globalv.deepks_setorb)
147148
{
148149
const Parallel_Orbitals* pv = &this->pv;
@@ -159,6 +160,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
159160
}
160161
}
161162
#endif
163+
*/
162164

163165
// 10) prepare sc calculation
164166
if (PARAM.inp.sc_mag_switch)

source/source_lcao/setup_deepks.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,38 @@ Setup_DeePKS<TK>::Setup_DeePKS(){}
88
template <typename TK>
99
Setup_DeePKS<TK>::~Setup_DeePKS(){}
1010

11+
12+
template <typename TK>
13+
void Setup_DeePKS<TK>::build_overlap(
14+
const UnitCell &ucell,
15+
const LCAO_Orbitals &orb,
16+
const Parallel_Orbitals &pv,
17+
const Grid_Driver &gd,
18+
TwoCenterIntegrator &overlap_orb_alpha,
19+
const Input_para &inp)
20+
{
21+
#ifdef __MLALGO
22+
// 9) for each ionic step, the overlap <phi|alpha> must be rebuilt
23+
// since it depends on ionic positions
24+
if (PARAM.globalv.deepks_setorb)
25+
{
26+
// allocate <phi(0)|alpha(R)>, phialpha is different every ion step, so it is allocated here
27+
DeePKS_domain::allocate_phialpha(inp.cal_force, ucell, orb, gd, &pv, this->ld.phialpha);
28+
29+
// build and save <phi(0)|alpha(R)> at beginning
30+
DeePKS_domain::build_phialpha(inp.cal_force, ucell, orb, gd,
31+
&pv, overlap_orb_alpha, this->ld.phialpha);
32+
33+
if (inp.deepks_out_unittest)
34+
{
35+
DeePKS_domain::check_phialpha(inp.cal_force, ucell, orb,
36+
gd, &pv, this->ld.phialpha, GlobalV::MY_RANK);
37+
}
38+
}
39+
#endif
40+
}
41+
42+
1143
template <typename TK>
1244
void Setup_DeePKS<TK>::before_runner(const UnitCell& ucell, // unitcell
1345
const int nks, // number of k points

source/source_lcao/setup_deepks.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "source_io/module_parameter/input_parameter.h" // Input_para
66
#include "source_basis/module_ao/parallel_orbitals.h" // parallel orbitals
77
#include "source_basis/module_ao/ORB_read.h" // orb
8+
#include "source_basis/module_nao/two_center_integrator.h" // overlap_orb_alpha
89

910
#ifdef __MLALGO
1011
#include "source_lcao/module_deepks/LCAO_deepks.h" // deepks
@@ -26,12 +27,20 @@ class Setup_DeePKS
2627
std::string dpks_out_type;
2728

2829
void before_runner(
29-
const UnitCell& ucell, // unitcell
30+
const UnitCell &ucell, // unitcell
3031
const int nks, // k points
3132
const LCAO_Orbitals &orb, // orbital info
3233
Parallel_Orbitals &pv, // parallel orbitals
3334
const Input_para &inp);
3435

36+
void build_overlap(
37+
const UnitCell &ucell,
38+
const LCAO_Orbitals &orb,
39+
const Parallel_Orbitals &pv,
40+
const Grid_Driver &gd,
41+
TwoCenterIntegrator &overlap_orb_alpha,
42+
const Input_para &inp);
43+
3544
void write_forces(
3645
const ModuleBase::matrix &fcs,
3746
const ModuleBase::matrix &fvnl_dalpha,

0 commit comments

Comments
 (0)