Skip to content

Commit 569ef02

Browse files
author
jrudz
committed
added force contributions, fixed energies, import changes
1 parent 454cd9f commit 569ef02

File tree

9 files changed

+116
-68
lines changed

9 files changed

+116
-68
lines changed

src/nomad_simulations/outputs.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
AbsorptionSpectrum,
4242
XASSpectrum,
4343
Permittivity,
44-
TotalEnergy
44+
TotalEnergy,
45+
TotalForce,
4546
)
4647

4748

@@ -112,7 +113,9 @@ class Outputs(ArchiveSection):
112113

113114
xas_spectra = SubSection(sub_section=XASSpectrum.m_def, repeats=True)
114115

115-
total_energy = SubSection(SubSection=TotalEnergy.m_def, repeats=True)
116+
total_energy = SubSection(sub_section=TotalEnergy.m_def, repeats=True)
117+
118+
total_force = SubSection(sub_section=TotalForce.m_def, repeats=True)
116119

117120
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
118121
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -296,6 +299,7 @@ def normalize(self, archive, logger) -> None:
296299
logger=logger,
297300
)
298301

302+
299303
class WorkflowOutputs(Outputs):
300304
"""
301305
This section contains output properties that depend on a single system, but were
@@ -320,6 +324,7 @@ class WorkflowOutputs(Outputs):
320324
def normalize(self, archive, logger) -> None:
321325
super().normalize(archive, logger)
322326

327+
323328
class TrajectoryOutputs(WorkflowOutputs):
324329
"""
325330
This section contains output properties that depend on a single system, but were
@@ -328,6 +333,7 @@ class TrajectoryOutputs(WorkflowOutputs):
328333

