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

New HVDC AC emulation LoadFlow parameter #2009

Merged
merged 2 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -63,7 +63,8 @@ public enum ConnectedComponentMode {
// VERSION = 1.4 dc, distributedSlack, balanceType
// VERSION = 1.5 dcUseTransformerRatio, countriesToBalance, computedConnectedComponentScope
// VERSION = 1.6 shuntCompensatorVoltageControlOn instead of simulShunt
public static final String VERSION = "1.6";
// VERSION = 1.7 hvdcAcEmulation
public static final String VERSION = "1.7";

public static final VoltageInitMode DEFAULT_VOLTAGE_INIT_MODE = VoltageInitMode.UNIFORM_VALUES;
public static final boolean DEFAULT_TRANSFORMER_VOLTAGE_CONTROL_ON = false;
Expand All @@ -79,6 +80,7 @@ public enum ConnectedComponentMode {
public static final boolean DEFAULT_DC_USE_TRANSFORMER_RATIO_DEFAULT = true;
public static final Set<Country> DEFAULT_COUNTRIES_TO_BALANCE = EnumSet.noneOf(Country.class);
public static final ConnectedComponentMode DEFAULT_CONNECTED_COMPONENT_MODE = ConnectedComponentMode.MAIN;
public static final boolean DEFAULT_HVDC_AC_EMULATION_ON = true;

private static final Supplier<ExtensionProviders<ConfigLoader>> SUPPLIER =
Suppliers.memoize(() -> ExtensionProviders.createProvider(ConfigLoader.class, "loadflow-parameters"));
Expand Down Expand Up @@ -128,6 +130,7 @@ protected static void load(LoadFlowParameters parameters, PlatformConfig platfor
parameters.setDcUseTransformerRatio(config.getBooleanProperty("dcUseTransformerRatio", DEFAULT_DC_USE_TRANSFORMER_RATIO_DEFAULT));
parameters.setCountriesToBalance(config.getEnumSetProperty("countriesToBalance", Country.class, DEFAULT_COUNTRIES_TO_BALANCE));
parameters.setConnectedComponentMode(config.getEnumProperty("connectedComponentMode", ConnectedComponentMode.class, DEFAULT_CONNECTED_COMPONENT_MODE));
parameters.setHvdcAcEmulation(config.getBooleanProperty("hvdcAcEmulation", DEFAULT_HVDC_AC_EMULATION_ON));
});
}

