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

Clean of CGMES options #2517

Merged
merged 2 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ public String getFormat() {
}

public static final String BASE_NAME = "iidm.export.cgmes.base-name";
public static final String BOUNDARY_EQ_ID = "iidm.export.cgmes.boundary-EQ-identifier";
public static final String BOUNDARY_TP_ID = "iidm.export.cgmes.boundary-TP-identifier";
public static final String CIM_VERSION = "iidm.export.cgmes.cim-version";
private static final String ENCODE_IDS = "iidm.export.cgmes.encode-ids";
public static final String EXPORT_BOUNDARY_POWER_FLOWS = "iidm.export.cgmes.export-boundary-power-flows";
public static final String EXPORT_POWER_FLOWS_FOR_SWITCHES = "iidm.export.cgmes.export-power-flows-for-switches";
public static final String NAMING_STRATEGY = "iidm.export.cgmes.naming-strategy";
public static final String PROFILES = "iidm.export.cgmes.profiles";
public static final String BOUNDARY_EQ_ID = "iidm.export.cgmes.boundary-EQ-identifier";
public static final String BOUNDARY_TP_ID = "iidm.export.cgmes.boundary-TP-identifier";

private static final Parameter BASE_NAME_PARAMETER = new Parameter(
BASE_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,6 @@ private Conversion.Config config(ReadOnlyDataSource ds, Properties p) {
p,
CREATE_BUSBAR_SECTION_FOR_EVERY_CONNECTIVITY_NODE_PARAMETER,
defaultValueConfig))
.setCreateCgmesExportMapping(
Parameter.readBoolean(
getFormat(),
p,
CREATE_CGMES_EXPORT_MAPPING_PARAMETER,
defaultValueConfig))
.setEnsureIdAliasUnicity(
Parameter.readBoolean(
getFormat(),
Expand Down Expand Up @@ -264,7 +258,7 @@ private Conversion.Config config(ReadOnlyDataSource ds, Properties p) {
p,
CREATE_FICTITIOUS_SWITCHES_FOR_DISCONNECTED_TERMINALS_MODE_PARAMETER,
defaultValueConfig)));
String namingStrategy = Parameter.readString(getFormat(), p, ID_MAPPING_FILE_NAMING_STRATEGY_PARAMETER, defaultValueConfig);
String namingStrategy = Parameter.readString(getFormat(), p, NAMING_STRATEGY_PARAMETER, defaultValueConfig);
String idMappingFilePath = Parameter.readString(getFormat(), p, ID_MAPPING_FILE_PATH_PARAMETER, defaultValueConfig);
if (idMappingFilePath == null) {
config.setNamingStrategy(NamingStrategyFactory.create(namingStrategy, ds, ds.getBaseName() + "_id_mapping.csv"));
Expand Down Expand Up @@ -305,21 +299,20 @@ private void copyStream(ReadOnlyDataSource from, DataSource to, String fromName,
public static final String CHANGE_SIGN_FOR_SHUNT_REACTIVE_POWER_FLOW_INITIAL_STATE = "iidm.import.cgmes.change-sign-for-shunt-reactive-power-flow-initial-state";
public static final String CONVERT_BOUNDARY = "iidm.import.cgmes.convert-boundary";
public static final String CONVERT_SV_INJECTIONS = "iidm.import.cgmes.convert-sv-injections";
public static final String CREATE_ACTIVE_POWER_CONTROL_EXTENSION = "iidm.import.cgmes.create-active-power-control-extension";
public static final String CREATE_BUSBAR_SECTION_FOR_EVERY_CONNECTIVITY_NODE = "iidm.import.cgmes.create-busbar-section-for-every-connectivity-node";
public static final String CREATE_CGMES_EXPORT_MAPPING = "iidm.import.cgmes.create-cgmes-export-mapping";
public static final String CREATE_FICTITIOUS_SWITCHES_FOR_DISCONNECTED_TERMINALS_MODE = "iidm.import.cgmes.create-fictitious-switches-for-disconnected-terminals-mode";
public static final String DECODE_ESCAPED_IDENTIFIERS = "iidm.import.cgmes.decode-escaped-identifiers";
public static final String ENSURE_ID_ALIAS_UNICITY = "iidm.import.cgmes.ensure-id-alias-unicity";
public static final String ID_MAPPING_FILE_PATH = "iidm.import.cgmes.id-mapping-file-path";
public static final String ID_MAPPING_FILE_NAMING_STRATEGY = "iidm.import.cgmes.id-mapping-file-naming-strategy";
public static final String IMPORT_CONTROL_AREAS = "iidm.import.cgmes.import-control-areas";
public static final String NAMING_STRATEGY = "iidm.import.cgmes.naming-strategy";
public static final String POST_PROCESSORS = "iidm.import.cgmes.post-processors";
public static final String POWSYBL_TRIPLESTORE = "iidm.import.cgmes.powsybl-triplestore";
public static final String PROFILE_FOR_INITIAL_VALUES_SHUNT_SECTIONS_TAP_POSITIONS = "iidm.import.cgmes.profile-for-initial-values-shunt-sections-tap-positions";
public static final String SOURCE_FOR_IIDM_ID = "iidm.import.cgmes.source-for-iidm-id";
public static final String STORE_CGMES_MODEL_AS_NETWORK_EXTENSION = "iidm.import.cgmes.store-cgmes-model-as-network-extension";
public static final String STORE_CGMES_CONVERSION_CONTEXT_AS_NETWORK_EXTENSION = "iidm.import.cgmes.store-cgmes-conversion-context-as-network-extension";
public static final String CREATE_ACTIVE_POWER_CONTROL_EXTENSION = "iidm.import.cgmes.create-active-power-control-extension";
public static final String DECODE_ESCAPED_IDENTIFIERS = "iidm.import.cgmes.decode-escaped-identifiers";
public static final String CREATE_FICTITIOUS_SWITCHES_FOR_DISCONNECTED_TERMINALS_MODE = "iidm.import.cgmes.create-fictitious-switches-for-disconnected-terminals-mode";

public static final String SOURCE_FOR_IIDM_ID_MRID = "mRID";
public static final String SOURCE_FOR_IIDM_ID_RDFID = "rdfID";
Expand Down Expand Up @@ -352,11 +345,6 @@ private void copyStream(ReadOnlyDataSource from, DataSource to, String fromName,
"Create busbar section for every connectivity node",
Boolean.FALSE)
.addAdditionalNames("createBusbarSectionForEveryConnectivityNode");
private static final Parameter CREATE_CGMES_EXPORT_MAPPING_PARAMETER = new Parameter(
CREATE_CGMES_EXPORT_MAPPING,
ParameterType.BOOLEAN,
"Create CGMES context for export",
Boolean.FALSE);
private static final Parameter ENSURE_ID_ALIAS_UNICITY_PARAMETER = new Parameter(
ENSURE_ID_ALIAS_UNICITY,
ParameterType.BOOLEAN,
Expand All @@ -369,11 +357,12 @@ private void copyStream(ReadOnlyDataSource from, DataSource to, String fromName,
null,
null,
ParameterScope.TECHNICAL);
private static final Parameter ID_MAPPING_FILE_NAMING_STRATEGY_PARAMETER = new Parameter(
ID_MAPPING_FILE_NAMING_STRATEGY,
private static final Parameter NAMING_STRATEGY_PARAMETER = new Parameter(
NAMING_STRATEGY,
ParameterType.STRING,
"Configure what type of naming strategy you want to use for the provided ID mapping file",
NamingStrategyFactory.IDENTITY);
NamingStrategyFactory.IDENTITY)
.addAdditionalNames("iidm.import.cgmes.id-mapping-file-naming-strategy");
private static final Parameter IMPORT_CONTROL_AREAS_PARAMETER = new Parameter(
IMPORT_CONTROL_AREAS,
ParameterType.BOOLEAN,
Expand Down Expand Up @@ -434,10 +423,9 @@ private void copyStream(ReadOnlyDataSource from, DataSource to, String fromName,
CONVERT_BOUNDARY_PARAMETER,
CONVERT_SV_INJECTIONS_PARAMETER,
CREATE_BUSBAR_SECTION_FOR_EVERY_CONNECTIVITY_NODE_PARAMETER,
CREATE_CGMES_EXPORT_MAPPING_PARAMETER,
ENSURE_ID_ALIAS_UNICITY_PARAMETER,
ID_MAPPING_FILE_PATH_PARAMETER,
ID_MAPPING_FILE_NAMING_STRATEGY_PARAMETER,
NAMING_STRATEGY_PARAMETER,
IMPORT_CONTROL_AREAS_PARAMETER,
POWSYBL_TRIPLESTORE_PARAMETER,
PROFILE_FOR_INITIAL_VALUES_SHUNT_SECTIONS_TAP_POSITIONS_PARAMETER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,15 +758,6 @@ public Config setCreateBusbarSectionForEveryConnectivityNode(boolean b) {
return this;
}

public boolean createCgmesExportMapping() {
return createCgmesExportMapping;
}

public Config setCreateCgmesExportMapping(boolean createCgmesExportMapping) {
this.createCgmesExportMapping = createCgmesExportMapping;
return this;
}

public boolean convertSvInjections() {
return convertSvInjections;
}
Expand Down Expand Up @@ -921,8 +912,6 @@ public Config createFictitiousSwitchesForDisconnectedTerminalsMode(CgmesImport.F
private boolean ensureIdAliasUnicity = false;
private boolean importControlAreas = true;

private boolean createCgmesExportMapping = false;

private NamingStrategy namingStrategy = new NamingStrategy.Identity();

// Default interpretation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void testExportUsingCgmesNamingStrategy(String namingStrategy, Network network,

// By default, the identity naming strategy is configured, we have to set a specific one if we have a mapping file
Properties reimportParams1 = new Properties(reimportParams);
reimportParams1.put(CgmesImport.ID_MAPPING_FILE_NAMING_STRATEGY, namingStrategy);
reimportParams1.put(CgmesImport.NAMING_STRATEGY, namingStrategy);

Network networkActual = Importers.importData("CGMES", exportedCgmes, reimportParams1);
Collection<Diff> diffs = compareNetworksUsingConnectedEquipment(network, networkActual, tmpDir.resolve("exportedCgmes" + baseName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Properties;

import static org.junit.jupiter.api.Assertions.*;

Expand All @@ -49,80 +48,64 @@ class EquipmentExportTest extends AbstractConverterTest {

@Test
void smallGridHvdc() throws IOException, XMLStreamException {
Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
ReadOnlyDataSource dataSource = CgmesConformity1Catalog.smallNodeBreakerHvdc().dataSource();
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), null);
Network actual = exportImportNodeBreaker(expected, dataSource);
compareNetworksEQdata(expected, actual);
}

@Test
void smallNodeBreaker() throws IOException, XMLStreamException {
Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
ReadOnlyDataSource dataSource = CgmesConformity1Catalog.smallNodeBreaker().dataSource();
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), null);
Network actual = exportImportNodeBreaker(expected, dataSource);
compareNetworksEQdata(expected, actual);
}

@Test
void smallBusBranch() throws IOException, XMLStreamException {
Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
ReadOnlyDataSource dataSource = CgmesConformity1Catalog.smallBusBranch().dataSource();
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), null);
Network actual = exportImportBusBranch(expected, dataSource);
compareNetworksEQdata(expected, actual);
}

@Test
void smallGridHvdcWithCapabilityCurve() throws IOException, XMLStreamException {
Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
ReadOnlyDataSource dataSource = CgmesConformity1ModifiedCatalog.smallNodeBreakerHvdcWithVsCapabilityCurve().dataSource();
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), null);
Network actual = exportImportNodeBreaker(expected, dataSource);
compareNetworksEQdata(expected, actual);
}

@Test
void miniNodeBreaker() throws IOException, XMLStreamException {
Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
ReadOnlyDataSource dataSource = CgmesConformity1Catalog.miniNodeBreaker().dataSource();
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), null);
Network actual = exportImportNodeBreaker(expected, dataSource);
compareNetworksEQdata(expected, actual);
}

