Skip to content

Commit

Permalink
align ipst to powsybl v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CBiasuzzi authored and sylvlecl committed Nov 2, 2018
1 parent f366f0e commit 075d9bf
Show file tree
Hide file tree
Showing 83 changed files with 931 additions and 920 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ protected static void reintegrateLfState(Network network, String workingStateId,
for (Generator g : network.getGenerators()) {
Terminal t = g.getTerminal();
if (!onlyVoltage) {
if (!Float.isNaN(t.getP())) {
float oldTargetP = g.getTargetP();
float newTargetP = -t.getP();
if (!Double.isNaN(t.getP())) {
double oldTargetP = g.getTargetP();
double newTargetP = -t.getP();
if (oldTargetP != newTargetP) {
g.setTargetP(newTargetP);
LOGGER.debug("LF result reintegration: targetP {} -> {}", oldTargetP, newTargetP);
}
}
if (!Float.isNaN(t.getQ())) {
float oldTargetQ = g.getTargetQ();
float newTargetQ = -t.getQ();
if (!Double.isNaN(t.getQ())) {
double oldTargetQ = g.getTargetQ();
double newTargetQ = -t.getQ();
if (oldTargetQ != newTargetQ) {
g.setTargetQ(newTargetQ);
LOGGER.debug("LF result reintegration: targetQ {} -> {}", oldTargetQ, newTargetQ);
Expand All @@ -187,9 +187,9 @@ protected static void reintegrateLfState(Network network, String workingStateId,
}
Bus b = t.getBusView().getBus();
if (b != null) {
if (!Float.isNaN(b.getV())) {
float oldV = g.getTargetV();
float newV = b.getV();
if (!Double.isNaN(b.getV())) {
double oldV = g.getTargetV();
double newV = b.getV();
if (oldV != newV) {
g.setTargetV(newV);
LOGGER.debug("LF result reintegration: targetV {} -> {}", oldV, newV);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;

import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -94,6 +95,11 @@ public InputStream newInputStream(String suffix, String ext) throws IOException
public InputStream newInputStream(String fileName) throws IOException {
throw new UnsupportedOperationException();
}

@Override
public Set<String> listNames(String s) throws IOException {
throw new UnsupportedOperationException();
}
}

private static void createFile(Path dir, String fileName) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -95,6 +96,11 @@ public InputStream newInputStream(String suffix, String ext) throws IOException
public InputStream newInputStream(String fileName) throws IOException {
throw new UnsupportedOperationException();
}

@Override
public Set<String> listNames(String s) throws IOException {
throw new UnsupportedOperationException();
}
}

private static void createFile(Path dir, String fileName) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ public static boolean isInMainCc(Branch branch, boolean noswitch) {
* Multiplying the line's nominalV by 2 corresponds to the fact that iIDM refers to the cable-ground voltage
* while Eurostag regulations to the cable-cable voltage
*/
public static float getHvdcLineDcVoltage(HvdcLine line) {
public static double getHvdcLineDcVoltage(HvdcLine line) {
Objects.requireNonNull(line);
return line.getNominalV() * 2.0f;
return line.getNominalV() * 2;
}

public static boolean isPMode(HvdcConverterStation vscConv, HvdcLine hvdcLine) {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ public void testHVDC() throws IOException {
.setConnectableBus("B1")
.setBus("B1")
.setVoltageRegulatorOn(true)
.setTargetP(100.0F)
.setTargetV(400.0F)
.setMinP(50.0F)
.setMaxP(150.0F)
.setTargetP(100.0)
.setTargetV(400.0)
.setMinP(50.0)
.setMaxP(150.0)
.add();
EsgSpecialParameters specialParameters = new EsgSpecialParameters();
test(network, "/eurostag-hvdc-test.ech", LocalDate.parse("2016-01-01"), specialParameters);
}

private void addLine(Network network, VoltageLevel vlhv1, VoltageLevel vlhv2, String idLine, float g1, float g2, float b1, float b2) {
private void addLine(Network network, VoltageLevel vlhv1, VoltageLevel vlhv2, String idLine, double g1, double g2, double b1, double b2) {
Bus nhv1 = vlhv1.getBusBreakerView().newBus()
.setId("N1" + idLine)
.add();
Expand Down Expand Up @@ -117,19 +117,19 @@ public void testLines() throws IOException {
.setTopologyKind(TopologyKind.BUS_BREAKER)
.add();

float bTest1 = EurostagEchExport.B_EPSILON * 2f;
double bTest1 = EurostagEchExport.B_EPSILON * 2;

//G and B are the same on each side, G are 0
addLine(network, vlhv1, vlhv2, "L1", 0f, 0f, 0f, 0f);
addLine(network, vlhv1, vlhv2, "L2", 0f, 0f, bTest1, bTest1);
addLine(network, vlhv1, vlhv2, "L1", 0, 0, 0, 0);
addLine(network, vlhv1, vlhv2, "L2", 0, 0, bTest1, bTest1);
//B are not the same, G are 0
addLine(network, vlhv1, vlhv2, "L3", 0f, 0f, bTest1, 0); // dummy shunt expected in the .ech
addLine(network, vlhv1, vlhv2, "L4", 0f, 0f, 0, bTest1); // dummy shunt expected in the .ech
addLine(network, vlhv1, vlhv2, "L5", 0f, 0f, EurostagEchExport.B_EPSILON / 2f, 0);
addLine(network, vlhv1, vlhv2, "L6", 0f, 0f, 0, EurostagEchExport.B_EPSILON / 2f);
addLine(network, vlhv1, vlhv2, "L3", 0, 0, bTest1, 0); // dummy shunt expected in the .ech
addLine(network, vlhv1, vlhv2, "L4", 0, 0, 0, bTest1); // dummy shunt expected in the .ech
addLine(network, vlhv1, vlhv2, "L5", 0, 0, EurostagEchExport.B_EPSILON / 2, 0);
addLine(network, vlhv1, vlhv2, "L6", 0, 0, 0, EurostagEchExport.B_EPSILON / 2);
//B are not the same, G are not 0
addLine(network, vlhv1, vlhv2, "L7", 1f, 0f, bTest1, 0);
addLine(network, vlhv1, vlhv2, "L8", 0f, 1f, bTest1, 0);
addLine(network, vlhv1, vlhv2, "L7", 1, 0, bTest1, 0);
addLine(network, vlhv1, vlhv2, "L8", 0, 1, bTest1, 0);

EsgSpecialParameters specialParameters = new EsgSpecialParameters();
test(network, "/eurostag-tutorial-example1_lines.ech", LocalDate.parse("2016-03-01"), specialParameters);
Expand All @@ -149,12 +149,12 @@ public void testCptRpt() throws IOException {
.setRegulationMode(PhaseTapChanger.RegulationMode.FIXED_TAP)
.setRegulationValue(200)
.beginStep()
.setAlpha(-20f)
.setRho(0.96f)
.setR(0f)
.setX(0f)
.setG(0f)
.setB(0f)
.setAlpha(-20)
.setRho(0.96)
.setR(0)
.setX(0)
.setG(0)
.setB(0)
.endStep()
.add();

Expand All @@ -169,7 +169,7 @@ public void testVoltageRegulationException() throws IOException {
//voltage regulator exception: if specificCompatibility && (g.getTargetP() < 0.0001) && (g.getMinP() > 0.0001)
// turn off g's voltage regulation
Generator g = network.getGenerator("GEN");
g.setMinP(300f);
g.setMinP(300);
g.setTargetP(0);

EsgSpecialParameters specialParameters = new EsgSpecialParameters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ CH L2 Y B2 0. 0. 100. 0. 0. 50.

G G1 Y B1 50. 100. 150. -2147483 21474836 V 400. B1 1. 0. 0.

SV SVC2 Y B2 28.87999 115.5199 V 390. 1. 0. 0.
SV SVC2 Y B2 28.88 115.52 V 390. 1. 0. 0.

Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ AA FR
48 1 22.8 380. 0.769231 0.
48NHV2 NLOAD 1 100. 0.021 0. 0. 1. 0. 0.
48 2 2 NLOAD 158. V
48 1 465.066 150. 1.8 0.
48 2 395.3061 150. 1.8 0.
48 1 465.0659 150. 1.8 0.
48 2 395.306 150. 1.8 0.
48 3 343.7444 150. 1.8 0.

CH LOAD Y NLOAD 0. 0. 600. 0. 0. 200. 0. 0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,16 @@ private static void dumpLimits(EurostagDictionary dictionary, BufferedWriter wri
}

private static void dumpLimits(EurostagDictionary dictionary, BufferedWriter writer, String branchId, CurrentLimits cl1, CurrentLimits cl2,
float nominalV1, float nominalV2) throws IOException {
double nominalV1, double nominalV2) throws IOException {
writer.write(dictionary.getEsgId(branchId));
writer.write(";");
writer.write(Float.toString(cl1 != null ? cl1.getPermanentLimit() : Float.MAX_VALUE));
writer.write(Double.toString(cl1 != null ? cl1.getPermanentLimit() : Double.MAX_VALUE));
writer.write(";");
writer.write(Float.toString(cl2 != null ? cl2.getPermanentLimit() : Float.MAX_VALUE));
writer.write(Double.toString(cl2 != null ? cl2.getPermanentLimit() : Double.MAX_VALUE));
writer.write(";");
writer.write(Float.toString(nominalV1));
writer.write(Double.toString(nominalV1));
writer.write(";");
writer.write(Float.toString(nominalV2));
writer.write(Double.toString(nominalV2));
writer.write(";");
writer.write(branchId);
writer.newLine();
Expand Down Expand Up @@ -295,14 +295,14 @@ protected static void writeLimits(Network network, EurostagDictionary dictionary
continue;
}
VoltageLevel vl = b.getVoltageLevel();
if (!Float.isNaN(vl.getLowVoltageLimit()) && !Float.isNaN(vl.getHighVoltageLimit())) {
if (!Double.isNaN(vl.getLowVoltageLimit()) && !Double.isNaN(vl.getHighVoltageLimit())) {
writer.write(dictionary.getEsgId(b.getId()));
writer.write(";");
writer.write(Float.toString(vl.getLowVoltageLimit()));
writer.write(Double.toString(vl.getLowVoltageLimit()));
writer.write(";");
writer.write(Float.toString(vl.getHighVoltageLimit()));
writer.write(Double.toString(vl.getHighVoltageLimit()));
writer.write(";");
writer.write(Float.toString(vl.getNominalV()));
writer.write(Double.toString(vl.getNominalV()));
writer.newLine();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,27 @@ public void hvLoadModelling(EsgNetwork networkEch) {
EsgLoad esgLoad = networkEch.getLoad(load);
Esg8charName nodeName = esgLoad.getZnodlo();
Esg8charName loadName = esgLoad.getZnamlo();
float pi = esgLoad.getPldstp();
float qi = esgLoad.getQldstp();
double pi = esgLoad.getPldstp();
double qi = esgLoad.getQldstp();

// Tfo parameters
float rate = (float) Math.max(1.0F, 1.5 * Math.sqrt(new Float(pi * pi + qi * qi).doubleValue()));
float vBase = 20.0F;
float ucc = 1.0F;
float vB = 1.14F;
float vT = 0.86F;
float pcu = 0.0F;
float cmagn = 0.0F;
float pfer = 0.0F;
float esat = 1.0F;
float voltr = vBase;
double rate = Math.max(1.0, 1.5 * Math.sqrt(new Float(pi * pi + qi * qi).doubleValue()));
double vBase = 20.0;
double ucc = 1.0;
double vB = 1.14;
double vT = 0.86;
double pcu = 0.0;
double cmagn = 0.0;
double pfer = 0.0;
double esat = 1.0;
double voltr = vBase;
int firstPlot = 1;
int lastPlot = 15;

// Choose the right initial tap because the load flow doesn't do it
EsgNode esgNode = networkEch.getNode(nodeName.toString());
float vCurHV = esgNode.getVinit();
int ktap8 = Math.round(firstPlot + (lastPlot - firstPlot) / (vB - vT) * (vCurHV - vT));
double vCurHV = esgNode.getVinit();
int ktap8 = (int) Math.round(firstPlot + (lastPlot - firstPlot) / (vB - vT) * (vCurHV - vT));
ktap8 = Math.max(firstPlot, ktap8);
ktap8 = Math.min(lastPlot, ktap8);
int ktpnom = 8;
Expand All @@ -78,8 +78,8 @@ public void hvLoadModelling(EsgNetwork networkEch) {
float vInit = 1.015F;

// Load parameters
float pf = pi;
float qf = qi - ucc / 100 * (pi * pi + qi * qi) / rate * 1 / (vInit * vInit);
double pf = pi;
double qf = qi - ucc / 100 * (pi * pi + qi * qi) / rate * 1 / (vInit * vInit);

Esg8charName lvNodeName = new Esg8charName(loadName.toString().toUpperCase()); // Upper Case for Eurostag 5.1.1
networkEch.addNode(new EsgNode(esgNode.getArea(), lvNodeName, vBase, vInit, 0, false));
Expand Down
Loading

0 comments on commit 075d9bf

Please sign in to comment.