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 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,11 @@ public double scale(Network n, double asked, ScalingParameters parameters) {

return done;
}

double availablePowerInPercentageOfAsked(Network network, double asked, double scalingPercentage) {
phiedw marked this conversation as resolved.
Show resolved Hide resolved
var generator = network.getGenerator(id);
var availablePower = generator.getMaxP() - generator.getTargetP();
var askedPower = asked * scalingPercentage / 100;
return askedPower > availablePower ? availablePower / askedPower : 100.0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

import com.powsybl.iidm.network.Network;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;

import static com.powsybl.iidm.modification.scalable.ScalingParameters.DistributionMode.STACKING_UP;
import static com.powsybl.iidm.modification.scalable.ScalingParameters.Priority.VENTILATION;
import static com.powsybl.iidm.modification.scalable.ScalingParameters.Priority.VOLUME;

/**
* Scalable that divides scale proportionally between multiple scalable.
Expand All @@ -23,12 +24,12 @@
class ProportionalScalable extends AbstractCompoundScalable {
private static final double EPSILON = 1e-2;

private static final class ScalablePercentage {
static final class ScalablePercentage {
private final Scalable scalable;
private final float percentage;
private double iterationPercentage;

private ScalablePercentage(Scalable scalable, float percentage) {
ScalablePercentage(Scalable scalable, float percentage) {
this.scalable = scalable;
this.percentage = percentage;
this.iterationPercentage = percentage;
Expand Down Expand Up @@ -61,6 +62,11 @@ void setIterationPercentage(double iterationPercentage) {

private final List<ScalablePercentage> scalablePercentageList;

ProportionalScalable() {
// Initialisation if the list
this.scalablePercentageList = new ArrayList<>();
}

ProportionalScalable(List<Float> percentages, List<Scalable> scalables) {
checkPercentages(percentages, scalables);
this.scalablePercentageList = new ArrayList<>();
Expand All @@ -70,7 +76,11 @@ void setIterationPercentage(double iterationPercentage) {
}

Collection<Scalable> getScalables() {
return scalablePercentageList.stream().map(ScalablePercentage::getScalable).collect(Collectors.toList());
return scalablePercentageList.stream().map(ScalablePercentage::getScalable).toList();
}

List<ScalablePercentage> getScalablePercentageList() {
return scalablePercentageList;
}

private static void checkPercentages(List<Float> percentages, List<Scalable> scalables) {
Expand Down Expand Up @@ -128,8 +138,7 @@ private double scaleIteration(Network n, double asked, ScalingParameters paramet
Scalable s = scalablePercentage.getScalable();
double iterationPercentage = scalablePercentage.getIterationPercentage();
double askedOnScalable = iterationPercentage / 100 * asked;
double doneOnScalable = 0;
doneOnScalable = s.scale(n, askedOnScalable, parameters);
double doneOnScalable = s.scale(n, askedOnScalable, parameters);
if (Math.abs(doneOnScalable - askedOnScalable) > EPSILON) {
scalablePercentage.setIterationPercentage(0);
}
Expand All @@ -143,7 +152,7 @@ public double scale(Network n, double asked, ScalingParameters parameters) {
Objects.requireNonNull(n);
Objects.requireNonNull(parameters);
reinitIterationPercentage();
if (parameters.isIterative()) {
if (parameters.getPriority() == VOLUME) {
return iterativeScale(n, asked, parameters);
} else {
return scaleIteration(n, asked, parameters);
Expand All @@ -154,5 +163,25 @@ private void reinitIterationPercentage() {
scalablePercentageList.forEach(scalablePercentage -> scalablePercentage.setIterationPercentage(scalablePercentage.getPercentage()));
}

/**
* Compute the power that can be scaled on the network while keeping the ventilation percentages valid.
phiedw marked this conversation as resolved.
Show resolved Hide resolved
* This method is only used if the distribution is not STACKING_UP and if the scaling priority is VENTILATION.
* @param asked power that shall be scaled on the network
* @param scalingParameters scaling parameters
* @param network network on which the scaling shall be done
* @return the effective power value that can be safely scaled while keeping the ventilation percentages valid
*/
double resizeAskedForVentilation(Network network, double asked, ScalingParameters scalingParameters) {
if (scalingParameters.getDistributionMode() != STACKING_UP && scalingParameters.getPriority() == VENTILATION) {
AtomicReference<Double> resizingPercentage = new AtomicReference<>(1.0);
scalablePercentageList.forEach(scalablePercentage ->
resizingPercentage.set(Math.min(((GeneratorScalable) scalablePercentage.getScalable()).availablePowerInPercentageOfAsked(network, asked, scalablePercentage.getPercentage()), resizingPercentage.get()))
phiedw marked this conversation as resolved.
Show resolved Hide resolved
);
return asked * resizingPercentage.get();
} else {
return asked;
}
}

}

Loading