Skip to content

Commit 4255198

Browse files
committed
Merge remote-tracking branch 'origin/develop' into nonlocal-correlation
2 parents 2221217 + f6480b7 commit 4255198

File tree

11 files changed

+79
-46
lines changed

11 files changed

+79
-46
lines changed

src/nomad_simulations/schema_packages/atoms_state.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,16 @@ class AtomsState(ParticleState):
11141114
""",
11151115
)
11161116

1117+
partial_charge = Quantity(
1118+
type=np.float64,
1119+
unit='elementary_charge',
1120+
description="""
1121+
Atom-centered partial charge used in force fields or population analyses
1122+
(e.g., Mulliken, Hirshfeld, CM5, NPA, RESP). This quantity is distinct from
1123+
the formal integer oxidation-like `charge`.
1124+
""",
1125+
)
1126+
11171127
spin = Quantity(
11181128
type=np.int32,
11191129
default=0,

src/nomad_simulations/schema_packages/force_field.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def normalize(self, archive, logger) -> None:
353353
except ValueError as e:
354354
logger.warning(
355355
f'Unable to derive tabulated forces from energies in {self.name},'
356-
f'Unkown error occurred in derivation: {e}'
356+
f'Unknown error occurred in derivation: {e}'
357357
)
358358

359359
if self.forces is not None and self.energies is None:
@@ -399,7 +399,7 @@ def normalize(self, archive, logger) -> None:
399399
except ValueError as e:
400400
logger.warning(
401401
f'Unable to derive tabulated energies from forces in {self.name},'
402-
f'Unkown error occurred in derivation: {e}'
402+
f'Unknown error occurred in derivation: {e}'
403403
)
404404

405405

src/nomad_simulations/schema_packages/model_method.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,13 @@ def normalize(self, archive, logger):
223223
)
224224

225225

226-
class ExplicitDispersionModel(BaseModelMethod):
227-
"""Explicit dispersion / vdW treatment used together with an ab-initio method.
226+
class EmpiricalDispersionModel(BaseModelMethod):
227+
"""Empirical dispersion correction used together with an ab-initio method.
228228
229229
Covers pairwise-additive (D2/D3/D3(BJ)/D4), density-dependent (TS/TS-SCS),
230-
many-body dispersion (MBD, e.g. MBD@rsSCS), and exchange-hole based (XDM) models.
230+
many-body dispersion (MBD, e.g. MBD@rsSCS), and exchange-hole based XDM.
231+
In literature, `DFT-D` is often used as an umbrella label; this schema stores
232+
the concrete generation explicitly when available (e.g. D2, D3, D3BJ, D4).
231233
232234
References
233235
----------
@@ -241,7 +243,7 @@ class ExplicitDispersionModel(BaseModelMethod):
241243

242244
model = Quantity(
243245
type=MEnum(
244-
# Pairwise / density-dependent
246+
# Pairwise / density-dependent empirical models
245247
'D2',
246248
'D3',
247249
'D3BJ',
@@ -257,7 +259,7 @@ class ExplicitDispersionModel(BaseModelMethod):
257259
'XDM',
258260
),
259261
description="""
260-
Identifier of the explicit dispersion / vdW model.
262+
Identifier of the empirical dispersion correction model.
261263
""",
262264
)
263265

@@ -266,11 +268,10 @@ class ExplicitDispersionModel(BaseModelMethod):
266268
description='Short-range damping: D3{zero,BJ}, TS{fermi}, XDM{rational}.',
267269
)
268270

269-
xc_partner_ref = Quantity(
270-
type=Reference(SectionProxy('XCFunctional')),
271-
description="""
272-
Reference to the baseline `XCFunctional` section this model is paired with.
273-
""",
271+
# TODO later: link to XCComponent(s)
272+
xc_partner = Quantity(
273+
type=str,
274+
description="Base XC functional used/tuned for (e.g. 'PBE', 'SCAN', 'B3LYP').",
274275
)
275276

276277

src/nomad_simulations/schema_packages/numerical_settings.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,9 +1287,9 @@ class SolvationSettings(NumericalSettings):
12871287
)
12881288

12891289

1290-
class DispersionKnob(ArchiveSection):
1290+
class EmpiricalDispersionKnob(ArchiveSection):
12911291
"""
1292-
A single typed numerical knob for an explicit dispersion / vdW correction.
1292+
A single typed numerical knob for an empirical dispersion correction.
12931293
12941294
This is a "typed physical constraint" record: it stores one scalar value
12951295
together with semantics that disambiguate what the value controls.
@@ -1305,14 +1305,12 @@ class DispersionKnob(ArchiveSection):
13051305
'a1',
13061306
'a2',
13071307
'sR',
1308-
# Nonlocal kernel parameter
1309-
'b',
13101308
# Many-body screening / range separation
13111309
'beta',
13121310
),
13131311
description="""
13141312
Identifies the dispersion parameter using standard notation.
1315-
(e.g. s6, a1, beta, b).
1313+
(e.g. s6, a1, beta).
13161314
13171315
All dispersion knobs are dimensionless.
13181316
""",
@@ -1323,7 +1321,6 @@ class DispersionKnob(ArchiveSection):
13231321
'pairwise',
13241322
'three_body_atm',
13251323
'many_body',
1326-
'nonlocal_kernel',
13271324
'density_partitioning',
13281325
),
13291326
description="""
@@ -1339,13 +1336,13 @@ class DispersionKnob(ArchiveSection):
13391336
)
13401337

13411338

1342-
class DispersionSettings(NumericalSettings):
1339+
class EmpiricalDispersionSettings(NumericalSettings):
13431340
"""
1344-
Numerical and evaluation settings for an explicit dispersion / vdW correction.
1341+
Numerical and evaluation settings for an empirical dispersion correction.
13451342
13461343
This section contains discrete switches and environment choices (e.g. whether
13471344
to include higher-order dispersion terms, which density partitioning is used),
1348-
as well as typed scalar parameters stored as `DispersionKnob`.
1345+
as well as typed scalar parameters stored as `EmpiricalDispersionKnob`.
13491346
"""
13501347

13511348
# switches for term inclusion / order
@@ -1405,14 +1402,14 @@ class DispersionSettings(NumericalSettings):
14051402

14061403
# typed scalar parameters
14071404
knobs = SubSection(
1408-
sub_section=DispersionKnob.m_def,
1405+
sub_section=EmpiricalDispersionKnob.m_def,
14091406
repeats=True,
14101407
description="""
14111408
Typed scalar parameters (knobs) for the dispersion correction.
14121409
14131410
Examples:
14141411
• D3BJ: s6/s8 (pairwise), a1/a2 (pairwise), optionally s9 (three_body_atm)
1415-
rVV10: b (nonlocal_kernel)
1412+
MBD@rsSCS: beta (many_body)
14161413
""",
14171414
)
14181415

src/nomad_simulations/schema_packages/properties/molecular_orbitals.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ class MolecularOrbitals(ElectronicEigenvalues):
2727

2828
# References
2929
basis_set_ref = Quantity(
30-
type=Reference(SectionProxy('AtomCenteredBasisSet')),
30+
type=Reference(
31+
SectionProxy(
32+
'nomad_simulations.schema_packages.basis_set.AtomCenteredBasisSet'
33+
)
34+
),
3135
description="""
3236
Reference to the atom-centered basis set in which these molecular
3337
orbitals are expanded.