@Test
void miniBusBranch() throws IOException, XMLStreamException {
Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
ReadOnlyDataSource dataSource = CgmesConformity1Catalog.miniBusBranch().dataSource();
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), null);
Network actual = exportImportBusBranchNoBoundaries(expected, dataSource);
compareNetworksEQdata(expected, actual);
}

@Test
void microGridWithTieFlowMappedToEquivalentInjection() throws IOException, XMLStreamException {
Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
ReadOnlyDataSource dataSource = CgmesConformity1ModifiedCatalog.microGridBaseCaseBEWithTieFlowMappedToEquivalentInjection().dataSource();
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), null);
Network actual = exportImportBusBranch(expected, dataSource);
compareNetworksEQdata(expected, actual);
}

@Test
void microGridBaseCaseAssembledSwitchAtBoundary() throws XMLStreamException, IOException {
Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
ReadOnlyDataSource dataSource = CgmesConformity1ModifiedCatalog.microGridBaseCaseAssembledSwitchAtBoundary().dataSource();
Network network = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);
Network network = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), null);

network.newExtension(CgmesControlAreasAdder.class).add();
CgmesControlAreas cgmesControlAreas = network.getExtension(CgmesControlAreas.class);
Expand Down Expand Up @@ -151,20 +134,16 @@ void microGridBaseCaseAssembledSwitchAtBoundary() throws XMLStreamException, IOE

