@Test public void writeDanglingLines() throws IOException { Network network = DanglingLineNetworkFactory.create(); MemDataSource dataSource = new MemDataSource(); export(network, dataSource); assertEqualsToRef(dataSource, "_network_branches", "inputs/dangling-line-branches.txt"); assertEqualsToRef(dataSource, "_network_buses", "inputs/dangling-line-buses.txt"); assertEqualsToRef(dataSource, "_network_limits", "inputs/dangling-line-limits.txt"); assertEqualsToRef(dataSource, "_network_loads", "inputs/dangling-line-loads.txt"); assertEqualsToRef(dataSource, "_network_substations", "inputs/dangling-line-substations.txt"); }
private void writeDanglingLines(AmplExportContext context, TableFormatter formatter) throws IOException { for (DanglingLine dl : network.getDanglingLines()) { Terminal t = dl.getTerminal(); Bus bus1 = AmplUtil.getBus(t); String bus1Id = getBusId(bus1); int bus1Num = getBusNum(bus1); String middleBusId = getDanglingLineMiddleBusId(dl); int middleBusNum = mapper.getInt(AmplSubset.BUS, middleBusId); if (isOnlyMainCc() && !(isBusExported(context, bus1Id) || isBusExported(context, middleBusId))) { continue; } VoltageLevel vl = t.getVoltageLevel(); String middleVlId = getDanglingLineMiddleVoltageLevelId(dl); context.voltageLevelIdsToExport.add(vl.getId()); context.voltageLevelIdsToExport.add(middleVlId); String id = dl.getId(); int num = mapper.getInt(AmplSubset.BRANCH, id); int vl1Num = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, vl.getId()); int middleVlNum = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, middleVlId); double vb = vl.getNominalV(); double zb = vb * vb / AmplConstants.SB; double p1 = t.getP(); double q1 = t.getQ(); SV sv = new SV(p1, q1, bus1 != null ? bus1.getV() : Double.NaN, bus1 != null ? bus1.getAngle() : Double.NaN).otherSide(dl); double p2 = sv.getP(); double q2 = sv.getQ(); double patl = getPermanentLimit(dl.getCurrentLimits()); formatter.writeCell(variantIndex) .writeCell(num) .writeCell(bus1Num) .writeCell(middleBusNum) .writeCell(-1) .writeCell(vl1Num) .writeCell(middleVlNum) .writeCell(dl.getR() / zb) .writeCell(dl.getX() / zb) .writeCell(dl.getG() / 2 * zb) .writeCell(dl.getG() / 2 * zb) .writeCell(dl.getB() / 2 * zb) .writeCell(dl.getB() / 2 * zb) .writeCell(1f) .writeCell(-1) .writeCell(-1) .writeCell(p1) .writeCell(p2) .writeCell(q1) .writeCell(q2) .writeCell(patl) .writeCell(patl) .writeCell(false) .writeCell(faultNum) .writeCell(actionNum) .writeCell(id) .writeCell(dl.getNameOrId()); addExtensions(num, dl); } }
AmplNetworkWriter { private void writeDanglingLines(AmplExportContext context, TableFormatter formatter) throws IOException { for (DanglingLine dl : network.getDanglingLines()) { Terminal t = dl.getTerminal(); Bus bus1 = AmplUtil.getBus(t); String bus1Id = getBusId(bus1); int bus1Num = getBusNum(bus1); String middleBusId = getDanglingLineMiddleBusId(dl); int middleBusNum = mapper.getInt(AmplSubset.BUS, middleBusId); if (isOnlyMainCc() && !(isBusExported(context, bus1Id) || isBusExported(context, middleBusId))) { continue; } VoltageLevel vl = t.getVoltageLevel(); String middleVlId = getDanglingLineMiddleVoltageLevelId(dl); context.voltageLevelIdsToExport.add(vl.getId()); context.voltageLevelIdsToExport.add(middleVlId); String id = dl.getId(); int num = mapper.getInt(AmplSubset.BRANCH, id); int vl1Num = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, vl.getId()); int middleVlNum = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, middleVlId); double vb = vl.getNominalV(); double zb = vb * vb / AmplConstants.SB; double p1 = t.getP(); double q1 = t.getQ(); SV sv = new SV(p1, q1, bus1 != null ? bus1.getV() : Double.NaN, bus1 != null ? bus1.getAngle() : Double.NaN).otherSide(dl); double p2 = sv.getP(); double q2 = sv.getQ(); double patl = getPermanentLimit(dl.getCurrentLimits()); formatter.writeCell(variantIndex) .writeCell(num) .writeCell(bus1Num) .writeCell(middleBusNum) .writeCell(-1) .writeCell(vl1Num) .writeCell(middleVlNum) .writeCell(dl.getR() / zb) .writeCell(dl.getX() / zb) .writeCell(dl.getG() / 2 * zb) .writeCell(dl.getG() / 2 * zb) .writeCell(dl.getB() / 2 * zb) .writeCell(dl.getB() / 2 * zb) .writeCell(1f) .writeCell(-1) .writeCell(-1) .writeCell(p1) .writeCell(p2) .writeCell(q1) .writeCell(q2) .writeCell(patl) .writeCell(patl) .writeCell(false) .writeCell(faultNum) .writeCell(actionNum) .writeCell(id) .writeCell(dl.getNameOrId()); addExtensions(num, dl); } } }
AmplNetworkWriter { private void writeDanglingLines(AmplExportContext context, TableFormatter formatter) throws IOException { for (DanglingLine dl : network.getDanglingLines()) { Terminal t = dl.getTerminal(); Bus bus1 = AmplUtil.getBus(t); String bus1Id = getBusId(bus1); int bus1Num = getBusNum(bus1); String middleBusId = getDanglingLineMiddleBusId(dl); int middleBusNum = mapper.getInt(AmplSubset.BUS, middleBusId); if (isOnlyMainCc() && !(isBusExported(context, bus1Id) || isBusExported(context, middleBusId))) { continue; } VoltageLevel vl = t.getVoltageLevel(); String middleVlId = getDanglingLineMiddleVoltageLevelId(dl); context.voltageLevelIdsToExport.add(vl.getId()); context.voltageLevelIdsToExport.add(middleVlId); String id = dl.getId(); int num = mapper.getInt(AmplSubset.BRANCH, id); int vl1Num = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, vl.getId()); int middleVlNum = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, middleVlId); double vb = vl.getNominalV(); double zb = vb * vb / AmplConstants.SB; double p1 = t.getP(); double q1 = t.getQ(); SV sv = new SV(p1, q1, bus1 != null ? bus1.getV() : Double.NaN, bus1 != null ? bus1.getAngle() : Double.NaN).otherSide(dl); double p2 = sv.getP(); double q2 = sv.getQ(); double patl = getPermanentLimit(dl.getCurrentLimits()); formatter.writeCell(variantIndex) .writeCell(num) .writeCell(bus1Num) .writeCell(middleBusNum) .writeCell(-1) .writeCell(vl1Num) .writeCell(middleVlNum) .writeCell(dl.getR() / zb) .writeCell(dl.getX() / zb) .writeCell(dl.getG() / 2 * zb) .writeCell(dl.getG() / 2 * zb) .writeCell(dl.getB() / 2 * zb) .writeCell(dl.getB() / 2 * zb) .writeCell(1f) .writeCell(-1) .writeCell(-1) .writeCell(p1) .writeCell(p2) .writeCell(q1) .writeCell(q2) .writeCell(patl) .writeCell(patl) .writeCell(false) .writeCell(faultNum) .writeCell(actionNum) .writeCell(id) .writeCell(dl.getNameOrId()); addExtensions(num, dl); } } AmplNetworkWriter(Network network, int variantIndex, DataSource dataSource, int faultNum, int actionNum,
                             boolean append, StringToIntMapper<AmplSubset> mapper, AmplExportConfig config);  AmplNetworkWriter(Network network, DataSource dataSource, int faultNum, int actionNum,
                             boolean append, StringToIntMapper<AmplSubset> mapper, AmplExportConfig config);  AmplNetworkWriter(Network network, DataSource dataSource, StringToIntMapper<AmplSubset> mapper,
                             AmplExportConfig config);  AmplNetworkWriter(Network network, DataSource dataSource, AmplExportConfig config); }
