Skip to content

Commit bf92c2d

Browse files
authored
Fix the issue of inconsistent behavior between estep and md_nstep. (#7198)
* update tddft subloop * Add files via upload * Update result.ref * Add files via upload * Add files via upload * Add files via upload * Delete tests/05_rtTDDFT/19_NO_hyb_exx_TDDFT directory * Update CASES_CPU.txt * Update reference values in result.ref file
1 parent e1946af commit bf92c2d

11 files changed

Lines changed: 113 additions & 5 deletions

File tree

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
185185
this->chr, PARAM.inp.ks_solver);
186186
}
187187
}
188-
else //if not, use the DMR calculated from last step
188+
else if(PARAM.inp.esolver_type!="tddft")//if not, use the DMR calculated from last step
189189
{
190190
// 13.1.2) two cases are considered:
191191
// 1. DMK in DensityMatrix is not empty (istep > 0), then DMR is initialized by DMK

source/source_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::runner(UnitCell& ucell, const int istep)
9494
// 1) before_scf (electronic iteration loops)
9595
//----------------------------------------------------------------
9696
this->before_scf(ucell, istep); // From ESolver_KS_LCAO
97+
if (PARAM.inp.td_stype == 2)
98+
{
99+
this->dmat.dm->cal_DMR_td(ucell, TD_info::cart_At);
100+
}
101+
else
102+
{
103+
this->dmat.dm->cal_DMR();
104+
}
97105
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT SCF");
98106

99107
// Initialize velocity operator for current calculation
@@ -151,7 +159,7 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::runner(UnitCell& ucell, const int istep)
151159
&this->sf,
152160
GlobalV::ofs_running,
153161
GlobalV::ofs_warning);
154-
// need to test if correct when estep>0
162+
this->exx_nao.before_scf(ucell, this->kv, this->orb_, this->p_chgmix, totstep, PARAM.inp);
155163
this->pelec->init_scf(ucell, this->Pgrid, this->sf.strucFac, this->locpp.numeric, ucell.symm);
156164

157165
if (totstep <= PARAM.inp.td_tend + 1)

source/source_estate/module_dm/density_matrix.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,11 @@ void DensityMatrix_Tools::cal_DMR_td(
352352
}
353353
ModuleBase::timer::end("DensityMatrix", "cal_DMR_td");
354354
}
355-
355+
template <>
356+
void DensityMatrix<double, double>::cal_DMR_td(const UnitCell& ucell, const ModuleBase::Vector3<double> At, const int ik_in)
357+
{
358+
return;
359+
}
356360
template <>
357361
void DensityMatrix<std::complex<double>, double>::cal_DMR_td(const UnitCell& ucell, const ModuleBase::Vector3<double> At, const int ik_in)
358362
{

source/source_estate/module_dm/init_dm.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "source_estate/elecstate_tools.h"
44
#include "source_estate/cal_ux.h"
55
#include "source_lcao/rho_tau_lcao.h" // mohan add 2025-11-12
6+
#include "source_lcao/module_rt/td_info.h"
67

78
template <typename TK>
89
void elecstate::init_dm(UnitCell& ucell,
@@ -22,7 +23,14 @@ void elecstate::init_dm(UnitCell& ucell,
2223
elecstate::calEBand(pelec->ekb, pelec->wg, pelec->f_en);
2324

2425
elecstate::cal_dm_psi(dmat.dm->get_paraV_pointer(), pelec->wg, *psi, *dmat.dm);
25-
dmat.dm->cal_DMR();
26+
if (PARAM.inp.esolver_type!="tddft" && PARAM.inp.td_stype == 2)
27+
{
28+
dmat.dm->cal_DMR_td(ucell, TD_info::cart_At);
29+
}
30+
else
31+
{
32+
dmat.dm->cal_DMR();
33+
}
2634

2735
// mohan add 2025-11-12, use density matrix to calculate the charge density
2836
LCAO_domain::dm2rho(dmat.dm->get_DMR_vector(), PARAM.inp.nspin, &chr);

tests/05_rtTDDFT/CASES_CPU.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
15_NO_TRI_TDDFT
1616
16_NO_vel_TDDFT
1717
17_NO_vel_TDDFT
18-
18_NO_hyb_TDDFT
18+
18_NO_hyb_TDDFT
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
INPUT_PARAMETERS
2+
3+
4+
5+
# general information
6+
calculation md
7+
esolver_type tddft
8+
md_type nve
9+
md_nstep 1
10+
estep_per_md 5
11+
td_dt 0.005
12+
md_tfirst 0
13+
14+
15+
# rt-TDDFT parameters
16+
td_vext 1 # add time-dependent external potential
17+
td_vext_dire 3 # direction along z
18+
td_stype 2 # 2: hybrid gauge
19+
td_ttype 3 # Heaviside type potential
20+
td_tstart 1 # the step electric field starts
21+
td_tend 10 # the step electric field ends
22+
td_heavi_t0 3
23+
td_heavi_amp 0.05
24+
25+
26+
# print out current information
27+
out_current 1
28+
29+
30+
suffix autotest
31+
pseudo_dir ../../PP_ORB
32+
orbital_dir ../../PP_ORB
33+
basis_type lcao
34+
gamma_only 0
35+
36+
37+
# electronic structure calculations
38+
ecutwfc 20
39+
scf_nmax 50
40+
scf_thr 1e-6
41+
ks_solver scalapack_gvx
42+
43+
44+
# charge mixing
45+
mixing_type broyden
46+
mixing_beta 0.7
47+
mixing_gg0 0.0
48+
49+
# functional
50+
dft_functional pbe0

tests/08_EXX/14_NO_TDDFT_PBE0/KPT

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
K_POINTS
2+
0
3+
Gamma
4+
2 1 1 0 0 0

tests/08_EXX/14_NO_TDDFT_PBE0/STRU

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ATOMIC_SPECIES
2+
Si 28.085 Si_ONCV_PBE-1.0.upf
3+
4+
NUMERICAL_ORBITAL
5+
Si_gga_6au_100Ry_2s2p1d.orb
6+
7+
LATTICE_CONSTANT
8+
10.2 // add lattice constant
9+
10+
LATTICE_VECTORS
11+
0.0 0.5 0.5
12+
0.5 0.0 0.5
13+
0.5 0.5 0.0
14+
15+
ATOMIC_POSITIONS
16+
Cartesian //Cartesian or Direct coordinate.
17+
18+
Si // Element type
19+
0.0 // magnetism
20+
2 // number of atoms
21+
0.00 0.00 0.00 0 0 0
22+
0.25 0.25 0.25 1 1 1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1 -2.4064298950993433e-19 2.4067857486819294e-19 2.4048227372973307e-19
2+
2 1.3583754132510189e-08 -1.3583754049585592e-08 2.4306592013239020e-06
3+
3 3.8454029971142809e-08 -3.8454029713369349e-08 7.2734897464115248e-06
4+
4 4.3394109439952714e-08 -4.3394109112344272e-08 9.6350822407378473e-06
5+
5 2.6144935011100098e-08 -2.6144935077756982e-08 9.4987415747287647e-06
6+
6 6.1114518547755749e-10 -6.1114527641090651e-10 9.2969143096824206e-06
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
etotref -170.67031862
2+
etotperatomref -85.33515931
3+
CompareCurrent_pass 0
4+
totaltimeref 16.38

0 commit comments

Comments
 (0)