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

Multiple scaling modifications #2666

Merged
merged 24 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
162fac8
Implementation of ProportionalScalable on loads and on generators
rolnico Aug 4, 2023
2488883
Implementation of ProportionalScalable on loads and on generators
rolnico Aug 7, 2023
d37ac44
Merge VariationParameters into existing ScalingParameters + make scal…
rolnico Aug 7, 2023
aae0a7d
Added Exceptions management and Tests
rolnico Aug 7, 2023
f45a773
Moved scaleOnLoads and scaleOnGenerators in Scalable, added STACKING_…
rolnico Aug 8, 2023
d957c35
Modified and moved the reporter, added a default value for a paramete…
rolnico Aug 9, 2023
4a40f89
Added tests for coverage
rolnico Aug 9, 2023
f51a09c
Added tests for coverage
rolnico Aug 9, 2023
b298cad
Merge branch 'main' into multiple_scaling_modifications
annetill Aug 23, 2023
1134ed2
create proportional and then scale rather than having a method doing …
phiedw Sep 4, 2023
b3b2489
removed scalingValue from ScalingParameters
phiedw Sep 4, 2023
794eb69
Reorganized code for Scalables
rolnico Sep 8, 2023
ce4410a
Checkstyle corrections
rolnico Sep 8, 2023
e91acea
Correction of testProportional (float to double)
rolnico Sep 11, 2023
bd21317
deletion of checkPositiveAskedWhenTarget and modification of getCurre…
rolnico Sep 13, 2023
190ed0a
Merge branch 'main' into multiple_scaling_modifications
rolnico Sep 13, 2023
8f14333
Merge branch 'main' into multiple_scaling_modifications
rolnico Sep 18, 2023
2395cc1
Renamed getCurrentPower to getOngoingPower
rolnico Sep 18, 2023
c2c65c0
Merge branch 'main' into multiple_scaling_modifications
rolnico Sep 18, 2023
0f4dd21
Renamed getOngoingPower to getSteadyStatePower
rolnico Sep 18, 2023
922a004
Javadoc corrected
rolnico Sep 18, 2023
84d7497
Merge branch 'main' into multiple_scaling_modifications
annetill Sep 18, 2023
4a995ec
Merge branch 'main' into multiple_scaling_modifications
annetill Sep 19, 2023
375f113
Header correction
rolnico Sep 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 getCurrentPower(Network network, ScalingConvention scalingConvention) {
colinepiloquet marked this conversation as resolved.
Show resolved Hide resolved
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 getCurrentPower(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 getCurrentPower(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