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

[WIP] Fix AC Emulation Disabled in Fast DC Security Analysis #1173

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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 @@ -68,8 +68,11 @@ protected ReportNode createSaRootReportNode() {
@Override
protected DcLoadFlowParameters createParameters(LoadFlowParameters lfParameters, OpenLoadFlowParameters lfParametersExt, boolean breakers) {
DcLoadFlowParameters dcParameters = super.createParameters(lfParameters, lfParametersExt, breakers);
// connectivity break analysis does not handle zero impedance lines
dcParameters.getNetworkParameters().setMinImpedance(true);
dcParameters.getNetworkParameters()
// connectivity break analysis does not handle zero impedance lines
.setMinImpedance(true)
// ac emulation is not yet supported
.setHvdcAcEmulation(false);
// needed an equation to force angle to zero when a PST is lost
dcParameters.getEquationSystemCreationParameters().setForcePhaseControlOffAndAddAngle1Var(true);
return dcParameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4034,4 +4034,73 @@ void testNoCc0Sc0() {
assertEquals(LoadFlowResult.ComponentResult.Status.CONVERGED, saResultAll.getPreContingencyResult().getStatus());
assertEquals(6, saResultAll.getPreContingencyResult().getNetworkResult().getBusResults().size()); // 6 buses in total
}

@ParameterizedTest
@ValueSource(booleans = {false, true})
void testDcSaHvdcLineContingency(boolean dcFastMode) {
Network network = HvdcNetworkFactory.createNetworkWithGenerators();

SecurityAnalysisParameters securityAnalysisParameters = new SecurityAnalysisParameters();
securityAnalysisParameters.getLoadFlowParameters().setDc(true).setHvdcAcEmulation(true);
OpenSecurityAnalysisParameters openSecurityAnalysisParameters = new OpenSecurityAnalysisParameters();
openSecurityAnalysisParameters.setDcFastMode(dcFastMode);
securityAnalysisParameters.addExtension(OpenSecurityAnalysisParameters.class, openSecurityAnalysisParameters);

List<StateMonitor> monitors = createAllBranchesMonitors(network);
List<Contingency> contingencies = List.of(new Contingency("hvdc34+g1", List.of(new HvdcLineContingency("hvdc34"), new GeneratorContingency("g1"))));
SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, monitors, securityAnalysisParameters);

// apply contingency by hand
network.getHvdcLine("hvdc34").remove();
network.getGenerator("g1").disconnect();
// run load flow to compare results
loadFlowRunner.run(network, securityAnalysisParameters.getLoadFlowParameters());

// post-contingency tests
PostContingencyResult postContingencyResult = getPostContingencyResult(result, "hvdc34+g1");
assertEquals(network.getLine("l12").getTerminal1().getP(), postContingencyResult.getNetworkResult().getBranchResult("l12").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(network.getLine("l13").getTerminal1().getP(), postContingencyResult.getNetworkResult().getBranchResult("l13").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(network.getLine("l23").getTerminal1().getP(), postContingencyResult.getNetworkResult().getBranchResult("l23").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(network.getLine("l25").getTerminal1().getP(), postContingencyResult.getNetworkResult().getBranchResult("l25").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(network.getLine("l45").getTerminal1().getP(), postContingencyResult.getNetworkResult().getBranchResult("l45").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(network.getLine("l46").getTerminal1().getP(), postContingencyResult.getNetworkResult().getBranchResult("l46").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(network.getLine("l56").getTerminal1().getP(), postContingencyResult.getNetworkResult().getBranchResult("l56").getP1(), LoadFlowAssert.DELTA_POWER);
}

@ParameterizedTest
@ValueSource(booleans = {false, true})
void testDcSaHvdcLineInAcEmulationContingency(boolean dcFastMode) {
Network network = HvdcNetworkFactory.createHvdcInAcEmulationInSymetricNetwork();
network.newLine()
.setId("l12_2")
.setBus1("b1")
.setConnectableBus1("b1")
.setBus2("b2")
.setConnectableBus2("b2")
.setR(0)
.setX(0.2f)
.add();

SecurityAnalysisParameters securityAnalysisParameters = new SecurityAnalysisParameters();
securityAnalysisParameters.getLoadFlowParameters().setDc(true).setHvdcAcEmulation(true);
OpenSecurityAnalysisParameters openSecurityAnalysisParameters = new OpenSecurityAnalysisParameters();
openSecurityAnalysisParameters.setDcFastMode(dcFastMode);
securityAnalysisParameters.addExtension(OpenSecurityAnalysisParameters.class, openSecurityAnalysisParameters);

List<StateMonitor> monitors = createAllBranchesMonitors(network);
List<Contingency> contingencies = List.of(Contingency.hvdcLine("hvdc12"));
SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, monitors, securityAnalysisParameters);

// apply contingency by hand
network.getHvdcLine("hvdc12").remove();
// run load flow to compare results
loadFlowRunner.run(network, securityAnalysisParameters.getLoadFlowParameters());

// post-contingency tests
PostContingencyResult hvdcContingencyResult = getPostContingencyResult(result, "hvdc12");
assertEquals(network.getLine("l12").getTerminal1().getP(), hvdcContingencyResult.getNetworkResult().getBranchResult("l12").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(network.getLine("l12").getTerminal2().getP(), hvdcContingencyResult.getNetworkResult().getBranchResult("l12").getP2(), LoadFlowAssert.DELTA_POWER);
assertEquals(network.getLine("l12_2").getTerminal1().getP(), hvdcContingencyResult.getNetworkResult().getBranchResult("l12_2").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(network.getLine("l12_2").getTerminal2().getP(), hvdcContingencyResult.getNetworkResult().getBranchResult("l12_2").getP2(), LoadFlowAssert.DELTA_POWER);
}
}
Loading