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

Get original ID #494

Merged
merged 9 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
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 @@ -7,6 +7,7 @@
package com.powsybl.openloadflow.network;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

Expand All @@ -27,6 +28,11 @@ protected AbstractElement(LfNetwork network) {
this.network = Objects.requireNonNull(network);
}

@Override
public List<String> getOriginalIds() {
return List.of(getId());
}

public int getNum() {
return num;
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/powsybl/openloadflow/network/LfBranch.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ public interface LfBranch extends LfElement {

double LOW_IMPEDANCE_THRESHOLD = Math.pow(10, -8); // in per unit

enum BranchType {
LINE,
TRANSFO_2,
TRANSFO_3_LEG_1,
TRANSFO_3_LEG_2,
TRANSFO_3_LEG_3,
DANGLING_LINE,
SWITCH
}

class LfLimit {

private int acceptableDuration;
Expand Down Expand Up @@ -55,6 +65,8 @@ public void setAcceptableDuration(int acceptableDuration) {
}
}

BranchType getBranchType();

LfBus getBus1();

LfBus getBus2();
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/powsybl/openloadflow/network/LfElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
*/
package com.powsybl.openloadflow.network;

import java.util.List;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface LfElement {

String getId();

List<String> getOriginalIds();

ElementType getType();

int getNum();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ enum GeneratorControlType {

String getId();

String getOriginalId();

LfBus getBus();

void setBus(LfBus bus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ protected AbstractLfGenerator(double targetP) {
this.targetP = targetP;
}

@Override
public String getOriginalId() {
return getId();
}

public LfBus getBus() {
return bus;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ public String getId() {
return branch.getId();
}

@Override
public BranchType getBranchType() {
return branch instanceof Line ? BranchType.LINE : BranchType.TRANSFO_2;
}

@Override
public boolean hasPhaseControlCapability() {
return branch.getType() == IdentifiableType.TWO_WINDINGS_TRANSFORMER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public String getId() {
return danglingLine.getId();
}

@Override
public BranchType getBranchType() {
return BranchType.DANGLING_LINE;
}

@Override
public boolean hasPhaseControlCapability() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.powsybl.iidm.network.DanglingLine;
import com.powsybl.openloadflow.network.LfNetwork;

import java.util.List;
import java.util.Objects;

/**
Expand Down Expand Up @@ -36,6 +37,11 @@ public static String getId(DanglingLine danglingLine) {
return danglingLine.getId() + "_BUS";
}

@Override
public List<String> getOriginalIds() {
return List.of(danglingLine.getId());
}

@Override
public String getId() {
return getId(danglingLine);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public String getId() {
return danglingLine.getId() + "_GEN";
}

@Override
public String getOriginalId() {
return danglingLine.getId();
}

@Override
public OptionalDouble getRemoteControlReactiveKey() {
return OptionalDouble.empty();
Expand Down
37 changes: 19 additions & 18 deletions src/main/java/com/powsybl/openloadflow/network/impl/LfHvdcImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,46 @@
/**
* @author Anne Tilloy <anne.tilloy at rte-france.com>
*/
public final class LfHvdcImpl extends AbstractElement implements LfHvdc {
public class LfHvdcImpl extends AbstractElement implements LfHvdc {

private String id;
private final String id;

private LfBus bus1;
private final LfBus bus1;

private LfBus bus2;
private final LfBus bus2;

private Evaluable p1 = NAN;

private Evaluable p2 = NAN;

private double droop;
private final double droop;

private double p0;
private final double p0;

private LfVscConverterStationImpl vsc1;

private LfVscConverterStationImpl vsc2;

public LfHvdcImpl(HvdcAngleDroopActivePowerControl control, LfBus bus1, LfBus bus2, LfNetwork network, String hvdcId) {
public LfHvdcImpl(String id, LfBus bus1, LfBus bus2, LfNetwork network, HvdcAngleDroopActivePowerControl control) {
super(network);
this.id = hvdcId;
this.id = Objects.requireNonNull(id);
this.bus1 = bus1;
this.bus2 = bus2;
Objects.requireNonNull(control);
droop = control.getDroop();
p0 = control.getP0();
}

@Override
public ElementType getType() {
return ElementType.HVDC;
}

@Override
public String getId() {
return id;
}

@Override
public LfBus getBus1() {
return this.bus1;
Expand Down Expand Up @@ -109,16 +120,6 @@ public void setConverterStation2(LfVscConverterStationImpl converterStation2) {
converterStation2.setTargetP(0);
}

@Override
public ElementType getType() {
return ElementType.HVDC;
}

@Override
public String getId() {
return id;
}

@Override
public void updateState() {
// Should be done before updating state of generators.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ public String getId() {
return getId(twt.getId(), getLegNum());
}

@Override
public BranchType getBranchType() {
if (leg == twt.getLeg1()) {
return BranchType.TRANSFO_3_LEG_1;
} else if (leg == twt.getLeg2()) {
return BranchType.TRANSFO_3_LEG_2;
} else {
return BranchType.TRANSFO_3_LEG_3;
}
}

@Override
public List<String> getOriginalIds() {
return List.of(twt.getId());
}

@Override
public boolean hasPhaseControlCapability() {
return leg.getPhaseTapChanger() != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ private static void createBranches(List<LfBus> lfBuses, LfNetwork lfNetwork, Loa
if (control != null && control.isEnabled()) {
LfBus lfBus1 = getLfBus(hvdcLine.getConverterStation1().getTerminal(), lfNetwork, parameters.isBreakers());
LfBus lfBus2 = getLfBus(hvdcLine.getConverterStation2().getTerminal(), lfNetwork, parameters.isBreakers());
LfHvdc lfHvdc = new LfHvdcImpl(control, lfBus1, lfBus2, lfNetwork, hvdcLine.getId());
LfHvdc lfHvdc = new LfHvdcImpl(hvdcLine.getId(), lfBus1, lfBus2, lfNetwork, control);
LfVscConverterStationImpl cs1 = (LfVscConverterStationImpl) lfNetwork.getGeneratorById(hvdcLine.getConverterStation1().getId());
LfVscConverterStationImpl cs2 = (LfVscConverterStationImpl) lfNetwork.getGeneratorById(hvdcLine.getConverterStation2().getId());
if (cs1 != null && cs2 != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ public List<String> getIds() {
return shuntCompensators.stream().map(ShuntCompensator::getId).collect(Collectors.toList());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete this getIds method then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete this getIds method then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

@Override
public List<String> getOriginalIds() {
return getIds();
}

@Override
public double getB() {
return b;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.powsybl.iidm.network.ThreeWindingsTransformer;
import com.powsybl.openloadflow.network.LfNetwork;

import java.util.List;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
Expand All @@ -29,6 +31,11 @@ public String getId() {
return t3wt.getId() + "_BUS0";
}

@Override
public List<String> getOriginalIds() {
return List.of(t3wt.getId());
}

@Override
public String getVoltageLevelId() {
return t3wt.getLeg1().getTerminal().getVoltageLevel().getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public String getId() {
return aSwitch.getId();
}

@Override
public BranchType getBranchType() {
return BranchType.SWITCH;
}

@Override
public boolean hasPhaseControlCapability() {
return false;
Expand Down