Skip to content

[FEATURE] Add tap regulator control side validation to data validator #1292

@Jerry-Jinfeng-Guo

Description

@Jerry-Jinfeng-Guo

Summary

Add validation to the Python data validator to detect invalid tap regulator control side configuration
before running power flow calculations. This validation should catch cases where a transformer is being
controlled from the non-source side towards the source side, which is currently only detected during
runtime calculation.

Related Issues and PRs

Problem Statement

Current Behavior

Currently, when a tap regulator has an invalid control side configuration (controlling from non-source
side towards source side), the error is only detected during power flow calculation in the C++ core:

AutomaticTapInputError: Automatic tap changer has invalid configuration. 
The transformer is being controlled from non source side towards source side.
Transformer IDs: [123, 456, 789]

Why This Is a Problem

  1. Late error detection: Errors are only discovered after the model is constructed and calculation
    begins, wasting computation time

  2. Poor development experience: Developers must wait for calculation to start before discovering
    data issues

  3. Incomplete validation workflow: The Python data validator doesn't catch this error, creating a
    gap in pre-calculation validation

  4. Inconsistent with best practices: The documentation recommends validating data before
    construction, but this specific check is missing

User Impact

For users with large models (e.g., 50+ transformers with tap regulators):

  • Cannot validate all input data (wrt this regulated side) before construction
  • Must rely on trial-and-error with calculations to find configuration issues
  • Difficult to integrate into automated data validation pipelines

Proposed Solution

Add a new validation check in the Python data validator
(src/power_grid_model/validation/_validation.py) to detect invalid tap regulator control side
configurations.

Validation Logic

The validation should check for each transformer_tap_regulator in topology:

  1. Identify the regulated transformer (using regulated_object field)

  2. Determine the trafo-topology:

    • Simplified trafo graph: build with shortest distance in mind
  3. Validate control side:

    • The control_side must point to a side that is closer to or at the source
    • If controlling from a side that is farther from the source, append trafo user side ID
    • raise a validation error containing these trafo user side IDs

Backward Compatibility

  • New validation should be additive only
  • Existing validation should continue to work
  • Consider adding a warning first, then making it an error in a future release

Metadata

Metadata

Labels

featureNew feature or request

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions