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

Support of new BalanceType PROPORTIONAL_TO_GENERATION_PARTICIPATION_FACTOR and PROPORTIONAL_TO_GENERATION_REMAINING_MARGIN #702

Merged
merged 18 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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 @@ -67,6 +67,10 @@ default double getDroop() {
return 0;
}

default double getParticipationFactor() {
return 0;
}

double getCalculatedQ();

void setCalculatedQ(double calculatedQ);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public final class LfBatteryImpl extends AbstractLfGenerator {

private double droop;

private double participationFactor;

private LfBatteryImpl(Battery battery, LfNetwork network, LfNetworkParameters parameters, LfNetworkLoadingReport report) {
super(network, battery.getTargetP());
this.batteryRef = new Ref<>(battery);
Expand All @@ -35,10 +37,13 @@ private LfBatteryImpl(Battery battery, LfNetwork network, LfNetworkParameters pa
// get participation factor from extension
ActivePowerControl<Battery> activePowerControl = battery.getExtension(ActivePowerControl.class);
if (activePowerControl != null) {
participating = activePowerControl.isParticipate() && activePowerControl.getDroop() != 0;
if (activePowerControl.getDroop() != 0) {
participating = activePowerControl.isParticipate();
if (!Double.isNaN(activePowerControl.getDroop())) {
droop = activePowerControl.getDroop();
}
if (activePowerControl.getParticipationFactor() > 0) {
participationFactor = activePowerControl.getParticipationFactor();
}
}

if (!checkActivePowerControl(battery.getTargetP(), battery.getMinP(), battery.getMaxP(), parameters, report)) {
Expand Down Expand Up @@ -98,6 +103,11 @@ public double getDroop() {
return droop;
}

@Override
public double getParticipationFactor() {
jeandemanged marked this conversation as resolved.
Show resolved Hide resolved
return participationFactor;
}

@Override
public void updateState() {
var battery = getBattery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,23 @@ public final class LfGeneratorImpl extends AbstractLfGenerator {

private double droop;

private double participationFactor;
obrix marked this conversation as resolved.
Show resolved Hide resolved

private LfGeneratorImpl(Generator generator, LfNetwork network, LfNetworkParameters parameters, LfNetworkLoadingReport report) {
super(network, generator.getTargetP());
this.generatorRef = new Ref<>(generator);
participating = true;
droop = DEFAULT_DROOP;
// get participation factor from extension
// get participation factor and droop from extension
ActivePowerControl<Generator> activePowerControl = generator.getExtension(ActivePowerControl.class);
if (activePowerControl != null) {
boolean withDroop = !Double.isNaN(activePowerControl.getDroop()) && activePowerControl.getDroop() != 0;
participating = activePowerControl.isParticipate() && withDroop;
if (withDroop) {
participating = activePowerControl.isParticipate();
if (!Double.isNaN(activePowerControl.getDroop())) {
droop = activePowerControl.getDroop();
}
if (activePowerControl.getParticipationFactor() > 0) {
participationFactor = activePowerControl.getParticipationFactor();
}
}

if (!checkActivePowerControl(generator.getTargetP(), generator.getMinP(), generator.getMaxP(), parameters, report)) {
Expand Down Expand Up @@ -127,6 +131,11 @@ public double getDroop() {
return droop;
}

@Override
public double getParticipationFactor() {
return participationFactor;
}

@Override
public void updateState() {
var generator = getGenerator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ public static Step getStep(LoadFlowParameters.BalanceType balanceType, boolean l
case PROPORTIONAL_TO_GENERATION_P:
step = new GenerationActivePowerDistributionStep(GenerationActivePowerDistributionStep.ParticipationType.TARGET);
break;
case PROPORTIONAL_TO_GENERATION_PARTICIPATION_FACTOR:
step = new GenerationActivePowerDistributionStep(GenerationActivePowerDistributionStep.ParticipationType.PARTICIPATION_FACTOR);
break;
case PROPORTIONAL_TO_GENERATION_REMAINING_MARGIN:
step = new GenerationActivePowerDistributionStep(GenerationActivePowerDistributionStep.ParticipationType.REMAINING_MARGIN);
break;
default:
throw new UnsupportedOperationException("Unknown balance type mode: " + balanceType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public class GenerationActivePowerDistributionStep implements ActivePowerDistrib

public enum ParticipationType {
MAX,
TARGET
TARGET,
PARTICIPATION_FACTOR,
REMAINING_MARGIN
}

private ParticipationType participationType;
Expand All @@ -45,7 +47,7 @@ public List<ParticipatingElement> getParticipatingElements(Collection<LfBus> bus
return buses.stream()
.filter(bus -> bus.isParticipating() && !bus.isDisabled() && !bus.isFictitious())
.flatMap(bus -> bus.getGenerators().stream())
.filter(generator -> generator.isParticipating() && getParticipationFactor(generator) != 0)
.filter(generator -> isParticipating(generator) && getParticipationFactor(generator) > 0)
.map(generator -> new ParticipatingElement(generator, getParticipationFactor(generator)))
.collect(Collectors.toList());
}
Expand Down Expand Up @@ -113,9 +115,32 @@ private double getParticipationFactor(LfGenerator generator) {
case TARGET:
factor = Math.abs(generator.getTargetP());
break;
case PARTICIPATION_FACTOR:
factor = generator.getParticipationFactor();
break;
case REMAINING_MARGIN:
factor = Math.max(0.0, generator.getMaxP() - generator.getTargetP());
break;
default:
throw new UnsupportedOperationException("Unknown balance type mode: " + participationType);
}
return factor;
}

private boolean isParticipating(LfGenerator generator) {
boolean isParticipating;
switch (participationType) {
case MAX:
isParticipating = generator.isParticipating() && generator.getDroop() != 0;
break;
case REMAINING_MARGIN:
case TARGET:
case PARTICIPATION_FACTOR:
isParticipating = generator.isParticipating();
break;
default:
throw new UnsupportedOperationException("Unknown balance type mode: " + participationType);
}
return isParticipating;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,56 @@ void testProportionalToGenerationPBalanceType() {
assertActivePowerEquals(-117.236, g4.getTerminal());
}

@Test
void testProportionalToGenerationPMaxBalanceType() {
// decrease g1 max limit power, so that distributed slack algo reach the g1 max
g1.setMaxP(105);
parameters.setBalanceType(LoadFlowParameters.BalanceType.PROPORTIONAL_TO_GENERATION_P_MAX);
LoadFlowResult result = loadFlowRunner.run(network, parameters);

assertTrue(result.isOk());
assertActivePowerEquals(-105, g1.getTerminal());
assertActivePowerEquals(-249.285, g2.getTerminal());
assertActivePowerEquals(-106.429, g3.getTerminal());
assertActivePowerEquals(-139.286, g4.getTerminal());
}

@Test
void testProportionalToGenerationParticipationFactorBalanceType() {
// decrease g1 max limit power, so that distributed slack algo reach the g1 max
g1.setMaxP(100);

// set participationFactor
// g1 NaN participationFactor should be discarded
g2.getExtension(ActivePowerControl.class).setParticipationFactor(3.0);
g3.getExtension(ActivePowerControl.class).setParticipationFactor(1.0);
g4.getExtension(ActivePowerControl.class).setParticipationFactor(-4.0); // Should be discarded

parameters.setBalanceType(LoadFlowParameters.BalanceType.PROPORTIONAL_TO_GENERATION_PARTICIPATION_FACTOR);
LoadFlowResult result = loadFlowRunner.run(network, parameters);

assertTrue(result.isOk());
assertActivePowerEquals(-100, g1.getTerminal());
assertActivePowerEquals(-290, g2.getTerminal());
assertActivePowerEquals(-120, g3.getTerminal());
assertActivePowerEquals(-90, g4.getTerminal());
}

@Test
void testProportionalToGenerationRemainingMarginBalanceType() {
// decrease g1 max limit power, so that distributed slack algo reach the g1 max
g1.setMaxP(105);

parameters.setBalanceType(LoadFlowParameters.BalanceType.PROPORTIONAL_TO_GENERATION_REMAINING_MARGIN);
LoadFlowResult result = loadFlowRunner.run(network, parameters);

assertTrue(result.isOk());
assertActivePowerEquals(-102.667, g1.getTerminal());
assertActivePowerEquals(-253.333, g2.getTerminal());
assertActivePowerEquals(-122.0, g3.getTerminal());
assertActivePowerEquals(-122.0, g4.getTerminal());
}

@Test
void maxTest() {
// decrease g1 max limit power, so that distributed slack algo reach the g1 max
Expand All @@ -118,7 +168,6 @@ void minTest() {
}

@Test
@SuppressWarnings("unchecked")
void zeroParticipatingGeneratorsTest() {
g1.getExtension(ActivePowerControl.class).setDroop(2);
g2.getExtension(ActivePowerControl.class).setDroop(-3);
Expand Down Expand Up @@ -159,7 +208,6 @@ void generatorWithMaxPEqualsToMinP() {

@Test
void nonParticipatingBus() {

//B1 and B2 are located in germany the rest is in france
Substation b1s = network.getSubstation("b1_s");
b1s.setCountry(Country.GE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ void testDanglingLine() {
assertTrue(lfNetwork.getBusById("DL_BUS").createBusResults().isEmpty());
}

@Test
void testVsc() {
Network network = HvdcNetworkFactory.createVsc();
List<LfNetwork> lfNetworks = Networks.load(network, new MostMeshedSlackBusSelector());
assertEquals(2, lfNetworks.size());
LfNetwork lfNetwork = lfNetworks.get(0);
assertEquals(0.0, lfNetwork.getGeneratorById("cs2").getParticipationFactor(), 1E-6);
}

@Test
void testMultipleConnectedComponentsACMainComponent() {
Network network = ConnectedComponentNetworkFactory.createTwoUnconnectedCC();
Expand Down