-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add version 1.2 of AMPL exporter (#3220)
* Add condenser column in generator file of extended ampl exporter * Add target Q for LCC converter stations * Add new version of extended ampl exporter * Remove public attribut to AbstractAmplExporterTest * Add columns to export active set points (targetP/ac emulation) of hvdc converter stations * Add columns for AC emulation and targetP in VSC table * Move AC emulation parameters from VSC table to HVDC lines table * Fix Q0 unit in batteries/lcc columns Signed-off-by: p-arvy <pierre.arvy@artelys.com>
- Loading branch information
Showing
16 changed files
with
367 additions
and
68 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
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
106 changes: 106 additions & 0 deletions
106
ampl-converter/src/main/java/com/powsybl/ampl/converter/version/ExtendedAmplExporterV2.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,106 @@ | ||
/** | ||
* Copyright (c) 2024, 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/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.ampl.converter.version; | ||
|
||
import com.powsybl.ampl.converter.AmplExportConfig; | ||
import com.powsybl.ampl.converter.AmplSubset; | ||
import com.powsybl.commons.io.table.Column; | ||
import com.powsybl.commons.io.table.TableFormatterHelper; | ||
import com.powsybl.commons.util.StringToIntMapper; | ||
import com.powsybl.iidm.network.*; | ||
import com.powsybl.iidm.network.extensions.HvdcAngleDroopActivePowerControl; | ||
import com.powsybl.iidm.network.util.HvdcUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static com.powsybl.ampl.converter.AmplConstants.*; | ||
|
||
/** | ||
* @author Pierre ARVY {@literal <pierre.arvy at artelys.com>} | ||
*/ | ||
public class ExtendedAmplExporterV2 extends ExtendedAmplExporter { | ||
|
||
private static final int BATTERY_Q0_COLUMN_INDEX = 6; | ||
private static final int GENERATOR_IS_CONDENSER_COLUMN_INDEX = 16; | ||
private static final int LCC_TARGET_Q_COLUMN_INDEX = 5; | ||
private static final int HVDC_AC_EMULATION_COLUMN_INDEX = 8; | ||
private static final int HVDC_P_OFFSET_COLUMN_INDEX = 10; | ||
private static final int HVDC_K_COLUMN_INDEX = 11; | ||
|
||
public ExtendedAmplExporterV2(AmplExportConfig config, | ||
Network network, | ||
StringToIntMapper<AmplSubset> mapper, | ||
int variantIndex, int faultNum, int actionNum) { | ||
super(config, network, mapper, variantIndex, faultNum, actionNum); | ||
} | ||
|
||
@Override | ||
public List<Column> getBatteriesColumns() { | ||
List<Column> batteriesColumns = new ArrayList<>(super.getBatteriesColumns()); | ||
// fix unit of q0 column | ||
batteriesColumns.set(BATTERY_Q0_COLUMN_INDEX, new Column(Q0)); | ||
return batteriesColumns; | ||
} | ||
|
||
@Override | ||
public List<Column> getGeneratorsColumns() { | ||
List<Column> generatorsColumns = new ArrayList<>(super.getGeneratorsColumns()); | ||
// add column to indicate if generator is a condenser | ||
generatorsColumns.add(GENERATOR_IS_CONDENSER_COLUMN_INDEX, new Column("condenser")); | ||
return generatorsColumns; | ||
} | ||
|
||
@Override | ||
public List<Column> getLccConverterStationsColumns() { | ||
List<Column> lccColumns = new ArrayList<>(super.getLccConverterStationsColumns()); | ||
// add columns for load target Q of converter station | ||
lccColumns.add(LCC_TARGET_Q_COLUMN_INDEX, new Column(Q0)); | ||
return lccColumns; | ||
} | ||
|
||
@Override | ||
public List<Column> getHvdcLinesColumns() { | ||
List<Column> hvdcColumns = new ArrayList<>(super.getHvdcLinesColumns()); | ||
// add columns for AC emulation | ||
hvdcColumns.add(HVDC_AC_EMULATION_COLUMN_INDEX, new Column("ac emul.")); | ||
hvdcColumns.add(HVDC_P_OFFSET_COLUMN_INDEX, new Column("P offset (MW)")); | ||
hvdcColumns.add(HVDC_K_COLUMN_INDEX, new Column("k (MW/rad)")); | ||
return hvdcColumns; | ||
} | ||
|
||
@Override | ||
public void addAdditionalCellsGenerator(TableFormatterHelper formatterHelper, Generator gen) { | ||
super.addAdditionalCellsGenerator(formatterHelper, gen); | ||
formatterHelper.addCell(gen.isCondenser(), GENERATOR_IS_CONDENSER_COLUMN_INDEX); | ||
} | ||
|
||
@Override | ||
public void addAdditionalCellsLccConverterStation(TableFormatterHelper formatterHelper, | ||
LccConverterStation lccStation) { | ||
double loadTargetQ = HvdcUtils.getLccConverterStationLoadTargetQ(lccStation); | ||
formatterHelper.addCell(loadTargetQ, LCC_TARGET_Q_COLUMN_INDEX); | ||
} | ||
|
||
@Override | ||
public void addAdditionalCellsHvdcLine(TableFormatterHelper formatterHelper, | ||
HvdcLine hvdcLine) { | ||
boolean isEnabled = false; | ||
double p0 = Double.NaN; | ||
double k = Double.NaN; | ||
HvdcAngleDroopActivePowerControl droopControl = hvdcLine.getExtension(HvdcAngleDroopActivePowerControl.class); | ||
if (droopControl != null) { | ||
isEnabled = droopControl.isEnabled(); | ||
p0 = droopControl.getP0(); | ||
k = droopControl.getDroop() * 180 / Math.PI; // export MW/rad as voltage angles are exported in rad | ||
} | ||
formatterHelper.addCell(isEnabled, HVDC_AC_EMULATION_COLUMN_INDEX); | ||
formatterHelper.addCell(p0, HVDC_P_OFFSET_COLUMN_INDEX); | ||
formatterHelper.addCell(k, HVDC_K_COLUMN_INDEX); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
ampl-converter/src/test/java/com/powsybl/ampl/converter/AbstractAmplExporterTest.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,46 @@ | ||
/** | ||
* Copyright (c) 2024, 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/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.ampl.converter; | ||
|
||
import com.powsybl.commons.datasource.MemDataSource; | ||
import com.powsybl.commons.test.AbstractSerDeTest; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Properties; | ||
|
||
import static com.powsybl.commons.test.ComparisonUtils.assertTxtEquals; | ||
|
||
/** | ||
* @author Geoffroy Jamgotchian {@literal <geoffroy.jamgotchian at rte-france.com>} | ||
* @author Pierre ARVY {@literal <pierre.arvy at artelys.com>} | ||
*/ | ||
abstract class AbstractAmplExporterTest extends AbstractSerDeTest { | ||
|
||
MemDataSource dataSource; | ||
AmplExporter exporter; | ||
Properties properties; | ||
|
||
protected void assertEqualsToRef(MemDataSource dataSource, String suffix, String refFileName) throws IOException { | ||
try (InputStream actual = new ByteArrayInputStream(dataSource.getData(suffix, "txt"))) { | ||
assertTxtEquals(getClass().getResourceAsStream("/" + refFileName), actual); | ||
} | ||
} | ||
|
||
@Override | ||
@BeforeEach | ||
public void setUp() throws IOException { | ||
super.setUp(); | ||
dataSource = new MemDataSource(); | ||
exporter = new AmplExporter(); | ||
properties = new Properties(); | ||
} | ||
|
||
} |
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
Oops, something went wrong.