Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMPL export : extended exporter #2604

Merged
merged 91 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
9379bef
add constructor with list instead of varargs
Jun 2, 2023
dbf18e0
WIP add ampl export version
Jun 2, 2023
4143d1a
refactor all writing to BasicAmplExporter
Jun 2, 2023
84987ea
match setVersion to return this
Jun 2, 2023
54fa975
AmplExportVersion is now an interface
Jun 2, 2023
8be12fe
missing author and licence
Jun 2, 2023
595b20b
typo in writeThreeWindingsTranformersMiddleBusesColumnsToFormatter
Jun 5, 2023
57cd659
integrating #2596 into this PR
Jun 5, 2023
73884d9
fix function accepting only implementation and not interface
Jun 7, 2023
8c67231
Accept version in parameters of AmplExport service
Jun 7, 2023
fc3adf0
add header file indicating version
Jun 12, 2023
38eba0a
fix test because of new version parameter
Jun 12, 2023
639bbd5
Merge remote-tracking branch 'origin/main' into ampl/export-slack
Jun 13, 2023
a0160f3
fix BasicAmplExporter according to b7f9c3df
Jun 13, 2023
261c0e0
clean
Jun 13, 2023
0770a2c
add networkUtil
Jun 7, 2023
54dd6c1
add getters for inheritance
Jun 7, 2023
7e559a9
added ExtendedAmplExporter
Jun 7, 2023
353c1f1
added new columns :
Jun 7, 2023
bde0378
wip tests
Jun 7, 2023
6e5cb2d
export is in busView
Jun 7, 2023
334e7e0
WIP tap tests
Jun 9, 2023
3e11f7b
clean public for tests
Jun 13, 2023
39060bf
fix constants typo
Aug 7, 2023
4e1c694
fix MVar to MVAr
Aug 9, 2023
96d8e90
fix MVar to MVAr
Aug 9, 2023
b96f2a9
Merge branch 'main' into ampl/export-slack
annetill Aug 31, 2023
0f27df1
Merge branch 'main' into ampl/export-slack
olperr1 Nov 2, 2023
43dabbb
formatting
pjeanmarie Nov 6, 2023
51a9598
SPDX clause missing
pjeanmarie Nov 6, 2023
20bc489
escape email to avoid javadoc warnings
pjeanmarie Nov 6, 2023
54cdc68
Add missing Override
pjeanmarie Nov 6, 2023
4db1b94
Improve switch case
pjeanmarie Nov 6, 2023
fa3aa31
To be consistent
pjeanmarie Nov 6, 2023
9a08421
Distinct columns headers from suffix
Nov 7, 2023
759507d
If we want to use valueOf which exist on enum, than there is not usag…
Nov 7, 2023
2331afe
Fix comment
Nov 10, 2023
5454e50
Light refacto
Nov 10, 2023
8f60ac3
Actual version of Ampl is 1.0 so use that instead of V1_LEGACY
Nov 10, 2023
c8dd384
Merge branch 'main' into ampl/export-slack
Nov 10, 2023
6d32105
Use exporter id instead of AmplExportVersion enum name in properties …
Nov 14, 2023
3234db3
Merge branch 'ampl/export-slack' into ampl/extended-exporter
Nov 15, 2023
aa351b4
Merge branch 'main' into ampl/export-slack
annetill Nov 15, 2023
39c09d2
Remove duplicate version instantiation of columns exporter, now it is…
Nov 16, 2023
5259117
Update comments for javadoc
Nov 16, 2023
8a64e54
Give a more specific name to the first columns extension
Nov 16, 2023
cfeaa23
Add ampl exporter version in ampl executor via AmplModelExecutionHand…
Nov 21, 2023
1c16e45
Merge branch 'main' into ampl/export-slack
olperr1 Nov 23, 2023
db125de
Merge branch 'ampl/export-slack' into ampl/extended-exporter
olperr1 Nov 23, 2023
d605507
Revert "fix MVar to MVAr"
olperr1 Nov 24, 2023
26fb1ca
Revert "fix MVar to MVAr"
olperr1 Nov 24, 2023
2dcdbf3
Revert "fix constants typo"
olperr1 Nov 24, 2023
7f8baa3
Merge branch 'main' into ampl/extended-exporter
olperr1 Nov 24, 2023
7c82c0b
Merge branch 'main' into ampl/extended-exporter
annetill Dec 15, 2023
e7effd5
Merge branch 'main' into ampl/extended-exporter
annetill Jan 9, 2024
dadb963
Merge branch 'main' into ampl/extended-exporter
annetill Jan 11, 2024
74281b1
Merge remote-tracking branch 'refs/remotes/origin/main' into ampl/ext…
p-arvy Sep 2, 2024
ab37a56
Refactor TUs
p-arvy Sep 2, 2024
23141d9
Small refactor
p-arvy Sep 2, 2024
626d1a2
Refactor table columns in extended ampl exporter
p-arvy Sep 2, 2024
906cd02
Add slack bus export for 3wt, dangling lines and tie lines buses in e…
p-arvy Sep 2, 2024
a2fe2c3
Add TUs for slack bus values in new extended ampl export
p-arvy Sep 2, 2024
c9c95c8
Small clean
p-arvy Sep 2, 2024
2222f61
Fix G/B per unitage in new ampl extended export for tap changer tables
p-arvy Sep 2, 2024
3f694eb
Merge branch 'refs/heads/main' into ampl/extended-exporter
p-arvy Sep 2, 2024
5c5e901
Improve TUs on remote regulating terminal
p-arvy Sep 2, 2024
dfc89a4
Add comment
p-arvy Sep 2, 2024
87d575e
Remove block of comments
p-arvy Sep 2, 2024
f1dd78e
Add TU
p-arvy Sep 2, 2024
5619c2d
Fix unused import
p-arvy Sep 2, 2024
ba29e11
Put extended version of the exporter as default version
p-arvy Sep 2, 2024
825e55d
Merge branch 'main' into ampl/extended-exporter
So-Fras Sep 5, 2024
c6fc222
Update version of iidm extensions
p-arvy Sep 11, 2024
1e643c1
Remove properties override in TUs
p-arvy Sep 11, 2024
0327b6a
Merge branch 'refs/heads/main' into ampl/extended-exporter
p-arvy Sep 11, 2024
661e9c1
initialize TableFormatterHelper
rolnico Sep 13, 2024
6e12d01
finish TableFormatterHelper
rolnico Sep 16, 2024
aafe76a
use record to lower number of method parameters
rolnico Sep 16, 2024
59a30f2
Merge branch 'main' into ampl/extended-exporter
So-Fras Sep 18, 2024
445c6ab
Merge branch 'main' into ampl/extended-exporter
So-Fras Sep 18, 2024
015b9ca
Use index constants instead of their numeric values
olperr1 Sep 19, 2024
fd0d55b
Merge branch 'nro/ampl-extended-exporter-with-position' into ampl/ext…
So-Fras Sep 20, 2024
4537070
Merge branch 'main' into ampl/extended-exporter
So-Fras Sep 20, 2024
7d60ce7
Rename ExtendedAmplExporter
p-arvy Sep 20, 2024
6378899
Modify extended ampl exporter javadoc
p-arvy Sep 20, 2024
97d728c
Add documentation about Ampl exporters
So-Fras Sep 24, 2024
55d7769
Fix typos
So-Fras Sep 24, 2024
02a787c
Update docs/grid_exchange_formats/ampl/export.md
So-Fras Sep 24, 2024
f0f05fa
Update docs/grid_exchange_formats/ampl/export.md
So-Fras Sep 24, 2024
ae08e3d
Fix typo following review
So-Fras Sep 24, 2024
d914f0b
Merge branch 'main' into ampl/extended-exporter
olperr1 Sep 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ampl-converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,9 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-iidm-extensions</artifactId>
p-arvy marked this conversation as resolved.
Show resolved Hide resolved
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,40 @@
import java.util.Locale;

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

