Skip to content

Commit f18d9d7

Browse files
authored
Merge branch 'develop' into move_fft
2 parents 1912e54 + 1bea8dd commit f18d9d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+7968
-47525
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2977,7 +2977,7 @@ These variables are relevant when using hybrid functionals with *[basis_type](#b
29772977
- **Type**: Real
29782978
- **Availability**: *[calculation](#calculation)==gen_opt_abfs*
29792979
- **Description**: The threshold when solving for the zeros of spherical Bessel functions. A reasonable choice is 1e-12.
2980-
- **Default**: 0
2980+
- **Default**: 1E-12
29812981

29822982
### exx_real_number
29832983

source/Makefile.Objects

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ OBJS_HAMILT=hamilt_pw.o\
334334
op_exx_pw.o\
335335
ekinetic_pw.o\
336336
ekinetic_op.o\
337+
exx_pw_ace.o\
338+
exx_pw_pot.o\
337339
hpsi_norm_op.o\
338340
veff_pw.o\
339341
veff_op.o\

source/source_cell/pseudo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "pseudo.h"
22
#include "source_base/tool_title.h"
3+
#include <cstdint>
34

45
pseudo::pseudo()
56
{

source/source_esolver/esolver_ks_pw.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,20 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
589589
auto start = std::chrono::high_resolution_clock::now();
590590
exx_helper.set_firstiter(false);
591591
exx_helper.op_exx->first_iter = false;
592+
double dexx = 0.0;
593+
if (PARAM.inp.exx_thr_type == "energy")
594+
{
595+
dexx = exx_helper.cal_exx_energy(this->kspw_psi);
596+
}
592597
exx_helper.set_psi(this->kspw_psi);
598+
if (PARAM.inp.exx_thr_type == "energy")
599+
{
600+
dexx -= exx_helper.cal_exx_energy(this->kspw_psi);
601+
// std::cout << "dexx = " << dexx << std::endl;
602+
}
603+
bool conv_ene = std::abs(dexx) < PARAM.inp.exx_ene_thr;
593604

594-
conv_esolver = exx_helper.exx_after_converge(iter);
595-
605+
conv_esolver = exx_helper.exx_after_converge(iter, conv_ene);
596606
if (!conv_esolver)
597607
{
598608
auto duration = std::chrono::high_resolution_clock::now() - start;
@@ -602,6 +612,7 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
602612
exx_helper.op_exx->first_iter = false;
603613
XC_Functional::set_xc_type(ucell.atoms[0].ncpp.xc_func);
604614
update_pot(ucell, istep, iter, conv_esolver);
615+
exx_helper.iter_inc();
605616
}
606617
}
607618
}
@@ -614,8 +625,9 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
614625
//----------------------------------------------------------
615626
// 3) Print out electronic wavefunctions in pw basis
616627
//----------------------------------------------------------
617-
if (iter % PARAM.inp.out_freq_elec == 0 || iter == PARAM.inp.scf_nmax || conv_esolver)
628+
if (iter % PARAM.inp.out_freq_elec == 0 || iter == PARAM.inp.scf_nmax)
618629
{
630+
// conv_esolver == true has already been dealt with in after_scf
619631
ModuleIO::write_wfc_pw(GlobalV::KPAR,
620632
GlobalV::MY_POOL,
621633
GlobalV::MY_RANK,

source/source_hamilt/module_xc/exx_info.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct Exx_Info
8181
{
8282
int abfs_Lmax = 0; // tmp
8383
double ecut_exx = 60;
84-
double tolerence = 1E-2;
84+
double tolerence = 1E-12;
8585
double kmesh_times = 4;
8686
};
8787
Exx_Info_Opt_ABFs info_opt_abfs;

source/source_io/module_parameter/input_parameter.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ struct Input_para
546546
///< calculating Columb potential is to that of atomic orbitals
547547
int exx_opt_orb_lmax = 0; ///< the maximum l of the spherical Bessel functions for opt ABFs
548548
double exx_opt_orb_ecut = 0.0; ///< the cut-off of plane wave expansion for opt ABFs
549-
double exx_opt_orb_tolerence = 0.0; ///< the threshold when solving for the zeros of spherical Bessel
549+
double exx_opt_orb_tolerence = 1E-12; ///< the threshold when solving for the zeros of spherical Bessel
550550
///< functions for opt ABFs
551551
bool exx_symmetry_realspace
552552
= true; ///< whether to reduce the real-space sector in when using symmetry=1 in EXX calculation
@@ -654,6 +654,8 @@ struct Input_para
654654
// EXX for planewave basis, rhx0820 2025-03-10
655655
bool exxace = true; // exxace, exact exchange for planewave basis, https://doi.org/10.1021/acs.jctc.6b00092
656656
bool exx_gamma_extrapolation = true; // gamma point extrapolation for exx, https://doi.org/10.1103/PhysRevB.79.205114
657+
std::string exx_thr_type = "density"; // threshold type for exx outer loop, energy or density
658+
double exx_ene_thr = 1e-5; // threshold for exx outer loop when exx_thr_type = energy
657659

658660
// ==== #Parameters (23.XC external parameterization) ========
659661
/*

source/source_io/read_input_item_other.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,32 @@ void ReadInput::item_others()
545545
read_sync_bool(input.exx_gamma_extrapolation);
546546
this->add_item(item);
547547
}
548+
{
549+
Input_Item item("exx_thr_type");
550+
item.annotation = "threshold type for exx outer loop, energy or density";
551+
read_sync_string(input.exx_thr_type);
552+
item.check_value = [](const Input_Item& item, const Parameter& para) {
553+
std::string thr_type = para.input.exx_thr_type;
554+
std::transform(thr_type.begin(), thr_type.end(), thr_type.begin(), ::tolower);
555+
if (thr_type != "energy" && thr_type != "density")
556+
{
557+
ModuleBase::WARNING_QUIT("ReadInput", "exx_thr_type should be energy or density");
558+
}
559+
};
560+
this->add_item(item);
561+
}
562+
{
563+
Input_Item item("exx_ene_thr");
564+
item.annotation = "threshold for exx outer loop when exx_thr_type = energy";
565+
read_sync_double(input.exx_ene_thr);
566+
item.check_value = [](const Input_Item& item, const Parameter& para) {
567+
if (para.input.exx_ene_thr <= 0)
568+
{
569+
ModuleBase::WARNING_QUIT("ReadInput", "exx_ene_thr must > 0");
570+
}
571+
};
572+
this->add_item(item);
573+
}
548574

549575
}
550576
} // namespace ModuleIO

source/source_io/test/read_input_ptest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ TEST_F(InputParaTest, ParaRead)
296296
EXPECT_DOUBLE_EQ(param.inp.rpa_ccp_rmesh_times, 10.0);
297297
EXPECT_EQ(param.inp.exx_opt_orb_lmax, 0);
298298
EXPECT_DOUBLE_EQ(param.inp.exx_opt_orb_ecut, 0.0);
299-
EXPECT_DOUBLE_EQ(param.inp.exx_opt_orb_tolerence, 0.0);
299+
EXPECT_DOUBLE_EQ(param.inp.exx_opt_orb_tolerence, 1E-12);
300300
EXPECT_FALSE(param.inp.noncolin);
301301
EXPECT_FALSE(param.inp.lspinorb);
302302
EXPECT_DOUBLE_EQ(param.inp.soc_lambda, 1.0);

source/source_io/test/support/INPUT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ exx_v_grad_r_threshold 0 #
291291
exx_ccp_rmesh_times default #
292292
exx_opt_orb_lmax 0 #
293293
exx_opt_orb_ecut 0 #
294-
exx_opt_orb_tolerence 0 #
294+
exx_opt_orb_tolerence 1E-12 #
295295

296296
#Parameters (16.tddft)
297297
td_vext 0 #add extern potential or not

source/source_lcao/module_deepks/deepks_basic.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ void DeePKS_domain::load_model(const std::string& model_file, torch::jit::script
6161
ModuleBase::TITLE("DeePKS_domain", "load_model");
6262
ModuleBase::timer::tick("DeePKS_domain", "load_model");
6363

64+
// check whether file exists
65+
std::ifstream ifs(model_file.c_str());
66+
if (!ifs)
67+
{
68+
ModuleBase::timer::tick("DeePKS_domain", "load_model");
69+
ModuleBase::WARNING_QUIT("DeePKS_domain::load_model", "No model file named " + model_file + ", please check!");
70+
return;
71+
}
72+
ifs.close();
6473
try
6574
{
6675
model = torch::jit::load(model_file);

0 commit comments

Comments
 (0)