@Test
void microGrid() throws IOException, XMLStreamException {
Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
ReadOnlyDataSource dataSource = CgmesConformity1Catalog.microGridType4BE().dataSource();
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), null);
Network actual = exportImportBusBranch(expected, dataSource);
compareNetworksEQdata(expected, actual);
}

@Test
void microGridCreateEquivalentInjectionAliases() throws IOException, XMLStreamException {
Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
ReadOnlyDataSource dataSource = CgmesConformity1Catalog.microGridBaseCaseBE().dataSource();
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), null);
// Remove aliases of equivalent injections, so they will have to be created during export
for (DanglingLine danglingLine : expected.getDanglingLines()) {
danglingLine.removeProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + "EquivalentInjection");
Expand All @@ -190,9 +169,7 @@ void nordic32() throws IOException, XMLStreamException {
void bPerSectionTest() throws IOException, XMLStreamException {
ReadOnlyDataSource ds = CgmesConformity1Catalog.microGridType4BE().dataSource();

Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
Network network = new CgmesImport().importData(ds, NetworkFactory.findDefault(), properties);
Network network = new CgmesImport().importData(ds, NetworkFactory.findDefault(), null);
ShuntCompensatorLinearModel sh = (ShuntCompensatorLinearModel) network.getShuntCompensator("d771118f-36e9-4115-a128-cc3d9ce3e3da").getModel();
assertEquals(0.024793, sh.getBPerSection(), 0.0);

Expand Down Expand Up @@ -247,10 +224,8 @@ void threeWindingsTransformerTest() throws IOException, XMLStreamException {

@Test
void testLoadGroups() throws XMLStreamException, IOException {
Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
ReadOnlyDataSource dataSource = CgmesConformity1ModifiedCatalog.microGridBaseCaseBEConformNonConformLoads().dataSource();
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), null);
Network actual = exportImportBusBranch(expected, dataSource);
compareNetworksEQdata(expected, actual);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private boolean inconsistentProfilesReported(ReporterModel reporter) {

private Network importNetwork(ReadOnlyDataSource dataSource) {
Properties params = new Properties();
params.put(CgmesImport.ID_MAPPING_FILE_NAMING_STRATEGY, NamingStrategyFactory.CGMES);
params.put(CgmesImport.NAMING_STRATEGY, NamingStrategyFactory.CGMES);
return Importers.importData("CGMES", dataSource, params);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Properties;

/**
* @author Marcos de Miguel <demiguelm at aia.es>
Expand Down Expand Up @@ -61,9 +60,7 @@ private void test(ReadOnlyDataSource dataSource) throws IOException, XMLStreamEx

private void test(ReadOnlyDataSource dataSource, boolean importSsh) throws IOException, XMLStreamException {
// Import original
Properties properties = new Properties();
properties.put(CgmesImport.CREATE_CGMES_EXPORT_MAPPING, "true");
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), null);

// Export TP
Path exportedTp = tmpDir.resolve("exportedTp.xml");
Expand All @@ -87,7 +84,7 @@ private void test(ReadOnlyDataSource dataSource, boolean importSsh) throws IOExc

// Import with new TP
Network actual = Network.read(repackaged,
DefaultComputationManagerConfig.load().createShortTimeExecutionComputationManager(), ImportConfig.load(), properties);
DefaultComputationManagerConfig.load().createShortTimeExecutionComputationManager(), ImportConfig.load(), null);

prepareNetworkForComparison(expected);
prepareNetworkForComparison(actual);
Expand Down