Skip to content

Commit

Permalink
Multiple scaling modifications (#2666)
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Philippe Edwards <philippe.edwards@rte-france.com>
  • Loading branch information
rolnico authored Sep 19, 2023
1 parent 6d10d47 commit 75dadba
Show file tree
Hide file tree
Showing 24 changed files with 1,401 additions and 139 deletions.
2 changes: 1 addition & 1 deletion action/action-dsl/src/test/resources/scalable.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ action('testProportional') {
script {
variationValue = 15000
gens = scalables('GEN', 'GEN2', 'GEN3')
variation = proportional([50.0f,20.0f,30.0f], gens)
variation = proportional([50.0d,20.0d,30.0d], gens)
variation.reset(network)
variation.scale(network, variationValue)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
*/
package com.powsybl.iidm.modification.scalable;

import com.powsybl.iidm.network.DanglingLine;
import com.powsybl.iidm.network.Injection;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.Terminal;
import com.powsybl.iidm.network.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -104,9 +101,10 @@ public void filterInjections(Network n, List<Injection> injections, List<String>

/**
* {@inheritDoc}
* <p>
* If scalingConvention is LOAD, the load active power increases for positive "asked" and decreases inversely
* If scalingConvention is GENERATOR, the load active power decreases for positive "asked" and increases inversely
* <ul>
* <li>If scalingConvention is LOAD, the load active power increases for positive "asked" and decreases inversely.</li>
* <li>If scalingConvention is GENERATOR, the load active power decreases for positive "asked" and increases inversely.</li>
* </ul>
*/
@Override
public double scale(Network n, double asked, ScalingParameters parameters) {
Expand Down Expand Up @@ -166,4 +164,15 @@ public double maximumValue(Network n) {
public double minimumValue(Network n) {
return minimumValue(n, scalingConvention);
}

@Override
public double getSteadyStatePower(Network network, ScalingConvention scalingConvention) {
DanglingLine line = network.getDanglingLine(id);
if (line == null) {
LOGGER.warn("DanglingLine {} not found", id);
return 0.0;
} else {
return scalingConvention == LOAD ? line.getP0() : -line.getP0();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ public void filterInjections(Network n, List<Injection> injections, List<String>
/**
* {@inheritDoc}
*
* If scalingConvention is GENERATOR, the generator active power increases for positive "asked" and decreases inversely
* If scalingConvention is LOAD, the generator active power decreases for positive "asked" and increases inversely
* <ul>
* <li>If scalingConvention is GENERATOR, the generator active power increases for positive "asked" and decreases inversely.</li>
* <li>If scalingConvention is LOAD, the generator active power decreases for positive "asked" and increases inversely.</li>
* </ul>
*/
@Override
public double scale(Network n, double asked, ScalingParameters parameters) {
Expand Down Expand Up @@ -154,4 +156,43 @@ public double scale(Network n, double asked, ScalingParameters parameters) {

return done;
}

/**
* Compute the percentage of asked power available for the scale. It takes into account the scaling convention
* specified by the user and the sign of the asked power.
*
* @param network Network on which the scaling is done
* @param asked Asked power (can be positive or negative)
* @param scalingPercentage Percentage of the asked power that shall be distributed to the current injection
* @param scalingConvention Scaling convention (GENERATOR or LOAD)
* @return the percentage of asked power available for the scale on the current injection
*/
double availablePowerInPercentageOfAsked(Network network, double asked, double scalingPercentage, ScalingConvention scalingConvention) {
var generator = network.getGenerator(id);

// In LOAD convention, a positive scale will imply a decrease of generators target power
var askedPower = asked * scalingPercentage / 100;
if (scalingConvention == LOAD) {
askedPower = -askedPower;
}

if (askedPower >= 0) {
var availablePower = Math.min(generator.getMaxP(), maxValue) - generator.getTargetP();
return askedPower > availablePower ? availablePower / askedPower : 100.0;
} else {
var availablePower = Math.max(generator.getMinP(), minValue) - generator.getTargetP();
return askedPower < availablePower ? availablePower / askedPower : 100.0;
}
}

@Override
public double getSteadyStatePower(Network network, ScalingConvention scalingConvention) {
Generator generator = network.getGenerator(id);
if (generator == null) {
LOGGER.warn("Generator {} not found", id);
return 0.0;
} else {
return scalingConvention == GENERATOR ? generator.getTargetP() : -generator.getTargetP();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ public void filterInjections(Network n, List<Injection> injections, List<String>
}
}

/**
* {@inheritDoc}
*
* <ul>
* <li>If scalingConvention is LOAD, the load active power increases for positive "asked" and decreases inversely.</li>
* <li>If scalingConvention is GENERATOR, the load active power decreases for positive "asked" and increases inversely.</li>
* </ul>
*/
@Override
public double scale(Network n, double asked, ScalingParameters parameters) {
Objects.requireNonNull(n);
Expand Down Expand Up @@ -151,4 +159,14 @@ public double scale(Network n, double asked, ScalingParameters parameters) {
return done;
}

@Override
public double getSteadyStatePower(Network network, ScalingConvention scalingConvention) {
Load load = network.getLoad(id);
if (load == null) {
LOGGER.warn("Load {} not found", id);
return 0.0;
} else {
return scalingConvention == LOAD ? load.getP0() : -load.getP0();
}
}
}
Loading

0 comments on commit 75dadba

Please sign in to comment.