Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/contingenciesProviderMock' into …
Browse files Browse the repository at this point in the history
…contingenciesProviderMock
  • Loading branch information
mathbagu authored and mathbagu committed Oct 12, 2016
2 parents e7e088d + a6be099 commit 97c8705
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 6 deletions.
19 changes: 19 additions & 0 deletions ampl-export/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,24 @@
<artifactId>network-merge</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>eu.itesla_project</groupId>
<artifactId>iidm-network-test</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>eu.itesla_project</groupId>
<artifactId>iidm-network-impl</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ public TableFormatter writeHeader() throws IOException {
if (bodyOngoing) {
throw new IllegalArgumentException("Table body is ongoing, cannot insert a header");
}
writer.append("#").append(title).append("\n")
writer.append("#").append(title).append(System.lineSeparator())
.append("#");
for (int i = 0; i < columns.length; i++) {
writer.append("\"").append(columns[i].getName()).append("\" ");
writer.append("\"").append(columns[i].getName()).append("\"");
if (i < columns.length-1) {
writer.append(" ");
}
}
writer.append("\n");
writer.append(System.lineSeparator());
headerDone = true;
return this;
}
Expand All @@ -63,7 +66,7 @@ public TableFormatter writeComment(String comment) throws IOException {
}
writer.write("#");
writer.write(comment);
writer.write("\n");
writer.write(System.lineSeparator());
return this;
}

Expand All @@ -72,7 +75,7 @@ public TableFormatter newRow() throws IOException {
throw new IllegalStateException("The current row does not have enough column: "
+ column + ", required " + columns.length);
}
writer.write("\n");
writer.write(System.lineSeparator());
column = 0;
return this;
}
Expand All @@ -82,7 +85,10 @@ private TableFormatter write(String value) throws IOException {
throw new IllegalStateException("The current row has too many column: "
+ (column + 1) + ", required " + columns.length);
}
writer.append(value).append(" ");
writer.append(value);
if (column < columns.length-1) {
writer.append(" ");
}
column++;
bodyOngoing = true;
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright (c) 2016, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.iidm.export.ampl;

import com.google.common.io.CharStreams;
import eu.itesla_project.iidm.datasource.MemDataSource;
import eu.itesla_project.iidm.network.Network;
import eu.itesla_project.iidm.network.test.EurostagTutorialExample1Factory;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

