Skip to content

Commit

Permalink
Fix sensi integration (#940)
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
  • Loading branch information
geofjamg authored Feb 6, 2025
1 parent b713a69 commit 16c2802
Showing 1 changed file with 14 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,37 +187,23 @@ SensitivityAnalysisResultContext run(Network network, SensitivityAnalysisParamet
}
}

switch (matrix.getFunctionType()) {
case BRANCH_ACTIVE_POWER_1, BRANCH_ACTIVE_POWER_2, BRANCH_ACTIVE_POWER_3,
BRANCH_REACTIVE_POWER_1, BRANCH_REACTIVE_POWER_2, BRANCH_REACTIVE_POWER_3,
BRANCH_CURRENT_1, BRANCH_CURRENT_2, BRANCH_CURRENT_3 -> {
for (String variableId : rows) {
for (String branchId : columns) {
SensitivityVariableType variableType = matrix.getVariableType();
boolean variableSet = false;
if (variableType == null) {
variableType = getVariableType(network, variableId);
if (variableType == null) {
if (variableSetsById.containsKey(variableId)) {
variableSet = true;
variableType = SensitivityVariableType.INJECTION_ACTIVE_POWER;
} else {
throw new PowsyblException("Variable '" + variableId + "' not found");
}
}
}
for (ContingencyContext cCtx : contingencyContexts) {
handler.onFactor(matrix.getFunctionType(), branchId, variableType, variableId, variableSet, cCtx);
for (String variableId : rows) {
for (String functionId : columns) {
SensitivityVariableType variableType = matrix.getVariableType();
boolean variableSet = false;
if (variableType == null) {
variableType = getVariableType(network, variableId);
if (variableType == null) {
if (variableSetsById.containsKey(variableId)) {
variableSet = true;
variableType = SensitivityVariableType.INJECTION_ACTIVE_POWER;
} else {
throw new PowsyblException("Variable '" + variableId + "' not found");
}
}
}
}
case BUS_VOLTAGE -> {
for (String targetVoltageId : rows) {
for (String busVoltageId : columns) {
handler.onFactor(SensitivityFunctionType.BUS_VOLTAGE, busVoltageId,
SensitivityVariableType.BUS_TARGET_VOLTAGE, targetVoltageId, false, ContingencyContext.all());
}
for (ContingencyContext cCtx : contingencyContexts) {
handler.onFactor(matrix.getFunctionType(), functionId, variableType, variableId, variableSet, cCtx);
}
}
}
Expand Down

0 comments on commit 16c2802

Please sign in to comment.