private AmplConstants() {
}

public static final String XNODE_COUNTRY_NAME = "XNODE";
public static final String FAULT = "fault";
public static final String DESCRIPTION = "description";
public static final String SUBSTATION = "substation";
public static final String TARGET_V = "targetV (pu)";
public static final String TARGET_Q = "targetQ (MVAr)";
public static final String CON_BUS = "con. bus";
public static final String MINP = "minP (MW)";
public static final String MAXP = "maxP (MW)";
public static final String V_REGUL = "v regul.";
public static final String V_REGUL_BUS = "v regul. bus";
public static final String ACTIVE_POWER = "P (MW)";
public static final String REACTIVE_POWER = "Q (MVAr)";
public static final String MIN_Q_MAX_P = "minQmaxP (MVAr)";
public static final String MIN_Q0 = "minQ0 (MVAr)";
public static final String MIN_Q_MIN_P = "minQminP (MVAr)";
public static final String MAX_Q_MAX_P = "maxQmaxP (MVAr)";
public static final String MAX_Q0 = "maxQ0 (MVAr)";
public static final String MAX_Q_MIN_P = "maxQminP (MVAr)";
public static final String NUM = "num";
public static final String BUS = "bus";
public static final String P0 = "p0 (MW)";
public static final String Q0 = "q0 (MW)";
public static final String ID = "id";
public static final String RATIO_TABLE = "_ratio_table";
public static final String PHASE_TABLE = "_phase_table";

