Skip to content

Commit

Permalink
add some documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Caio Luke <caioluke97@gmail.com>
  • Loading branch information
caioluke committed Sep 13, 2024
1 parent 3a3c36a commit 8bd347c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 45 deletions.
18 changes: 16 additions & 2 deletions docs/flow_decomposition/algorithm-description.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ The difference between reference AC flow and the sum of the parts of the decompo
parts proportionally to their rectified linear unit ($\mathrm{ReLU}(x) = \mathrm{max}(x, 0)$).

#### Proportional rescaling
Each flow is rescaled with a proportional coefficient. The coefficient is defined by $$\alpha_{\text{rescale}} = \frac{max(|AC p1|, |AC p2|)}{|DC p1|}$$.
Each flow is rescaled by a proportional coefficient. The coefficient is defined by $$\alpha_{\text{rescale}} = \frac{max(|AC p1|, |AC p2|)}{|DC p1|}$$.
In this way, the DC flow will have the same magnitude as the AC flow.
Since we divide by the DC flow to calculate the coefficient, lines with a too small DC flow are not rescaled.
Since we divide by the DC flow to calculate the coefficient, lines with a too small DC flow are not rescaled.

#### Max current overload rescaling
Each flow is rescaled by the same coefficient. The goal is to rescale DC flows in such a way that we find the same level of current overload as in the AC case - the maximum of the two terminals.
Therefore, we first compare AC current overloads to find which terminal (1 or 2) has the highest current overload. Then, we get the associated active power to rescale DC flows.
In case there are missing limits, we just compare AC currents instead of overloads.
Hence, the coefficient is defined as
1) With current limits:
- if $$\frac{AC I1}{I_{max}1} >= \frac{AC I2}{I_{max}2}$$, then $$\alpha_{\text{rescale}} = \frac{\sqrt{3} \cdot AC I1 \cdot \frac{V1_{nominal}}{1000}}{|DC p1|}$$
- else, $$\alpha_{\text{rescale}} = \frac{\sqrt{3} \cdot AC I2 \cdot \frac{V2_{nominal}}{1000}}{|DC p1|}$$
2) Without current limits:
- if $$AC I1 >= AC I2$$, then $$\alpha_{\text{rescale}} = \frac{\sqrt{3} \cdot AC I1 \cdot \frac{V1_{nominal}}{1000}}{|DC p1|}$$
- else, $$\alpha_{\text{rescale}} = \frac{\sqrt{3} \cdot AC I2 \cdot \frac{V2_{nominal}}{1000}}{|DC p1|}$$

Since we divide by the DC flow to calculate the coefficient, lines with a too small DC flow are not rescaled.
18 changes: 9 additions & 9 deletions docs/flow_decomposition/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## Dedicated parameters

| Name | Type | Default value | Description |
|-------------------------------------------|---------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| enable-losses-compensation | boolean | false | When set to true, adds losses compensation step of the algorithm. Otherwise, all losses will be compensated using chosen power flow compensation strategy. |
| losses-compensation-epsilon | double | 1e-5 | Threshold used in losses compensation step of the algorihm. If actual losses are below the given threshold on a branch, no injection is created in the network to compensate these losses. Used to avoid creating too many injections in the network. May have an impact in overall algorithm performance and memory usage. |
| sensitivity-epsilon | double | 1e-5 | Threshold used when filling PTDF and PSDF matrices. If a sensitivity is below the given threshold, it is set to zero. Used to keep sparse matrices in the algorithm. May have an impact in overall algorithm performance and memory usage. |
| rescale-mode | enum | NONE | Use NONE if you don't want to rescale flow decomposition results. Use ACER_METHODOLOGY for the ACER methodology rescaling strategy. Use PROPORTIONAL for a proportional rescaling. See [Flow parts rescaling](../flow_decomposition/algorithm-description.md#flow-parts-rescaling) for more details. |
| proportional-rescaler-min-flow-tolerance | double | 1e-6 | Option only used if rescale-mode is PROPORTIONAL. Defines the minimum DC flow required in MW for the rescaling to happen. |
| dc-fallback-enabled-after-ac-divergence | boolean | true | Defines the fallback behavior after an AC divergence Use True to run DC loadflow if an AC loadflow diverges (default). Use False to throw an exception if an AC loadflow diverges. |
| sensitivity-variable-batch-size | int | 15000 | When set to a lower value, this parameter will reduce memory usage, but it might increase computation time |
| Name | Type | Default value | Description |
|-------------------------------------------|---------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| enable-losses-compensation | boolean | false | When set to true, adds losses compensation step of the algorithm. Otherwise, all losses will be compensated using chosen power flow compensation strategy. |
| losses-compensation-epsilon | double | 1e-5 | Threshold used in losses compensation step of the algorihm. If actual losses are below the given threshold on a branch, no injection is created in the network to compensate these losses. Used to avoid creating too many injections in the network. May have an impact in overall algorithm performance and memory usage. |
| sensitivity-epsilon | double | 1e-5 | Threshold used when filling PTDF and PSDF matrices. If a sensitivity is below the given threshold, it is set to zero. Used to keep sparse matrices in the algorithm. May have an impact in overall algorithm performance and memory usage. |
| rescale-mode | enum | NONE | Use NONE if you don't want to rescale flow decomposition results. Use ACER_METHODOLOGY for the ACER methodology rescaling strategy. Use PROPORTIONAL for a proportional rescaling. Use MAX_CURRENT_OVERLOAD for a rescaling based on AC current overloads. See [Flow parts rescaling](../flow_decomposition/algorithm-description.md#flow-parts-rescaling) for more details. |
| proportional-rescaler-min-flow-tolerance | double | 1e-6 | Option used from rescale modes PROPORTIONAL and MAX_CURRENT_OVERLOAD. Defines the minimum DC flow required in MW for the rescaling to happen. |
| dc-fallback-enabled-after-ac-divergence | boolean | true | Defines the fallback behavior after an AC divergence Use True to run DC loadflow if an AC loadflow diverges (default). Use False to throw an exception if an AC loadflow diverges. |
| sensitivity-variable-batch-size | int | 15000 | When set to a lower value, this parameter will reduce memory usage, but it might increase computation time |

