Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ public interface VoltageLevel extends Container<VoltageLevel> {
*/
interface NodeBreakerView {

default boolean hasFictitiousP0() {
return false;
}

/**
* Returns the fictitious active power injection to the node if set, or 0. The value is in MW and uses the load sign convention (a positive value has the same effect as a load connected to the node)
* A fictitious injection is meant to be considered as a load by simulators or exporters. It is typically used to represent the remainder of a state estimator.
Expand All @@ -421,6 +425,10 @@ default NodeBreakerView setFictitiousP0(int node, double p0) {
return this;
}

default boolean hasFictitiousQ0() {
return false;
}

/**
* Returns the fictitious reactive power injection to the node if set, or 0. The value is in MVar and uses the load sign convention (a positive value has the same effect as a load connected to the node)
* A fictitious injection is meant to be considered as a load by simulators or exporters. It is typically used to represent the remainder of a state estimator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@ static PowsyblException createNotSupportedBusBreakerTopologyException() {
}

private final VoltageLevelExt.NodeBreakerViewExt nodeBreakerView = new VoltageLevelExt.NodeBreakerViewExt() {

@Override
public boolean hasFictitiousP0() {
throw createNotSupportedBusBreakerTopologyException();
}

@Override
public double getFictitiousP0(int node) {
throw createNotSupportedBusBreakerTopologyException();
Expand All @@ -399,6 +405,11 @@ public VoltageLevel.NodeBreakerView setFictitiousP0(int node, double p0) {
throw createNotSupportedBusBreakerTopologyException();
}

@Override
public boolean hasFictitiousQ0() {
throw createNotSupportedBusBreakerTopologyException();
}

@Override
public double getFictitiousQ0(int node) {
throw createNotSupportedBusBreakerTopologyException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ public double getQ() {
@Override
public double getFictitiousP0() {
checkValidity();
if (!voltageLevel.getNodeBreakerView().hasFictitiousP0()) {
return 0.0;
}
return Networks.getNodes(id, voltageLevel, getBusFromTerminal)
.mapToDouble(n -> voltageLevel.getNodeBreakerView().getFictitiousP0(n))
.reduce(0.0, Double::sum);
Expand All @@ -165,6 +168,9 @@ public Bus setFictitiousP0(double p0) {
@Override
public double getFictitiousQ0() {
checkValidity();
if (!voltageLevel.getNodeBreakerView().hasFictitiousQ0()) {
return 0.0;
}
return Networks.getNodes(id, voltageLevel, getBusFromTerminal)
.mapToDouble(n -> voltageLevel.getNodeBreakerView().getFictitiousQ0(n))
.reduce(0.0, Double::sum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,23 @@ void removeSwitchFromTopology(String switchId, boolean notify) {
private final TIntObjectMap<TDoubleArrayList> fictitiousP0ByNode = TCollections.synchronizedMap(new TIntObjectHashMap<>());
private final TIntObjectMap<TDoubleArrayList> fictitiousQ0ByNode = TCollections.synchronizedMap(new TIntObjectHashMap<>());

@Override
public boolean hasFictitiousP0() {
if (fictitiousP0ByNode.isEmpty()) {
return false;
}
int variantIndex = getNetwork().getVariantIndex();
for (int i = 0; i < fictitiousP0ByNode.size(); i++) {
TDoubleArrayList p0ByVariant = fictitiousP0ByNode.get(i);
if (p0ByVariant != null) {
if (p0ByVariant.get(variantIndex) != 0.0) {
return true;
}
}
}
return false;
}

@Override
public double getFictitiousP0(int node) {
TDoubleArrayList fictP0 = fictitiousP0ByNode.get(node);
Expand Down Expand Up @@ -684,6 +701,23 @@ public VoltageLevel.NodeBreakerView setFictitiousP0(int node, double p0) {
return this;
}

@Override
public boolean hasFictitiousQ0() {
if (fictitiousQ0ByNode.isEmpty()) {
return false;
}
int variantIndex = getNetwork().getVariantIndex();
for (int i = 0; i < fictitiousQ0ByNode.size(); i++) {
TDoubleArrayList q0ByVariant = fictitiousQ0ByNode.get(i);
if (q0ByVariant != null) {
if (q0ByVariant.get(variantIndex) != 0.0) {
return true;
}
}
}
return false;
}

@Override
public double getFictitiousQ0(int node) {
TDoubleArrayList fictQ0 = fictitiousQ0ByNode.get(node);
Expand Down