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

Distributed active power calculation #544

Merged
merged 5 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -145,7 +145,7 @@ private LoadFlowResult runAc(Network network, LoadFlowParameters parameters, Rep
result.getNewtonRaphsonIterations(),
result.getNetwork().getSlackBus().getId(),
result.getSlackBusActivePowerMismatch() * PerUnit.SB,
Double.NaN));
result.getDistributedActivePower() * PerUnit.SB));
}

// zero or low impedance branch flows computation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ public class AcLoadFlowResult {

private final double slackBusActivePowerMismatch;

private final double distributedActivePower;

public AcLoadFlowResult(LfNetwork network, int outerLoopIterations, int newtonRaphsonIterations, NewtonRaphsonStatus newtonRaphsonStatus,
double slackBusActivePowerMismatch) {
double slackBusActivePowerMismatch, double distributedActivePower) {
this.network = Objects.requireNonNull(network);
this.outerLoopIterations = outerLoopIterations;
this.newtonRaphsonIterations = newtonRaphsonIterations;
this.newtonRaphsonStatus = newtonRaphsonStatus;
this.slackBusActivePowerMismatch = slackBusActivePowerMismatch;
this.distributedActivePower = distributedActivePower;
}

public LfNetwork getNetwork() {
Expand All @@ -56,12 +59,17 @@ public double getSlackBusActivePowerMismatch() {
return slackBusActivePowerMismatch;
}

public double getDistributedActivePower() {
return distributedActivePower;
}

@Override
public String toString() {
return "AcLoadFlowResult(outerLoopIterations=" + outerLoopIterations
+ ", newtonRaphsonIterations=" + newtonRaphsonIterations
+ ", newtonRaphsonStatus=" + newtonRaphsonStatus
+ ", slackBusActivePowerMismatch=" + slackBusActivePowerMismatch * PerUnit.SB
+ ", distributedActivePower=" + distributedActivePower * PerUnit.SB
+ ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public AcLoadFlowResult run(Reporter reporter) {

// run initial Newton-Raphson
runningContext.lastNrResult = newtonRaphson.run(voltageInitializer, reporter);
double initialSlackBusActivePowerMismatch = runningContext.lastNrResult.getSlackBusActivePowerMismatch();

// continue with outer loops only if initial Newton-Raphson succeed
if (runningContext.lastNrResult.getStatus() == NewtonRaphsonStatus.CONVERGED) {
Expand Down Expand Up @@ -141,8 +142,12 @@ public AcLoadFlowResult run(Reporter reporter) {
int nrIterations = runningContext.lastNrResult.getIteration();
int outerLoopIterations = runningContext.outerLoopIterationByType.values().stream().mapToInt(MutableInt::getValue).sum() + 1;

AcLoadFlowResult result = new AcLoadFlowResult(context.getNetwork(), outerLoopIterations, nrIterations, runningContext.lastNrResult.getStatus(),
runningContext.lastNrResult.getSlackBusActivePowerMismatch());
AcLoadFlowResult result = new AcLoadFlowResult(context.getNetwork(),
outerLoopIterations,
nrIterations,
runningContext.lastNrResult.getStatus(),
runningContext.lastNrResult.getSlackBusActivePowerMismatch(),
initialSlackBusActivePowerMismatch - runningContext.lastNrResult.getSlackBusActivePowerMismatch());

LOGGER.info("Ac loadflow complete on network {} (result={})", context.getNetwork(), result);

Expand All @@ -159,7 +164,7 @@ public static <T> List<AcLoadFlowResult> run(T network, LfNetworkLoader<T> netwo
.run(reporter);
}
}
return new AcLoadFlowResult(n, 0, 0, NewtonRaphsonStatus.NO_CALCULATION, Double.NaN);
return new AcLoadFlowResult(n, 0, 0, NewtonRaphsonStatus.NO_CALCULATION, Double.NaN, 0);
})
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public double run(List<ParticipatingElement> participatingElements, int iteratio
}

LOGGER.debug("{} MW / {} MW distributed at iteration {} to {} buses ({} at min consumption)",
done * PerUnit.SB, -remainingMismatch * PerUnit.SB, iteration, modifiedBuses, loadsAtMin);
-done * PerUnit.SB, -remainingMismatch * PerUnit.SB, iteration, modifiedBuses, loadsAtMin);

return done;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.powsybl.openloadflow.OpenLoadFlowProvider;
import com.powsybl.openloadflow.network.DistributedSlackNetworkFactory;
import com.powsybl.openloadflow.network.SlackBusSelectionMode;
import com.powsybl.openloadflow.util.LoadFlowAssert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -25,8 +26,7 @@

import static com.powsybl.openloadflow.util.LoadFlowAssert.assertActivePowerEquals;
import static com.powsybl.openloadflow.util.LoadFlowAssert.assertReactivePowerEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
Expand Down Expand Up @@ -60,6 +60,8 @@ void setUp() {
void test() {
Copy link
Member

@annetill annetill Jun 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried this use case with a distribution on loads and it seems that we have a or several sign issues... indeed the definition of distributed active power here does not depend on which equipment is called for it. In your use case, the distribution on generators means increasing generation. The distribution on loads means decreasing consumption.

LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertTrue(result.isOk());
assertEquals(1, result.getComponentResults().size());
assertEquals(120, result.getComponentResults().get(0).getDistributedActivePower(), LoadFlowAssert.DELTA_POWER);
assertActivePowerEquals(-115, g1.getTerminal());
assertActivePowerEquals(-245, g2.getTerminal());
assertActivePowerEquals(-105, g3.getTerminal());
Expand Down