Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/koopmans/aiida/setup/pseudos/_norm_conserving.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
11 changes: 11 additions & 0 deletions tests/test_norm_conserving_families.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down