Skip to content

Commit

Permalink
Fix on expert filter for two windings transformer (#30)
Browse files Browse the repository at this point in the history
* Remove RATIO_REGULATING and PHASE_REGULATING fields for expert filter on two windings transformer.
Change options for RATIO_REGULATION_MODE field.
Change evaluation for rule using RATIO_REGULATION_MODE and PHASE_REGULATION_MODE fields.

Signed-off-by: Franck LECUYER <[email protected]>
  • Loading branch information
FranckLecuyer authored Jun 28, 2024
1 parent c2010a2 commit d4b03fb
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,27 +251,49 @@ private static String getSubstationFieldValue(FieldType field, Substation substa
};
}

private static String getRatioRegulationMode(RatioTapChanger ratioTapChanger) {
if (ratioTapChanger.hasLoadTapChangingCapabilities() && ratioTapChanger.isRegulating()) {
return RatioRegulationModeType.VOLTAGE_REGULATION.name();
} else if (!ratioTapChanger.isRegulating()) {
return RatioRegulationModeType.FIXED_RATIO.name();
} else {
return null;
}
}

private static String getRatioTapChangerFieldValue(FieldType field, @Nullable RatioTapChanger ratioTapChanger) {
if (ratioTapChanger == null) {
return null;
}
return switch (field) {
case RATIO_REGULATING -> String.valueOf(ratioTapChanger.isRegulating());
case RATIO_TARGET_V -> String.valueOf(ratioTapChanger.getTargetV());
case LOAD_TAP_CHANGING_CAPABILITIES -> String.valueOf(ratioTapChanger.hasLoadTapChangingCapabilities());
case RATIO_REGULATION_MODE -> ratioTapChanger.getRegulationMode() != null ? ratioTapChanger.getRegulationMode().name() : null;
case RATIO_REGULATION_MODE -> String.valueOf(getRatioRegulationMode(ratioTapChanger));
default -> throw new PowsyblException(FIELD_AND_TYPE_NOT_IMPLEMENTED + " [" + field + ",ratioTapChanger]");
};
}

private static String getPhaseRegulationMode(PhaseTapChanger phaseTapChanger) {
if (phaseTapChanger.getRegulationMode() == PhaseTapChanger.RegulationMode.ACTIVE_POWER_CONTROL && phaseTapChanger.isRegulating()) {
return PhaseTapChanger.RegulationMode.ACTIVE_POWER_CONTROL.name();
} else if (phaseTapChanger.getRegulationMode() == PhaseTapChanger.RegulationMode.CURRENT_LIMITER && phaseTapChanger.isRegulating()) {
return PhaseTapChanger.RegulationMode.CURRENT_LIMITER.name();
} else if (phaseTapChanger.getRegulationMode() == PhaseTapChanger.RegulationMode.FIXED_TAP ||
phaseTapChanger.getRegulationMode() == PhaseTapChanger.RegulationMode.CURRENT_LIMITER && !phaseTapChanger.isRegulating() ||
phaseTapChanger.getRegulationMode() == PhaseTapChanger.RegulationMode.ACTIVE_POWER_CONTROL && !phaseTapChanger.isRegulating()) {
return PhaseTapChanger.RegulationMode.FIXED_TAP.name();
} else {
return null;
}
}

