Repository navigation
Add RPA smooth coulomb cutoff for V_cut #8212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
293f817
0133ed4
bf59ad2
73d698b
2430c47
8695536
feada6a
c4ba0f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,9 @@ | ||
| AddTest( | ||
| TARGET MODULE_HAMILT_RpaCutoffConfig | ||
| LIBS parameter base device | ||
| SOURCES test_exx_info.cpp ../exx_info.cpp | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please gate this target or its PBE section on |
||
| ) | ||
|
|
||
| AddTest( | ||
| TARGET MODULE_HAMILT_XCTest_PBE | ||
| LIBS parameter MPI::MPI_CXX Libxc::xc | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #include "../exx_info.h" | ||
| #include "source_io/module_parameter/input_parameter.h" | ||
| #include <gtest/gtest.h> | ||
| #include <stdexcept> | ||
|
|
||
| TEST(RpaCutoffConfig, HseDefaultsRemainSupportedButNondefaultCutoffsAreRejected) | ||
| { | ||
| Input_para cut_input; | ||
| cut_input.basis_type = "lcao"; | ||
| cut_input.rpa = true; | ||
| cut_input.dft_functional = "hse"; | ||
| // Prepared HSE defaults, after INPUT reset hooks have resolved "default". | ||
| cut_input.exx_fock_alpha.clear(); | ||
| cut_input.exx_fock_lambda.clear(); | ||
| cut_input.exx_erfc_alpha = {"0.25"}; | ||
| cut_input.exx_erfc_omega = {"0.11"}; | ||
| cut_input.exx_singularity_correction = "limits"; | ||
| cut_input.exx_real_number = "1"; | ||
| cut_input.exx_ccp_rmesh_times = "2"; | ||
| Exx_Info cut_default_info; | ||
| EXPECT_NO_THROW(init_exx_info(cut_default_info, cut_input)); | ||
| EXPECT_EQ(cut_default_info.info_ri.coulomb_param.count(Conv_Coulomb_Pot_K::Coulomb_Type::Fock), 0); | ||
| EXPECT_EQ(cut_default_info.info_ri.coulomb_param.count(Conv_Coulomb_Pot_K::Coulomb_Type::Erfc), 1); | ||
|
|
||
| cut_input.rpa_cut_coulomb = "log_erfc"; | ||
| Exx_Info cut_smooth_info; | ||
| EXPECT_THROW(init_exx_info(cut_smooth_info, cut_input), std::invalid_argument); | ||
| cut_input.rpa_cut_coulomb = "hard"; | ||
| cut_input.rpa_cut_radius = "inscribed"; | ||
| Exx_Info cut_inscribed_info; | ||
| EXPECT_THROW(init_exx_info(cut_inscribed_info, cut_input), std::invalid_argument); | ||
|
|
||
| cut_input.dft_functional = "pbe"; | ||
| cut_input.rpa_cut_coulomb = "log_erfc"; | ||
| Exx_Info cut_pbe_info; | ||
| ASSERT_NO_THROW(init_exx_info(cut_pbe_info, cut_input)); | ||
| const auto& cut_fock = cut_pbe_info.info_ri.coulomb_param.at(Conv_Coulomb_Pot_K::Coulomb_Type::Fock); | ||
| ASSERT_EQ(cut_fock.size(), 1); | ||
| EXPECT_EQ(cut_fock.front().at("rpa_cut_coulomb"), "log_erfc"); | ||
| EXPECT_EQ(cut_fock.front().at("rpa_cut_radius"), "inscribed"); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -569,6 +569,42 @@ Use the same scheme for consistent SCF and NSCF bands. A source configuration mi | |
| }; | ||
| this->add_item(item); | ||
| } | ||
| { | ||
| Input_Item item("rpa_cut_coulomb"); | ||
| item.annotation = "post-SCF truncated Coulomb kernel for RPA/GW export"; | ||
| item.category = "Exact Exchange (LCAO)"; | ||
| item.type = "String"; | ||
| item.description = "Post-SCF cut-Coulomb kernel: hard preserves Spencer truncation; log_erfc uses erfc(log(r/Rc)/log(rpa_cut_width))/2r. Applies to Fock components in compressed and uncompressed cut exports; Erfc components retain their existing kernel. Non-default kernel/radius requests require a Fock component. Full Coulomb is unchanged. Forces and stresses for log_erfc are not validated."; | ||
| item.default_value = "hard"; | ||
| item.unit = ""; | ||
| read_sync_string(input.rpa_cut_coulomb); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please declare both enum choices with
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in |
||
| item.domain.set_choices({"hard", "log_erfc"}); | ||
| this->add_item(item); | ||
| } | ||
| { | ||
| Input_Item item("rpa_cut_radius"); | ||
| item.annotation = "radius convention for post-SCF cut Coulomb"; | ||
| item.category = "Exact Exchange (LCAO)"; | ||
| item.type = "String"; | ||
| item.description = "legacy preserves the existing cutoff radius. inscribed uses half the shortest nonzero BvK superlattice vector, including the lattice scale in Bohr. Applies only to Fock components; inscribed is rejected if the RPA Coulomb configuration has no Fock component. Independent of rpa_cut_coulomb; intended for controlled radius-versus-smoothing comparisons."; | ||
| item.default_value = "legacy"; | ||
| item.unit = ""; | ||
| read_sync_string(input.rpa_cut_radius); | ||
| item.domain.set_choices({"legacy", "inscribed"}); | ||
| this->add_item(item); | ||
| } | ||
| { | ||
| Input_Item item("rpa_cut_width"); | ||
| item.annotation = "multiplicative width of the log-erfc cutoff"; | ||
| item.category = "Exact Exchange (LCAO)"; | ||
| item.type = "Real"; | ||
| item.description = "Width factor for log_erfc. Must be finite and greater than 1 and at most 1.25. The default matches the logged Si FHI-aims width; it is not a universal FHI-aims constant. The finite radial integration range must resolve the smooth tail."; | ||
| item.default_value = "1.091868692359"; | ||
| item.unit = ""; | ||
| read_sync_double(input.rpa_cut_width); | ||
| item.domain.set_rule("value>1 and value<=1.25"); | ||
| this->add_item(item); | ||
| } | ||
| { | ||
| Input_Item item("exx_symmetry_realspace"); | ||
| item.annotation = "whether to reduce real-space sector in Hexx calculation"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| #include "conv_coulomb_pot_k.h" | ||
| #include "smooth_cut_coulomb.h" | ||
| #include "source_base/constants.h" | ||
| #include "source_io/module_parameter/parameter.h" | ||
| #include "source_basis/module_ao/orb_atomic_lm.h" | ||
|
|
@@ -162,11 +163,26 @@ namespace Conv_Coulomb_Pot_K | |
| case Conv_Coulomb_Pot_K::Coulomb_Type::Fock: { | ||
| for (const auto& param: param_list.second) | ||
| { | ||
| psik2_ccp = psik2_ccp | ||
| + std::stod(param.at("alpha")) | ||
| * cal_psi_fock_spencer(orbs.get_psif(), | ||
| orbs.get_k_radial(), | ||
| std::stod(param.at("Rcut"))); | ||
| const auto cut_mode = param.find("rpa_cut_coulomb"); | ||
| if (cut_mode != param.end() && cut_mode->second == "log_erfc") | ||
| { | ||
| const double cut_radius = std::stod(param.at("Rcut")); | ||
| const double cut_width = std::stod(param.at("rpa_cut_width")); | ||
| const double cut_alpha = std::stod(param.at("alpha")); | ||
| for (size_t cut_ik = 0; cut_ik < psik2_ccp.size(); ++cut_ik) | ||
| { | ||
| psik2_ccp[cut_ik] += cut_alpha * ModuleBase::FOUR_PI * orbs.get_psif()[cut_ik] | ||
| * log_erfc_cut_factor(orbs.get_k_radial()[cut_ik], cut_radius, cut_width); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking: please consider tabulating the cutoff factor once per distinct momentum grid, radius and width within this conversion, then reusing it across auxiliary orbitals. The factor is independent of the orbital amplitude, but the recursive conversion repeats its 128-or-more-panel quadrature at nonzero momentum on shared grids. A local table avoids global mutable state, and this can follow after merge if current performance is acceptable. |
||
| } | ||
| } | ||
| else | ||
| { | ||
| psik2_ccp = psik2_ccp | ||
| + std::stod(param.at("alpha")) | ||
| * cal_psi_fock_spencer(orbs.get_psif(), | ||
| orbs.get_k_radial(), | ||
| std::stod(param.at("Rcut"))); | ||
| } | ||
| } | ||
| break; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With
rpa=true,dft_functional=hseand default exchange parameters, this map contains onlyErfc, sorpa_cut_coulomb=log_erfcandrpa_cut_radius=inscribedare silently ignored here. Please reject or explicitly diagnose these unsupported requests and document the Fock-only scope, with a configuration-level regression. The existing HSE kernel convention can remain unchanged.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in
73d698b649bb0bd91f6638fd0ccbee6490ae3e02: initialization now rejects nondefault kernel/radius requests on an Erfc-only map, and the INPUT descriptions state the Fock-only scope. This was checked by static source tracing; the new configuration test's LibRI-disabled registration issue is tracked separately. No runtime validation was performed.