Skip to content

Commit ecedf4f

Browse files
committed
reduce calculation time of tests: rdmft
1 parent 4ae4f07 commit ecedf4f

File tree

20 files changed

+71
-143
lines changed

20 files changed

+71
-143
lines changed

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -938,24 +938,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(const int istep, int& iter)
938938
}
939939
}
940940

941-
// 2.5) determine whether rdmft needs to get the initial value, added by jghan, 2024-10-25
942-
int one_step_exx = false;
943-
bool get_init_value_rdmft = false;
944-
if( iter == 1 ) get_init_value_rdmft = true; // the case without hybrid functionals
945941
#ifdef __EXX
946-
if( GlobalC::exx_info.info_global.cal_exx )
947-
{
948-
if( this->conv_esolver ) one_step_exx = true;
949-
// the case with hybrid functionals, calculate rdmft just after updateExx, cal once in one inner loop
950-
if( one_step_exx ) get_init_value_rdmft = true;
951-
else get_init_value_rdmft = false;
952-
}
953-
#endif
954-
955-
#ifdef __EXX
956-
957-
if( GlobalC::exx_info.info_global.cal_exx && this->conv_esolver ) one_step_exx = true;
958-
959942
// 3) save exx matrix
960943
if (PARAM.inp.calculation != "nscf")
961944
{
@@ -1037,23 +1020,6 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(const int istep, int& iter)
10371020
{
10381021
GlobalC::dftu.initialed_locale = true;
10391022
}
1040-
1041-
// 7) rdmft, added by jghan, 2024-10-25
1042-
if ( PARAM.inp.rdmft == true && get_init_value_rdmft )
1043-
{
1044-
ModuleBase::matrix occ_number_ks(this->pelec->wg);
1045-
for(int ik=0; ik < occ_number_ks.nr; ++ik) { for(int inb=0; inb < occ_number_ks.nc; ++inb) occ_number_ks(ik, inb) /= this->kv.wk[ik]; }
1046-
this->rdmft_solver.update_elec(occ_number_ks, *(this->psi));
1047-
1048-
//initialize the gradients of Etotal on occupation numbers and wfc, and set all elements to 0.
1049-
ModuleBase::matrix dE_dOccNum(this->pelec->wg.nr, this->pelec->wg.nc, true);
1050-
psi::Psi<TK> dE_dWfc(this->psi->get_nk(), this->psi->get_nbands(), this->psi->get_nbasis());
1051-
dE_dWfc.zero_out();
1052-
1053-
double Etotal_RDMFT = this->rdmft_solver.run(dE_dOccNum, dE_dWfc);
1054-
// break;
1055-
}
1056-
10571023
}
10581024

10591025
//------------------------------------------------------------------------------

source/module_rdmft/cal_V_rdmft.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ void RDMFT<TK, TR>::cal_V_TV()
7575
orb->cutoffs(),
7676
&GlobalC::GridD,
7777
nspin,
78-
7978
charge,
8079
rho_basis,
8180
vloc,
@@ -95,7 +94,6 @@ void RDMFT<TK, TR>::cal_V_TV()
9594
orb->cutoffs(),
9695
&GlobalC::GridD,
9796
nspin,
98-
9997
charge,
10098
rho_basis,
10199
vloc,
@@ -129,7 +127,6 @@ void RDMFT<TK, TR>::cal_V_hartree()
129127
orb->cutoffs(),
130128
&GlobalC::GridD,
131129
nspin,
132-
133130
charge,
134131
rho_basis,
135132
vloc,
@@ -150,7 +147,6 @@ void RDMFT<TK, TR>::cal_V_hartree()
150147
orb->cutoffs(),
151148
&GlobalC::GridD,
152149
nspin,
153-
154150
charge,
155151
rho_basis,
156152
vloc,
@@ -215,7 +211,6 @@ void RDMFT<TK, TR>::cal_V_XC()
215211
orb->cutoffs(),
216212
&GlobalC::GridD,
217213
nspin,
218-
219214
charge,
220215
rho_basis,
221216
vloc,
@@ -238,7 +233,6 @@ void RDMFT<TK, TR>::cal_V_XC()
238233
orb->cutoffs(),
239234
&GlobalC::GridD,
240235
nspin,
241-
242236
charge,
243237
rho_basis,
244238
vloc,

