Skip to content

Commit 10e782c

Browse files
committed
add OrbitalLocalization to numerical_settings.py
1 parent 4ac1076 commit 10e782c

File tree

3 files changed

+79
-16
lines changed

3 files changed

+79
-16
lines changed

src/nomad_simulations/schema_packages/basis_set.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,21 @@ class AtomCenteredFunction(ArchiveSection):
202202
)
203203

204204
function_type = Quantity(
205-
type=MEnum('s', 'p', 'd', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
206-
'sp', 'spd', 'spdf',
207-
),
205+
type=MEnum(
206+
's',
207+
'p',
208+
'd',
209+
'f',
210+
'g',
211+
'h',
212+
'i',
213+
'j',
214+
'k',
215+
'l',
216+
'sp',
217+
'spd',
218+
'spdf',
219+
),
208220
description="""
209221
L=a+b+c
210222
The angular momentum of GTO to be added.
@@ -229,7 +241,7 @@ class AtomCenteredFunction(ArchiveSection):
229241

230242
contraction_coefficients = Quantity(
231243
type=np.float32,
232-
shape=['*'], # Flexible shape to handle combined types (e.g. SP, SPD..)
244+
shape=['*'], # Flexible shape to handle combined types (e.g. SP, SPD..)
233245
description="""
234246
List of contraction coefficients corresponding to the exponents.
235247
""",
@@ -255,8 +267,8 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
255267
if self.n_primitive is not None:
256268
if self.exponents is not None and len(self.exponents) != self.n_primitive:
257269
raise ValueError(
258-
f"Mismatch in number of exponents: expected {self.n_primitive}, "
259-
f"found {len(self.exponents)}."
270+
f'Mismatch in number of exponents: expected {self.n_primitive}, '
271+
f'found {len(self.exponents)}.'
260272
)
261273

262274
# Resolve combined types
@@ -266,8 +278,8 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
266278
expected_coeffs = num_types * self.n_primitive
267279
if len(self.contraction_coefficients) != expected_coeffs:
268280
raise ValueError(
269-
f"Mismatch in contraction coefficients for {self.function_type} type: "
270-
f"expected {expected_coeffs}, found {len(self.contraction_coefficients)}."
281+
f'Mismatch in contraction coefficients for {self.function_type} type: '
282+
f'expected {expected_coeffs}, found {len(self.contraction_coefficients)}.'
271283
)
272284

273285
# Split coefficients into separate lists for each type
@@ -278,16 +290,18 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
278290

279291
# Debug: Log split coefficients
280292
for t, coeffs in self.coefficient_sets.items():
281-
logger.info(f"{t}-type coefficients: {coeffs}")
293+
logger.info(f'{t}-type coefficients: {coeffs}')
282294
else:
283-
logger.warning(f"No contraction coefficients provided for {self.function_type} type.")
295+
logger.warning(
296+
f'No contraction coefficients provided for {self.function_type} type.'
297+
)
284298

285299
# For single types, ensure coefficients match primitives
286300
elif self.contraction_coefficients is not None:
287301
if len(self.contraction_coefficients) != self.n_primitive:
288302
raise ValueError(
289-
f"Mismatch in contraction coefficients: expected {self.n_primitive}, "
290-
f"found {len(self.contraction_coefficients)}."
303+
f'Mismatch in contraction coefficients: expected {self.n_primitive}, '
304+
f'found {len(self.contraction_coefficients)}.'
291305
)
292306

293307

@@ -330,7 +344,7 @@ class AtomCenteredBasisSet(BasisSetComponent):
330344

331345
total_number_of_basis_functions = Quantity(
332346
type=np.int32,
333-
description="",
347+
description='',
334348
)
335349

336350
functional_composition = SubSection(

src/nomad_simulations/schema_packages/numerical_settings.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,42 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
952952
super().normalize(archive, logger)
953953

954954

955+
class OrbitalLocalization(SelfConsistency):
956+
"""
957+
Numerical settings that control orbital localization.
958+
"""
959+
960+
localization_method = (
961+
Quantity(
962+
type=MEnum('FB', 'PM', 'IBO', 'IAOIBO', 'IAOBOYS' 'NEWBOYS' 'AHFB'),
963+
description="""
964+
Name of the localization method.
965+
""",
966+
),
967+
)
968+
969+
orbital_window = (
970+
Quantity(
971+
shape=['*'],
972+
description="""
973+
the Molecular orbital range to be localized.
974+
""",
975+
),
976+
)
977+
978+
core_threshold = (
979+
Quantity(
980+
type=np.float64,
981+
description="""
982+
the energy window for the first occupied MO to be localized (in a.u.).
983+
""",
984+
),
985+
)
986+
987+
def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
988+
super().normalize(archive, logger)
989+
990+
955991
class GTOIntegralDecomposition(NumericalSettings):
956992
"""
957993
A general class for integral decomposition techniques for Coulomb and exchange integrals.

tests/test_basis_set.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,22 @@ def test_quick_step() -> None:
426426
[
427427
('cc-pVTZ', 'GTO', 'orbital', 'cc-pVTZ', 'GTO', 'orbital'),
428428
('def2-TZVP', 'GTO', 'auxiliary_scf', 'def2-TZVP', 'GTO', 'auxiliary_scf'),
429-
('aug-cc-pVDZ', 'STO', 'auxiliary_post_hf', 'aug-cc-pVDZ', 'STO', 'auxiliary_post_hf'),
430-
('custom_basis', None, None, 'custom_basis', None, None), # Undefined type and role
429+
(
430+
'aug-cc-pVDZ',
431+
'STO',
432+
'auxiliary_post_hf',
433+
'aug-cc-pVDZ',
434+
'STO',
435+
'auxiliary_post_hf',
436+
),
437+
(
438+
'custom_basis',
439+
None,
440+
None,
441+
'custom_basis',
442+
None,
443+
None,
444+
), # Undefined type and role
431445
],
432446
)
433447
def test_atom_centered_basis_set_init(
@@ -536,4 +550,3 @@ def test_atom_centered_basis_set_invalid_data():
536550
# Call normalize to trigger validation
537551
with pytest.raises(ValueError, match='Mismatch in number of exponents'):
538552
invalid_function.normalize(None, None)
539-

0 commit comments

Comments
 (0)