AmplNetworkWriter { private void writeDanglingLines(AmplExportContext context, TableFormatter formatter) throws IOException { for (DanglingLine dl : network.getDanglingLines()) { Terminal t = dl.getTerminal(); Bus bus1 = AmplUtil.getBus(t); String bus1Id = getBusId(bus1); int bus1Num = getBusNum(bus1); String middleBusId = getDanglingLineMiddleBusId(dl); int middleBusNum = mapper.getInt(AmplSubset.BUS, middleBusId); if (isOnlyMainCc() && !(isBusExported(context, bus1Id) || isBusExported(context, middleBusId))) { continue; } VoltageLevel vl = t.getVoltageLevel(); String middleVlId = getDanglingLineMiddleVoltageLevelId(dl); context.voltageLevelIdsToExport.add(vl.getId()); context.voltageLevelIdsToExport.add(middleVlId); String id = dl.getId(); int num = mapper.getInt(AmplSubset.BRANCH, id); int vl1Num = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, vl.getId()); int middleVlNum = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, middleVlId); double vb = vl.getNominalV(); double zb = vb * vb / AmplConstants.SB; double p1 = t.getP(); double q1 = t.getQ(); SV sv = new SV(p1, q1, bus1 != null ? bus1.getV() : Double.NaN, bus1 != null ? bus1.getAngle() : Double.NaN).otherSide(dl); double p2 = sv.getP(); double q2 = sv.getQ(); double patl = getPermanentLimit(dl.getCurrentLimits()); formatter.writeCell(variantIndex) .writeCell(num) .writeCell(bus1Num) .writeCell(middleBusNum) .writeCell(-1) .writeCell(vl1Num) .writeCell(middleVlNum) .writeCell(dl.getR() / zb) .writeCell(dl.getX() / zb) .writeCell(dl.getG() / 2 * zb) .writeCell(dl.getG() / 2 * zb) .writeCell(dl.getB() / 2 * zb) .writeCell(dl.getB() / 2 * zb) .writeCell(1f) .writeCell(-1) .writeCell(-1) .writeCell(p1) .writeCell(p2) .writeCell(q1) .writeCell(q2) .writeCell(patl) .writeCell(patl) .writeCell(false) .writeCell(faultNum) .writeCell(actionNum) .writeCell(id) .writeCell(dl.getNameOrId()); addExtensions(num, dl); } } AmplNetworkWriter(Network network, int variantIndex, DataSource dataSource, int faultNum, int actionNum,
                             boolean append, StringToIntMapper<AmplSubset> mapper, AmplExportConfig config);  AmplNetworkWriter(Network network, DataSource dataSource, int faultNum, int actionNum,
                             boolean append, StringToIntMapper<AmplSubset> mapper, AmplExportConfig config);  AmplNetworkWriter(Network network, DataSource dataSource, StringToIntMapper<AmplSubset> mapper,
                             AmplExportConfig config);  AmplNetworkWriter(Network network, DataSource dataSource, AmplExportConfig config); static String getTableTitle(Network network, String tableName); void write(); void write(AmplExportContext context); }
