Skip to content

Commit

Permalink
fix the get suscepatnce value per section (#560)
Browse files Browse the repository at this point in the history
Signed-off-by: Rehili Ghazwa <ghazwarhili@gmail.com>
  • Loading branch information
ghazwarhili authored Nov 7, 2024
1 parent a7dc5ff commit b9d16c0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public enum ShuntCompensatorField {
public static String getReferenceValue(ShuntCompensator shuntCompensator, String shuntCompensatorField) {
VoltageLevel voltageLevel = shuntCompensator.getTerminal().getVoltageLevel();
ShuntCompensatorField field = ShuntCompensatorField.valueOf(shuntCompensatorField);
double bPerSection = shuntCompensator.getB() / shuntCompensator.getSectionCount();
return switch (field) {
case MAXIMUM_SECTION_COUNT -> String.valueOf(shuntCompensator.getMaximumSectionCount());
case SECTION_COUNT -> String.valueOf(shuntCompensator.getSectionCount());
case MAXIMUM_SUSCEPTANCE -> String.valueOf(shuntCompensator.getB() * shuntCompensator.getMaximumSectionCount());
case MAXIMUM_Q_AT_NOMINAL_VOLTAGE -> String.valueOf(Math.abs(Math.pow(voltageLevel.getNominalV(), 2) * shuntCompensator.getB()) * shuntCompensator.getMaximumSectionCount());
case MAXIMUM_SUSCEPTANCE -> String.valueOf(bPerSection * shuntCompensator.getMaximumSectionCount());
case MAXIMUM_Q_AT_NOMINAL_VOLTAGE -> String.valueOf(Math.abs(Math.pow(voltageLevel.getNominalV(), 2) * bPerSection) * shuntCompensator.getMaximumSectionCount());
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static void modifyMaximumSectionCount(AttributeModification<Integer> maxi
if (maximumSectionCountModif != null) {
var maximumSectionCount = maximumSectionCountModif.getValue();
if (maxSusceptance == null && maxQAtNominalV == null) {
model.setBPerSection(model.getBPerSection() * shuntCompensator.getMaximumSectionCount() / maximumSectionCount);
model.setBPerSection((model.getBPerSection() * shuntCompensator.getMaximumSectionCount()) / maximumSectionCount);
}
if (reports != null) {
reports.add(ModificationUtils.getInstance().buildModificationReport(shuntCompensator.getMaximumSectionCount(), maximumSectionCount, "Maximum section count"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ protected List<FormulaInfos> getUpdatedFormulaInfos() {
protected void assertAfterNetworkModificationCreation() {
ShuntCompensator shuntCompensator1 = getNetwork().getShuntCompensator(SHUNT_COMPENSATOR_ID_1);
assertEquals(8, shuntCompensator1.getMaximumSectionCount());
assertEquals(2.625, shuntCompensator1.getModel(ShuntCompensatorLinearModel.class).getBPerSection(), 0);
assertEquals(1.625, shuntCompensator1.getModel(ShuntCompensatorLinearModel.class).getBPerSection(), 0);

ShuntCompensator shuntCompensator2 = getNetwork().getShuntCompensator(SHUNT_COMPENSATOR_ID_2);
assertEquals(6, shuntCompensator2.getMaximumSectionCount());
assertEquals(0.5, shuntCompensator2.getModel(ShuntCompensatorLinearModel.class).getBPerSection(), 0);
assertEquals(0.25, shuntCompensator2.getModel(ShuntCompensatorLinearModel.class).getBPerSection(), 0);

ShuntCompensator shuntCompensator3 = getNetwork().getShuntCompensator(SHUNT_COMPENSATOR_ID_3);
assertEquals(12, shuntCompensator3.getMaximumSectionCount());
assertEquals(3, shuntCompensator3.getModel(ShuntCompensatorLinearModel.class).getBPerSection(), 0);
assertEquals(0.75, shuntCompensator3.getModel(ShuntCompensatorLinearModel.class).getBPerSection(), 0);

ShuntCompensator shuntCompensator4 = getNetwork().getShuntCompensator(SHUNT_COMPENSATOR_ID_4);
assertEquals(13, shuntCompensator4.getSectionCount());
Expand Down

0 comments on commit b9d16c0

Please sign in to comment.