Expand Down Expand Up @@ -159,11 +162,13 @@ protected static void load(LoadFlowParameters parameters, PlatformConfig platfor

private ConnectedComponentMode connectedComponentMode;

private boolean hvdcAcEmulation;

public LoadFlowParameters(VoltageInitMode voltageInitMode, boolean transformerVoltageControlOn,
boolean noGeneratorReactiveLimits, boolean phaseShifterRegulationOn,
boolean twtSplitShuntAdmittance, boolean shuntCompensatorVoltageControlOn, boolean readSlackBus, boolean writeSlackBus,
boolean dc, boolean distributedSlack, BalanceType balanceType, boolean dcUseTransformerRatio,
Set<Country> countriesToBalance, ConnectedComponentMode connectedComponentMode) {
Set<Country> countriesToBalance, ConnectedComponentMode connectedComponentMode, boolean hvdcAcEmulation) {
this.voltageInitMode = voltageInitMode;
this.transformerVoltageControlOn = transformerVoltageControlOn;
this.noGeneratorReactiveLimits = noGeneratorReactiveLimits;
Expand All @@ -178,13 +183,14 @@ public LoadFlowParameters(VoltageInitMode voltageInitMode, boolean transformerVo
this.dcUseTransformerRatio = dcUseTransformerRatio;
this.countriesToBalance = countriesToBalance;
this.connectedComponentMode = connectedComponentMode;
this.hvdcAcEmulation = hvdcAcEmulation;
}

public LoadFlowParameters(VoltageInitMode voltageInitMode, boolean transformerVoltageControlOn,
boolean noGeneratorReactiveLimits, boolean phaseShifterRegulationOn,
boolean twtSplitShuntAdmittance) {
this(voltageInitMode, transformerVoltageControlOn, noGeneratorReactiveLimits, phaseShifterRegulationOn, twtSplitShuntAdmittance, DEFAULT_SHUNT_COMPENSATOR_VOLTAGE_CONTROL_ON, DEFAULT_READ_SLACK_BUS, DEFAULT_WRITE_SLACK_BUS,
DEFAULT_DC, DEFAULT_DISTRIBUTED_SLACK, DEFAULT_BALANCE_TYPE, DEFAULT_DC_USE_TRANSFORMER_RATIO_DEFAULT, DEFAULT_COUNTRIES_TO_BALANCE, DEFAULT_CONNECTED_COMPONENT_MODE);
DEFAULT_DC, DEFAULT_DISTRIBUTED_SLACK, DEFAULT_BALANCE_TYPE, DEFAULT_DC_USE_TRANSFORMER_RATIO_DEFAULT, DEFAULT_COUNTRIES_TO_BALANCE, DEFAULT_CONNECTED_COMPONENT_MODE, DEFAULT_HVDC_AC_EMULATION_ON);
}

public LoadFlowParameters(VoltageInitMode voltageInitMode, boolean transformerVoltageControlOn) {
Expand Down Expand Up @@ -215,6 +221,7 @@ protected LoadFlowParameters(LoadFlowParameters other) {
dcUseTransformerRatio = other.dcUseTransformerRatio;
countriesToBalance = other.countriesToBalance;
connectedComponentMode = other.connectedComponentMode;
hvdcAcEmulation = other.hvdcAcEmulation;
}

public VoltageInitMode getVoltageInitMode() {
Expand Down Expand Up @@ -380,7 +387,8 @@ protected Map<String, Object> toMap() {
.put("balanceType", balanceType)
.put("dcUseTransformerRatio", dcUseTransformerRatio)
.put("countriesToBalance", countriesToBalance)
.put("computedConnectedComponentScope", connectedComponentMode);
.put("computedConnectedComponentScope", connectedComponentMode)
.put("hvdcAcEmulation", hvdcAcEmulation);
return immutableMapBuilder.build();
}

Expand Down Expand Up @@ -411,6 +419,15 @@ public LoadFlowParameters setConnectedComponentMode(ConnectedComponentMode conne
return this;
}

public boolean isHvdcAcEmulation() {
return hvdcAcEmulation;
}

public LoadFlowParameters setHvdcAcEmulation(boolean hvdcAcEmulation) {
this.hvdcAcEmulation = hvdcAcEmulation;
return this;
}

/**
* This copy methods uses json serializer mechanism to rebuild all extensions in the this parameters.
* If an extension's serializer not found via {@code @AutoService}, the extension would be lost in copied.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ public LoadFlowParameters deserialize(JsonParser parser, DeserializationContext
parameters.setConnectedComponentMode(parser.readValueAs(LoadFlowParameters.ConnectedComponentMode.class));
break;

case "hvdcAcEmulation":
JsonUtil.assertGreaterOrEqualThanReferenceVersion(CONTEXT_NAME, "Tag: hvdcAcEmulation" + parser.getCurrentName(), version, "1.7");
parser.nextToken();
parameters.setHvdcAcEmulation(parser.readValueAs(Boolean.class));
break;

case "extensions":
parser.nextToken();
extensions = JsonUtil.updateExtensions(parser, deserializationContext, JsonLoadFlowParameters.getExtensionSerializers(), parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void serialize(LoadFlowParameters parameters, JsonGenerator jsonGenerator
}
jsonGenerator.writeEndArray();
jsonGenerator.writeStringField("connectedComponentMode", parameters.getConnectedComponentMode().name());
jsonGenerator.writeBooleanField("hvdcAcEmulation", parameters.isHvdcAcEmulation());

JsonUtil.writeExtensions(parameters, jsonGenerator, serializerProvider, JsonLoadFlowParameters.getExtensionSerializers());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ private void checkValues(LoadFlowParameters parameters, LoadFlowParameters.Volta
boolean simulShunt, boolean readSlackBus, boolean writeSlackBus,
boolean dc, boolean distributedSlack, LoadFlowParameters.BalanceType balanceType,
boolean dcUseTransformerRatio, Set<Country> countriesToBalance,
LoadFlowParameters.ConnectedComponentMode computedConnectedComponent) {
LoadFlowParameters.ConnectedComponentMode computedConnectedComponent,
boolean hvdcAcEmulation) {
assertEquals(parameters.getVoltageInitMode(), voltageInitMode);
assertEquals(parameters.isTransformerVoltageControlOn(), transformerVoltageControlOn);
assertEquals(parameters.isPhaseShifterRegulationOn(), phaseShifterRegulationOn);
Expand All @@ -77,6 +78,7 @@ private void checkValues(LoadFlowParameters parameters, LoadFlowParameters.Volta
assertEquals(parameters.isDcUseTransformerRatio(), dcUseTransformerRatio);
assertEquals(parameters.getCountriesToBalance(), countriesToBalance);
assertEquals(parameters.getConnectedComponentMode(), computedConnectedComponent);
assertEquals(parameters.isHvdcAcEmulation(), hvdcAcEmulation);
}

@Test
Expand All @@ -96,7 +98,8 @@ public void testNoConfig() {
LoadFlowParameters.DEFAULT_BALANCE_TYPE,
LoadFlowParameters.DEFAULT_DC_USE_TRANSFORMER_RATIO_DEFAULT,
LoadFlowParameters.DEFAULT_COUNTRIES_TO_BALANCE,
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE);
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE,
LoadFlowParameters.DEFAULT_HVDC_AC_EMULATION_ON);
}

@Test
Expand All @@ -116,6 +119,7 @@ public void checkConfig() {
boolean dcUseTransformerRatio = true;
Set<Country> countriesToBalance = new HashSet<>();
LoadFlowParameters.ConnectedComponentMode computedConnectedComponent = LoadFlowParameters.ConnectedComponentMode.MAIN;
boolean hvdcAcEmulation = true;

MapModuleConfig moduleConfig = platformConfig.createModuleConfig("load-flow-default-parameters");
moduleConfig.setStringProperty("voltageInitMode", "UNIFORM_VALUES");
Expand All @@ -133,12 +137,13 @@ public void checkConfig() {
moduleConfig.setStringProperty("dcUseTransformerRatio", Boolean.toString(dc));
moduleConfig.setStringListProperty("countriesToBalance", countriesToBalance.stream().map(e -> e.name()).collect(Collectors.toList()));
moduleConfig.setStringProperty("computedConnectedComponent", computedConnectedComponent.name());
moduleConfig.setStringProperty("hvdcAcEmulation", Boolean.toString(hvdcAcEmulation));

LoadFlowParameters parameters = new LoadFlowParameters();
LoadFlowParameters.load(parameters, platformConfig);
checkValues(parameters, voltageInitMode, transformerVoltageControlOn,
noGeneratorReactiveLimits, phaseShifterRegulationOn, twtSplitShuntAdmittance, simulShunt, readSlackBus, writeSlackBus,
dc, distributedSlack, balanceType, dcUseTransformerRatio, countriesToBalance, computedConnectedComponent);
dc, distributedSlack, balanceType, dcUseTransformerRatio, countriesToBalance, computedConnectedComponent, hvdcAcEmulation);
}

@Test
Expand All @@ -154,7 +159,7 @@ public void checkIncompleteConfig() {
LoadFlowParameters.DEFAULT_SHUNT_COMPENSATOR_VOLTAGE_CONTROL_ON, LoadFlowParameters.DEFAULT_READ_SLACK_BUS, LoadFlowParameters.DEFAULT_WRITE_SLACK_BUS,
LoadFlowParameters.DEFAULT_DC, LoadFlowParameters.DEFAULT_DISTRIBUTED_SLACK, LoadFlowParameters.DEFAULT_BALANCE_TYPE,
LoadFlowParameters.DEFAULT_DC_USE_TRANSFORMER_RATIO_DEFAULT, LoadFlowParameters.DEFAULT_COUNTRIES_TO_BALANCE,
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE);
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE, LoadFlowParameters.DEFAULT_HVDC_AC_EMULATION_ON);
}

@Test
Expand All @@ -167,7 +172,7 @@ public void checkDefaultPlatformConfig() {
LoadFlowParameters.DEFAULT_SHUNT_COMPENSATOR_VOLTAGE_CONTROL_ON, LoadFlowParameters.DEFAULT_READ_SLACK_BUS, LoadFlowParameters.DEFAULT_WRITE_SLACK_BUS,
LoadFlowParameters.DEFAULT_DC, LoadFlowParameters.DEFAULT_DISTRIBUTED_SLACK, LoadFlowParameters.DEFAULT_BALANCE_TYPE,
LoadFlowParameters.DEFAULT_DC_USE_TRANSFORMER_RATIO_DEFAULT, LoadFlowParameters.DEFAULT_COUNTRIES_TO_BALANCE,
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE);
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE, LoadFlowParameters.DEFAULT_HVDC_AC_EMULATION_ON);
}

@Test
Expand All @@ -180,7 +185,7 @@ public void checkConstructorByVoltageInitMode() {
LoadFlowParameters.DEFAULT_SHUNT_COMPENSATOR_VOLTAGE_CONTROL_ON, LoadFlowParameters.DEFAULT_READ_SLACK_BUS, LoadFlowParameters.DEFAULT_WRITE_SLACK_BUS,
LoadFlowParameters.DEFAULT_DC, LoadFlowParameters.DEFAULT_DISTRIBUTED_SLACK, LoadFlowParameters.DEFAULT_BALANCE_TYPE,
LoadFlowParameters.DEFAULT_DC_USE_TRANSFORMER_RATIO_DEFAULT, LoadFlowParameters.DEFAULT_COUNTRIES_TO_BALANCE,
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE);
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE, LoadFlowParameters.DEFAULT_HVDC_AC_EMULATION_ON);
}

@Test
Expand All @@ -199,7 +204,8 @@ public void checkConstructorByVoltageInitModeAndTransformerVoltageControlOn() {
LoadFlowParameters.DEFAULT_BALANCE_TYPE,
LoadFlowParameters.DEFAULT_DC_USE_TRANSFORMER_RATIO_DEFAULT,
LoadFlowParameters.DEFAULT_COUNTRIES_TO_BALANCE,
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE);
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE,
LoadFlowParameters.DEFAULT_HVDC_AC_EMULATION_ON);
}

@Test
Expand All @@ -218,7 +224,8 @@ public void checkConstructorByLoadFlowParameters() {
LoadFlowParameters.DEFAULT_BALANCE_TYPE,
LoadFlowParameters.DEFAULT_DC_USE_TRANSFORMER_RATIO_DEFAULT,
LoadFlowParameters.DEFAULT_COUNTRIES_TO_BALANCE,
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE);
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE,
LoadFlowParameters.DEFAULT_HVDC_AC_EMULATION_ON);

LoadFlowParameters parameters1 = new LoadFlowParameters(parameters);
parameters1.setDc(true);
Expand All @@ -237,7 +244,8 @@ public void checkConstructorByLoadFlowParameters() {
LoadFlowParameters.BalanceType.PROPORTIONAL_TO_LOAD,
LoadFlowParameters.DEFAULT_DC_USE_TRANSFORMER_RATIO_DEFAULT,
LoadFlowParameters.DEFAULT_COUNTRIES_TO_BALANCE,
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE);
LoadFlowParameters.DEFAULT_CONNECTED_COMPONENT_MODE,
LoadFlowParameters.DEFAULT_HVDC_AC_EMULATION_ON);
}

@Test
Expand All @@ -256,6 +264,7 @@ public void checkSetters() {
boolean dcUseTransformerRatio = true;
Set<Country> countriesToBalance = new HashSet<>();
LoadFlowParameters.ConnectedComponentMode computedConnectedComponent = LoadFlowParameters.ConnectedComponentMode.MAIN;
boolean hvdcAcEmulation = false;

LoadFlowParameters parameters = new LoadFlowParameters();
LoadFlowParameters.load(parameters, platformConfig);
Expand All @@ -269,11 +278,12 @@ public void checkSetters() {
.setWriteSlackBus(writeSlackBus)
.setDc(dc)
.setDistributedSlack(distributedSlack)
.setBalanceType(balanceType);
.setBalanceType(balanceType)
.setHvdcAcEmulation(hvdcAcEmulation);

checkValues(parameters, voltageInitMode, transformerVoltageControlOn, noGeneratorReactiveLimits,
phaseShifterRegulationOn, twtSplitShuntAdmittance, simulShunt, readSlackBus, writeSlackBus,
dc, distributedSlack, balanceType, dcUseTransformerRatio, countriesToBalance, computedConnectedComponent);
dc, distributedSlack, balanceType, dcUseTransformerRatio, countriesToBalance, computedConnectedComponent, hvdcAcEmulation);
}

@Test
Expand All @@ -292,15 +302,16 @@ public void checkClone() {
boolean dcUseTransformerRatio = true;
Set<Country> countriesToBalance = new HashSet<>();
LoadFlowParameters.ConnectedComponentMode computedConnectedComponent = LoadFlowParameters.ConnectedComponentMode.MAIN;
boolean hvdcAcEmulation = true;
LoadFlowParameters parameters = new LoadFlowParameters(voltageInitMode, transformerVoltageControlOn,
noGeneratorReactiveLimits, phaseShifterRegulationOn, twtSplitShuntAdmittance, simulShunt, readSlackBus, writeSlackBus,
dc, distributedSlack, balanceType, dcUseTransformerRatio, countriesToBalance, computedConnectedComponent);
dc, distributedSlack, balanceType, dcUseTransformerRatio, countriesToBalance, computedConnectedComponent, hvdcAcEmulation);
LoadFlowParameters parametersCloned = parameters.copy();
checkValues(parametersCloned, parameters.getVoltageInitMode(), parameters.isTransformerVoltageControlOn(),
parameters.isNoGeneratorReactiveLimits(), parameters.isPhaseShifterRegulationOn(), parameters.isTwtSplitShuntAdmittance(),
parameters.isShuntCompensatorVoltageControlOn(), parameters.isReadSlackBus(), parameters.isWriteSlackBus(),
parameters.isDc(), parameters.isDistributedSlack(), parameters.getBalanceType(), parameters.isDcUseTransformerRatio(),
parameters.getCountriesToBalance(), parameters.getConnectedComponentMode());
parameters.getCountriesToBalance(), parameters.getConnectedComponentMode(), parameters.isHvdcAcEmulation());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ public void readJsonVersion16() {
assertFalse(parameters.isShuntCompensatorVoltageControlOn());
}

@Test
public void readJsonVersion17() {
LoadFlowParameters parameters = JsonLoadFlowParameters
.read(getClass().getResourceAsStream("/LoadFlowParametersVersion17.json"));
assertTrue(parameters.isHvdcAcEmulation());
}

@Test
public void readJsonVersion10Exception() {
InputStream inputStream = getClass().getResourceAsStream("/LoadFlowParametersVersion10Exception.json");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version" : "1.6",
"version" : "1.7",
"voltageInitMode" : "PREVIOUS_VALUES",
"transformerVoltageControlOn" : true,
"phaseShifterRegulationOn" : false,
Expand All @@ -13,5 +13,6 @@
"balanceType" : "PROPORTIONAL_TO_GENERATION_P_MAX",
"dcUseTransformerRatio" : true,
"countriesToBalance" : [ ],
"connectedComponentMode" : "MAIN"
"connectedComponentMode" : "MAIN",
"hvdcAcEmulation" : true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version" : "1.7",
"voltageInitMode" : "PREVIOUS_VALUES",
"transformerVoltageControlOn" : true,
"phaseShifterRegulationOn" : false,
"noGeneratorReactiveLimits" : true,
"twtSplitShuntAdmittance" : false,
"shuntCompensatorVoltageControlOn" : false,
"readSlackBus" : false,
"writeSlackBus" : false,
"dc" : false,
"distributedSlack" : true,
"balanceType" : "PROPORTIONAL_TO_GENERATION_P_MAX",
"dcUseTransformerRatio" : true,
"countriesToBalance" : [ "FR" , "KI" ],
"connectedComponentMode" : "MAIN",
"hvdcAcEmulation" : true
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version" : "1.6",
"version" : "1.7",
"voltageInitMode" : "UNIFORM_VALUES",
"transformerVoltageControlOn" : false,
"phaseShifterRegulationOn" : false,
Expand All @@ -14,6 +14,7 @@
"dcUseTransformerRatio" : true,
"countriesToBalance" : [ ],
"connectedComponentMode" : "MAIN",
"hvdcAcEmulation" : true,
"extensions" : {
"dummy-extension" : { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"high-voltage-absolute-threshold" : 0.0
},
"load-flow-parameters" : {
"version" : "1.6",
"version" : "1.7",
"voltageInitMode" : "UNIFORM_VALUES",
"transformerVoltageControlOn" : false,
"phaseShifterRegulationOn" : false,
Expand All @@ -22,6 +22,7 @@
"balanceType" : "PROPORTIONAL_TO_GENERATION_P_MAX",
"dcUseTransformerRatio" : true,
"countriesToBalance" : [ ],
"connectedComponentMode" : "MAIN"
"connectedComponentMode" : "MAIN",
"hvdcAcEmulation" : true
}
}
Loading