Skip to content

Commit

Permalink
Add new phase shifter regulation mode: active power control
Browse files Browse the repository at this point in the history
  • Loading branch information
geofjamg committed Oct 20, 2016
1 parent 5717dd7 commit 62fbfc1
Show file tree
Hide file tree
Showing 18 changed files with 153 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -548,23 +548,19 @@ private void createPhaseTapChanger(cim1.model.PhaseTapChanger ptc, cim1.model.Te
} else {
regulatingTerminal = getTerminalMapping(rc.getTerminal().getTopologicalNode());
}
ptca.setRegulating(true)
.setThresholdI(rc.getTargetValue())
ptca.setRegulationMode(PhaseTapChanger.RegulationMode.CURRENT_LIMITER)
.setRegulationValue(rc.getTargetValue())
.setTerminal(regulatingTerminal);
break;

case fixed:
ptca.setRegulating(false);
break;

default:
ptca.setRegulating(false);
LOGGER.warn("Phase tap changer '{}' of power transformer '{}'" +
" has an unsupported regulating mode: {}",
ptc.getId(), transfo.getId(), rc.getMode());
}
} else {
ptca.setRegulating(false);
}
ptca.add();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private void createTransformers(EsgNetwork esgNetwork, EsgGeneralParameters para
}

} else if (ptc != null && rtc == null) {
if (ptc.isRegulating()) {
if (ptc.getRegulationMode() == PhaseTapChanger.RegulationMode.CURRENT_LIMITER) {
String regulbus = EchUtil.getBus(ptc.getTerminal(), config).getId();
if (regulbus.equals(bus1.getId())) {
regulatingMode = EsgDetailedTwoWindingTransformer.RegulatingMode.ACTIVE_FLUX_SIDE_1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ public void dumpDataAutomatons(SimulatorInst eurostagSim, DDBManager ddbmanager,
) {
dumpDataTransformerAutomaton(t, eurostagSim, "A14_HT", dtaOutStream, iidm2eurostagId);
} else if(t.getPhaseTapChanger() != null
&& t.getPhaseTapChanger().isRegulating()) { // TD
&& t.getPhaseTapChanger().getRegulationMode() != PhaseTapChanger.RegulationMode.OFF) { // TD
//TODO
//dumpDataTransformerAutomaton(t, eurostagSim, "A14_TD", dtaOutStream, iidm2eurostagId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,43 @@
*/
public interface PhaseTapChanger extends TapChanger<PhaseTapChanger, PhaseTapChangerStep> {

enum RegulationMode {
CURRENT_LIMITER,
ACTIVE_POWER_CONTROL,
OFF
}

/**
* Get the regulation mode.
* <p>
* Depends on the working state.
* @return the regulation mode
*/
RegulationMode getRegulationMode();

/**
* Set the regulation mode
* @param regulationMode the regulation mode
* @return itself for method chaining
*/
PhaseTapChanger setRegulationMode(RegulationMode regulationMode);

/**
* Get the threshold current in A.
* Get the the regulation value.
* - a threshold in A in case of current limiter regulation
* - a setpoint in MW in case of active power control regulation
* <p>
* Depends on the working state.
* @see StateManager
*/
float getThresholdI();
float getRegulationValue();

/**
* Set the threshold current in A.
* Set the regulation value.
* <p>
* Depends on the working state.
* @see StateManager
*/
PhaseTapChanger setThresholdI(float thresholdI);
PhaseTapChanger setRegulationValue(float regulationValue);

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ interface StepAdder {

PhaseTapChangerAdder setTapPosition(int tapPosition);

PhaseTapChangerAdder setRegulating(boolean regulating);
PhaseTapChangerAdder setRegulationMode(PhaseTapChanger.RegulationMode regulationMode);

PhaseTapChangerAdder setThresholdI(float thresholdI);
PhaseTapChangerAdder setRegulationValue(float regulationValue);

PhaseTapChangerAdder setTerminal(Terminal terminal);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,20 @@ public interface RatioTapChanger extends TapChanger<RatioTapChanger, RatioTapCha
*/
boolean hasLoadTapChangingCapabilities();

/**
* Get the regulating status.
* <p>
* Depends on the working state.
* @see StateManager
*/
boolean isRegulating();

/**
* Set the regulating status.
* <p>
* Depends on the working state.
* @see StateManager
*/
RatioTapChanger setRegulating(boolean regulating);

}
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,6 @@ public interface TapChanger<TC extends TapChanger<TC, TCS>, TCS extends TapChang
*/
TCS getCurrentStep();

/**
* Get the regulating status.
* <p>
* Depends on the working state.
* @see StateManager
*/
boolean isRegulating();

/**
* Set the regulating status.
* <p>
* Depends on the working state.
* @see StateManager
*/
TC setRegulating(boolean regulating);

/**
* Get the terminal used for regulation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import eu.itesla_project.iidm.network.PhaseTapChanger;
import eu.itesla_project.iidm.network.PhaseTapChangerAdder;
import eu.itesla_project.iidm.network.RatioTapChangerAdder;
import eu.itesla_project.iidm.network.Terminal;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -26,9 +27,9 @@ class PhaseTapChangerAdderImpl implements PhaseTapChangerAdder {

private final List<PhaseTapChangerStepImpl> steps = new ArrayList<>();

private Boolean regulating;
private PhaseTapChanger.RegulationMode regulationMode = PhaseTapChanger.RegulationMode.OFF;

private float thresholdI = Float.NaN;
private float regulationValue = Float.NaN;

private TerminalExt terminal;

Expand Down Expand Up @@ -130,14 +131,14 @@ public PhaseTapChangerAdder setTapPosition(int tapPosition) {
}

@Override
public PhaseTapChangerAdder setRegulating(boolean regulating) {
this.regulating = regulating;
public PhaseTapChangerAdder setRegulationMode(PhaseTapChanger.RegulationMode regulationMode) {
this.regulationMode = regulationMode;
return this;
}

@Override
public PhaseTapChangerAdder setThresholdI(float thresholdI) {
this.thresholdI = thresholdI;
public PhaseTapChangerAdder setRegulationValue(float regulationValue) {
this.regulationValue = regulationValue;
return this;
}

Expand Down Expand Up @@ -166,23 +167,9 @@ public PhaseTapChanger add() {
+ tapPosition + " [" + lowTapPosition + ", "
+ highTapPosition + "]");
}
if (regulating == null) {
throw new ValidationException(transformer, "regulating status is not set");
}
if (regulating) {
if (Float.isNaN(thresholdI)) {
throw new ValidationException(transformer, "a threshold current has to be set for a regulating phase tap changer");
}
if (terminal == null) {
throw new ValidationException(transformer, "a regulation terminal has to be set for a regulating phase tap changer");
}
if (terminal.getVoltageLevel().getNetwork() != getNetwork()) {
throw new ValidationException(transformer, "terminal is not part of the network");
}
}
ValidationUtil.checkPhaseTapChangerRegulation(transformer, regulationMode, regulationValue, terminal, getNetwork());
PhaseTapChangerImpl tapChanger
= new PhaseTapChangerImpl(transformer, lowTapPosition, steps, terminal,
tapPosition, regulating, thresholdI);
= new PhaseTapChangerImpl(transformer, lowTapPosition, steps, terminal, tapPosition, regulationMode, regulationValue);
transformer.setPhaseTapChanger(tapChanger);
return tapChanger;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

import eu.itesla_project.iidm.network.PhaseTapChanger;
import gnu.trove.list.array.TFloatArrayList;
import gnu.trove.list.array.TIntArrayList;

import java.util.BitSet;
import java.util.List;

/**
Expand All @@ -19,16 +22,20 @@ class PhaseTapChangerImpl extends TapChangerImpl<TwoWindingsTransformerImpl, Pha

// attributes depending on the state

private final TFloatArrayList thresholdI;
private final TIntArrayList regulationMode;

private final TFloatArrayList regulationValue;

PhaseTapChangerImpl(TwoWindingsTransformerImpl parent, int lowTapPosition,
List<PhaseTapChangerStepImpl> steps, TerminalExt terminal,
int tapPosition, boolean regulating, float thresholdI) {
super(parent.getNetwork().getRef(), parent, lowTapPosition, steps, terminal, tapPosition, regulating);
int tapPosition, RegulationMode regulationMode, float regulationValue) {
super(parent.getNetwork().getRef(), parent, lowTapPosition, steps, terminal, tapPosition);
int stateArraySize = network.get().getStateManager().getStateArraySize();
this.thresholdI = new TFloatArrayList(stateArraySize);
this.regulationMode = new TIntArrayList(stateArraySize);
this.regulationValue = new TFloatArrayList(stateArraySize);
for (int i = 0; i < stateArraySize; i++) {
this.thresholdI.add(thresholdI);
this.regulationMode.add(regulationMode.ordinal());
this.regulationValue.add(regulationValue);
}
}

Expand All @@ -38,25 +45,26 @@ protected NetworkImpl getNetwork() {
}

@Override
public PhaseTapChangerImpl setRegulating(boolean regulating) {
if (Float.isNaN(getThresholdI())) {
throw new ValidationException(parent,
"cannot change the regulating status if the threshold current is not set");
}
return super.setRegulating(regulating);
public RegulationMode getRegulationMode() {
return RegulationMode.values()[regulationMode.get(network.get().getStateIndex())];
}

@Override
public PhaseTapChanger setRegulationMode(RegulationMode regulationMode) {
ValidationUtil.checkPhaseTapChangerRegulation(parent, regulationMode, getRegulationValue(), getTerminal(), getNetwork());
this.regulationMode.set(network.get().getStateIndex(), regulationMode.ordinal());
return this;
}

@Override
public float getThresholdI() {
return thresholdI.get(network.get().getStateIndex());
public float getRegulationValue() {
return regulationValue.get(network.get().getStateIndex());
}

@Override
public PhaseTapChanger setThresholdI(float thresholdI) {
if (Float.isNaN(thresholdI)) {
throw new ValidationException(parent, "invalid threshold current value (NaN)");
}
this.thresholdI.set(network.get().getStateIndex(), thresholdI);
public PhaseTapChanger setRegulationValue(float regulationValue) {
ValidationUtil.checkPhaseTapChangerRegulation(parent, getRegulationMode(), regulationValue, getTerminal(), getNetwork());
this.regulationValue.set(network.get().getStateIndex(), regulationValue);
return this;
}

Expand All @@ -68,16 +76,19 @@ public void remove() {
@Override
public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) {
super.extendStateArraySize(initStateArraySize, number, sourceIndex);
thresholdI.ensureCapacity(thresholdI.size() + number);
regulationMode.ensureCapacity(regulationMode.size() + number);
regulationValue.ensureCapacity(regulationValue.size() + number);
for (int i = 0; i < number; i++) {
thresholdI.add(thresholdI.get(sourceIndex));
regulationMode.add(regulationMode.get(sourceIndex));
regulationValue.add(regulationValue.get(sourceIndex));
}
}

@Override
public void reduceStateArraySize(int number) {
super.reduceStateArraySize(number);
thresholdI.remove(thresholdI.size() - number, number);
regulationMode.remove(regulationMode.size() - number, number);
regulationValue.remove(regulationValue.size() - number, number);
}

@Override
Expand All @@ -90,7 +101,8 @@ public void deleteStateArrayElement(int index) {
public void allocateStateArrayElement(int[] indexes, final int sourceIndex) {
super.allocateStateArrayElement(indexes, sourceIndex);
for (int index : indexes) {
thresholdI.set(index, thresholdI.get(sourceIndex));
regulationMode.set(index, regulationMode.get(sourceIndex));
regulationValue.set(index, regulationValue.get(sourceIndex));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import eu.itesla_project.iidm.network.RatioTapChanger;
import eu.itesla_project.iidm.network.Terminal;
import gnu.trove.list.array.TFloatArrayList;

import java.util.BitSet;
import java.util.List;

/**
Expand All @@ -23,23 +25,31 @@ class RatioTapChangerImpl extends TapChangerImpl<RatioTapChangerParent, RatioTap

private final TFloatArrayList targetV;

protected final BitSet regulating;

RatioTapChangerImpl(RatioTapChangerParent parent, int lowTapPosition,
List<RatioTapChangerStepImpl> steps, TerminalExt terminal, boolean loadTapChangingCapabilities,
int tapPosition, boolean regulating, float targetV) {
super(parent.getNetwork().getRef(), parent, lowTapPosition, steps, terminal, tapPosition, regulating);
super(parent.getNetwork().getRef(), parent, lowTapPosition, steps, terminal, tapPosition);
this.loadTapChangingCapabilities = loadTapChangingCapabilities;
int stateArraySize = network.get().getStateManager().getStateArraySize();
this.targetV = new TFloatArrayList(stateArraySize);
for (int i = 0; i < stateArraySize; i++) {
this.targetV.add(targetV);
}
this.regulating = new BitSet(stateArraySize);
this.regulating.set(0, stateArraySize, regulating);
}

@Override
protected NetworkImpl getNetwork() {
return parent.getNetwork();
}

public boolean isRegulating() {
return regulating.get(network.get().getStateIndex());
}

@Override
public RatioTapChangerImpl setRegulating(boolean regulating) {
if (!loadTapChangingCapabilities) {
Expand All @@ -51,7 +61,12 @@ public RatioTapChangerImpl setRegulating(boolean regulating) {
throw new ValidationException(parent,
"cannot change the regulating status if the target voltage is not set");
}
return super.setRegulating(regulating);
if (regulating && terminal == null) {
throw new ValidationException(parent,
"cannot change the regulating status if the regulation terminal is not set");
}
this.regulating.set(network.get().getStateIndex(), regulating);
return this;
}

@Override
Expand Down Expand Up @@ -99,6 +114,7 @@ public void extendStateArraySize(int initStateArraySize, int number, int sourceI
targetV.ensureCapacity(targetV.size() + number);
for (int i = 0; i < number; i++) {
targetV.add(targetV.get(sourceIndex));
regulating.set(initStateArraySize + i, regulating.get(sourceIndex));
}
}

Expand All @@ -119,6 +135,7 @@ public void allocateStateArrayElement(int[] indexes, final int sourceIndex) {
super.allocateStateArrayElement(indexes, sourceIndex);
for (int index : indexes) {
targetV.set(index, targetV.get(sourceIndex));
regulating.set(index, regulating.get(sourceIndex));
}
}

Expand Down

0 comments on commit 62fbfc1

Please sign in to comment.