import static org.junit.Assert.*;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class AmplNetworkWriterTest {

private void assertEqualsToRef(MemDataSource dataSource, String suffix, String refFileName) throws IOException {
assertEquals(new String(dataSource.getData(suffix, "txt"), StandardCharsets.UTF_8),
CharStreams.toString(new InputStreamReader(getClass().getResourceAsStream("/" + refFileName), StandardCharsets.UTF_8)));
}

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

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

assertEqualsToRef(dataSource, "_network_substations", "eurostag-tutorial-example1-substations.txt");
assertEqualsToRef(dataSource, "_network_buses", "eurostag-tutorial-example1-buses.txt");
assertEqualsToRef(dataSource, "_network_tct", "eurostag-tutorial-example1-tct.txt");
assertEqualsToRef(dataSource, "_network_rtc", "eurostag-tutorial-example1-rtc.txt");
assertEqualsToRef(dataSource, "_network_ptc", "eurostag-tutorial-example1-ptc.txt");
assertEqualsToRef(dataSource, "_network_loads", "eurostag-tutorial-example1-loads.txt");
assertEqualsToRef(dataSource, "_network_shunts", "eurostag-tutorial-example1-shunts.txt");
assertEqualsToRef(dataSource, "_network_generators", "eurostag-tutorial-example1-generators.txt");
assertEqualsToRef(dataSource, "_network_limits", "eurostag-tutorial-example1-limits.txt");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Branches (sim1/InitialState)
#"num" "bus1" "bus2" "3wt num" "sub.1" "sub.2" "r (pu)" "x (pu)" "g1 (pu)" "g2 (pu)" "b1 (pu)" "b2 (pu)" "cst ratio (pu)" "ratio tc" "phase tc" "p1 (MW)" "p2 (MW)" "q1 (MVar)" "q2 (MVar)" "patl1 (A)" "patl2 (A)" "merged" "fault" "curative" "id" "description"
1 2 3 -1 2 3 0.00207756 0.0228532 0.00000 0.00000 0.278692 0.278692 1.00000 -1 -1 -99999.0 -99999.0 -99999.0 -99999.0 -99999.0 -99999.0 false 0 0 "NHV1_NHV2_1" "NHV1_NHV2_1"
2 2 3 -1 2 3 0.00207756 0.0228532 0.00000 0.00000 0.278692 0.278692 1.00000 -1 -1 -99999.0 -99999.0 -99999.0 -99999.0 -99999.0 -99999.0 false 0 0 "NHV1_NHV2_2" "NHV1_NHV2_2"
3 1 2 -1 1 2 0.000184615 0.00769009 0.00000 0 0.00000 0 1.05263 -1 -1 -99999.0 -99999.0 -99999.0 -99999.0 -99999.0 -99999.0 false 0 0 "NGEN_NHV1" "NGEN_NHV1"
4 3 4 -1 3 4 0.000210000 0.0179988 0.00000 0 0.00000 0 1.00067 1 -1 -99999.0 -99999.0 -99999.0 -99999.0 -99999.0 -99999.0 false 0 0 "NHV2_NLOAD" "NHV2_NLOAD"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Buses (sim1/InitialState)
#"num" "substation" "cc" "v (pu)" "theta (rad)" "p (MW)" "q (MVar)" "fault" "curative"
1 1 0 -99999.0 -99999.0 0.00000 0.00000 0 0
2 2 0 -99999.0 -99999.0 0.00000 0.00000 0 0
3 3 0 -99999.0 -99999.0 0.00000 0.00000 0 0
4 4 0 -99999.0 -99999.0 0.00000 0.00000 0 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Generators (sim1/InitialState)
#"num" "bus" "con. bus" "substation" "minP (MW)" "maxP (MW)" "minQmaxP (MVar)" "minQminP (MVar)" "maxQmaxP (MVar)" "maxQminP (MVar)" "v regul." "targetV (pu)" "targetP (MW)" "targetQ (MVar)" "fault" "curative" "id" "description"
1 1 1 1 -9999.99 9999.99 -9999.99 -9999.99 9999.99 9999.99 true 1.02083 607.000 301.000 0 0 "GEN" "GEN"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Temporary current limits (sim1/InitialState)
#"num" "branch" "side" "limit (A)" "accept. duration (s)" "fault" "curative"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Loads (sim1/InitialState)
#"num" "bus" "substation" "p (MW)" "q (MVar)" "fault" "curative" "id" "description"
1 4 4 600.000 200.000 0 0 "LOAD" "LOAD"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Phase tap changers (sim1/InitialState)
#"num" "tap" "table" "fault" "curative" "id"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Ratio tap changers (sim1/InitialState)
#"num" "tap" "table" "onLoad" "fault" "curative" "id"
1 2 1 true 0 0 "NHV2_NLOAD"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Shunts (sim1/InitialState)
#"num" "bus" "con. bus" "substation" "minB (pu)" "maxB (pu)" "inter. points" "b (pu)" "fault" "curative" "id" "description"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Substations (sim1/InitialState)
#"num" "horizon" "reference date distance (minutes)" "nomV (KV)" "minV (pu)" "maxV (pu)" "fault" "curative" "country" "id" "description"
1 "SN" 0 24.0000 -99999.0 -99999.0 0 0 "FR" "VLGEN" "VLGEN"
2 "SN" 0 380.000 -99999.0 -99999.0 0 0 "FR" "VLHV1" "VLHV1"
3 "SN" 0 380.000 -99999.0 -99999.0 0 0 "FR" "VLHV2" "VLHV2"
4 "SN" 0 150.000 -99999.0 -99999.0 0 0 "FR" "VLLOAD" "VLLOAD"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Tap changer table (sim1/InitialState)
#"num" "tap" "var ratio" "x (pu)" "angle (rad)" "fault" "curative"
1 1 0.850567 0.0179988 0.00000 0 0
1 2 1.00067 0.0179988 0.00000 0 0
1 3 1.15077 0.0179988 0.00000 0 0

0 comments on commit 97c8705

Please sign in to comment.