Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve docs and tests for PTDF calculation in Flow Decomposition #159

Merged
merged 9 commits into from
Oct 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,16 @@ private static SensitivityResultWriter getSensitivityResultWriter(List<Pair<Stri
@Override
public void writeSensitivityValue(int factorIndex, int contingencyIndex, double value, double functionReference) {
Pair<String, String> factor = factors.get(factorIndex);
double referenceOrientedSensitivity = functionReference < 0 ? -value : value;
// Add threshold to avoid unwanted ptdf sign flipping
// Threshold value = 100 * 1E-13 = 1E-11
// 1e-13 -> FUNCTION_REFERENCE_ZER0_THRESHOLD from powsybl-open-loadflow
// 100 -> coming from unscaleFunction(factor, functionValue) from powsybl-open-loadflow
// Contingency case from flow decomposition bypasses the fixZeroFunctionReference in DcSensitivityAnalysis
double fixedFunctionReference = functionReference;
if (Math.abs(fixedFunctionReference) < 1E-11) {
fixedFunctionReference = 0.0;
}
double referenceOrientedSensitivity = fixedFunctionReference < 0 ? -value : value;
sensitivityMatrixTriplet.addItem(factor.getFirst(), factor.getSecond(), referenceOrientedSensitivity);
}

Expand Down
Loading