diff --git a/src/koopmans/aiida/setup/pseudos/_norm_conserving.py b/src/koopmans/aiida/setup/pseudos/_norm_conserving.py index ed74a886..d06b981f 100644 --- a/src/koopmans/aiida/setup/pseudos/_norm_conserving.py +++ b/src/koopmans/aiida/setup/pseudos/_norm_conserving.py @@ -25,11 +25,12 @@ def get_content(self) -> str: # UPF ``pseudo_type`` values that are not norm-conserving. "NC" and "SL" -# (semilocal) are; "1/r" is a bare Coulomb potential, which pw.x takes but the -# Koopmans codes do not. "US" is what a v1 header carries, where there are no -# flags to fall back on; "USPP" is PSlibrary's v2 spelling, and "1/r" is -# carried against a header that names a type without flagging itself. -_NOT_NORM_CONSERVING = {"US", "USPP", "PAW", "1/r"} +# (semilocal) are; "US" is what a v1 header carries, where there are no +# flags to fall back on; "USPP" is PSlibrary's v2 spelling. A bare Coulomb +# potential ("1/r") passes: both kcp.x and kcw.x synthesise its local +# potential and treat it like any local-only norm-conserving potential +# (CPV/src/pseudopot_sub.f90, upflib/vloc_mod.f90). +_NOT_NORM_CONSERVING = {"US", "USPP", "PAW"} # UPF v2 writes the header as XML attributes. Only the first 4 kB after the # tag is searched, which covers the longest real header and keeps a stray diff --git a/tests/conftest.py b/tests/conftest.py index 0a5934a9..44596f7d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,6 +18,7 @@ clear_database_after_test, code_without_mpi_flag, compiled_binaries, + fake_coulomb_family, fake_declared_nc_family, fake_paw_family, fake_pseudodojo_lda_family, diff --git a/tests/fixtures.py b/tests/fixtures.py index fd69fed3..9774ab78 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -781,6 +781,12 @@ def fake_ultrasoft_family(aiida_profile: Any) -> Any: return _install_fake_family("MyPseudos/ultrasoft", {"Si": 4.0}, cutoffs=True, pseudo_type="US") +@pytest.fixture +def fake_coulomb_family(aiida_profile: Any) -> Any: + """Install a self-built family whose Si pseudopotential is a bare Coulomb potential.""" + return _install_fake_family("MyPseudos/coulomb", {"Si": 4.0}, cutoffs=True, pseudo_type="1/r") + + @pytest.fixture def fake_paw_family(aiida_profile: Any) -> Any: """Install a self-built family whose Si pseudopotential is PAW.""" diff --git a/tests/test_norm_conserving_families.py b/tests/test_norm_conserving_families.py index fde3ce96..77d6e3b8 100644 --- a/tests/test_norm_conserving_families.py +++ b/tests/test_norm_conserving_families.py @@ -57,6 +57,17 @@ def test_an_ultrasoft_or_paw_family_is_refused( assert f"Si ({pseudo_type})" in message assert "workflow.pseudo_library" in message + def test_a_bare_coulomb_family_is_accepted( + self, aiida_profile_clean: Any, fake_coulomb_family: Any + ) -> None: + """A bare Coulomb potential ("1/r") passes the check. + + kcp.x and kcw.x synthesise its local potential and treat it like a + local-only norm-conserving potential, so there is nothing to refuse. + """ + _, pseudo_family, _ = _dispatch("MyPseudos/coulomb") + assert pseudo_family == "MyPseudos/coulomb" + def test_a_family_declaring_itself_nc_is_accepted( self, aiida_profile_clean: Any, fake_declared_nc_family: Any ) -> None: