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

Refactor hvdc macro connect #199

Merged
merged 3 commits into from
Apr 20, 2023
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 @@ -10,10 +10,14 @@
import com.powsybl.commons.PowsyblException;
import com.powsybl.dynawaltz.DynaWaltzContext;
import com.powsybl.dynawaltz.models.AbstractBlackBoxModel;
import com.powsybl.dynawaltz.models.Side;
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.HvdcLine;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -47,20 +51,21 @@ public void createMacroConnections(DynaWaltzContext context) {
if (hvdc == null) {
throw new PowsyblException("Hvdc static id unknown: " + staticId);
}
createMacroConnections(getVarConnectionsWithConverters(), context);
createMacroConnections(BusUtils.getConnectableBusStaticId(hvdc.getConverterStation1().getTerminal()), BusModel.class, this::getVarConnectionsWithBus, context, Side.ONE);
createMacroConnections(BusUtils.getConnectableBusStaticId(hvdc.getConverterStation2().getTerminal()), BusModel.class, this::getVarConnectionsWithBus, context, Side.TWO);
}

@Override
public List<VarMapping> getVarsMapping() {
return VAR_MAPPING;
}

public List<VarConnection> getVarConnectionsWithConverters() {
return Arrays.asList(
new VarConnection("hvdc_terminal1", "@STATIC_ID@@NODE1@_ACPIN"),
new VarConnection("hvdc_switchOffSignal1Side1", "@STATIC_ID@@NODE1@_switchOff"),
new VarConnection("hvdc_terminal2", "@STATIC_ID@@NODE2@_ACPIN"),
new VarConnection("hvdc_switchOffSignal1Side2", "@STATIC_ID@@NODE2@_switchOff")
);
private List<VarConnection> getVarConnectionsWithBus(BusModel connected, Side side) {
List<VarConnection> varConnections = new ArrayList<>(2);
varConnections.add(new VarConnection("hvdc_terminal" + side.getSideNumber(), connected.getTerminalVarName()));
connected.getSwitchOffSignalVarName()
.map(switchOff -> new VarConnection("hvdc_switchOffSignal1" + side.getSideSuffix(), switchOff))
.ifPresent(varConnections::add);
return varConnections;
}
}
15 changes: 9 additions & 6 deletions dynawaltz/src/test/resources/hvdc_dyd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
<dyn:blackBoxModel id="BBM_L" lib="HvdcPV" parFile="models.par" parId="hv" staticId="L">
<dyn:macroStaticRef id="MSR_HvdcPV"/>
</dyn:blackBoxModel>
<dyn:macroConnector id="MC_HvdcPV">
<dyn:connect var1="hvdc_terminal1" var2="@STATIC_ID@@NODE1@_ACPIN"/>
<dyn:connect var1="hvdc_switchOffSignal1Side1" var2="@STATIC_ID@@NODE1@_switchOff"/>
<dyn:connect var1="hvdc_terminal2" var2="@STATIC_ID@@NODE2@_ACPIN"/>
<dyn:connect var1="hvdc_switchOffSignal1Side2" var2="@STATIC_ID@@NODE2@_switchOff"/>
<dyn:macroConnector id="MC_HvdcPVSide1-NetworkBus">
<dyn:connect var1="hvdc_terminal1" var2="@NAME@_ACPIN"/>
<dyn:connect var1="hvdc_switchOffSignal1Side1" var2="@NAME@_switchOff"/>
</dyn:macroConnector>
<dyn:macroConnector id="MC_HvdcPVSide2-NetworkBus">
<dyn:connect var1="hvdc_terminal2" var2="@NAME@_ACPIN"/>
<dyn:connect var1="hvdc_switchOffSignal1Side2" var2="@NAME@_switchOff"/>
</dyn:macroConnector>
<dyn:macroStaticReference id="MSR_HvdcPV">
<dyn:staticRef var="hvdc_PInj1Pu" staticVar="p1"/>
Expand All @@ -17,5 +19,6 @@
<dyn:staticRef var="hvdc_QInj2Pu" staticVar="q2"/>
<dyn:staticRef var="hvdc_state" staticVar="state2"/>
</dyn:macroStaticReference>
<dyn:macroConnect connector="MC_HvdcPV" id1="BBM_L" id2="NETWORK"/>
<dyn:macroConnect connector="MC_HvdcPVSide1-NetworkBus" id1="BBM_L" id2="NETWORK" name2="B1"/>
<dyn:macroConnect connector="MC_HvdcPVSide2-NetworkBus" id1="BBM_L" id2="NETWORK" name2="VL2_2"/>
</dyn:dynamicModelsArchitecture>