Skip to content

Commit ebbe224

Browse files
committed
try
Signed-off-by: zhen0427 <Zhen.Wang@alliander.com>
1 parent 2adf2fa commit ebbe224

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

src/power_grid_model/validation/_validation.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ def validate_values(data: SingleDataset, calculation_type: CalculationType | Non
491491
errors += validate_generic_power_sensor(data, ComponentType.sym_power_sensor)
492492
if "asym_power_sensor" in data:
493493
errors += validate_generic_power_sensor(data, ComponentType.asym_power_sensor)
494+
if "sym_current_sensor" in data:
495+
errors += validate_generic_current_sensor(data, ComponentType.sym_current_sensor)
496+
if "asym_current_sensor" in data:
497+
errors += validate_generic_current_sensor(data, ComponentType.asym_current_sensor)
494498

495499
if calculation_type in (None, CalculationType.short_circuit) and "fault" in data:
496500
errors += validate_fault(data)
@@ -962,6 +966,62 @@ def validate_generic_power_sensor(data: SingleDataset, component: ComponentType)
962966
return errors
963967

964968

969+
def validate_generic_current_sensor(data: SingleDataset, component: ComponentType) -> list[ValidationError]:
970+
971+
errors = validate_base(data, component)
972+
errors += _all_greater_than_zero(data, component, "i_sigma")
973+
errors += _all_greater_than_zero(data, component, "i_angle_sigma")
974+
errors += _all_valid_enum_values(data, component, "measured_terminal_type", MeasuredTerminalType)
975+
errors += _all_valid_ids(
976+
data,
977+
component,
978+
field="measured_object",
979+
ref_components=[
980+
ComponentType.line,
981+
ComponentType.generic_branch,
982+
ComponentType.transformer,
983+
ComponentType.three_winding_transformer,
984+
],
985+
)
986+
errors += _all_valid_ids(
987+
data,
988+
component,
989+
field="measured_object",
990+
ref_components=[ComponentType.line, ComponentType.generic_branch, ComponentType.transformer],
991+
measured_terminal_type=MeasuredTerminalType.branch_from,
992+
)
993+
errors += _all_valid_ids(
994+
data,
995+
component,
996+
field="measured_object",
997+
ref_components=[ComponentType.line, ComponentType.generic_branch, ComponentType.transformer],
998+
measured_terminal_type=MeasuredTerminalType.branch_to,
999+
)
1000+
errors += _all_valid_ids(
1001+
data,
1002+
component,
1003+
field="measured_object",
1004+
ref_components=ComponentType.three_winding_transformer,
1005+
measured_terminal_type=MeasuredTerminalType.branch3_1,
1006+
)
1007+
errors += _all_valid_ids(
1008+
data,
1009+
component,
1010+
field="measured_object",
1011+
ref_components=ComponentType.three_winding_transformer,
1012+
measured_terminal_type=MeasuredTerminalType.branch3_2,
1013+
)
1014+
errors += _all_valid_ids(
1015+
data,
1016+
component,
1017+
field="measured_object",
1018+
ref_components=ComponentType.three_winding_transformer,
1019+
measured_terminal_type=MeasuredTerminalType.branch3_3,
1020+
)
1021+
1022+
return errors
1023+
1024+
9651025
def validate_fault(data: SingleDataset) -> list[ValidationError]:
9661026
errors = validate_base(data, ComponentType.fault)
9671027
errors += _all_boolean(data, ComponentType.fault, "status")

0 commit comments

Comments
 (0)