public static final float INVALID_FLOAT_VALUE = -99999f;

public static final Locale LOCALE = Locale.US;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
package com.powsybl.ampl.converter;

import com.powsybl.ampl.converter.version.AmplExportVersion;
import com.powsybl.ampl.converter.version.AmplExportVersionImpl;

import java.util.Objects;

/**
Expand Down Expand Up @@ -38,6 +41,8 @@ public String getLabel() {

private ExportScope exportScope;

private AmplExportVersion version;

private boolean exportXNodes;

private ExportActionType actionType;
Expand All @@ -47,15 +52,24 @@ public String getLabel() {
private boolean twtSplitShuntAdmittance;

public AmplExportConfig(ExportScope exportScope, boolean exportXNodes, ExportActionType actionType) {
this(exportScope, exportXNodes, actionType, false, false);
this(exportScope, exportXNodes, actionType, false, false, AmplExportVersionImpl.V1_LEGACY);
}

public AmplExportConfig(ExportScope exportScope, boolean exportXNodes, ExportActionType actionType, boolean exportRatioTapChangerVoltageTarget, boolean twtSplitShuntAdmittance) {
public AmplExportConfig(ExportScope exportScope, boolean exportXNodes, ExportActionType actionType,
boolean exportRatioTapChangerVoltageTarget, boolean twtSplitShuntAdmittance) {
this(exportScope, exportXNodes, actionType, exportRatioTapChangerVoltageTarget, twtSplitShuntAdmittance,
AmplExportVersionImpl.V1_LEGACY);
}

public AmplExportConfig(ExportScope exportScope, boolean exportXNodes, ExportActionType actionType,
boolean exportRatioTapChangerVoltageTarget, boolean twtSplitShuntAdmittance,
AmplExportVersion version) {
this.exportScope = Objects.requireNonNull(exportScope);
this.exportXNodes = exportXNodes;
this.actionType = Objects.requireNonNull(actionType);
this.exportRatioTapChangerVoltageTarget = exportRatioTapChangerVoltageTarget;
this.twtSplitShuntAdmittance = twtSplitShuntAdmittance;
this.version = Objects.requireNonNull(version);
}

public ExportScope getExportScope() {
Expand Down Expand Up @@ -103,4 +117,13 @@ public AmplExportConfig setTwtSplitShuntAdmittance(boolean twtSplitShuntAdmittan
return this;
}

public AmplExportVersion getVersion() {
return version;
}

public AmplExportConfig setVersion(AmplExportVersion version) {
this.version = Objects.requireNonNull(version);
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
package com.powsybl.ampl.converter;

import com.google.auto.service.AutoService;
import com.powsybl.ampl.converter.version.AmplExportVersion;
import com.powsybl.ampl.converter.version.AmplExportVersionImpl;
import com.powsybl.commons.config.PlatformConfig;
import com.powsybl.commons.datasource.DataSource;
import com.powsybl.iidm.network.Exporter;
import com.powsybl.iidm.network.Network;
import com.powsybl.commons.parameters.Parameter;
import com.powsybl.commons.parameters.ParameterDefaultValueConfig;
import com.powsybl.commons.parameters.ParameterType;
import com.powsybl.iidm.network.Exporter;
import com.powsybl.iidm.network.Network;

import java.io.IOException;
import java.io.UncheckedIOException;
Expand All @@ -36,22 +38,33 @@ public class AmplExporter implements Exporter {
public static final String EXPORT_ACTION_TYPE = "iidm.export.ampl.action-type";
public static final String EXPORT_RATIOTAPCHANGER_VT = "iidm.export.ampl.export-ratio-tap-changer-voltage-target";
public static final String TWT_SPLIT_SHUNT_ADMITTANCE = "iidm.export.ampl.twt-split-shunt-admittance";
public static final String EXPORT_VERSION = "iidm.export.ampl.export-version";

private static final Parameter EXPORT_SCOPE_PARAMETER = new Parameter(EXPORT_SCOPE, ParameterType.STRING, "Export scope",
AmplExportConfig.ExportScope.ALL.name(),
Arrays.stream(AmplExportConfig.ExportScope.values()).map(Enum::name).collect(Collectors.toList()));
private static final Parameter EXPORT_XNODES_PARAMETER = new Parameter(EXPORT_XNODES, ParameterType.BOOLEAN, "Export Xnodes of tie-lines", Boolean.FALSE);
private static final Parameter EXPORT_ACTION_TYPE_PARAMETER = new Parameter(EXPORT_ACTION_TYPE, ParameterType.STRING, "Type of the remedial actions (preventive or curative)",
AmplExportConfig.ExportActionType.CURATIVE.name(),
Arrays.stream(AmplExportConfig.ExportActionType.values()).map(Enum::name).collect(Collectors.toList()));
private static final Parameter EXPORT_RATIOTAPCHANGER_VT_PARAMETER = new Parameter(EXPORT_RATIOTAPCHANGER_VT, ParameterType.BOOLEAN, "Export ratio tap changer voltage target", Boolean.FALSE)
.addAdditionalNames("iidm.export.ampl.exportRatioTapChangerVoltageTarget");
private static final Parameter TWT_SPLIT_SHUNT_ADMITTANCE_PARAMETER = new Parameter(TWT_SPLIT_SHUNT_ADMITTANCE, ParameterType.BOOLEAN, "Export twt split shunt admittance", Boolean.FALSE)
Arrays.stream(AmplExportConfig.ExportScope.values()).map(Enum::name).collect(Collectors.toList()));
private static final Parameter EXPORT_XNODES_PARAMETER = new Parameter(EXPORT_XNODES, ParameterType.BOOLEAN,
"Export Xnodes of tie-lines", Boolean.FALSE);
private static final Parameter EXPORT_ACTION_TYPE_PARAMETER = new Parameter(EXPORT_ACTION_TYPE,
ParameterType.STRING, "Type of the remedial actions (preventive or curative)",
AmplExportConfig.ExportActionType.CURATIVE.name(),
Arrays.stream(AmplExportConfig.ExportActionType.values()).map(Enum::name).collect(Collectors.toList()));
private static final Parameter EXPORT_RATIOTAPCHANGER_VT_PARAMETER = new Parameter(EXPORT_RATIOTAPCHANGER_VT,
ParameterType.BOOLEAN, "Export ratio tap changer voltage target", Boolean.FALSE)
.addAdditionalNames("iidm.export.ampl.exportRatioTapChangerVoltageTarget");
private static final Parameter TWT_SPLIT_SHUNT_ADMITTANCE_PARAMETER = new Parameter(TWT_SPLIT_SHUNT_ADMITTANCE,
ParameterType.BOOLEAN, "Export twt split shunt admittance", Boolean.FALSE)
.addAdditionalNames("iidm.export.ampl.specific-compatibility")
.addAdditionalNames("iidm.export.ampl.specificCompatibility");

private static final List<Parameter> STATIC_PARAMETERS = List.of(EXPORT_SCOPE_PARAMETER, EXPORT_XNODES_PARAMETER, EXPORT_ACTION_TYPE_PARAMETER,
EXPORT_RATIOTAPCHANGER_VT_PARAMETER, TWT_SPLIT_SHUNT_ADMITTANCE_PARAMETER);
private static final Parameter EXPORT_VERSION_PARAMETER = new Parameter(EXPORT_VERSION, ParameterType.STRING,
"The version of the export.",
AmplExportVersionImpl.V1_LEGACY.name(),
Arrays.stream(AmplExportVersionImpl.values()).map(Enum::name).collect(Collectors.toList()));

private static final List<Parameter> STATIC_PARAMETERS = List.of(EXPORT_SCOPE_PARAMETER, EXPORT_XNODES_PARAMETER,
EXPORT_ACTION_TYPE_PARAMETER,
EXPORT_RATIOTAPCHANGER_VT_PARAMETER, TWT_SPLIT_SHUNT_ADMITTANCE_PARAMETER, EXPORT_VERSION_PARAMETER);

private final ParameterDefaultValueConfig defaultValueConfig;

Expand Down Expand Up @@ -82,9 +95,13 @@ public void export(Network network, Properties parameters, DataSource dataSource
boolean exportXnodes = Parameter.readBoolean(getFormat(), parameters, EXPORT_XNODES_PARAMETER, defaultValueConfig);
AmplExportConfig.ExportActionType actionType = AmplExportConfig.ExportActionType.valueOf(Parameter.readString(getFormat(), parameters, EXPORT_ACTION_TYPE_PARAMETER, defaultValueConfig));
boolean exportRatioTapChangerVoltageTarget = Parameter.readBoolean(getFormat(), parameters, EXPORT_RATIOTAPCHANGER_VT_PARAMETER, defaultValueConfig);
boolean twtSplitShuntAdmittance = Parameter.readBoolean(getFormat(), parameters, TWT_SPLIT_SHUNT_ADMITTANCE_PARAMETER, defaultValueConfig);
boolean twtSplitShuntAdmittance = Parameter.readBoolean(getFormat(), parameters,
TWT_SPLIT_SHUNT_ADMITTANCE_PARAMETER, defaultValueConfig);
AmplExportVersion exportVersion = AmplExportVersionImpl.valueOf(
Parameter.readString(getFormat(), parameters, EXPORT_VERSION_PARAMETER, defaultValueConfig));

AmplExportConfig config = new AmplExportConfig(scope, exportXnodes, actionType, exportRatioTapChangerVoltageTarget, twtSplitShuntAdmittance);
AmplExportConfig config = new AmplExportConfig(scope, exportXnodes, actionType,
exportRatioTapChangerVoltageTarget, twtSplitShuntAdmittance, exportVersion);

new AmplNetworkWriter(network, dataSource, config).write();
} catch (IOException e) {
Expand Down
Loading