Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
173 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
eurostag-ech-export/src/test/java/eu/itesla_project/iidm/eurostag/export/EchUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright (c) 2018, 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.eurostag.export; | ||
|
||
import com.google.common.collect.Lists; | ||
import com.google.common.jimfs.Configuration; | ||
import com.google.common.jimfs.Jimfs; | ||
import com.powsybl.commons.config.InMemoryPlatformConfig; | ||
import com.powsybl.commons.config.MapModuleConfig; | ||
import com.powsybl.iidm.network.Network; | ||
import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; | ||
import com.powsybl.iidm.network.test.HvdcTestNetwork; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.nio.file.FileSystem; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
|
||
/** | ||
* @author Christian Biasuzzi <christian.biasuzzi@techrain.it> | ||
*/ | ||
public class EchUtilsTest { | ||
|
||
|
||
private final float delta = 0.0f; | ||
private Network network; | ||
private Network networkHvdc; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
network = EurostagTutorialExample1Factory.create(); | ||
networkHvdc = HvdcTestNetwork.createVsc(); | ||
} | ||
|
||
private EurostagEchExportConfig getConfig(boolean noSwitch, boolean exportMainCCOnly) { | ||
FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix()); | ||
InMemoryPlatformConfig platformConfig = new InMemoryPlatformConfig(fileSystem); | ||
MapModuleConfig moduleConfig = platformConfig.createModuleConfig("eurostag-ech-export"); | ||
moduleConfig.setStringProperty("noSwitch", Boolean.toString(noSwitch)); | ||
moduleConfig.setStringProperty("exportMainCCOnly", Boolean.toString(exportMainCCOnly)); | ||
return EurostagEchExportConfig.load(platformConfig); | ||
} | ||
|
||
private EurostagEchExportConfig getConfig(boolean noSwitch) { | ||
return getConfig(noSwitch, false); | ||
} | ||
|
||
@Test | ||
public void testGetHvdcLineDcVoltage() { | ||
networkHvdc.getHvdcLineStream().forEach(line -> assertEquals(line.getNominalV() * 2.0f, EchUtil.getHvdcLineDcVoltage(line), delta)); | ||
} | ||
|
||
@Test | ||
public void testGetHvdcLineDcVoltageNull() { | ||
try { | ||
EchUtil.getHvdcLineDcVoltage(null); | ||
fail("Expected not null parameter"); | ||
} catch (NullPointerException e) { | ||
} | ||
|
||
} | ||
|
||
@Test | ||
public void testIsImMainCcBus() { | ||
Lists.newArrayList(true, false).stream().forEach(exportMainCCOnly -> { | ||
EchUtil.getBuses(networkHvdc, getConfig(false, exportMainCCOnly)).forEach(bus -> { | ||
assertEquals(EchUtil.isInMainCc(bus), true); | ||
}); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testIsImMainCcGen() { | ||
Lists.newArrayList(true, false).stream().forEach(exportMainCCOnly -> { | ||
network.getGeneratorStream().forEach(gen -> { | ||
assertEquals(EchUtil.isInMainCc(gen, exportMainCCOnly), true); | ||
}); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testIsImMainCcLine() { | ||
Lists.newArrayList(true, false).stream().forEach(exportMainCCOnly -> { | ||
network.getLines().forEach(line -> { | ||
assertEquals(EchUtil.isInMainCc(line, exportMainCCOnly), true); | ||
}); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
eurostag-ech-export/src/test/resources/eurostag-hvdc-test.ech
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
HEADER 01/01/16 5.1 | ||
|
||
B | ||
|
||
9 1 0 0 1 1 20 0.005 4 100. 1 1 | ||
|
||
SP INPVPQ 2 | ||
SP THMAX 0.100000 | ||
SP EMAXF 0.100000 | ||
SP ZMIN 0.000200 | ||
SP RAMIN 0.800000 | ||
SP RAMAX 1.200000 | ||
SP TOLPLO 0.001000 | ||
|
||
GC hvdctest/InitialState | ||
|
||
AA FA | ||
AA FR | ||
DA DC | ||
|
||
1FAFAKENOD1 380. 1. 0. 0. 0. | ||
1FAFAKENOD2 380. 1. 0. 0. 0. | ||
1FRB1 400. 1. 0. 0. 0. | ||
5 B1 0. | ||
1FRVL2_0 400. 1. 0. 0. 0. | ||
1FRVL2_1 400. 1. 0. 0. 0. | ||
|
||
6 VL2_0 VL2_1 1 0. 0. | ||
|
||
G G1 Y B1 50. 100. 150. -2147483 21474836 V 400. B1 1. 0. 0. | ||
|
||
DC N DC_C1 DC 800. 1. | ||
DC N DC_C2 DC 800. 1. | ||
|
||
DC L DC_C1 DC_C2 1 1. | ||
|
||
DC V C1 DC_C1 GROUND B1 P Q 0. 16. 280. 800. -50. 1. | ||
DC V -300. 300. 0. 10. 0. 0. 0. | ||
DC V C2 DC_C2 GROUND VL2_1 V Q 0. 16. -280. 800. 123. 1. | ||
DC V -300. 300. 0. 10. 0. 0. 0. | ||
|