Skip to content

Commit

Permalink
add OrbitalLocalization to numerical_settings.py
Browse files Browse the repository at this point in the history
  • Loading branch information
EBB2675 committed Dec 4, 2024
1 parent 4ac1076 commit 10e782c
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 16 deletions.
40 changes: 27 additions & 13 deletions src/nomad_simulations/schema_packages/basis_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,21 @@ class AtomCenteredFunction(ArchiveSection):
)

function_type = Quantity(
type=MEnum('s', 'p', 'd', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
'sp', 'spd', 'spdf',
),
type=MEnum(
's',
'p',
'd',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'sp',
'spd',
'spdf',
),
description="""
L=a+b+c
The angular momentum of GTO to be added.
Expand All @@ -229,7 +241,7 @@ class AtomCenteredFunction(ArchiveSection):

contraction_coefficients = Quantity(
type=np.float32,
shape=['*'], # Flexible shape to handle combined types (e.g. SP, SPD..)
shape=['*'], # Flexible shape to handle combined types (e.g. SP, SPD..)
description="""
List of contraction coefficients corresponding to the exponents.
""",
Expand All @@ -255,8 +267,8 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
if self.n_primitive is not None:
if self.exponents is not None and len(self.exponents) != self.n_primitive:
raise ValueError(
f"Mismatch in number of exponents: expected {self.n_primitive}, "
f"found {len(self.exponents)}."
f'Mismatch in number of exponents: expected {self.n_primitive}, '
f'found {len(self.exponents)}.'
)

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

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

# Debug: Log split coefficients
for t, coeffs in self.coefficient_sets.items():
logger.info(f"{t}-type coefficients: {coeffs}")
logger.info(f'{t}-type coefficients: {coeffs}')
else:
logger.warning(f"No contraction coefficients provided for {self.function_type} type.")
logger.warning(
f'No contraction coefficients provided for {self.function_type} type.'
)

# For single types, ensure coefficients match primitives
elif self.contraction_coefficients is not None:
if len(self.contraction_coefficients) != self.n_primitive:
raise ValueError(
f"Mismatch in contraction coefficients: expected {self.n_primitive}, "
f"found {len(self.contraction_coefficients)}."
f'Mismatch in contraction coefficients: expected {self.n_primitive}, '
f'found {len(self.contraction_coefficients)}.'
)


Expand Down Expand Up @@ -330,7 +344,7 @@ class AtomCenteredBasisSet(BasisSetComponent):

total_number_of_basis_functions = Quantity(
type=np.int32,
description="",
description='',
)

functional_composition = SubSection(
Expand Down
36 changes: 36 additions & 0 deletions src/nomad_simulations/schema_packages/numerical_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,42 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
super().normalize(archive, logger)


class OrbitalLocalization(SelfConsistency):
"""
Numerical settings that control orbital localization.
"""

localization_method = (
Quantity(
type=MEnum('FB', 'PM', 'IBO', 'IAOIBO', 'IAOBOYS' 'NEWBOYS' 'AHFB'),
description="""
Name of the localization method.
""",
),
)

orbital_window = (
Quantity(
shape=['*'],
description="""
the Molecular orbital range to be localized.
""",
),
)

core_threshold = (
Quantity(
type=np.float64,
description="""
the energy window for the first occupied MO to be localized (in a.u.).
""",
),
)

def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
super().normalize(archive, logger)


class GTOIntegralDecomposition(NumericalSettings):
"""
A general class for integral decomposition techniques for Coulomb and exchange integrals.
Expand Down
19 changes: 16 additions & 3 deletions tests/test_basis_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,22 @@ def test_quick_step() -> None:
[
('cc-pVTZ', 'GTO', 'orbital', 'cc-pVTZ', 'GTO', 'orbital'),
('def2-TZVP', 'GTO', 'auxiliary_scf', 'def2-TZVP', 'GTO', 'auxiliary_scf'),
('aug-cc-pVDZ', 'STO', 'auxiliary_post_hf', 'aug-cc-pVDZ', 'STO', 'auxiliary_post_hf'),
('custom_basis', None, None, 'custom_basis', None, None), # Undefined type and role
(
'aug-cc-pVDZ',
'STO',
'auxiliary_post_hf',
'aug-cc-pVDZ',
'STO',
'auxiliary_post_hf',
),
(
'custom_basis',
None,
None,
'custom_basis',
None,
None,
), # Undefined type and role
],
)
def test_atom_centered_basis_set_init(
Expand Down Expand Up @@ -536,4 +550,3 @@ def test_atom_centered_basis_set_invalid_data():
# Call normalize to trigger validation
with pytest.raises(ValueError, match='Mismatch in number of exponents'):
invalid_function.normalize(None, None)

1 comment on commit 10e782c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/nomad_simulations
   __init__.py4250%3–4
   _version.py11282%5–6
src/nomad_simulations/schema_packages
   __init__.py15287%39–41
   atoms_state.py1902189%13–15, 201–204, 228, 283–284, 352–353, 355, 537, 549–550, 611–615, 630–634, 641
   basis_set.py2674085%8–9, 122–133, 172–185, 275–302, 536–540, 562–563, 607–610, 729, 760, 762
   general.py89891%4–7, 121, 185, 295–296, 306
   model_method.py2697871%10–12, 171–174, 177–184, 276–277, 297, 318–339, 355–381, 384–401, 587, 780, 791, 833–840, 878, 897, 977, 1034, 1109, 1223
   model_system.py3483789%45–51, 235, 254, 258, 261, 264, 290, 376–377, 454–455, 472–473, 686–689, 736–743, 917–918, 1140–1144, 1150–1151, 1159–1160, 1165, 1188
   numerical_settings.py2846876%12–14, 204–210, 280, 282–283, 286–289, 293–294, 301–304, 313–316, 320–323, 325–328, 333–336, 342–345, 532–559, 634, 669–672, 696, 699, 744, 746–749, 753, 757, 804, 808–829, 884–885, 952, 988, 1010
   outputs.py1201092%9–10, 252–255, 295–298, 323, 325, 362, 381
   physical_property.py102793%20–22, 202, 331–333
   variables.py861286%8–10, 98, 121, 145, 167, 189, 211, 233, 256, 276
src/nomad_simulations/schema_packages/properties
   band_gap.py51590%8–10, 135–136
   band_structure.py1232580%9–11, 232–265, 278, 285, 321–322, 325, 372–373, 378
   energies.py42979%7–9, 36, 57, 82, 103, 119, 134
   fermi_surface.py17476%7–9, 40
   forces.py22673%7–9, 36, 56, 79
   greens_function.py991387%7–9, 210–211, 214, 235–236, 239, 260–261, 264, 400
   hopping_matrix.py29583%7–9, 58, 94
   permittivity.py48883%7–9, 97–105
   spectral_profile.py26012851%9–11, 57–60, 95–98, 199–300, 356–368, 393–396, 416, 421–424, 466–502, 526, 573–576, 592–593, 598–604
   thermodynamics.py752764%7–9, 35, 56, 72, 81, 90, 101, 110, 137, 147, 157, 172–174, 177, 193, 213–215, 218, 234, 254–256, 259
src/nomad_simulations/schema_packages/utils
   utils.py791680%8–11, 65–74, 83–84, 89, 92, 169–170
TOTAL264153380% 

Tests Skipped Failures Errors Time
423 0 💤 0 ❌ 0 🔥 6.737s ⏱️

Please sign in to comment.