Skip to content

Commit 617b96f

Browse files
committed
refactor: esolver to ctrl_scf_lcao
1 parent f8a6fc5 commit 617b96f

2 files changed

Lines changed: 37 additions & 30 deletions

File tree

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "source_io/print_info.h"
2121
#include "source_lcao/rho_tau_lcao.h" // mohan add 20251024
2222
#include "source_lcao/LCAO_set.h" // mohan add 20251111
23-
#include "source_lcao/module_operator_lcao/overlap_new.h"
2423

2524
namespace ModuleESolver
2625
{
@@ -555,37 +554,10 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep, const
555554
PARAM.inp, this->kv, this->pelec, this->dmat.dm, this->pv,
556555
this->gd, this->psi, hamilt_lcao, this->dftu, this->two_center_bundle_,
557556
this->orb_, this->pw_wfc, this->pw_rho, this->pw_big, this->sf,
558-
this->rdmft_solver, this->deepks, this->exx_nao,
557+
this->rdmft_solver, this->deepks, this->exx_nao,
559558
this->conv_esolver, this->scf_nmax_flag, istep);
560559

561-
//! 3) Calculate and output asynchronous overlap matrix for Hefei-NAMD
562-
if (PARAM.inp.cal_syns && (istep > 0 || PARAM.inp.init_vel))
563-
{
564-
// Create a new OverlapNew instance specifically for SR_async calculation
565-
// This allows SR_async to be initialized with velocity-shifted dtau
566-
hamilt::OverlapNew<hamilt::OperatorLCAO<TK, TR>>* overlap_async =
567-
new hamilt::OverlapNew<hamilt::OperatorLCAO<TK, TR>>(
568-
nullptr, // hsk_in: not needed for SR_async calculation
569-
this->kv.kvec_d,
570-
nullptr, // hR_in: not needed for SR_async calculation
571-
nullptr, // SR_in: not needed for SR_async calculation
572-
&ucell,
573-
this->orb_.cutoffs(),
574-
&this->gd,
575-
this->two_center_bundle_.overlap_orb.get());
576-
577-
// Use same precision as DMR output (default 8 if not specified)
578-
const int precision = PARAM.inp.out_dmr[0] > 0 ? PARAM.inp.out_dmr[1] : 8;
579-
const Parallel_Orbitals* paraV = hamilt_lcao->getSR()->get_paraV();
580-
hamilt::HContainer<TR>* SR_async = overlap_async->calculate_SR_async(ucell, PARAM.mdp.md_dt, paraV);
581-
overlap_async->output_SR_async_csr(istep, SR_async, precision);
582-
583-
// Clean up
584-
delete SR_async;
585-
delete overlap_async;
586-
}
587-
588-
//! 4) Clean up RA, which is used to serach for adjacent atoms
560+
//! 3) Clean up RA, which is used to serach for adjacent atoms
589561
if (!PARAM.inp.cal_force && !PARAM.inp.cal_stress)
590562
{
591563
this->RA.delete_grid();

source/source_io/ctrl_scf_lcao.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "source_io/to_qo.h" // use toQO
3232
#include "source_lcao/module_rdmft/rdmft.h" // use RDMFT codes
3333
#include "source_lcao/rho_tau_lcao.h" // mohan add 2025-10-24
34+
#include "source_lcao/module_operator_lcao/overlap_new.h" // use hamilt::OverlapNew for NAMD
3435

3536
template <typename TK, typename TR>
3637
void ModuleIO::ctrl_scf_lcao(UnitCell& ucell,
@@ -459,6 +460,40 @@ void ModuleIO::ctrl_scf_lcao(UnitCell& ucell,
459460
tqo.calculate();
460461
}
461462

463+
//------------------------------------------------------------------
464+
//! 18) Calculate and output asynchronous overlap matrix for Hefei-NAMD
465+
//------------------------------------------------------------------
466+
if (inp.cal_syns && (istep > 0 || inp.init_vel))
467+
{
468+
ModuleBase::TITLE("ModuleIO", "output_namd_async_overlap");
469+
ModuleBase::timer::tick("ModuleIO", "output_namd_async_overlap");
470+
471+
// Create a new OverlapNew instance specifically for SR_async calculation
472+
// This allows SR_async to be initialized with velocity-shifted dtau
473+
hamilt::OverlapNew<hamilt::OperatorLCAO<TK, TR>>* overlap_async =
474+
new hamilt::OverlapNew<hamilt::OperatorLCAO<TK, TR>>(
475+
nullptr, // hsk_in: not needed for SR_async calculation
476+
kv.kvec_d,
477+
nullptr, // hR_in: not needed for SR_async calculation
478+
nullptr, // SR_in: not needed for SR_async calculation
479+
&ucell,
480+
orb.cutoffs(),
481+
&gd,
482+
two_center_bundle.overlap_orb.get());
483+
484+
// Use same precision as DMR output (default 8 if not specified)
485+
const int precision = inp.out_dmr[0] > 0 ? inp.out_dmr[1] : 8;
486+
const Parallel_Orbitals* paraV = p_hamilt->getSR()->get_paraV();
487+
hamilt::HContainer<TR>* SR_async = overlap_async->calculate_SR_async(ucell, PARAM.mdp.md_dt, paraV);
488+
overlap_async->output_SR_async_csr(istep, SR_async, precision);
489+
490+
// Clean up
491+
delete SR_async;
492+
delete overlap_async;
493+
494+
ModuleBase::timer::tick("ModuleIO", "output_namd_async_overlap");
495+
}
496+
462497
ModuleBase::timer::tick("ModuleIO", "ctrl_scf_lcao");
463498
}
464499

0 commit comments

Comments
 (0)