src/nomad_simulations/schema_packages/workflow/equation_of_state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def normalize(self, archive: EntryArchive, logger: BoundLogger) -> None:
215215
)
216216
self.eos_fit.append(eos_fit)
217217
except Exception:
218-
logger.warning('EOS fit unsuccesful.')
218+
logger.warning('EOS fit unsuccessful.')
219219

220220

221221
class EquationOfState(ParallelWorkflow):

src/nomad_simulations/schema_packages/workflow/geometry_optimization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class GeometryOptimizationMethod(SimulationWorkflowMethod):
3030
3131
| `"atomic"` | the atomic coordinates alone are updated |
3232
33-
| `"cell_volume"` | `"atomic"` + cell lattice paramters are updated isotropically |
33+
| `"cell_volume"` | `"atomic"` + cell lattice parameters are updated isotropically |
3434
3535
| `"cell_shape"` | `"cell_volume"` but without the isotropic constraint: all cell parameters are updated |
3636
@@ -42,7 +42,7 @@ class GeometryOptimizationMethod(SimulationWorkflowMethod):
4242
shape=[],
4343
description="""
4444
The method used for geometry optimization. Some known possible values are:
45-
`"steepest_descent"`, `"conjugant_gradient"`, `"low_memory_broyden_fletcher_goldfarb_shanno"`.
45+
`"steepest_descent"`, `"conjugate_gradient"`, `"low_memory_broyden_fletcher_goldfarb_shanno"`.
4646
""",
4747
)
4848

@@ -100,7 +100,7 @@ class GeometryOptimizationMethod(SimulationWorkflowMethod):
100100

101101

102102
class GeometryOptimizationResults(SimulationWorkflowResults):
103-
_label = 'Geometry optimiztation results'
103+
_label = 'Geometry optimization results'
104104

