-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Static var compensator model * Add SVC integration test * Refactor Objects.requireNonNull use in equipment instantiation Signed-off-by: lisrte <laurent.issertial@rte-france.com>
- Loading branch information
Showing
22 changed files
with
379 additions
and
22 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
...waltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/models/svcs/SvcGroovyExtension.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
dynawaltz/src/main/java/com/powsybl/dynawaltz/models/svcs/StaticVarCompensatorModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/SvcModelXmlTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.