source/module_rdmft/rdmft.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ void RDMFT<TK, TR>::cal_Energy(const int cal_type)
427427
template <typename TK, typename TR>
428428
double RDMFT<TK, TR>::run(ModuleBase::matrix& E_gradient_occNum, psi::Psi<TK>& E_gradient_wfc)
429429
{
430-
ModuleBase::TITLE("RDMFT", "E & Egradient");
431-
ModuleBase::timer::tick("RDMFT", "E & Egradient");
430+
ModuleBase::TITLE("RDMFT", "E_Egradient");
431+
ModuleBase::timer::tick("RDMFT", "E_Egradient");
432432

433433
// this->cal_V_hartree();
434434
// this->cal_V_XC();
@@ -443,7 +443,7 @@ double RDMFT<TK, TR>::run(ModuleBase::matrix& E_gradient_occNum, psi::Psi<TK>& E
443443
TK* pwfc_out = &E_gradient_wfc(0, 0, 0);
444444
for(int i=0; i<wfc.size(); ++i) { pwfc_out[i] = pwfc[i]; }
445445

446-
ModuleBase::timer::tick("RDMFT", "E & Egradient");
446+
ModuleBase::timer::tick("RDMFT", "E_Egradient");
447447
// return E_RDMFT[3];
448448
return Etotal;
449449
}

source/module_rdmft/rdmft_tools.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,6 @@ void Veff_rdmft<double, double>::contributeHR()
430430

431431

432432

433-
434-
435-
436433
}
437434

438435

source/module_rdmft/rdmft_tools.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,6 @@ namespace rdmft
9393
double occNum_func(double eta, int symbol = 0, const std::string XC_func_rdmft = "hf", const double alpha_power = 1.0);
9494

9595

96-
template <typename TK>
97-
void set_zero_vector(std::vector<TK>& HK)
98-
{
99-
for(int i=0; i<HK.size(); ++i) { HK[i] = 0.0;
100-
}
101-
}
102-
103-
104-
// template <typename TK>
105-
// void set_zero_psi(psi::Psi<TK>& wfc)
106-
// {
107-
// TK* pwfc_in = &wfc(0, 0, 0);
108-
// #ifdef _OPENMP
109-
// #pragma omp parallel for schedule(static, 1024)
110-
// #endif
111-
// for(int i=0; i<wfc.size(); ++i) pwfc_in[i] = 0.0;
112-
// }
11396

11497

11598
template <typename TK>
@@ -321,7 +304,6 @@ class Veff_rdmft : public hamilt::OperatorLCAO<TK, TR>
321304
const std::vector<double>& orb_cutoff,
322305
Grid_Driver* GridD_in,
323306
const int& nspin,
324-
325307
const Charge* charge_in,
326308
const ModulePW::PW_Basis* rho_basis_in,
327309
const ModuleBase::matrix* vloc_in,
@@ -336,7 +318,6 @@ class Veff_rdmft : public hamilt::OperatorLCAO<TK, TR>
336318
ucell(ucell_in),
337319
gd(GridD_in),
338320
hamilt::OperatorLCAO<TK, TR>(hsk_in, kvec_d_in, hR_in),
339-
340321
charge_(charge_in),
341322
rho_basis_(rho_basis_in),
342323
vloc_(vloc_in),
@@ -360,7 +341,6 @@ class Veff_rdmft : public hamilt::OperatorLCAO<TK, TR>
360341
const std::vector<double>& orb_cutoff,
361342
Grid_Driver* GridD_in,
362343
const int& nspin,
363-
364344
const Charge* charge_in,
365345
const ModulePW::PW_Basis* rho_basis_in,
366346
const ModuleBase::matrix* vloc_in,
@@ -373,7 +353,6 @@ class Veff_rdmft : public hamilt::OperatorLCAO<TK, TR>
373353
orb_cutoff_(orb_cutoff),
374354
pot(pot_in),
375355
hamilt::OperatorLCAO<TK, TR>(hsk_in, kvec_d_in, hR_in),
376-
377356
ucell(ucell_in),
378357
gd(GridD_in),
379358
charge_(charge_in),

