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

Additional clarifications on power flow inputs (SSH) and state values (SV) #1963

Merged
merged 9 commits into from
Feb 8, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ private Conversion.Config config(Properties p) {
p,
CREATE_BUSBAR_SECTION_FOR_EVERY_CONNECTIVITY_NODE_PARAMETER,
defaultValueConfig))
.setProfileUsedForInitialStateValues(
.setProfileForInitialValuesShuntSectionsTapPositions(
ConversionParameters.readStringParameter(
getFormat(),
p,
PROFILE_USED_FOR_INITIAL_STATE_VALUES_PARAMETER,
PROFILE_FOR_INITIAL_VALUES_SHUNT_SECTIONS_TAP_POSITIONS_PARAMETER,
defaultValueConfig))
.setStoreCgmesModelAsNetworkExtension(
ConversionParameters.readBooleanParameter(
Expand Down Expand Up @@ -248,7 +248,7 @@ private void copyStream(ReadOnlyDataSource from, DataSource to, String fromName,
public static final String IMPORT_CONTROL_AREAS = "iidm.import.cgmes.import-control-areas";
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_USED_FOR_INITIAL_STATE_VALUES = "iidm.import.cgmes.profile-used-for-initial-state-values";
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 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";

Expand Down Expand Up @@ -306,11 +306,12 @@ private void copyStream(ReadOnlyDataSource from, DataSource to, String fromName,
"The triplestore used during the import",
TripleStoreFactory.defaultImplementation())
.addAdditionalNames("powsyblTripleStore");
private static final Parameter PROFILE_USED_FOR_INITIAL_STATE_VALUES_PARAMETER = new Parameter(
PROFILE_USED_FOR_INITIAL_STATE_VALUES,
ParameterType.STRING,
"Profile used for initial state values",
"SSH");
private static final Parameter PROFILE_FOR_INITIAL_VALUES_SHUNT_SECTIONS_TAP_POSITIONS_PARAMETER = new Parameter(
PROFILE_FOR_INITIAL_VALUES_SHUNT_SECTIONS_TAP_POSITIONS,
ParameterType.STRING,
"Profile used for initial state values",
"SSH")
.addAdditionalNames("iidm.import.cgmes.profile-used-for-initial-state-values");
private static final Parameter STORE_CGMES_CONVERSION_CONTEXT_AS_NETWORK_EXTENSION_PARAMETER = new Parameter(
STORE_CGMES_CONVERSION_CONTEXT_AS_NETWORK_EXTENSION,
ParameterType.BOOLEAN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static com.powsybl.cgmes.conversion.Conversion.Config.StateProfile.SSH;

/**
Expand Down Expand Up @@ -757,18 +756,18 @@ public Config setConvertSvInjections(boolean convertSvInjections) {
return this;
}

public StateProfile getProfileUsedForInitialStateValues() {
return profileUsedForInitialStateValues;
public StateProfile getProfileForInitialValuesShuntSectionsTapPositions() {
return profileForInitialValuesShuntSectionsTapPositions;
}

public Config setProfileUsedForInitialStateValues(String profileUsedForInitialFlowsValues) {
switch (Objects.requireNonNull(profileUsedForInitialFlowsValues)) {
public Config setProfileForInitialValuesShuntSectionsTapPositions(String profileForInitialValuesShuntSectionsTapPositions) {
switch (Objects.requireNonNull(profileForInitialValuesShuntSectionsTapPositions)) {
case "SSH":
case "SV":
this.profileUsedForInitialStateValues = StateProfile.valueOf(profileUsedForInitialFlowsValues);
this.profileForInitialValuesShuntSectionsTapPositions = StateProfile.valueOf(profileForInitialValuesShuntSectionsTapPositions);
break;
default:
throw new CgmesModelException("Unexpected profile used for state hypothesis: " + profileUsedForInitialFlowsValues);
throw new CgmesModelException("Unexpected profile used for shunt sections / tap positions state hypothesis: " + profileForInitialValuesShuntSectionsTapPositions);
}
return this;
}
Expand Down Expand Up @@ -865,7 +864,7 @@ public void setXfmr3StructuralRatio(Xfmr3StructuralRatioInterpretationAlternativ

private boolean createBusbarSectionForEveryConnectivityNode = false;
private boolean convertSvInjections = true;
private StateProfile profileUsedForInitialStateValues = SSH;
private StateProfile profileForInitialValuesShuntSectionsTapPositions = SSH;
private boolean storeCgmesModelAsNetworkExtension = true;
private boolean storeCgmesConversionContextAsNetworkExtension = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void convertInsideBoundary() {
// is to accumulate the power flows of connected terminals at boundary node
for (int k = 1; k <= numTerminals; k++) {
if (terminalConnected(k)) {
context.boundary().addPowerFlowAtNode(nodeId(k), powerFlow(k));
context.boundary().addPowerFlowAtNode(nodeId(k), powerFlowSV(k));
}
}
}
Expand Down Expand Up @@ -261,7 +261,7 @@ public void convertToDanglingLine(int boundarySide, double r, double x, double g
// do it and assign the result at the terminal of the dangling line
if (context.config().computeFlowsAtBoundaryDanglingLines()
&& terminalConnected(modelSide)
&& !powerFlow(modelSide).defined()
&& !powerFlowSV(modelSide).defined()
&& context.boundary().hasVoltage(boundaryNode)) {

if (isZ0(dl)) {
Expand Down Expand Up @@ -426,45 +426,11 @@ private PowerFlow steadyStateHypothesisPowerFlow() {
}

PowerFlow powerFlow() {
switch (context.config().getProfileUsedForInitialStateValues()) {
case SSH:
if (steadyStateHypothesisPowerFlow().defined()) {
return steadyStateHypothesisPowerFlow();
}
if (stateVariablesPowerFlow().defined()) {
return stateVariablesPowerFlow();
}
break;
case SV:
if (stateVariablesPowerFlow().defined()) {
return stateVariablesPowerFlow();
}
if (steadyStateHypothesisPowerFlow().defined()) {
return steadyStateHypothesisPowerFlow();
}
break;
if (steadyStateHypothesisPowerFlow().defined()) {
return steadyStateHypothesisPowerFlow();
}
return PowerFlow.UNDEFINED;
}

PowerFlow powerFlow(int n) {
switch (context.config().getProfileUsedForInitialStateValues()) {
case SSH:
if (steadyStateHypothesisPowerFlow().defined()) {
return steadyStateHypothesisPowerFlow();
}
if (stateVariablesPowerFlow(n).defined()) {
return stateVariablesPowerFlow(n);
}
break;
case SV:
if (stateVariablesPowerFlow(n).defined()) {
return stateVariablesPowerFlow(n);
}
if (steadyStateHypothesisPowerFlow().defined()) {
return steadyStateHypothesisPowerFlow();
}
break;
if (stateVariablesPowerFlow().defined()) {
return stateVariablesPowerFlow();
}
return PowerFlow.UNDEFINED;
}
Expand Down Expand Up @@ -688,7 +654,7 @@ protected BoundaryLine createBoundaryLine(String boundaryNode) {
if (context.nodeBreaker()) {
modelNode = iidmNode(modelEnd);
}
PowerFlow modelPowerFlow = powerFlow(modelEnd);
PowerFlow modelPowerFlow = powerFlowSV(modelEnd);
return new BoundaryLine(id, name, modelIidmVoltageLevelId, modelBus, modelTconnected, modelNode,
modelTerminalId, boundaryTerminalId, modelPowerFlow);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public ShuntConversion(PropertyBag sh, Context context) {
}

private int getSections(PropertyBag p, int normalSections) {
switch (context.config().getProfileUsedForInitialStateValues()) {
switch (context.config().getProfileForInitialValuesShuntSectionsTapPositions()) {
case SSH:
return fromContinuous(p.asDouble("SSHsections", p.asDouble("SVsections", normalSections)));
case SV:
return fromContinuous(p.asDouble("SVsections", p.asDouble("SSHsections", normalSections)));
default:
throw new PowsyblException("Unexpected profile used for initial state values");
throw new PowsyblException("Unexpected profile used for initial values");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ static CgmesPhaseTapChangerBuilder newPhaseTapChanger(PropertyBag phaseTapChange
}

protected int initialTapPosition(int defaultStep) {
switch (context.config().getProfileUsedForInitialStateValues()) {
switch (context.config().getProfileForInitialValuesShuntSectionsTapPositions()) {
case SSH:
return AbstractObjectConversion.fromContinuous(p.asDouble(CgmesNames.STEP, p.asDouble(CgmesNames.SV_TAP_STEP, defaultStep)));
case SV:
return AbstractObjectConversion.fromContinuous(p.asDouble(CgmesNames.SV_TAP_STEP, p.asDouble(CgmesNames.STEP, defaultStep)));
default:
throw new CgmesModelException("Unexpected profile used for initial flows values: " + context.config().getProfileUsedForInitialStateValues());
throw new CgmesModelException("Unexpected profile used for initial values: " + context.config().getProfileForInitialValuesShuntSectionsTapPositions());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ private Network networkModel(TestGridModel testGridModel, Conversion.Config conf
CgmesModel cgmes = CgmesModelFactory.create(ds, impl);

config.setConvertSvInjections(true);
config.setProfileUsedForInitialStateValues(Conversion.Config.StateProfile.SSH.name());
Conversion c = new Conversion(cgmes, config);
Network n = c.convert();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ private static Network networkModel(TestGridModel testGridModel, Conversion.Conf
CgmesModel cgmes = CgmesModelFactory.create(ds, impl);

config.setConvertSvInjections(true);
config.setProfileUsedForInitialStateValues(Conversion.Config.StateProfile.SSH.name());
Conversion c = new Conversion(cgmes, config);
Network n = c.convert();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ private Network networkModel(TestGridModel testGridModel, Conversion.Config conf
CgmesModel cgmes = CgmesModelFactory.create(ds, impl);

config.setConvertSvInjections(true);
config.setProfileUsedForInitialStateValues(Conversion.Config.StateProfile.SSH.name());
Conversion c = new Conversion(cgmes, config);
Network n = c.convert();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ private Network networkModel(TestGridModel testGridModel, Conversion.Config conf
CgmesModel cgmes = CgmesModelFactory.create(ds, impl);

config.setConvertSvInjections(true);
config.setProfileUsedForInitialStateValues(Conversion.Config.StateProfile.SSH.name());
Conversion c = new Conversion(cgmes, config);
Network n = c.convert();

Expand All @@ -473,7 +472,6 @@ private Network networkModel(TestGridModel testGridModel, Conversion.Config conf
CgmesModel cgmes = CgmesModelFactory.create(ds, impl);

config.setConvertSvInjections(true);
config.setProfileUsedForInitialStateValues(Conversion.Config.StateProfile.SSH.name());
Conversion c = new Conversion(cgmes, config, postProcessors);
Network n = c.convert();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ private Network networkModel(TestGridModel testGridModel, Conversion.Config conf
CgmesModel cgmes = CgmesModelFactory.create(ds, impl);

config.setConvertSvInjections(true);
config.setProfileUsedForInitialStateValues(Conversion.Config.StateProfile.SSH.name());
Conversion c = new Conversion(cgmes, config);
return c.convert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void microGridBaseCaseBEBusBalanceValidation() throws IOException {
// the interpretation of the location of tap changer
// relative to the transmission impedance is correct
Properties params = new Properties();
params.put(CgmesImport.PROFILE_USED_FOR_INITIAL_STATE_VALUES, "SV");
params.put(CgmesImport.PROFILE_FOR_INITIAL_VALUES_SHUNT_SECTIONS_TAP_POSITIONS, "SV");
ConversionTester t = new ConversionTester(
params,
TripleStoreFactory.onlyDefaultImplementation(),
Expand Down Expand Up @@ -171,7 +171,7 @@ public void miniNodeBreakerBusBalanceValidation() throws IOException {
// that will be computed by IIDM from CGMES node-breaker ConnectivityNodes,
// have proper balances from SV values
Properties params = new Properties();
params.put(CgmesImport.PROFILE_USED_FOR_INITIAL_STATE_VALUES, "SV");
params.put(CgmesImport.PROFILE_FOR_INITIAL_VALUES_SHUNT_SECTIONS_TAP_POSITIONS, "SV");
ConversionTester t = new ConversionTester(
params,
TripleStoreFactory.onlyDefaultImplementation(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ private static Network networkModel(TestGridModel testGridModel, Conversion.Conf
CgmesModel cgmes = CgmesModelFactory.create(ds, impl);

config.setConvertSvInjections(true);
config.setProfileUsedForInitialStateValues(Conversion.Config.StateProfile.SSH.name());
Conversion c = new Conversion(cgmes, config);
Network n = c.convert();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public void miniBusBranchWithSvInjectionExportQ() throws IOException, XMLStreamE

private static Network importNetwork(ReadOnlyDataSource ds) {
Properties properties = new Properties();
properties.put("iidm.import.cgmes.profile-used-for-initial-state-values", "SV");
properties.put("iidm.import.cgmes.create-cgmes-export-mapping", "true");
return new CgmesImport().importData(ds, NetworkFactory.findDefault(), properties);
}
Expand Down Expand Up @@ -185,7 +184,6 @@ private void test(ReadOnlyDataSource dataSource, int svVersion, boolean exportFl
private void test(ReadOnlyDataSource dataSource, int svVersion, boolean exportFlowsForSwitches, Consumer<Repackager> repackagerConsumer) throws XMLStreamException, IOException {
// Import original
Properties properties = new Properties();
properties.put("iidm.import.cgmes.profile-used-for-initial-state-values", "SV");
properties.put("iidm.import.cgmes.create-cgmes-export-mapping", "true");
Network expected0 = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ private void test(ReadOnlyDataSource dataSource, int version, DifferenceEvaluato
private void test(ReadOnlyDataSource dataSource, int version, DifferenceEvaluator knownDiffsSsh, DifferenceEvaluator knownDiffsIidm) throws IOException, XMLStreamException {
// Import original
Properties properties = new Properties();
properties.put("iidm.import.cgmes.profile-used-for-initial-state-values", "SSH");
properties.put("iidm.import.cgmes.create-cgmes-export-mapping", "true");
Network expected = new CgmesImport().importData(dataSource, NetworkFactory.findDefault(), properties);

Expand Down