Skip to content

Commit e66175a

Browse files
committed
add typed XC partner references
1 parent 72228d1 commit e66175a

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/nomad_simulations/schema_packages/model_method.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
URL,
88
MEnum,
99
Quantity,
10+
Reference,
1011
Section,
12+
SectionProxy,
1113
SubSection,
1214
)
1315

@@ -265,10 +267,20 @@ class ExplicitDispersionModel(BaseModelMethod):
265267
description='Short-range damping: D3{zero,BJ}, TS{fermi}, XDM{rational}.',
266268
)
267269

268-
# TODO later: link to XCComponent(s)
270+
xc_partner_ref = Quantity(
271+
type=Reference(SectionProxy('XCFunctional')),
272+
description="""
273+
Reference to the baseline `XCFunctional` section this model is paired with.
274+
""",
275+
)
276+
277+
# Deprecated compatibility field. Prefer `xc_partner_ref`.
269278
xc_partner = Quantity(
270279
type=str,
271-
description="Base XC functional used/tuned for (e.g. 'PBE', 'SCAN', 'B3LYP').",
280+
description="""
281+
Deprecated string label for the baseline XC partner
282+
(e.g. 'PBE', 'SCAN', 'B3LYP'). Prefer `xc_partner_ref`.
283+
""",
272284
)
273285

274286

@@ -372,10 +384,20 @@ class NonlocalCorrelation(BaseModelMethod):
372384
""",
373385
)
374386

375-
# TODO later: link to XCComponent(s)
387+
xc_partner_ref = Quantity(
388+
type=Reference(SectionProxy('XCFunctional')),
389+
description="""
390+
Reference to the baseline `XCFunctional` section this nonlocal term is paired with.
391+
""",
392+
)
393+
394+
# Deprecated compatibility field. Prefer `xc_partner_ref`.
376395
xc_partner = Quantity(
377396
type=str,
378-
description="Base XC functional used/tuned for (e.g. 'PBE', 'SCAN', 'B3LYP').",
397+
description="""
398+
Deprecated string label for the baseline XC partner
399+
(e.g. 'PBE', 'SCAN', 'B3LYP'). Prefer `xc_partner_ref`.
400+
""",
379401
)
380402

381403

@@ -648,6 +670,7 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
648670
existing_nonlocal.type = nonlocal_corr_addon
649671

650672
if base_xc_key:
673+
existing_nonlocal.xc_partner_ref = self.xc
651674
existing_nonlocal.xc_partner = base_xc_key
652675

653676
# XC-specific normalization now handled by XCFunctional

tests/test_model_method.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ def test_dft_nonlocal_addon_creates_nonlocal_contribution_and_sets_partner():
696696
]
697697
assert len(nonlocal_terms) == 1
698698
assert nonlocal_terms[0].type == 'rVV10'
699+
assert nonlocal_terms[0].xc_partner_ref is dft.xc
699700
assert nonlocal_terms[0].xc_partner == 'SCAN'
700701

701702

@@ -713,6 +714,7 @@ def test_dft_nonlocal_addon_reuses_existing_matching_nonlocal_contribution():
713714
assert len(nonlocal_terms) == 1
714715
assert nonlocal_terms[0] is existing_nonlocal
715716
assert nonlocal_terms[0].type == 'VV10'
717+
assert nonlocal_terms[0].xc_partner_ref is dft.xc
716718
assert nonlocal_terms[0].xc_partner == 'PBE'
717719

718720

@@ -730,6 +732,7 @@ def test_dft_nonlocal_addon_fills_empty_existing_nonlocal_type():
730732
assert len(nonlocal_terms) == 1
731733
assert nonlocal_terms[0] is existing_nonlocal
732734
assert nonlocal_terms[0].type == 'VV10'
735+
assert nonlocal_terms[0].xc_partner_ref is dft.xc
733736
assert nonlocal_terms[0].xc_partner == 'r2SCAN'
734737

735738

0 commit comments

Comments
 (0)