105105
n_steps = Quantity(
106106
type=int,

tests/test_atoms_state.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,25 @@ def test_atomic_number_to_symbol(self, atomic_number: int, chemical_symbol: str)
487487
atom_state.normalize(EntryArchive(), logger)
488488
assert atom_state.chemical_symbol == chemical_symbol
489489

490+
def test_partial_charge_is_independent_of_formal_charge(self):
491+
"""
492+
Test that `partial_charge` is preserved independently from the formal
493+
integer `charge` after normalization.
494+
"""
495+
atom_state = AtomsState(
496+
chemical_symbol='O',
497+
charge=-1,
498+
partial_charge=-0.42 * ureg.elementary_charge,
499+
)
500+
atom_state.normalize(EntryArchive(), logger)
501+
502+
assert atom_state.charge == -1
503+
assert atom_state.partial_charge is not None
504+
assert (
505+
pytest.approx(atom_state.partial_charge.to('elementary_charge').magnitude)
506+
== -0.42
507+
)
508+
490509

491510
class TestCGBeadState:
492511
"""

tests/test_model_method.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
DFT,
1111
TB,
1212
ActiveSpace,
13-
ExplicitDispersionModel,
13+
EmpiricalDispersionModel,
1414
ImplicitSolvationModel,
1515
MultireferencePT,
1616
MultireferenceSCF,
@@ -631,7 +631,7 @@ def test_dft_contributions_solvation_dispersion_relativity_normalize():
631631
refractive_index=1.33,
632632
)
633633

634-
edm = ExplicitDispersionModel(
634+
edm = EmpiricalDispersionModel(
635635
model='D3BJ',
636636
damping_function='BJ',
637637
)
@@ -651,7 +651,7 @@ def test_dft_contributions_solvation_dispersion_relativity_normalize():
651651

652652
assert len(dft.contributions) == 3
653653
assert isinstance(dft.contributions[0], ImplicitSolvationModel)
654-
assert isinstance(dft.contributions[1], ExplicitDispersionModel)
654+
assert isinstance(dft.contributions[1], EmpiricalDispersionModel)
655655
assert isinstance(dft.contributions[2], RelativityModel)
656656

657657
# Solvation

tests/test_numerical_settings.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from nomad.units import ureg
55

66
from nomad_simulations.schema_packages.numerical_settings import (
7-
DispersionKnob,
8-
DispersionSettings,
7+
EmpiricalDispersionKnob,
8+
EmpiricalDispersionSettings,
99
KLinePath,
1010
KMesh,
1111
KSpaceFunctionalities,
@@ -491,27 +491,27 @@ def test_resolve_points(self, k_line_path: KLinePath):
491491
assert np.allclose(k_line_path.points, points)
492492

493493

494-
class TestDispersionSettings:
494+
class TestEmpiricalDispersionSettings:
495495
"""
496496
Tests for dispersion numerical settings schema:
497-
- typed physical constraints via DispersionKnob
498-
- container section DispersionSettings
497+
- typed physical constraints via EmpiricalDispersionKnob
498+
- container section EmpiricalDispersionSettings
499499
"""
500500

501501
def test_knobs_roundtrip_and_normalize_noop(self):
502502
"""
503503
Knobs should be storable and survive normalize() unchanged
504504
(no special normalization is defined currently).
505505
"""
506-
dns = DispersionSettings(
506+
dns = EmpiricalDispersionSettings(
507507
include_c8=True,
508508
include_three_body_atm=False,
509509
partition_scheme='Hirshfeld',
510510
density_source='valence-only',
511511
knobs=[
512-
DispersionKnob(kind='s6', applies_to='pairwise', value=1.0),
513-
DispersionKnob(kind='a1', applies_to='pairwise', value=0.40),
514-
DispersionKnob(kind='a2', applies_to='pairwise', value=4.00),
512+
EmpiricalDispersionKnob(kind='s6', applies_to='pairwise', value=1.0),
513+
EmpiricalDispersionKnob(kind='a1', applies_to='pairwise', value=0.40),
514+
EmpiricalDispersionKnob(kind='a2', applies_to='pairwise', value=4.00),
515515
],
516516
)
517517

@@ -543,7 +543,7 @@ def test_switch_fields(
543543
"""
544544
Basic storage test for the inclusion switches and max_dispersion_order.
545545
"""
546-
dns = DispersionSettings(
546+
dns = EmpiricalDispersionSettings(
547547
include_three_body_atm=include_three_body_atm,
548548
include_c8=include_c8,
549549
include_c10=include_c10,
@@ -570,7 +570,7 @@ def test_environment_fields(self, partition_scheme, charge_model, density_source
570570
"""
571571
Storage test for environment/charge/density-source categorical fields.
572572
"""
573-
dns = DispersionSettings(
573+
dns = EmpiricalDispersionSettings(
574574
partition_scheme=partition_scheme,
575575
charge_model=charge_model,
576576
density_source=density_source,
@@ -586,10 +586,12 @@ def test_multiple_knobs_same_kind_allowed(self):
586586
It should be allowed to store multiple knobs of the same kind if they
587587
apply to different contributions (or even if not, schema-wise).
588588
"""
589-
dns = DispersionSettings(
589+
dns = EmpiricalDispersionSettings(
590590
knobs=[
591-
DispersionKnob(kind='s9', applies_to='three_body_atm', value=1.0),
592-
DispersionKnob(kind='s9', applies_to='pairwise', value=0.0),
591+
EmpiricalDispersionKnob(
592+
kind='s9', applies_to='three_body_atm', value=1.0
593+
),
594+
EmpiricalDispersionKnob(kind='s9', applies_to='pairwise', value=0.0),
593595
]
594596
)
595597
dns.normalize(EntryArchive(), logger=logger)

0 commit comments

Comments
 (0)