Skip to content

Scf convergence migration#151

Merged
ndaelman-hu merged 13 commits intoschema_update_convergence_targetsfrom
scf-convergence-migration
Mar 23, 2026
Merged

Scf convergence migration#151
ndaelman-hu merged 13 commits intoschema_update_convergence_targetsfrom
scf-convergence-migration

Conversation

@JFRudzinski
Copy link
Copy Markdown
Collaborator

@JFRudzinski JFRudzinski commented Feb 17, 2026

Implemented SCF convergence migration across all target parsers (abinit, ams, crystal, exciting, fhiaims, gpaw, quantumespresso, vasp) to the new workflow + scf_steps model.

High-level changes:

  • Ported parser-specific SCF iteration signals into outputs.scf_steps (energy deltas, energies, durations, and code-specific SCF metadata where available).
  • Populated new workflow convergence targets in workflow2 (SinglePoint, GeometryOptimization, and MD where relevant), including SCF and geometry thresholds.
  • Updated parser schema mappings to expose the new scf_steps fields and avoid duplicated/legacy convergence storage.
  • Added/extended parser tests with explicit assertions on:
    • workflow type/method and convergence target thresholds/types
    • SCF-step quantity presence, lengths, and representative values
  • Updated migration documentation (SCF_CONVERGENCE_MIGRATION.md) with per-parser status, approach, caveats, and test outcomes.

Net result:

  • Convergence information now follows one consistent structure across parsers, aligned with the refactored schema and NOMAD unit handling semantics.

depends on FAIRmat-NFDI/nomad-simulations#260

@JFRudzinski JFRudzinski changed the base branch from develop to schema_update_convergence_targets February 17, 2026 22:14
@JFRudzinski
Copy link
Copy Markdown
Collaborator Author

Here are the implementation notes:

SCF_CONVERGENCE_MIGRATION.md

- Update Abinit test to handle dimensionless threshold for relative convergence
- Update Exciting test helper to handle both plain floats and Pint Quantities
- Both parsers now work correctly with flexible_unit=True
Remove `.magnitude` extraction in `get_optimization_convergence()` to pass
complete Pint Quantity instead of bare float.

**Problem:**
GUI crashed with error: "Please provide the value for a Quantity as a number,
or as a multidimensional array of numbers" when displaying convergence targets.

**Root cause:**
- Parser extracted only the numeric value: `threshold.to('newton').magnitude`
- This created a bare float without units
- When serialized (before `normalize()` runs), bare floats lack `m_unit` field
- GUI expects ALL quantities to have `m_unit` field, even dimensionless

**Fix:**
Keep threshold as Pint Quantity: `threshold.to('newton')`

**Serialization comparison:**
Before (bare float):
```json
{
  "threshold": {
    "m_value": 4.11e-09
    // Missing m_unit!
  }
}
```

After (Pint Quantity):
```json
{
  "threshold": {
    "m_value": 4.11e-09,
    "m_unit": "newton",
    "m_original_unit": "newton"
  }
}
```

All tests pass. GUI can now display convergence targets correctly.
Change charge convergence unit from `elementary_charge` to `coulomb` to fix
GUI unit parser error. The GUI uses mathjs units which doesn't recognize
`elementary_charge` as a valid unit name.

**Error fixed:**
```
SyntaxError: Unit "elementary_charge" not found.
at parseInternal (src/components/units/common.js:313)
```

**Changes:**
- exciting parser: Use `ureg.coulomb` instead of `ureg.elementary_charge` for charge convergence threshold
- Test expectations: Update values from elementary_charge-based to coulomb-based

**Conversion factor:** `1 elementary_charge = 1.602176634e-19 coulomb`

All tests pass.
@ndaelman-hu ndaelman-hu self-assigned this Mar 23, 2026
@ndaelman-hu ndaelman-hu added enhancement New feature or request electronic parser labels Mar 23, 2026
@ndaelman-hu ndaelman-hu marked this pull request as ready for review March 23, 2026 10:23
@ndaelman-hu ndaelman-hu merged commit 6b1ea62 into schema_update_convergence_targets Mar 23, 2026
3 checks passed
ndaelman-hu added a commit that referenced this pull request Mar 23, 2026
Temporarily disable mappings to `convergence_tolerance_energy_difference` and
`convergence_tolerance_force_maximum` in abinit and gromacs schema packages.

These fields were removed from `GeometryOptimizationMethod` in nomad-simulations#260
(merged March 19) and replaced with `WorkflowConvergenceTarget` subsections.

PR #151 was written against the old API but merged after the schema change,
causing parser loading failures.

This commit restores functionality. Follow-up commit will migrate to the new
`WorkflowConvergenceTarget` API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

electronic parser enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants