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

CGMES import: active power control extension is optional #2462

Merged
merged 4 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -244,6 +244,12 @@ private Conversion.Config config(ReadOnlyDataSource ds, Properties p) {
getFormat(),
p,
STORE_CGMES_CONVERSION_CONTEXT_AS_NETWORK_EXTENSION_PARAMETER,
defaultValueConfig))
.setCreateActivePowerControlExtension(
Parameter.readBoolean(
getFormat(),
p,
CREATE_ACTIVE_POWER_CONTROL_EXTENSION_PARAMETER,
defaultValueConfig));
String namingStrategy = Parameter.readString(getFormat(), p, ID_MAPPING_FILE_NAMING_STRATEGY_PARAMETER, defaultValueConfig);
String idMappingFilePath = Parameter.readString(getFormat(), p, ID_MAPPING_FILE_PATH_PARAMETER, defaultValueConfig);
Expand Down Expand Up @@ -298,6 +304,7 @@ private void copyStream(ReadOnlyDataSource from, DataSource to, String fromName,
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 SOURCE_FOR_IIDM_ID_MRID = "mRID";
public static final String SOURCE_FOR_IIDM_ID_RDFID = "rdfID";
Expand Down Expand Up @@ -377,6 +384,11 @@ private void copyStream(ReadOnlyDataSource from, DataSource to, String fromName,
ParameterType.BOOLEAN,
"Store the CGMES-IIDM terminal mapping as a network extension",
Boolean.FALSE);
private static final Parameter CREATE_ACTIVE_POWER_CONTROL_EXTENSION_PARAMETER = new Parameter(
CREATE_ACTIVE_POWER_CONTROL_EXTENSION,
ParameterType.BOOLEAN,
"Create active power control extension during import",
Boolean.FALSE);
private static final Parameter STORE_CGMES_MODEL_AS_NETWORK_EXTENSION_PARAMETER = new Parameter(
STORE_CGMES_MODEL_AS_NETWORK_EXTENSION,
ParameterType.BOOLEAN,
Expand Down Expand Up @@ -405,7 +417,8 @@ private void copyStream(ReadOnlyDataSource from, DataSource to, String fromName,
PROFILE_FOR_INITIAL_VALUES_SHUNT_SECTIONS_TAP_POSITIONS_PARAMETER,
SOURCE_FOR_IIDM_ID_PARAMETER,
STORE_CGMES_CONVERSION_CONTEXT_AS_NETWORK_EXTENSION_PARAMETER,
STORE_CGMES_MODEL_AS_NETWORK_EXTENSION_PARAMETER);
STORE_CGMES_MODEL_AS_NETWORK_EXTENSION_PARAMETER,
CREATE_ACTIVE_POWER_CONTROL_EXTENSION_PARAMETER);

private final Parameter boundaryLocationParameter;
private final Parameter postProcessorsParameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,15 @@ public Config setStoreCgmesConversionContextAsNetworkExtension(boolean storeCgme
return this;
}

public boolean createActivePowerControlExtension() {
return createActivePowerControlExtension;
}

public Config setCreateActivePowerControlExtension(boolean createActivePowerControlExtension) {
this.createActivePowerControlExtension = createActivePowerControlExtension;
return this;
}

public boolean isEnsureIdAliasUnicity() {
return ensureIdAliasUnicity;
}
Expand Down Expand Up @@ -896,6 +905,7 @@ public void setXfmr3StructuralRatio(Xfmr3StructuralRatioInterpretationAlternativ
private StateProfile profileForInitialValuesShuntSectionsTapPositions = SSH;
private boolean storeCgmesModelAsNetworkExtension = true;
private boolean storeCgmesConversionContextAsNetworkExtension = false;
private boolean createActivePowerControlExtension = false;

private boolean ensureIdAliasUnicity = false;
private boolean importControlAreas = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ public void convert() {
}
double normalPF = p.asDouble("normalPF");
if (!Double.isNaN(normalPF)) {
g.newExtension(ActivePowerControlAdder.class)
.withParticipate(normalPF != 0.0)
.withParticipationFactor(normalPF)
.add();
if (context.config().createActivePowerControlExtension()) {
g.newExtension(ActivePowerControlAdder.class)
.withParticipate(true)
.withParticipationFactor(normalPF)
.add();
} else {
g.setProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + "normalPF", String.valueOf(normalPF));
}
}
String generatingUnit = p.getId("GeneratingUnit");
if (generatingUnit != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,14 @@ private static void writeGeneratingUnitsParticitationFactors(Network network, St
}

private static GeneratingUnit generatingUnitForGenerator(Generator g, CgmesExportContext context) {
if (g.hasProperty(GENERATING_UNIT_PROPERTY) && (g.getExtension(ActivePowerControl.class) != null)) {
if (g.hasProperty(GENERATING_UNIT_PROPERTY) && ((g.getExtension(ActivePowerControl.class) != null) || g.hasProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + "normalPF"))) {
GeneratingUnit gu = new GeneratingUnit();
gu.id = context.getNamingStrategy().getCgmesIdFromProperty(g, GENERATING_UNIT_PROPERTY);
gu.participationFactor = g.getExtension(ActivePowerControl.class).getParticipationFactor();
if (g.getExtension(ActivePowerControl.class) != null) {
gu.participationFactor = g.getExtension(ActivePowerControl.class).getParticipationFactor();
} else {
gu.participationFactor = Double.valueOf(g.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + "normalPF"));
}
gu.className = generatingUnitClassname(g);
return gu;
}
Expand Down