329334
time = Quantity(
330335
type=np.float64,
336+
unit='ps',
331337
description="""
332338
The elapsed simulated physical time since the start of the trajectory.
333339
""",

src/nomad_simulations/physical_property.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,4 @@ def normalize(self, archive, logger) -> None:
320320
super().normalize(archive, logger)
321321

322322
# Resolve if the physical property `is_derived` or not from another physical property.
323-
self.is_derived = self._is_derived()
323+
self.is_derived = self._is_derived()

src/nomad_simulations/properties/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
ClassicalEnergyContributions,
2424
QuantumEnergyContributions,
2525
)
26+
from .forces import TotalForce, ForceContributions
2627
from .band_gap import ElectronicBandGap
2728
from .spectral_profile import (
2829
SpectralProfile,

src/nomad_simulations/properties/energies.py

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
import numpy as np
2020

2121
from nomad.metainfo import Quantity, Section, Context, SubSection, MEnum
22+
from nomad.datamodel.data import ArchiveSection
2223

2324
from nomad_simulations.physical_property import PhysicalProperty
2425

26+
2527
class FermiLevel(PhysicalProperty):
2628
"""
2729
Energy required to add or extract a charge from a material at zero temperature. It can be also defined as the chemical potential at zero temperature.
@@ -82,6 +84,7 @@ def normalize(self, archive, logger) -> None:
8284
# List of classical energy contribuions
8385
####################################################
8486

87+
8588
class PotentialEnergy(PhysicalProperty):
8689
"""
8790
Section containing the potential energy of a (sub)system.
@@ -98,6 +101,7 @@ class PotentialEnergy(PhysicalProperty):
98101
def normalize(self, archive, logger) -> None:
99102
super().normalize(archive, logger)
100103

104+
101105
class KineticEnergy(PhysicalProperty):
102106
"""
103107
Section containing the kinetic energy of a (sub)system.
@@ -152,6 +156,7 @@ class VDWEnergy(PhysicalProperty):
152156
def normalize(self, archive, logger) -> None:
153157
super().normalize(archive, logger)
154158

159+
155160
class ElectrostaticEnergy(PhysicalProperty):
156161
"""
157162
Section containing all electrostatic contributions to the potential energy of a (sub)system.
@@ -168,6 +173,7 @@ class ElectrostaticEnergy(PhysicalProperty):
168173
def normalize(self, archive, logger) -> None:
169174
super().normalize(archive, logger)
170175

176+
171177
class ElectrostaticShortRangeEnergy(PhysicalProperty):
172178
"""
173179
Section containing short-range electrostatic contributions to the potential energy of a (sub)system.
@@ -184,6 +190,7 @@ class ElectrostaticShortRangeEnergy(PhysicalProperty):
184190
def normalize(self, archive, logger) -> None:
185191
super().normalize(archive, logger)
186192

193+
187194
class ElectrostaticLongRangeEnergy(PhysicalProperty):
188195
"""
189196
Section containing long-range electrostatic contributions to the potential energy of a (sub)system.
@@ -200,6 +207,7 @@ class ElectrostaticLongRangeEnergy(PhysicalProperty):
200207
def normalize(self, archive, logger) -> None:
201208
super().normalize(archive, logger)
202209

210+
203211
class BondedEnergy(PhysicalProperty):
204212
"""
205213
Section containing all bonded (i.e., intramolecular) contributions to the potential energy of a (sub)system.
@@ -216,6 +224,7 @@ class BondedEnergy(PhysicalProperty):
216224
def normalize(self, archive, logger) -> None:
217225
super().normalize(archive, logger)
218226

227+
219228
class BondEnergy(PhysicalProperty):
220229
"""
221230
Section containing contributions to the potential energy from bond interactions of a (sub)system.
@@ -232,6 +241,7 @@ class BondEnergy(PhysicalProperty):
232241
def normalize(self, archive, logger) -> None:
233242
super().normalize(archive, logger)
234243

244+
235245
class AngleEnergy(PhysicalProperty):
236246
"""
237247
Section containing contributions to the potential energy from angle interactions of a (sub)system.
@@ -248,6 +258,7 @@ class AngleEnergy(PhysicalProperty):
248258
def normalize(self, archive, logger) -> None:
249259
super().normalize(archive, logger)
250260

261+
251262
class DihedralEnergy(PhysicalProperty):
252263
"""
253264
Section containing contributions to the potential energy from dihedral interactions of a (sub)system.
@@ -264,6 +275,7 @@ class DihedralEnergy(PhysicalProperty):
264275
def normalize(self, archive, logger) -> None:
265276
super().normalize(archive, logger)
266277

278+
267279
class ImproperDihedralEnergy(PhysicalProperty):
268280
"""
269281
Section containing contributions to the potential energy from improper dihedral interactions of a (sub)system.
@@ -280,6 +292,7 @@ class ImproperDihedralEnergy(PhysicalProperty):
280292
def normalize(self, archive, logger) -> None:
281293
super().normalize(archive, logger)
282294

295+
283296
class ExternalEnergy(PhysicalProperty):
284297
"""
285298
Section containing contributions to the potential energy from external interactions of a (sub)system.
@@ -296,6 +309,7 @@ class ExternalEnergy(PhysicalProperty):
296309
def normalize(self, archive, logger) -> None:
297310
super().normalize(archive, logger)
298311

312+
299313
class ClassicalEnergyContributions(ArchiveSection):
300314
"""
301315
Section containing contributions to the potential energy from a classical force field.
@@ -309,9 +323,13 @@ class ClassicalEnergyContributions(ArchiveSection):
309323

310324
electrostatic = SubSection(sub_section=ElectrostaticEnergy.m_def, repeats=False)
311325

312-
electrostatic_short_range = SubSection(sub_section=ElectrostaticShortRangeEnergy.m_def, repeats=False)
326+
electrostatic_short_range = SubSection(
327+
sub_section=ElectrostaticShortRangeEnergy.m_def, repeats=False
328+
)
313329

314-
electrostatic_long_range = SubSection(sub_section=ElectrostaticLongRangeEnergy.m_def, repeats=False)
330+
electrostatic_long_range = SubSection(
331+
sub_section=ElectrostaticLongRangeEnergy.m_def, repeats=False
332+
)
315333

316334
bonded = SubSection(sub_section=BondedEnergy.m_def, repeats=False)
317335

@@ -321,7 +339,9 @@ class ClassicalEnergyContributions(ArchiveSection):
321339

322340
dihedral = SubSection(sub_section=DihedralEnergy.m_def, repeats=False)
323341

324-
improper_dihedral = SubSection(sub_section=ImproperDihedralEnergy.m_def, repeats=False)
342+
improper_dihedral = SubSection(
343+
sub_section=ImproperDihedralEnergy.m_def, repeats=False
344+
)
325345

326346
external = SubSection(sub_section=ExternalEnergy.m_def, repeats=False)
327347

@@ -330,10 +350,12 @@ def normalize(self, archive, logger) -> None:
330350
# Set the name of the section
331351
self.name = self.m_def.name
332352

353+
333354
######################################
334355
# List of quantum energy contributions
335356
######################################
336357

358+
337359
class ElectronicEnergy(PhysicalProperty):
338360
"""
339361
Section containing the electronic energy of a (sub)system.
@@ -347,12 +369,11 @@ class ElectronicEnergy(PhysicalProperty):
347369
""",
348370
)
349371

350-
contributions = SubSection(sub_section=EnergyContributions.m_def, repeats=True)
351-
352372
def normalize(self, archive, logger) -> None:
353373
super().normalize(archive, logger)
354374
allowed_contributions = ['PotKin']
355375

376+
356377
class ElectronicKineticEnergy(PhysicalProperty):
357378
"""
358379
Section containing the electronic kinetic energy of a (sub)system.
@@ -369,11 +390,13 @@ class ElectronicKineticEnergy(PhysicalProperty):
369390
def normalize(self, archive, logger) -> None:
370391
super().normalize(archive, logger)
371392

393+
372394
class XCEnergy(PhysicalProperty):
373395
"""
374396
Section containing the exchange-correlation (XC) energy of a (sub)system,
375397
calculated using the functional stored in XC_functional.
376398
"""
399+
377400
# ! Someone check this description!
378401
# ? Do we really want to specify the method here? This can't be user-defined?
379402

@@ -388,6 +411,7 @@ class XCEnergy(PhysicalProperty):
388411
def normalize(self, archive, logger) -> None:
389412
super().normalize(archive, logger)
390413

414+
391415
class XCPotentialEnergy(PhysicalProperty):
392416
"""
393417
Section containing the potential energy contribution to the exchange-correlation (XC) energy,
@@ -396,6 +420,7 @@ class XCPotentialEnergy(PhysicalProperty):
396420
of XC that is in the sum of the eigenvalues. Value associated with the
397421
configuration, should be the most converged value. |
398422
"""
423+
399424
# ! Someone check this description!
400425
# ? Do we really want to specify the method here? This can't be user-defined?
401426

@@ -410,12 +435,14 @@ class XCPotentialEnergy(PhysicalProperty):
410435
def normalize(self, archive, logger) -> None:
411436
super().normalize(archive, logger)
412437

438+
413439
# ? XCCorrelationEnergy?
414440
class CorrelationEnergy(PhysicalProperty):
415441
"""
416442
Section containing the correlation energy of a (sub)system,
417443
calculated using the method described in XC_functional.
418444
"""
445+
419446
# ! Someone check this description!
420447
# ? Do we really want to specify the method here? This can't be user-defined?
421448

@@ -430,12 +457,14 @@ class CorrelationEnergy(PhysicalProperty):
430457
def normalize(self, archive, logger) -> None:
431458
super().normalize(archive, logger)
432459

460+
433461
# ? XCExchangeEnergy?
434462
class ExchangeEnergy(PhysicalProperty):
435463
"""
436464
Section containing the exchange energy of a (sub)system,
437465
calculated using the method described in XC_functional.
438466
"""
467+
439468
# ! Someone check this description!
440469
# ? Do we really want to specify the method here? This can't be user-defined?
441470

@@ -468,11 +497,13 @@ class ZeroTemperatureEnergy(PhysicalProperty):
468497
def normalize(self, archive, logger) -> None:
469498
super().normalize(archive, logger)
470499

500+
471501
class ZeroPointEnergy(PhysicalProperty):
472502
"""
473503
Section containing the zero-point vibrational energy of a (sub)system,
474504
calculated using the method described in zero_point_method.
475505
"""
506+
476507
# ! Someone check this description!
477508
# ? Do we really want to specify the method here? This can't be user-defined?
478509

@@ -487,6 +518,7 @@ class ZeroPointEnergy(PhysicalProperty):
487518
def normalize(self, archive, logger) -> None:
488519
super().normalize(archive, logger)
489520

521+
490522
class ElectrostaticEnergy(PhysicalProperty):
491523
"""
492524
Section containing the electrostatic energy (nuclei + electrons) of a (sub)system.
@@ -503,6 +535,7 @@ class ElectrostaticEnergy(PhysicalProperty):
503535
def normalize(self, archive, logger) -> None:
504536
super().normalize(archive, logger)
505537

538+
506539
class NuclearRepulsionEnergy(PhysicalProperty):
507540
"""
508541
Section containing the nuclear-nuclear repulsion energy of a (sub)system.
@@ -524,11 +557,14 @@ class QuantumEnergyContributions(ArchiveSection):
524557
"""
525558
Section containing contributions to the potential energy from a DFT calculation.
526559
"""
527-
...
560+
561+
...
528562

529563
electronic = SubSection(sub_section=ElectronicEnergy.m_def, repeats=False)
530564

531-
electronic_kinetic = SubSection(sub_section=ElectronicKineticEnergy.m_def, repeats=False)
565+
electronic_kinetic = SubSection(
566+
sub_section=ElectronicKineticEnergy.m_def, repeats=False
567+
)
532568

533569
xc = SubSection(sub_section=XCEnergy.m_def, repeats=False)
534570

@@ -538,18 +574,24 @@ class QuantumEnergyContributions(ArchiveSection):
538574

539575
exchange = SubSection(sub_section=ExchangeEnergy.m_def, repeats=False)
540576

541-
zero_temperature = SubSection(sub_section=ZeroTemperatureEnergy.m_def, repeats=False)
577+
zero_temperature = SubSection(
578+
sub_section=ZeroTemperatureEnergy.m_def, repeats=False
579+
)
542580

543581
zero_point = SubSection(sub_section=ZeroPointEnergy.m_def, repeats=False)
544582

545583
electrostatic = SubSection(sub_section=ElectrostaticEnergy.m_def, repeats=False)
546584

547-
nuclear_repulsion = SubSection(sub_section=NuclearRepulsionEnergy.m_def, repeats=False)
585+
nuclear_repulsion = SubSection(
586+
sub_section=NuclearRepulsionEnergy.m_def, repeats=False
587+
)
588+
548589

549590
##########################
550591
# Other / General energies
551592
##########################
552593

594+
553595
class TotalEnergy(PhysicalProperty):
554596
"""
555597
Section containing the total energy of a (sub)system.
@@ -564,12 +606,17 @@ class TotalEnergy(PhysicalProperty):
564606
)
565607
# ? Do we need these descriptions under value? It ends up simply duplicating the section info to some extent.
566608

567-
classical_contributions = SubSection(sub_section=ClassicalEnergyContributions.m_def, repeats=False)
609+
classical_contributions = SubSection(
610+
sub_section=ClassicalEnergyContributions.m_def, repeats=False
611+
)
568612

569-
quantum_contributions = SubSection(sub_section=QuantumEnergyContributions.m_def, repeats=False)
613+
quantum_contributions = SubSection(
614+
sub_section=QuantumEnergyContributions.m_def, repeats=False
615+
)
570616

571617
def normalize(self, archive, logger) -> None:
572618
super().normalize(archive, logger)
619+
#? Should we set total energy value as sum of all contributions if not set explicitly?
573620

574621
# madelung = SubSection(
575622
# sub_section=EnergyEntry.m_def,
@@ -709,7 +756,6 @@ def normalize(self, archive, logger) -> None:
709756
# """,
710757
# )
711758

712-
713759
# # TODO this should be removed and replaced by correction in EnergyEntry
714760
# current = SubSection(
715761
# sub_section=EnergyEntry.m_def,
@@ -723,8 +769,6 @@ def normalize(self, archive, logger) -> None:
723769
# )
724770

725771

726-
727-
728772
# # ? Do we want to allow this?
729773
# class EnergyCustom(PhysicalProperty):
730774
# """

0 commit comments

Comments
 (0)