AmplNetworkWriter { private void writeDanglingLines(AmplExportContext context, TableFormatter formatter) throws IOException { for (DanglingLine dl : network.getDanglingLines()) { Terminal t = dl.getTerminal(); Bus bus1 = AmplUtil.getBus(t); String bus1Id = getBusId(bus1); int bus1Num = getBusNum(bus1); String middleBusId = getDanglingLineMiddleBusId(dl); int middleBusNum = mapper.getInt(AmplSubset.BUS, middleBusId); if (isOnlyMainCc() && !(isBusExported(context, bus1Id) || isBusExported(context, middleBusId))) { continue; } VoltageLevel vl = t.getVoltageLevel(); String middleVlId = getDanglingLineMiddleVoltageLevelId(dl); context.voltageLevelIdsToExport.add(vl.getId()); context.voltageLevelIdsToExport.add(middleVlId); String id = dl.getId(); int num = mapper.getInt(AmplSubset.BRANCH, id); int vl1Num = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, vl.getId()); int middleVlNum = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, middleVlId); double vb = vl.getNominalV(); double zb = vb * vb / AmplConstants.SB; double p1 = t.getP(); double q1 = t.getQ(); SV sv = new SV(p1, q1, bus1 != null ? bus1.getV() : Double.NaN, bus1 != null ? bus1.getAngle() : Double.NaN).otherSide(dl); double p2 = sv.getP(); double q2 = sv.getQ(); double patl = getPermanentLimit(dl.getCurrentLimits()); formatter.writeCell(variantIndex) .writeCell(num) .writeCell(bus1Num) .writeCell(middleBusNum) .writeCell(-1) .writeCell(vl1Num) .writeCell(middleVlNum) .writeCell(dl.getR() / zb) .writeCell(dl.getX() / zb) .writeCell(dl.getG() / 2 * zb) .writeCell(dl.getG() / 2 * zb) .writeCell(dl.getB() / 2 * zb) .writeCell(dl.getB() / 2 * zb) .writeCell(1f) .writeCell(-1) .writeCell(-1) .writeCell(p1) .writeCell(p2) .writeCell(q1) .writeCell(q2) .writeCell(patl) .writeCell(patl) .writeCell(false) .writeCell(faultNum) .writeCell(actionNum) .writeCell(id) .writeCell(dl.getNameOrId()); addExtensions(num, dl); } } AmplNetworkWriter(Network network, int variantIndex, DataSource dataSource, int faultNum, int actionNum,
                             boolean append, StringToIntMapper<AmplSubset> mapper, AmplExportConfig config);  AmplNetworkWriter(Network network, DataSource dataSource, int faultNum, int actionNum,
                             boolean append, StringToIntMapper<AmplSubset> mapper, AmplExportConfig config);  AmplNetworkWriter(Network network, DataSource dataSource, StringToIntMapper<AmplSubset> mapper,
                             AmplExportConfig config);  AmplNetworkWriter(Network network, DataSource dataSource, AmplExportConfig config); static String getTableTitle(Network network, String tableName); void write(); void write(AmplExportContext context);  }