tests/integrate/1001_NO_Si2_dzp_rdmft/INPUT

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ calculation scf
77
symmetry 1
88

99
#Parameters (2.Iteration)
10-
ecutwfc 60
11-
scf_thr 1e-6
10+
ecutwfc 40
11+
scf_thr 1e-4
1212
scf_nmax 100
1313
cal_force 0
1414
cal_stress 0
@@ -21,6 +21,7 @@ smearing_sigma 0.002
2121

2222
#Parameters (5.Mixing)
2323
mixing_type broyden
24+
mixing_gg0 0
2425
#mixing_beta 0.3
2526
#gamma_only 1
2627
ks_solver genelpa
@@ -29,4 +30,4 @@ ks_solver genelpa
2930
rdmft 1
3031
dft_functional cwp22
3132
exx_hse_omega 0.33
32-
rdmft_power_alpha 0.656
33+
rdmft_power_alpha 0.656
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
K_POINTS
22
0
33
Gamma
4-
2 2 1 0 0 0
4+
1 1 1 0 0 0
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
etotref -201.4138882681562848
2-
etotperatomref -100.7069441341
3-
pointgroupref BvK
4-
spacegroupref BvK
5-
nksibzref 3
1+
etotref -190.6366264651852021
2+
etotperatomref -95.3183132326
3+
pointgroupref T_d
4+
spacegroupref O_h
5+
nksibzref 1
66

77
The following energy units are in Rydberg:
8-
E_TV_RDMFT_ref 5.2788851446
9-
E_hartree_RDMFT_ref 1.3622516604
10-
Exc_cwp22_RDMFT_ref -4.5448173113
11-
E_Ewald_ref -16.8997585734
8+
E_TV_RDMFT_ref 6.0192500768
9+
E_hartree_RDMFT_ref 1.7433860179
10+
Exc_cwp22_RDMFT_ref -4.8744261767
11+
E_Ewald_ref -16.8997586021
1212
E_entropy_ref -0.0000000000
1313
E_descf_ref 0.0000000000
14-
Etotal_RDMFT_ref -14.8034390797
15-
Exc_ksdft_ref -2.4788985117
16-
E_exx_ksdft_ref -2.0657389944
14+
Etotal_RDMFT_ref -14.0115486841
15+
Exc_ksdft_ref -2.5444035632
16+
E_exx_ksdft_ref -2.3298744016
1717

18-
totaltimeref 118.49
18+
totaltimeref 60.45

tests/integrate/1002_NO_H2_dzp_rdmft/INPUT

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ suffix autotest
33
ntype 1
44
calculation scf
55
basis_type lcao
6-
ecutwfc 50
7-
scf_thr 1e-5
6+
ecutwfc 40
7+
scf_thr 1e-4
88
scf_nmax 100
99
gamma_only 0
1010
#symmetry -1

tests/integrate/1002_NO_H2_dzp_rdmft/STRU

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ NUMERICAL_ORBITAL
55
../../PP_ORB/H_gga_6au_60Ry_2s1p.orb
66

77
LATTICE_CONSTANT
8-
50.0 #37.79532, 22.6767
8+
40.0 #37.79532, 22.6767
99

1010
LATTICE_VECTORS
1111
1.0 0.0 0.0
@@ -20,5 +20,5 @@ Direct
2020
H
2121
0
2222
2
23-
0.5 0.5 0.49125 0 0 0 # 0.0175
24-
0.5 0.5 0.50875 0 0 0
23+
0.5 0.5 0.4825 0 0 0 # 0.035
24+
0.5 0.5 0.5175 0 0 0

0 commit comments

Comments
 (0)