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

Fixes in CGMES export #2574

Merged
merged 41 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
20ce48f
Remove regulation status from EQ
colinepiloquet May 23, 2023
e6e1820
Fix dependencies: remove one of double dependency to SSH in SV and ad…
colinepiloquet May 23, 2023
10be4e2
Change ReactiveCapabilityCurve CurveStyle to straightLineYValues
colinepiloquet May 23, 2023
164bd6b
Export power flows for switches to true
colinepiloquet May 23, 2023
1ce2bca
Add LoadArea and SubLoadArea in LoadGroups.
colinepiloquet May 23, 2023
76d1421
Add modelAuthoritySet in parameters.
colinepiloquet May 24, 2023
a384f1a
Add energyArea in ControlArea
colinepiloquet May 24, 2023
6a1765d
Add double max value parameter
colinepiloquet May 24, 2023
951c662
TopologicalIsland name should be less than 32 characters
colinepiloquet May 24, 2023
19f7404
Terminal must have a name: the one from the conducting equipment
colinepiloquet May 24, 2023
d70f8f3
RatedS for PowerTransformer and SynchronousMachine should be defined …
colinepiloquet May 24, 2023
b102a4f
fix : some terminals and busbar sections have the same mRID
colinepiloquet May 24, 2023
7e02227
Switches retained and connected to same bus on both side are ignored.
colinepiloquet May 24, 2023
a341214
MaxP of GeneratingUnit cannot be equal to 0.
colinepiloquet May 24, 2023
fce6799
Add interpolation of ReactiveCapabilityCurve + don't write ReactiveCa…
colinepiloquet May 24, 2023
9fccf09
Export all SvPowerflow for switches - tests to do.
colinepiloquet May 24, 2023
c548534
Write tieFlow for boundary
colinepiloquet May 24, 2023
1f24b03
EnergyConsumer should not be used, NonConformLoad by default - test t…
colinepiloquet May 24, 2023
2cfcad9
In EQ write positive minP and maxP - test to do.
colinepiloquet May 24, 2023
8731fc4
Revert "RatedS for PowerTransformer and SynchronousMachine should be …
colinepiloquet May 24, 2023
8b96355
Revert "MaxP of GeneratingUnit cannot be equal to 0."
colinepiloquet May 24, 2023
90b201f
Revert "Add interpolation of ReactiveCapabilityCurve + don't write Re…
colinepiloquet May 24, 2023
4db25e0
Revert "Export all SvPowerflow for switches - tests to do."
colinepiloquet May 24, 2023
1aa0ed4
Revert "EnergyConsumer should not be used, NonConformLoad by default …
colinepiloquet May 24, 2023
3c99bce
Revert "In EQ write positive minP and maxP - test to do."
colinepiloquet May 24, 2023
9510d70
Merge branch 'main' into fixes_cgmes_export
annetill May 25, 2023
a020f1a
Clean and add comments.
annetill May 25, 2023
23b8587
NonConformLoad by default if loadDetail is not null
colinepiloquet May 25, 2023
469240d
Fix kind of synchronous machine in EQ so that it fits the mode in SSH
colinepiloquet May 26, 2023
0e9bd79
Fix kind of synchronous machine in EQ so that it fits the mode in SSH
colinepiloquet May 26, 2023
b475196
RatedS for PowerTransformer and SynchronousMachine needs to be define…
colinepiloquet May 24, 2023
2f67462
Merge branch 'fixes_cgmes_export' of https://github.com/powsybl/powsy…
colinepiloquet May 31, 2023
f17656a
Merge branch 'main' into fixes_cgmes_export
annetill May 31, 2023
28d9590
Remove parameter max value from context.
annetill May 31, 2023
2243c0e
format max double always using scientific notation
zamarrenolm May 31, 2023
1dbd454
Clean.
annetill May 31, 2023
5acb1bf
synchronous machine: decide the kind using the P limits of the equipm…
zamarrenolm May 31, 2023
bea0a79
avoid code smell
zamarrenolm May 31, 2023
f429df2
Merge branch 'main' into fixes_cgmes_export
annetill May 31, 2023
8e844f3
comment on ignoring generator ratedS when comparing networks
zamarrenolm May 31, 2023
2a77fbd
Merge branch 'main' into fixes_cgmes_export
annetill May 31, 2023
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 @@ -76,6 +76,10 @@ public void export(Network network, Properties params, DataSource ds, Reporter r
.setBoundaryEqId(getBoundaryId("EQ", network, params, BOUNDARY_EQ_ID_PARAMETER))
.setBoundaryTpId(getBoundaryId("TP", network, params, BOUNDARY_TP_ID_PARAMETER))
.setReporter(reporter);
context.getEqModelDescription().setModelingAuthoritySet(Parameter.readString(getFormat(), params, MODELING_AUTHORITY_SET_PARAMETER, defaultValueConfig));
context.getTpModelDescription().setModelingAuthoritySet(Parameter.readString(getFormat(), params, MODELING_AUTHORITY_SET_PARAMETER, defaultValueConfig));
context.getSshModelDescription().setModelingAuthoritySet(Parameter.readString(getFormat(), params, MODELING_AUTHORITY_SET_PARAMETER, defaultValueConfig));
context.getSvModelDescription().setModelingAuthoritySet(Parameter.readString(getFormat(), params, MODELING_AUTHORITY_SET_PARAMETER, defaultValueConfig));
String cimVersionParam = Parameter.readString(getFormat(), params, CIM_VERSION_PARAMETER, defaultValueConfig);
if (cimVersionParam != null) {
context.setCimVersion(Integer.parseInt(cimVersionParam));
Expand Down Expand Up @@ -177,6 +181,7 @@ public String getFormat() {
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 MODELING_AUTHORITY_SET = "iidm.export.cgmes.modeling-authority-set";

private static final Parameter BASE_NAME_PARAMETER = new Parameter(
BASE_NAME,
Expand All @@ -193,17 +198,17 @@ public String getFormat() {
ENCODE_IDS,
ParameterType.BOOLEAN,
"Encode IDs as valid URI",
Boolean.TRUE);
CgmesExportContext.ENCODE_IDS_DEFAULT_VALUE);
private static final Parameter EXPORT_BOUNDARY_POWER_FLOWS_PARAMETER = new Parameter(
EXPORT_BOUNDARY_POWER_FLOWS,
ParameterType.BOOLEAN,
"Export boundaries' power flows",
Boolean.TRUE);
CgmesExportContext.EXPORT_BOUNDARY_POWER_FLOWS_DEFAULT_VALUE);
private static final Parameter EXPORT_POWER_FLOWS_FOR_SWITCHES_PARAMETER = new Parameter(
EXPORT_POWER_FLOWS_FOR_SWITCHES,
ParameterType.BOOLEAN,
"Export power flows for switches",
Boolean.FALSE);
CgmesExportContext.EXPORT_POWER_FLOWS_FOR_SWITCHES_DEFAULT_VALUE);
private static final Parameter NAMING_STRATEGY_PARAMETER = new Parameter(
NAMING_STRATEGY,
ParameterType.STRING,
Expand All @@ -227,6 +232,12 @@ public String getFormat() {
"Boundary TP model identifier",
null);

private static final Parameter MODELING_AUTHORITY_SET_PARAMETER = new Parameter(
MODELING_AUTHORITY_SET,
ParameterType.STRING,
"Modeling authority set",
"powsybl.org");

private static final List<Parameter> STATIC_PARAMETERS = List.of(
BASE_NAME_PARAMETER,
CIM_VERSION_PARAMETER,
Expand All @@ -235,7 +246,8 @@ public String getFormat() {
NAMING_STRATEGY_PARAMETER,
PROFILES_PARAMETER,
BOUNDARY_EQ_ID_PARAMETER,
BOUNDARY_TP_ID_PARAMETER);
BOUNDARY_TP_ID_PARAMETER,
MODELING_AUTHORITY_SET_PARAMETER);

private static final Logger LOG = LoggerFactory.getLogger(CgmesExport.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,15 @@ public class CgmesExportContext {

private NamingStrategy namingStrategy = new NamingStrategy.Identity();

private boolean exportBoundaryPowerFlows = true;
private boolean exportFlowsForSwitches = false;
annetill marked this conversation as resolved.
Show resolved Hide resolved
public static final boolean EXPORT_BOUNDARY_POWER_FLOWS_DEFAULT_VALUE = true;
public static final boolean EXPORT_POWER_FLOWS_FOR_SWITCHES_DEFAULT_VALUE = true;
public static final boolean ENCODE_IDS_DEFAULT_VALUE = true;
public static final double MAXIMUM_DOUBLE_DEFAULT_VALUE = Double.MAX_VALUE;

private boolean exportBoundaryPowerFlows = EXPORT_BOUNDARY_POWER_FLOWS_DEFAULT_VALUE;
private boolean exportFlowsForSwitches = EXPORT_POWER_FLOWS_FOR_SWITCHES_DEFAULT_VALUE;
private boolean exportEquipment = false;
private boolean encodeIds = true;
private boolean encodeIds = ENCODE_IDS_DEFAULT_VALUE;

private final Map<Double, BaseVoltageMapping.BaseVoltageSource> baseVoltageByNominalVoltageMapping = new HashMap<>();

Expand All @@ -69,7 +74,7 @@ public class CgmesExportContext {

// Update dependencies in a way that:
// [EQ.dependentOn EQ_BD]
// SV.dependentOn TP, SSH
// SV.dependentOn TP, SSH[, TP_BD]
// TP.dependentOn EQ[, EQ_BD][, TP_BD]
// SSH.dependentOn EQ
public void updateDependencies() {
Expand All @@ -89,14 +94,14 @@ public void updateDependencies() {
Set<String> sshModelIds = getSshModelDescription().getIds();
if (!sshModelIds.isEmpty()) {
getSvModelDescription().addDependencies(sshModelIds);
getSvModelDescription().addDependencies(sshModelIds);
}
if (boundaryEqId != null) {
getEqModelDescription().addDependency(boundaryEqId);
getTpModelDescription().addDependency(boundaryEqId);
}
if (boundaryTpId != null) {
getTpModelDescription().addDependency(boundaryTpId);
getSvModelDescription().addDependency(boundaryTpId);
}
}
}
Expand Down Expand Up @@ -339,6 +344,13 @@ public boolean isExportedEquipment(Identifiable<?> c) {
boolean ignored = c.isFictitious() &&
(c instanceof Load
|| c instanceof Switch && "true".equals(c.getProperty(Conversion.PROPERTY_IS_CREATED_FOR_DISCONNECTED_TERMINAL)));
if (c instanceof Switch) {
Switch ss = (Switch) c;
VoltageLevel.BusBreakerView view = ss.getVoltageLevel().getBusBreakerView();
if (ss.isRetained() && view.getBus1(ss.getId()).equals(view.getBus2(ss.getId()))) {
ignored = true;
}
}
return !ignored;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,20 @@ private CgmesExportUtil() {
private static final Pattern ENTSOE_BD_EXCEPTIONS_PATTERN1 = Pattern.compile("(?i)[a-f\\d]{8}-[a-f\\d]{4}-[a-f\\d]{4}-[a-f\\d]{4}-[a-f\\d]{7}");
private static final Pattern ENTSOE_BD_EXCEPTIONS_PATTERN2 = Pattern.compile("(?i)[a-f\\d]{8}[a-f\\d]{4}[a-f\\d]{4}[a-f\\d]{4}[a-f\\d]{12}");

private static double fixValue(double value) {
return Double.isNaN(value) ? 0.0 : value; // disconnected equipment in general, a bit dangerous.
}

public static String format(double value) {
return DOUBLE_FORMAT.format(Double.isNaN(value) ? 0.0 : value);
// Always use scientific format for extreme values
if (value == Double.MAX_VALUE || value == -Double.MAX_VALUE) {
return scientificFormat(value);
}
return DOUBLE_FORMAT.format(fixValue(value));
}

public static String scientificFormat(double value) {
return SCIENTIFIC_FORMAT.format(Double.isNaN(value) ? 0.0 : value);
return SCIENTIFIC_FORMAT.format(fixValue(value));
}

public static String format(int value) {
Expand Down Expand Up @@ -182,10 +190,10 @@ public static String loadClassName(LoadDetail loadDetail) {
if (loadDetail.getFixedActivePower() == 0 && loadDetail.getFixedReactivePower() == 0
&& (loadDetail.getVariableActivePower() != 0 || loadDetail.getVariableReactivePower() != 0)) {
return CgmesNames.CONFORM_LOAD;
}
// NonConform load if fixed part is non-zero and variable part is all zero
if (loadDetail.getVariableActivePower() == 0 && loadDetail.getVariableReactivePower() == 0
&& (loadDetail.getFixedActivePower() != 0 || loadDetail.getFixedReactivePower() != 0)) {
} else if (loadDetail.getVariableActivePower() == 0 && loadDetail.getVariableReactivePower() == 0
&& (loadDetail.getFixedActivePower() != 0 || loadDetail.getFixedReactivePower() != 0)) { // NonConform load if fixed part is non-zero and variable part is all zero
return CgmesNames.NONCONFORM_LOAD;
} else {
return CgmesNames.NONCONFORM_LOAD;
}
}
Expand Down
Loading