-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add static var compensator #201
Changes from all commits
c9cc867
c339335
08ae043
178a32a
4fcac1d
fa4a10c
e4d7cca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com/) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.dynawaltz.dsl.models.svcs | ||
|
||
import com.google.auto.service.AutoService | ||
import com.powsybl.dsl.DslException | ||
import com.powsybl.dynamicsimulation.DynamicModel | ||
import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension | ||
import com.powsybl.dynawaltz.dsl.AbstractEquipmentGroovyExtension | ||
import com.powsybl.dynawaltz.dsl.models.builders.AbstractDynamicModelBuilder | ||
import com.powsybl.dynawaltz.models.svcs.StaticVarCompensatorModel | ||
import com.powsybl.iidm.network.Network | ||
import com.powsybl.iidm.network.StaticVarCompensator | ||
|
||
/** | ||
* @author Laurent Issertial <laurent.issertial at rte-france.com> | ||
*/ | ||
@AutoService(DynamicModelGroovyExtension.class) | ||
class SvcGroovyExtension extends AbstractEquipmentGroovyExtension<DynamicModel> implements DynamicModelGroovyExtension { | ||
|
||
protected static final String SVC = "staticVarCompensators" | ||
|
||
SvcGroovyExtension() { | ||
ConfigSlurper config = new ConfigSlurper() | ||
modelTags = config.parse(this.getClass().getClassLoader().getResource(MODELS_CONFIG)).get(SVC).keySet() as List | ||
} | ||
|
||
@Override | ||
protected SvcBuilder createBuilder(Network network, String currentTag) { | ||
new SvcBuilder(network, currentTag) | ||
} | ||
|
||
static class SvcBuilder extends AbstractDynamicModelBuilder { | ||
|
||
StaticVarCompensator svc | ||
String tag | ||
|
||
SvcBuilder(Network network, String tag) { | ||
super(network) | ||
this.tag = tag | ||
} | ||
|
||
void checkData() { | ||
super.checkData() | ||
svc = network.getStaticVarCompensator(staticId) | ||
if (svc == null) { | ||
throw new DslException("Static var compensator static id unknown: " + staticId) | ||
} | ||
} | ||
|
||
@Override | ||
StaticVarCompensatorModel build() { | ||
checkData() | ||
new StaticVarCompensatorModel(dynamicModelId, svc, parameterSetId, tag) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,10 +23,12 @@ | |
import com.powsybl.dynawaltz.models.lines.StandardLine; | ||
import com.powsybl.dynawaltz.models.loads.LoadAlphaBeta; | ||
import com.powsybl.dynawaltz.models.loads.LoadOneTransformer; | ||
import com.powsybl.dynawaltz.models.svcs.StaticVarCompensatorModel; | ||
import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatio; | ||
import com.powsybl.iidm.network.Network; | ||
import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; | ||
import com.powsybl.iidm.network.test.HvdcTestNetwork; | ||
import com.powsybl.iidm.network.test.SvcTestCaseFactory; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
|
@@ -48,7 +50,7 @@ class DynamicModelsSupplierTest extends AbstractModelSupplierTest { | |
|
||
@Test | ||
void testGroovyExtensionCount() { | ||
assertEquals(10, EXTENSIONS.size()); | ||
assertEquals(11, EXTENSIONS.size()); | ||
} | ||
|
||
@ParameterizedTest(name = "{0}") | ||
|
@@ -91,7 +93,8 @@ private static Stream<Arguments> provideEquipmentModelData() { | |
Arguments.of("genFictitious", GeneratorFictitious.class, EurostagTutorialExample1Factory.create(), "GEN", "BBM_GEN", "GF", "GeneratorFictitious"), | ||
Arguments.of("gen", GeneratorSynchronous.class, EurostagTutorialExample1Factory.create(), "GEN", "BBM_GEN", "GSFWPR", "GeneratorSynchronousFourWindingsProportionalRegulations"), | ||
Arguments.of("omegaGen", OmegaRefGenerator.class, EurostagTutorialExample1Factory.create(), "GEN", "BBM_GEN", "GPQ", "GeneratorPQ"), | ||
Arguments.of("transformer", TransformerFixedRatio.class, EurostagTutorialExample1Factory.create(), "NGEN_NHV1", "BBM_NGEN_NHV1", "TFR", "TransformerFixedRatio") | ||
Arguments.of("transformer", TransformerFixedRatio.class, EurostagTutorialExample1Factory.create(), "NGEN_NHV1", "BBM_NGEN_NHV1", "TFR", "TransformerFixedRatio"), | ||
Arguments.of("svc", StaticVarCompensatorModel.class, SvcTestCaseFactory.create(), "SVC2", "BBM_SVC", "svc", "StaticVarCompensatorPV") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a comment, which is not related to current PR, thus this should not be addressed here. As the name of the file is deduced in |
||
); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com/) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package dynamicModels | ||
|
||
StaticVarCompensatorPV { | ||
staticId "SVC2" | ||
dynamicModelId "BBM_SVC" | ||
parameterSetId "svc" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com/) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.dynawaltz.models.svcs; | ||
|
||
import com.powsybl.dynawaltz.DynaWaltzContext; | ||
import com.powsybl.dynawaltz.models.AbstractEquipmentBlackBoxModel; | ||
import com.powsybl.dynawaltz.models.VarConnection; | ||
import com.powsybl.dynawaltz.models.VarMapping; | ||
import com.powsybl.dynawaltz.models.buses.BusModel; | ||
import com.powsybl.dynawaltz.models.utils.BusUtils; | ||
import com.powsybl.iidm.network.StaticVarCompensator; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* @author Laurent Issertial <laurent.issertial at rte-france.com> | ||
*/ | ||
public class StaticVarCompensatorModel extends AbstractEquipmentBlackBoxModel<StaticVarCompensator> { | ||
|
||
private static final List<VarMapping> VAR_MAPPING = Arrays.asList( | ||
new VarMapping("SVarC_injector_PInjPu", "p"), | ||
new VarMapping("SVarC_injector_QInjPu", "q"), | ||
new VarMapping("SVarC_injector_state", "state"), | ||
new VarMapping("SVarC_modeHandling_mode_value", "regulatingMode")); | ||
|
||
private final String compensatorLib; | ||
|
||
public StaticVarCompensatorModel(String dynamicModelId, StaticVarCompensator svc, String parameterSetId, String compensatorLib) { | ||
super(dynamicModelId, parameterSetId, svc); | ||
this.compensatorLib = Objects.requireNonNull(compensatorLib); | ||
} | ||
|
||
@Override | ||
public void createMacroConnections(DynaWaltzContext context) { | ||
createMacroConnections(BusUtils.getConnectableBusStaticId(equipment), BusModel.class, this::getVarConnectionsWithBus, context); | ||
} | ||
|
||
private List<VarConnection> getVarConnectionsWithBus(BusModel connected) { | ||
return List.of(new VarConnection("SVarC_terminal", connected.getTerminalVarName())); | ||
} | ||
|
||
@Override | ||
public List<VarMapping> getVarsMapping() { | ||
return VAR_MAPPING; | ||
} | ||
|
||
@Override | ||
public String getLib() { | ||
return compensatorLib; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com/) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.dynawaltz.xml; | ||
|
||
import com.powsybl.dynawaltz.models.svcs.StaticVarCompensatorModel; | ||
import com.powsybl.iidm.network.test.SvcTestCaseFactory; | ||
import org.junit.jupiter.api.Test; | ||
import org.xml.sax.SAXException; | ||
|
||
import javax.xml.stream.XMLStreamException; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author Laurent Issertial <laurent.issertial at rte-france.com> | ||
*/ | ||
class SvcModelXmlTest extends AbstractDynamicModelXmlTest { | ||
|
||
@Override | ||
protected void setupNetwork() { | ||
network = SvcTestCaseFactory.create(); | ||
} | ||
|
||
@Override | ||
protected void addDynamicModels() { | ||
dynamicModels.add(new StaticVarCompensatorModel("BBM_SVC2", network.getStaticVarCompensator("SVC2"), "svc", "StaticVarCompensator")); | ||
} | ||
|
||
@Test | ||
void writeSvcModel() throws SAXException, IOException, XMLStreamException { | ||
DydXml.write(tmpDir, context); | ||
validate("dyd.xsd", "svc_dyd.xml", tmpDir.resolve(DynaWaltzConstants.DYD_FILENAME)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<dyn:dynamicModelsArchitecture xmlns:dyn="http://www.rte-france.com/dynawo"> | ||
<dyn:blackBoxModel id="BBM_SVC2" lib="StaticVarCompensator" parFile="models.par" parId="svc" staticId="SVC2"> | ||
<dyn:macroStaticRef id="MSR_StaticVarCompensator"/> | ||
</dyn:blackBoxModel> | ||
<dyn:macroConnector id="MC_StaticVarCompensator-NetworkBus"> | ||
<dyn:connect var1="SVarC_terminal" var2="@NAME@_ACPIN"/> | ||
</dyn:macroConnector> | ||
<dyn:macroStaticReference id="MSR_StaticVarCompensator"> | ||
<dyn:staticRef var="SVarC_injector_PInjPu" staticVar="p"/> | ||
<dyn:staticRef var="SVarC_injector_QInjPu" staticVar="q"/> | ||
<dyn:staticRef var="SVarC_injector_state" staticVar="state"/> | ||
<dyn:staticRef var="SVarC_modeHandling_mode_value" staticVar="regulatingMode"/> | ||
</dyn:macroStaticReference> | ||
<dyn:macroConnect connector="MC_StaticVarCompensator-NetworkBus" id1="BBM_SVC2" id2="NETWORK" name2="B2"/> | ||
</dyn:dynamicModelsArchitecture> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we keep that unit test?