Skip to content

Commit 705b7d9

Browse files
committed
Clean up WorkflowConvergenceTarget enum and imports
- Remove `residuum` from `threshold_type` enum (semantically inconsistent - describes WHAT not HOW) - Remove unused imports (`Iterable`, `jmespath`, `SimulationTime`, `Outputs`) - Simplify `WorkflowConvergenceTarget` docstring
1 parent ca62f90 commit 705b7d9

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/nomad_simulations/schema_packages/workflow/general.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
from collections.abc import Iterable
2-
3-
import jmespath
41
import numpy as np
52
from nomad.datamodel import ArchiveSection, EntryArchive
63
from nomad.datamodel.metainfo.workflow import Link, Task, TaskReference, Workflow
74
from nomad.metainfo import Datetime, MEnum, Quantity, SchemaPackage, SubSection
85
from structlog.stdlib import BoundLogger
96

10-
from nomad_simulations.schema_packages.common import SimulationTime
117
from nomad_simulations.schema_packages.data_types import positive_float
128
from nomad_simulations.schema_packages.model_method import ModelMethod
139
from nomad_simulations.schema_packages.model_system import ModelSystem
14-
from nomad_simulations.schema_packages.outputs import Outputs
1510
from nomad_simulations.schema_packages.properties import ElectronicDensityOfStates
1611
from nomad_simulations.schema_packages.utils import log
1712
from nomad_simulations.schema_packages.workflow.trajectory import (
@@ -33,17 +28,17 @@ class SimulationTask(Task):
3328

3429
class WorkflowConvergenceTarget(ArchiveSection):
3530
"""
36-
Abstract base class for defining convergence targets.
31+
Base section for defining convergence targets.
32+
It handles all convergence checking logic based on `threshold_type`.
3733
38-
Child classes define specific physical properties
39-
(e.g., energy, force) with proper units. The base class handles all convergence
40-
checking logic based on the threshold_type enum.
34+
Use inheritance todefine specific physical properties (e.g., energy, force).
35+
This is most relevant when defining the appropriate units.
4136
"""
4237

43-
threshold: Quantity = None
38+
threshold: Quantity = None # to be defined in child classes with appropriate type and unit
4439

4540
threshold_type = Quantity(
46-
type=MEnum('absolute', 'relative', 'maximum', 'rms', 'residuum'),
41+
type=MEnum('absolute', 'relative', 'maximum', 'rms'),
4742
description=r"""Specifies the mathematical method used to evaluate convergence between successive self-consistent field (SCF) iterations.
4843
This determines how differences between iterations are calculated and compared against the convergence threshold.
4944
@@ -53,7 +48,6 @@ class WorkflowConvergenceTarget(ArchiveSection):
5348
| --------- | -------------------------------- |
5449
| `'absolute'` | Measures the absolute difference between two subsequent iterations (e.g., \|E_n - E_{n-1}\|). Most common for energy convergence. |
5550
| `'relative'` | Calculates the relative difference as a fraction of the total property value (e.g., \|E_n - E_{n-1}\|/\|E_n\|). Useful when the magnitude of the property varies widely across systems. |
56-
| `'residuum'` | Computes the absolute difference between the current value and the value estimated from the wavefunction at the start of the step. Often used for evaluating convergence of the electron density. |
5751
| `'maximum'` | Reports the maximum absolute difference across all components of a multi-component property (e.g., max\|F_i,n - F_i,{n-1}\| for forces). Suitable for vector quantities like forces or stress tensor elements. |
5852
| `'rms'` | Calculates the root mean square of differences across all components (e.g., √(∑\|F_i,n - F_i,{n-1}\|²/N)). Provides a statistical measure of overall convergence for multi-component properties. |
5953

tests/workflow/test_convergence_targets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ class TestConvergenceTypeEnumeration:
578578

579579
@pytest.mark.parametrize(
580580
'threshold_type',
581-
['absolute', 'relative', 'maximum', 'rms', 'residuum'],
581+
['absolute', 'relative', 'maximum', 'rms'],
582582
)
583583
def test_valid_convergence_types(
584584
self, threshold_type: str, archive, logger, energy_target

0 commit comments

Comments
 (0)