## Impact of existing parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,6 @@ void testProportionalNormalizationWithFlowDecompositionResultsWithPstNetwork() {
testNormalizationWithFlowDecompositionResults(networkFileName, FlowDecompositionParameters.RescaleMode.PROPORTIONAL);
}

@Test
void testMaxCurrentOverloadNormalizationWithFlowDecompositionResultsWithPstNetwork() {
String networkFileName = "NETWORK_PST_FLOW_WITH_COUNTRIES.uct";
testNormalizationWithFlowDecompositionResults(networkFileName, FlowDecompositionParameters.RescaleMode.MAX_CURRENT_OVERLOAD);
}

@Test
void testMaxCurrentOverloadNormalizationWithFlowDecompositionResults2() {
String networkFileName = "19700101_0000_FO4_UX1.uct";
testNormalizationWithFlowDecompositionResults(networkFileName, FlowDecompositionParameters.RescaleMode.MAX_CURRENT_OVERLOAD);
}

static void testNormalizationWithFlowDecompositionResults(String networkFileName, FlowDecompositionParameters.RescaleMode rescaleMode) {
Network network = TestUtils.importNetwork(networkFileName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,7 @@ public static void assertCoherenceTotalFlow(FlowDecompositionParameters.RescaleM
switch (rescaleMode) {
case ACER_METHODOLOGY -> assertEquals(Math.abs(decomposedFlow.getAcTerminal1ReferenceFlow()), decomposedFlow.getTotalFlow(), EPSILON);
case PROPORTIONAL -> assertEquals(decomposedFlow.getMaxAbsAcFlow(), decomposedFlow.getTotalFlow(), EPSILON);
case MAX_CURRENT_OVERLOAD -> {
Branch<?> branch = network.getBranch(decomposedFlow.getBranchId());
double acCurrentTerminal1 = decomposedFlow.getAcTerminal1Current();
double acCurrentTerminal2 = decomposedFlow.getAcTerminal2Current();
double nominalVoltageTerminal1 = branch.getTerminal1().getVoltageLevel().getNominalV();
double nominalVoltageTerminal2 = branch.getTerminal2().getVoltageLevel().getNominalV();
CurrentLimits currentLimitsTerminal1 = branch.getNullableCurrentLimits1();
CurrentLimits currentLimitsTerminal2 = branch.getNullableCurrentLimits2();

double pTerminal1ActivePowerOnly = acCurrentTerminal1 * (nominalVoltageTerminal1 / 1000) * Math.sqrt(3);
double pTerminal2ActivePowerOnly = acCurrentTerminal2 * (nominalVoltageTerminal2 / 1000) * Math.sqrt(3);

double pActivePowerOnly;
if (currentLimitsTerminal1 == null || currentLimitsTerminal2 == null) {
pActivePowerOnly = acCurrentTerminal1 >= acCurrentTerminal2 ? pTerminal1ActivePowerOnly : pTerminal2ActivePowerOnly;
} else {
double currentOverloadTerminal1 = acCurrentTerminal1 / currentLimitsTerminal1.getPermanentLimit();
double currentOverloadTerminal2 = acCurrentTerminal2 / currentLimitsTerminal2.getPermanentLimit();
pActivePowerOnly = currentOverloadTerminal1 >= currentOverloadTerminal2 ? pTerminal1ActivePowerOnly : pTerminal2ActivePowerOnly;
}
assertEquals(pActivePowerOnly, decomposedFlow.getTotalFlow(), EPSILON);
}
case MAX_CURRENT_OVERLOAD -> throw new IllegalArgumentException("Rescaling method not tested");
default -> assertEqualsWithoutRescaling(xnec, decomposedFlow);
}
}
Expand Down

0 comments on commit 8bd347c

Please sign in to comment.