Skip to content

Commit f8a6fc5

Browse files
committed
Fix: Hefei-NAMD interface of file syns_nao.csr and parameter cal_syns
1 parent 3561573 commit f8a6fc5

14 files changed

Lines changed: 1074 additions & 86 deletions

File tree

docs/advanced/input_files/input-main.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3472,8 +3472,9 @@ These variables are used to control molecular dynamics calculations. For more in
34723472
### cal_syns
34733473

34743474
- **Type**: Boolean
3475-
- **Description**: Whether the asynchronous overlap matrix is calculated for Hefei-NAMD.
3475+
- **Description**: Whether to calculate and output asynchronous overlap matrix for Hefei-NAMD interface. When enabled, calculates `<phi(t-1)|phi(t)>` by computing overlap between basis functions at atomic positions from previous time step and current time step. The overlap is calculated by shifting atom positions backward by `velocity × md_dt`. Output file: `OUT.*/syns_nao.csr` in CSR format.
34763476
- **Default**: False
3477+
- **Note**: Only works with LCAO basis and molecular dynamics calculations. Requires atomic velocities. Output starts from the second MD step (istep > 0).
34773478

34783479
### dmax
34793480

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
#include "../source_lcao/module_ri/exx_opt_orb.h"
1313
#endif
1414
#include "source_lcao/module_rdmft/rdmft.h"
15-
#include "source_estate/module_charge/chgmixing.h" // use charge mixing, mohan add 20251006
15+
#include "source_estate/module_charge/chgmixing.h" // use charge mixing, mohan add 20251006
1616
#include "source_estate/module_dm/init_dm.h" // init dm from electronic wave functions
17-
#include "source_io/ctrl_runner_lcao.h" // use ctrl_runner_lcao()
18-
#include "source_io/ctrl_iter_lcao.h" // use ctrl_iter_lcao()
17+
#include "source_io/ctrl_runner_lcao.h" // use ctrl_runner_lcao()
18+
#include "source_io/ctrl_iter_lcao.h" // use ctrl_iter_lcao()
1919
#include "source_io/ctrl_scf_lcao.h" // use ctrl_scf_lcao()
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"
2324

2425
namespace ModuleESolver
2526
{
@@ -557,7 +558,34 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep, const
557558
this->rdmft_solver, this->deepks, this->exx_nao,
558559
this->conv_esolver, this->scf_nmax_flag, istep);
559560

560-
//! 3) Clean up RA, which is used to serach for adjacent atoms
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
561589
if (!PARAM.inp.cal_force && !PARAM.inp.cal_stress)
562590
{
563591
this->RA.delete_grid();

source/source_lcao/FORCE_gamma.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,6 @@ void Force_LCAO<double>::allocate(const UnitCell& ucell,
109109
&gd,
110110
nullptr);
111111

112-
// calculate asynchronous S matrix to output for Hefei-NAMD
113-
if (PARAM.inp.cal_syns)
114-
{
115-
cal_deri = false;
116-
ModuleBase::timer::tick("Forces", "allocate");
117-
ModuleBase::WARNING_QUIT("cal_syns", "this function has been broken and will be fixed later.");
118-
}
119-
120112
ModuleBase::timer::tick("Forces", "allocate");
121113
return;
122114
}

source/source_lcao/FORCE_k.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -132,33 +132,6 @@ void Force_LCAO<std::complex<double>>::allocate(const UnitCell& ucell,
132132
&gd,
133133
nullptr); // delete lm.Hloc_fixedR
134134

135-
// calculate asynchronous S matrix to output for Hefei-NAMD
136-
if (PARAM.inp.cal_syns)
137-
{
138-
cal_deri = false;
139-
140-
ModuleBase::WARNING_QUIT("cal_syns", "This function has been broken and will be fixed later.");
141-
142-
LCAO_domain::build_ST_new(fsr,
143-
'S',
144-
cal_deri,
145-
PARAM.inp.cal_stress,
146-
ucell,
147-
orb,
148-
pv,
149-
two_center_bundle,
150-
&(gd),
151-
nullptr, // delete lm.SlocR
152-
PARAM.inp.cal_syns,
153-
PARAM.inp.dmax);
154-
155-
for (int ik = 0; ik < nks; ik++)
156-
{
157-
158-
bool bit = false; // LiuXh, 2017-03-21
159-
}
160-
}
161-
162135
ModuleBase::timer::tick("Forces", "allocate");
163136
return;
164137
}

0 commit comments

Comments
 (0)