Skip to content

Commit 2ffb4e2

Browse files
maki49mohanchen
andauthored
Fix: remove the dependence of EXX on RPA (#3969)
* fix: remove the dependence of exx on rpa * add parameter rpa_ccp_rmesh_times to seperate with exx * fix pbe+rpa bug in stod('default') update rpa parameter check fix test --------- Co-authored-by: Mohan Chen <[email protected]>
1 parent f1d065a commit 2ffb4e2

File tree

10 files changed

+48
-11
lines changed

10 files changed

+48
-11
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@
233233
- [exx\_opt\_orb\_ecut](#exx_opt_orb_ecut)
234234
- [exx\_opt\_orb\_tolerence](#exx_opt_orb_tolerence)
235235
- [exx\_real\_number](#exx_real_number)
236+
- [rpa\_ccp\_rmesh\_times](#rpa_ccp_rmesh_times)
236237
- [Molecular dynamics](#molecular-dynamics)
237238
- [md\_type](#md_type)
238239
- [md\_nstep](#md_nstep)
@@ -2276,6 +2277,12 @@ These variables are relevant when using hybrid functionals.
22762277
- True: if gamma_only
22772278
- False: else
22782279

2280+
### rpa_ccp_rmesh_times
2281+
2282+
- **Type**: Real
2283+
- **Description**: How many times larger the radial mesh required is to that of atomic orbitals in the postprocess calculation of the **bare** Coulomb matrix for RPA, GW, etc.
2284+
- **Default**: 10
2285+
22792286
[back to top](#full-list-of-input-keywords)
22802287

22812288
## Molecular dynamics

source/module_io/input.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ void Input::Default(void)
436436
exx_cauchy_stress_threshold = 1E-7;
437437
exx_ccp_threshold = 1E-8;
438438
exx_ccp_rmesh_times = "default";
439+
rpa_ccp_rmesh_times = 10.0;
439440

440441
exx_distribute_type = "htime";
441442

@@ -2778,10 +2779,12 @@ void Input::Default_2(void) // jiyy add 2019-08-04
27782779
{
27792780
std::string dft_functional_lower = dft_functional;
27802781
std::transform(dft_functional.begin(), dft_functional.end(), dft_functional_lower.begin(), tolower);
2781-
if (dft_functional_lower == "hf" || rpa)
2782+
if (dft_functional_lower == "hf")
27822783
exx_hybrid_alpha = "1";
27832784
else if (dft_functional_lower == "pbe0" || dft_functional_lower == "hse" || dft_functional_lower == "scan0")
27842785
exx_hybrid_alpha = "0.25";
2786+
else // no exx in scf, but will change to non-zero in postprocess like rpa
2787+
exx_hybrid_alpha = "0";
27852788
}
27862789
if (exx_real_number == "default")
27872790
{
@@ -2798,6 +2801,8 @@ void Input::Default_2(void) // jiyy add 2019-08-04
27982801
exx_ccp_rmesh_times = "5";
27992802
else if (dft_functional_lower == "hse")
28002803
exx_ccp_rmesh_times = "1.5";
2804+
else // no exx in scf
2805+
exx_ccp_rmesh_times = "1";
28012806
}
28022807
if (symmetry == "default")
28032808
{ // deal with no-forced default value
@@ -4123,6 +4128,13 @@ void Input::Check(void)
41234128
ModuleBase::WARNING_QUIT("INPUT", "exx_opt_orb_tolerence must >=0");
41244129
}
41254130
}
4131+
if (rpa)
4132+
{
4133+
if (rpa_ccp_rmesh_times < 1)
4134+
{
4135+
ModuleBase::WARNING_QUIT("INPUT", "must rpa_ccp_rmesh_times >= 1");
4136+
}
4137+
}
41264138

41274139
if (berry_phase)
41284140
{

source/module_io/input.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ class Input
393393
double exx_cauchy_stress_threshold;
394394
double exx_ccp_threshold;
395395
std::string exx_ccp_rmesh_times;
396+
double rpa_ccp_rmesh_times;
396397

397398
std::string exx_distribute_type;
398399

source/module_io/input_conv.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,6 @@ void Input_Conv::Convert(void)
594594
GlobalC::exx_info.info_global.cal_exx = false;
595595
Exx_Abfs::Jle::generate_matrix = true;
596596
}
597-
else if (INPUT.rpa)
598-
{
599-
GlobalC::exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Hf;
600-
}
601597
else
602598
{
603599
GlobalC::exx_info.info_global.cal_exx = false;

source/module_io/parameter_pool.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,10 @@ void input_parameters_set(std::map<std::string, InputParameter> input_parameters
12711271
{
12721272
INPUT.exx_opt_orb_tolerence = *static_cast<double*>(input_parameters["exx_opt_orb_tolerence"].get());
12731273
}
1274+
else if (input_parameters.count("rpa_ccp_rmesh_times") != 0)
1275+
{
1276+
INPUT.rpa_ccp_rmesh_times = *static_cast<double*>(input_parameters["rpa_ccp_rmesh_times"].get());
1277+
}
12741278
else if (input_parameters.count("td_force_dt") != 0)
12751279
{
12761280
INPUT.td_force_dt = *static_cast<double*>(input_parameters["td_force_dt"].get());

source/module_io/test/input_test.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,9 @@ TEST_F(InputTest, Default)
260260
EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_force_threshold,1E-7);
261261
EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_stress_threshold,1E-7);
262262
EXPECT_DOUBLE_EQ(INPUT.exx_ccp_threshold,1E-8);
263-
EXPECT_EQ(INPUT.exx_ccp_rmesh_times,"default");
264-
EXPECT_EQ(INPUT.exx_distribute_type,"htime");
263+
EXPECT_EQ(INPUT.exx_ccp_rmesh_times, "default");
264+
EXPECT_DOUBLE_EQ(INPUT.rpa_ccp_rmesh_times, 10.0);
265+
EXPECT_EQ(INPUT.exx_distribute_type, "htime");
265266
EXPECT_EQ(INPUT.exx_opt_orb_lmax,0);
266267
EXPECT_DOUBLE_EQ(INPUT.exx_opt_orb_ecut,0.0);
267268
EXPECT_DOUBLE_EQ(INPUT.exx_opt_orb_tolerence,0.0);
@@ -625,8 +626,9 @@ TEST_F(InputTest, Read)
625626
EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_force_threshold,0);
626627
EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_stress_threshold,0);
627628
EXPECT_DOUBLE_EQ(INPUT.exx_ccp_threshold,1E-8);
628-
EXPECT_EQ(INPUT.exx_ccp_rmesh_times,"default");
629-
EXPECT_EQ(INPUT.exx_distribute_type,"htime");
629+
EXPECT_EQ(INPUT.exx_ccp_rmesh_times, "default");
630+
EXPECT_DOUBLE_EQ(INPUT.rpa_ccp_rmesh_times, 10.0);
631+
EXPECT_EQ(INPUT.exx_distribute_type, "htime");
630632
EXPECT_EQ(INPUT.exx_opt_orb_lmax,0);
631633
EXPECT_DOUBLE_EQ(INPUT.exx_opt_orb_ecut,0.0);
632634
EXPECT_DOUBLE_EQ(INPUT.exx_opt_orb_tolerence,0.0);
@@ -1468,6 +1470,14 @@ TEST_F(InputTest, Check)
14681470
output = testing::internal::GetCapturedStdout();
14691471
EXPECT_THAT(output,testing::HasSubstr("must exx_ccp_rmesh_times >= 1"));
14701472
INPUT.exx_ccp_rmesh_times = "1.5";
1473+
//
1474+
INPUT.rpa = true;
1475+
INPUT.rpa_ccp_rmesh_times = -1;
1476+
testing::internal::CaptureStdout();
1477+
EXPECT_EXIT(INPUT.Check(), ::testing::ExitedWithCode(0), "");
1478+
output = testing::internal::GetCapturedStdout();
1479+
EXPECT_THAT(output, testing::HasSubstr("must rpa_ccp_rmesh_times >= 1"));
1480+
INPUT.rpa_ccp_rmesh_times = 10.0;
14711481
//
14721482
INPUT.exx_distribute_type = "arbitrary";
14731483
testing::internal::CaptureStdout();

source/module_io/test/input_test_para.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ TEST_F(InputParaTest, Bcast)
270270
EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_stress_threshold, 1E-7);
271271
EXPECT_DOUBLE_EQ(INPUT.exx_ccp_threshold, 1E-8);
272272
EXPECT_EQ(INPUT.exx_ccp_rmesh_times, "default");
273+
EXPECT_DOUBLE_EQ(INPUT.rpa_ccp_rmesh_times, 10.0);
273274
EXPECT_EQ(INPUT.exx_distribute_type, "htime");
274275
EXPECT_EQ(INPUT.exx_opt_orb_lmax, 0);
275276
EXPECT_DOUBLE_EQ(INPUT.exx_opt_orb_ecut, 0.0);

source/module_io/test/write_input_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,14 +663,14 @@ TEST_F(write_input, Exx14)
663663
testing::HasSubstr(
664664
"exx_cauchy_force_threshold 1e-07 #threshold to screen exx force using Cauchy-Schwartz inequality"));
665665
EXPECT_THAT(output,
666-
testing::HasSubstr("exx_ccp_rmesh_times default #how many times larger the radial mesh "
666+
testing::HasSubstr("exx_ccp_rmesh_times default #how many times larger the radial mesh "
667667
"required for calculating Columb potential is to that of atomic orbitals"));
668668
EXPECT_THAT(
669669
output,
670670
testing::HasSubstr(
671671
"exx_cauchy_stress_threshold 1e-07 #threshold to screen exx stress using Cauchy-Schwartz inequality"));
672672
EXPECT_THAT(output,
673-
testing::HasSubstr("exx_ccp_rmesh_times default #how many times larger the radial mesh "
673+
testing::HasSubstr("rpa_ccp_rmesh_times 10 #how many times larger the radial mesh "
674674
"required for calculating Columb potential is to that of atomic orbitals"));
675675
EXPECT_THAT(output,
676676
testing::HasSubstr(

source/module_io/write_input.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ ModuleBase::GlobalFunc::OUTP(ofs, "out_bandgap", out_bandgap, "if true, print ou
399399
ModuleBase::GlobalFunc::OUTP(ofs, "exx_opt_orb_lmax", exx_opt_orb_lmax, "the maximum l of the spherical Bessel functions for opt ABFs");
400400
ModuleBase::GlobalFunc::OUTP(ofs, "exx_opt_orb_ecut", exx_opt_orb_ecut, "the cut-off of plane wave expansion for opt ABFs");
401401
ModuleBase::GlobalFunc::OUTP(ofs, "exx_opt_orb_tolerence", exx_opt_orb_tolerence, "the threshold when solving for the zeros of spherical Bessel functions for opt ABFs");
402+
ModuleBase::GlobalFunc::OUTP(ofs, "rpa_ccp_rmesh_times", rpa_ccp_rmesh_times, "how many times larger the radial mesh required for calculating Columb potential is to that of atomic orbitals");
402403

403404
ofs << "\n#Parameters (16.tddft)" << std::endl;
404405
ModuleBase::GlobalFunc::OUTP(ofs, "td_force_dt", td_force_dt, "time of force change");

source/module_ri/RPA_LRI.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ void RPA_LRI<T, Tdata>::cal_postSCF_exx(const elecstate::DensityMatrix<T, Tdata>
7171
? RI_2D_Comm::split_m2D_ktoR<Tdata>(kv, mix_DMk_2D.get_DMk_gamma_out(), *dm.get_paraV_pointer())
7272
: RI_2D_Comm::split_m2D_ktoR<Tdata>(kv, mix_DMk_2D.get_DMk_k_out(), *dm.get_paraV_pointer());
7373

74+
// set parameters for bare Coulomb potential
75+
GlobalC::exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Hf;
76+
GlobalC::exx_info.info_global.hybrid_alpha = 1;
77+
GlobalC::exx_info.info_ri.ccp_rmesh_times = INPUT.rpa_ccp_rmesh_times;
78+
7479
exx_lri_rpa.init(mpi_comm_in, kv);
7580
exx_lri_rpa.cal_exx_ions();
7681
exx_lri_rpa.cal_exx_elec(Ds, *dm.get_paraV_pointer());

0 commit comments

Comments
 (0)