private static String getPhaseTapChangerFieldValue(FieldType field, @Nullable PhaseTapChanger phaseTapChanger) {
if (phaseTapChanger == null) {
return null;
}
return switch (field) {
case PHASE_REGULATING -> String.valueOf(phaseTapChanger.isRegulating());
case PHASE_REGULATION_VALUE -> String.valueOf(phaseTapChanger.getRegulationValue());
case PHASE_REGULATION_MODE -> phaseTapChanger.getRegulationMode() != null ? phaseTapChanger.getRegulationMode().name() : null;
case PHASE_REGULATION_MODE -> String.valueOf(getPhaseRegulationMode(phaseTapChanger));
default -> throw new PowsyblException(FIELD_AND_TYPE_NOT_IMPLEMENTED + " [" + field + ",phaseTapChanger]");
};
}
Expand All @@ -293,13 +315,11 @@ private static String getTwoWindingsTransformerFieldValue(FieldType field, Strin
case MAGNETIZING_CONDUCTANCE -> String.valueOf(twoWindingsTransformer.getG());
case MAGNETIZING_SUSCEPTANCE -> String.valueOf(twoWindingsTransformer.getB());
case HAS_RATIO_TAP_CHANGER -> String.valueOf(twoWindingsTransformer.hasRatioTapChanger());
case RATIO_REGULATING,
RATIO_TARGET_V,
case RATIO_TARGET_V,
LOAD_TAP_CHANGING_CAPABILITIES,
RATIO_REGULATION_MODE -> getRatioTapChangerFieldValue(field, twoWindingsTransformer.getRatioTapChanger());
case HAS_PHASE_TAP_CHANGER -> String.valueOf(twoWindingsTransformer.hasPhaseTapChanger());
case PHASE_REGULATING,
PHASE_REGULATION_MODE,
case PHASE_REGULATION_MODE,
PHASE_REGULATION_VALUE -> getPhaseTapChangerFieldValue(field, twoWindingsTransformer.getPhaseTapChanger());
case SUBSTATION_PROPERTIES_1 -> twoWindingsTransformer.getTerminal1().getVoltageLevel().getNullableSubstation().getProperty(propertyName);
case SUBSTATION_PROPERTIES_2 -> twoWindingsTransformer.getTerminal2().getVoltageLevel().getNullableSubstation().getProperty(propertyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ public enum FieldType {
MAGNETIZING_SUSCEPTANCE,
LOAD_TYPE,
HAS_RATIO_TAP_CHANGER,
RATIO_REGULATING,
LOAD_TAP_CHANGING_CAPABILITIES,
RATIO_REGULATION_MODE,
RATIO_TARGET_V,
HAS_PHASE_TAP_CHANGER,
PHASE_REGULATING,
PHASE_REGULATION_MODE,
PHASE_REGULATION_VALUE,
FREE_PROPERTIES,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.filter.utils.expertfilter;

/**
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
*/
public enum RatioRegulationModeType {
VOLTAGE_REGULATION,
FIXED_RATIO
}
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,11 @@ private static Stream<Arguments> provideArgumentsForTwoWindingTransformerTest()
Arguments.of(EQUALS, FieldType.CONNECTED_2, false, twoWindingsTransformer, false),

// RatioTapChanger fields
Arguments.of(EQUALS, FieldType.RATIO_REGULATING, true, twoWindingsTransformer, true),
Arguments.of(EQUALS, FieldType.RATIO_REGULATING, false, twoWindingsTransformer, false),
Arguments.of(EQUALS, FieldType.LOAD_TAP_CHANGING_CAPABILITIES, true, twoWindingsTransformer, true),
Arguments.of(EQUALS, FieldType.LOAD_TAP_CHANGING_CAPABILITIES, false, twoWindingsTransformer, false),
Arguments.of(EQUALS, FieldType.HAS_RATIO_TAP_CHANGER, true, twoWindingsTransformer, true),

// PhaseTapChanger fields
Arguments.of(EQUALS, FieldType.PHASE_REGULATING, false, twoWindingsTransformer, true),
Arguments.of(EQUALS, FieldType.PHASE_REGULATING, true, twoWindingsTransformer, false),
Arguments.of(EQUALS, FieldType.HAS_PHASE_TAP_CHANGER, true, twoWindingsTransformer, true),

// --- NOT_EQUALS--- //
Expand All @@ -282,23 +278,17 @@ private static Stream<Arguments> provideArgumentsForTwoWindingTransformerTest()
Arguments.of(NOT_EQUALS, FieldType.CONNECTED_2, true, twoWindingsTransformer, false),

// RatioTapChanger fields
Arguments.of(NOT_EQUALS, FieldType.RATIO_REGULATING, false, twoWindingsTransformer, true),
Arguments.of(NOT_EQUALS, FieldType.RATIO_REGULATING, true, twoWindingsTransformer, false),
Arguments.of(NOT_EQUALS, FieldType.LOAD_TAP_CHANGING_CAPABILITIES, false, twoWindingsTransformer, true),
Arguments.of(NOT_EQUALS, FieldType.LOAD_TAP_CHANGING_CAPABILITIES, true, twoWindingsTransformer, false),
Arguments.of(NOT_EQUALS, FieldType.HAS_RATIO_TAP_CHANGER, true, twoWindingsTransformer, false),

// null RatioTapChanger
Arguments.of(NOT_EQUALS, FieldType.RATIO_REGULATING, false, twoWindingsTransformer2, false),
Arguments.of(NOT_EQUALS, FieldType.HAS_RATIO_TAP_CHANGER, false, twoWindingsTransformer2, false),

// PhaseTapChanger fields
Arguments.of(NOT_EQUALS, FieldType.PHASE_REGULATING, true, twoWindingsTransformer, true),
Arguments.of(NOT_EQUALS, FieldType.PHASE_REGULATING, false, twoWindingsTransformer, false),
Arguments.of(NOT_EQUALS, FieldType.HAS_PHASE_TAP_CHANGER, true, twoWindingsTransformer, false),

// null PhaseTapChanger
Arguments.of(NOT_EQUALS, FieldType.PHASE_REGULATING, false, twoWindingsTransformer2, false),
Arguments.of(NOT_EQUALS, FieldType.HAS_PHASE_TAP_CHANGER, false, twoWindingsTransformer2, false)
);
}
Expand Down
Loading

0 comments on commit d4b03fb

Please sign in to comment.