Skip to content

Commit

Permalink
Add a dummy TXT export for HVDC and SVC
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Bague committed Jan 10, 2017
1 parent a2db412 commit 383d02d
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1201,14 +1201,20 @@ private void writeShunts(AmplExportContext context) throws IOException {

private void writeStaticVarCompensators(AmplExportContext context) throws IOException {
try (TableFormatter formatter = new AmplDatTableFormatter(
new OutputStreamWriter(dataSource.newOutputStream("_network_static_var_compensatiors", "txt", append), StandardCharsets.UTF_8),
new OutputStreamWriter(dataSource.newOutputStream("_network_static_var_compensators", "txt", append), StandardCharsets.UTF_8),
getTableTitle("Static VAR compensators"),
INVALID_FLOAT_VALUE,
!append,
LOCALE)) {
LOCALE,
new Column("num"),
new Column("id"))) {
List<String> skipped = new ArrayList<>();
for (StaticVarCompensator svc : network.getStaticVarCompensators()) {
throw new UnsupportedOperationException(); // FIXME
// FIXME
String id = svc.getId();
int num = mapper.getInt(AmplSubset.STATIC_VAR_COMPENSATOR, id);
formatter.writeCell(num)
.writeCell(id);
}
if (skipped.size() > 0) {
LOGGER.trace("Skip static VAR compensators {} because not connected and not connectable", skipped);
Expand Down Expand Up @@ -1390,10 +1396,16 @@ private void writeHVDCLines(AmplExportContext context) throws IOException {
getTableTitle("HVDC lines"),
INVALID_FLOAT_VALUE,
!append,
LOCALE)) {
LOCALE,
new Column("num"),
new Column("id"))) {
List<String> skipped = new ArrayList<>();
for (HvdcLine hvdcLine : network.getHvdcLines()) {
throw new UnsupportedOperationException(); // FIXME
// FIXME
String id = hvdcLine.getId();
int num = mapper.getInt(AmplSubset.HVDC_LINE, id);
formatter.writeCell(num)
.writeCell(id);
}
if (skipped.size() > 0) {
LOGGER.trace("Skip HVDC lines {} because not connected and not connectable", skipped);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import eu.itesla_project.commons.util.IntCounter;

/**
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public enum AmplSubset implements IntCounter {
Expand All @@ -28,11 +27,13 @@ public enum AmplSubset implements IntCounter {
THREE_WINDINGS_TRANSFO(1),
FAULT(1),
CURATIVE_ACTION(1),
PREVENTIVE_ACTION(1);
PREVENTIVE_ACTION(1),
STATIC_VAR_COMPENSATOR(1),
HVDC_LINE(1);

private final int initialValue;

private AmplSubset(int initialValue) {
AmplSubset(int initialValue) {
this.initialValue = initialValue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ public static void fillMapper(StringToIntMapper<AmplSubset> mapper, Network netw
mapper.newInt(AmplSubset.GENERATOR, g.getId());
}

// static var compensators
network.getStaticVarCompensatorStream().forEach(svc -> mapper.newInt(AmplSubset.STATIC_VAR_COMPENSATOR, svc.getId()));

// HVDC lines
network.getHvdcLineStream().forEach(hvdc -> mapper.newInt(AmplSubset.HVDC_LINE, hvdc.getId()));

// limits
for (Line l : network.getLines()) {
if (l.getCurrentLimits1() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import eu.itesla_project.iidm.datasource.MemDataSource;
import eu.itesla_project.iidm.network.Network;
import eu.itesla_project.iidm.network.test.EurostagTutorialExample1Factory;
import eu.itesla_project.iidm.network.test.HvdcTestNetwork;
import eu.itesla_project.iidm.network.test.SvcTestCaseFactory;
import org.junit.Test;

import java.io.IOException;
Expand All @@ -29,7 +31,7 @@ private void assertEqualsToRef(MemDataSource dataSource, String suffix, String r
}

@Test
public void write() throws Exception {
public void writeEurostag() throws Exception {
Network network = EurostagTutorialExample1Factory.create();

MemDataSource dataSource = new MemDataSource();
Expand All @@ -47,4 +49,36 @@ public void write() throws Exception {
assertEqualsToRef(dataSource, "_network_limits", "eurostag-tutorial-example1-limits.txt");
}

@Test
public void writeSVC() throws Exception {
Network network = SvcTestCaseFactory.create();

MemDataSource dataSource = new MemDataSource();
new AmplNetworkWriter(network, dataSource, new AmplExportConfig(AmplExportConfig.ExportScope.ALL, true, AmplExportConfig.ExportActionType.CURATIVE))
.write();

assertEqualsToRef(dataSource, "_network_static_var_compensators", "svc-test-case.txt");
}

@Test
public void writeLcc() throws Exception {
Network network = HvdcTestNetwork.createLcc();

MemDataSource dataSource = new MemDataSource();
new AmplNetworkWriter(network, dataSource, new AmplExportConfig(AmplExportConfig.ExportScope.ALL, true, AmplExportConfig.ExportActionType.CURATIVE))
.write();

assertEqualsToRef(dataSource, "_network_hvdc", "lcc-test-case.txt");
}

@Test
public void writeVsc() throws Exception {
Network network = HvdcTestNetwork.createVsc();

MemDataSource dataSource = new MemDataSource();
new AmplNetworkWriter(network, dataSource, new AmplExportConfig(AmplExportConfig.ExportScope.ALL, true, AmplExportConfig.ExportActionType.CURATIVE))
.write();

assertEqualsToRef(dataSource, "_network_hvdc", "vsc-test-case.txt");
}
}
3 changes: 3 additions & 0 deletions ampl-export/src/test/resources/lcc-test-case.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#HVDC lines (hvdctest/InitialState)
#"num" "id"
1 "L"
3 changes: 3 additions & 0 deletions ampl-export/src/test/resources/svc-test-case.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Static VAR compensators (svcTestCase/InitialState)
#"num" "id"
1 "SVC2"
3 changes: 3 additions & 0 deletions ampl-export/src/test/resources/vsc-test-case.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#HVDC lines (hvdctest/InitialState)
#"num" "id"
1 "L"

0 comments on commit 383d02d

Please sign in to comment.