-
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.
Signed-off-by: lisrte <[email protected]>
- Loading branch information
Showing
11 changed files
with
249 additions
and
4 deletions.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShunt.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,55 @@ | ||
/** | ||
* Copyright (c) 2024, 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.shunts; | ||
|
||
import com.powsybl.dynawaltz.models.AbstractEquipmentBlackBoxModel; | ||
import com.powsybl.dynawaltz.models.VarConnection; | ||
import com.powsybl.dynawaltz.models.buses.EquipmentConnectionPoint; | ||
import com.powsybl.dynawaltz.models.macroconnections.MacroConnectionsAdder; | ||
import com.powsybl.iidm.network.ShuntCompensator; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>} | ||
*/ | ||
public class BaseShunt extends AbstractEquipmentBlackBoxModel<ShuntCompensator> implements ShuntModel { | ||
|
||
protected BaseShunt(String dynamicModelId, ShuntCompensator svarc, String parameterSetId, String lib) { | ||
super(dynamicModelId, parameterSetId, svarc, lib); | ||
} | ||
|
||
@Override | ||
public void createMacroConnections(MacroConnectionsAdder adder) { | ||
adder.createTerminalMacroConnections(this, equipment.getTerminal(), this::getVarConnectionsWith); | ||
} | ||
|
||
private List<VarConnection> getVarConnectionsWith(EquipmentConnectionPoint connected) { | ||
return List.of(new VarConnection("shunt_terminal", connected.getTerminalVarName())); | ||
} | ||
|
||
@Override | ||
public String getSwitchOffSignalEventVarName() { | ||
return "shunt_switchOffSignal2"; | ||
} | ||
|
||
@Override | ||
public String getStateVarName() { | ||
return "shunt_state"; | ||
} | ||
|
||
@Override | ||
public String getIsCapacitorVarName() { | ||
return "shunt_isCapacitor"; | ||
} | ||
|
||
@Override | ||
public String getIsAvailableVarName() { | ||
return "shunt_isAvailable"; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShuntBuilder.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,69 @@ | ||
/** | ||
* 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.shunts; | ||
|
||
import com.powsybl.commons.report.ReportNode; | ||
import com.powsybl.dynawaltz.builders.*; | ||
import com.powsybl.iidm.network.IdentifiableType; | ||
import com.powsybl.iidm.network.Network; | ||
import com.powsybl.iidm.network.ShuntCompensator; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>} | ||
*/ | ||
public class BaseShuntBuilder extends AbstractEquipmentModelBuilder<ShuntCompensator, BaseShuntBuilder> { | ||
|
||
public static final String CATEGORY = "BASE_SHUNT"; | ||
private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); | ||
|
||
public static BaseShuntBuilder of(Network network) { | ||
return of(network, ReportNode.NO_OP); | ||
} | ||
|
||
public static BaseShuntBuilder of(Network network, ReportNode reportNode) { | ||
return new BaseShuntBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reportNode); | ||
} | ||
|
||
public static BaseShuntBuilder of(Network network, String lib) { | ||
return of(network, lib, ReportNode.NO_OP); | ||
} | ||
|
||
public static BaseShuntBuilder of(Network network, String lib, ReportNode reportNode) { | ||
ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); | ||
if (modelConfig == null) { | ||
BuilderReports.reportLibNotFound(reportNode, BaseShuntBuilder.class.getSimpleName(), lib); | ||
return null; | ||
} | ||
return new BaseShuntBuilder(network, modelConfig, reportNode); | ||
} | ||
|
||
public static Set<String> getSupportedLibs() { | ||
return MODEL_CONFIGS.getSupportedLibs(); | ||
} | ||
|
||
protected BaseShuntBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { | ||
super(network, modelConfig, IdentifiableType.SHUNT_COMPENSATOR, reportNode); | ||
} | ||
|
||
@Override | ||
protected ShuntCompensator findEquipment(String staticId) { | ||
return network.getShuntCompensator(staticId); | ||
} | ||
|
||
@Override | ||
public BaseShunt build() { | ||
return isInstantiable() ? new BaseShunt(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib()) : null; | ||
} | ||
|
||
@Override | ||
protected BaseShuntBuilder self() { | ||
return this; | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/ShuntModelXmlTest.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,42 @@ | ||
/** | ||
* Copyright (c) 2024, 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.shunts.BaseShuntBuilder; | ||
import com.powsybl.iidm.network.test.ShuntTestCaseFactory; | ||
import org.junit.jupiter.api.Test; | ||
import org.xml.sax.SAXException; | ||
|
||
import javax.xml.stream.XMLStreamException; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>} | ||
*/ | ||
class ShuntModelXmlTest extends AbstractDynamicModelXmlTest { | ||
|
||
@Override | ||
protected void setupNetwork() { | ||
network = ShuntTestCaseFactory.create(); | ||
} | ||
|
||
@Override | ||
protected void addDynamicModels() { | ||
dynamicModels.add(BaseShuntBuilder.of(network, "ShuntB") | ||
.dynamicModelId("BBM_SHUNT") | ||
.staticId("SHUNT") | ||
.parameterSetId("sh") | ||
.build()); | ||
} | ||
|
||
@Test | ||
void writeModel() throws SAXException, IOException, XMLStreamException { | ||
DydXml.write(tmpDir, context); | ||
validate("dyd.xsd", "shunt_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
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<dyn:dynamicModelsArchitecture xmlns:dyn="http://www.rte-france.com/dynawo"> | ||
<dyn:blackBoxModel id="BBM_SHUNT" lib="ShuntB" parFile="models.par" parId="sh" staticId="SHUNT"/> | ||
<dyn:macroConnector id="MC_ShuntB-DefaultEquipmentConnectionPoint"> | ||
<dyn:connect var1="shunt_terminal" var2="@STATIC_ID@@NODE@_ACPIN"/> | ||
</dyn:macroConnector> | ||
<dyn:macroConnect connector="MC_ShuntB-DefaultEquipmentConnectionPoint" id1="BBM_SHUNT" id2="NETWORK"/> | ||
</dyn:dynamicModelsArchitecture> |