Skip to content

Commit

Permalink
Merge branch 'master' into adjust_online_parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mathbagu committed Oct 25, 2016
2 parents a286934 + ac52fbe commit ad60b5b
Show file tree
Hide file tree
Showing 22 changed files with 231 additions and 187 deletions.
Expand Up @@ -540,31 +540,28 @@ private void createPhaseTapChanger(cim1.model.PhaseTapChanger ptc, cim1.model.Te
cim1.model.RegulatingControl rc = ptc.getRegulatingControl();
switch (rc.getMode()) {
case currentFlow:
Terminal regulatingTerminal;
Terminal regulationTerminal;
if (rc.getTerminal() == t1) {
regulatingTerminal = transfo.getTerminal1();
regulationTerminal = transfo.getTerminal1();
} else if (rc.getTerminal() == t2) {
regulatingTerminal = transfo.getTerminal2();
regulationTerminal = transfo.getTerminal2();
} else {
regulatingTerminal = getTerminalMapping(rc.getTerminal().getTopologicalNode());
regulationTerminal = getTerminalMapping(rc.getTerminal().getTopologicalNode());
}
ptca.setRegulating(true)
.setThresholdI(rc.getTargetValue())
.setTerminal(regulatingTerminal);
ptca.setRegulationMode(PhaseTapChanger.RegulationMode.CURRENT_LIMITER)
.setRegulationValue(rc.getTargetValue())
.setRegulating(true)
.setRegulationTerminal(regulationTerminal);
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 Expand Up @@ -611,19 +608,19 @@ private void createRatioTapChanger(cim1.model.RatioTapChanger rtc, Supplier<Rati
regulating = false;
targetV = Float.NaN;
}
Terminal regulatingTerminal = null;
Terminal regulationTerminal = null;
for (Map.Entry<cim1.model.Terminal, Terminal> e : terminals.entrySet()) {
if (rc.getTerminal() == e.getKey()) {
regulatingTerminal = e.getValue();
regulationTerminal = e.getValue();
}
}
if (regulatingTerminal == null) {
regulatingTerminal = getTerminalMapping(rc.getTerminal().getTopologicalNode());
if (regulationTerminal == null) {
regulationTerminal = getTerminalMapping(rc.getTerminal().getTopologicalNode());
}
rtca.setLoadTapChangingCapabilities(true)
.setRegulating(regulating)
.setTargetV(targetV)
.setTerminal(regulatingTerminal);
.setRegulationTerminal(regulationTerminal);
break;

case fixed:
Expand Down
7 changes: 7 additions & 0 deletions distribution/pom.xml
Expand Up @@ -54,6 +54,13 @@
<version>${project.version}</version>
</dependency>

<!-- case-repositories -->
<dependency>
<groupId>eu.itesla_project</groupId>
<artifactId>entsoe-case-repository</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Dynamic database (mysql) -->
<dependency>
<groupId>eu.itesla_project.iidm-ddb</groupId>
Expand Down
Expand Up @@ -257,7 +257,7 @@ private void createTransformers(EsgNetwork esgNetwork, EsgGeneralParameters para
PhaseTapChanger ptc = twt.getPhaseTapChanger();
if (rtc != null && ptc == null) {
if (rtc.isRegulating()) {
ConnectionBus regulatingBus = ConnectionBus.fromTerminal(rtc.getTerminal(), config, null);
ConnectionBus regulatingBus = ConnectionBus.fromTerminal(rtc.getRegulationTerminal(), config, null);
if (regulatingBus.getId() != null) {
regulatingMode = EsgDetailedTwoWindingTransformer.RegulatingMode.VOLTAGE;
zbusr = new Esg8charName(dictionary.getEsgId(regulatingBus.getId()));
Expand All @@ -272,8 +272,8 @@ private void createTransformers(EsgNetwork esgNetwork, EsgGeneralParameters para
}

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

enum RegulationMode {
CURRENT_LIMITER,
ACTIVE_POWER_CONTROL,
FIXED_TAP
}

/**
* Get the regulation mode.
* @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 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);

}
Expand Up @@ -35,9 +35,11 @@ interface StepAdder {

PhaseTapChangerAdder setRegulating(boolean regulating);

PhaseTapChangerAdder setThresholdI(float thresholdI);
PhaseTapChangerAdder setRegulationMode(PhaseTapChanger.RegulationMode regulationMode);

PhaseTapChangerAdder setTerminal(Terminal terminal);
PhaseTapChangerAdder setRegulationValue(float regulationValue);

PhaseTapChangerAdder setRegulationTerminal(Terminal regulationTerminal);

StepAdder beginStep();

Expand Down
Expand Up @@ -37,7 +37,7 @@ public interface StepAdder {

RatioTapChangerAdder setTargetV(float targetV);

RatioTapChangerAdder setTerminal(Terminal terminal);
RatioTapChangerAdder setRegulationTerminal(Terminal regulationTerminal);

StepAdder beginStep();

Expand Down
Expand Up @@ -82,12 +82,12 @@ public interface TapChanger<TC extends TapChanger<TC, TCS>, TCS extends TapChang
/**
* Get the terminal used for regulation.
*/
Terminal getTerminal();
Terminal getRegulationTerminal();

/**
* Set the terminal used for regulation.
*/
void setTerminal(Terminal t);
TC setRegulationTerminal(Terminal regulationTerminal);

/**
* Remove the tap changer.
Expand Down
Expand Up @@ -26,11 +26,13 @@ class PhaseTapChangerAdderImpl implements PhaseTapChangerAdder {

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

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

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

private TerminalExt terminal;
private boolean regulating = false;

private TerminalExt regulationTerminal;

class StepAdderImpl implements StepAdder {

Expand Down Expand Up @@ -130,20 +132,26 @@ 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 setRegulationValue(float regulationValue) {
this.regulationValue = regulationValue;
return this;
}

@Override
public PhaseTapChangerAdder setThresholdI(float thresholdI) {
this.thresholdI = thresholdI;
public PhaseTapChangerAdder setRegulating(boolean regulating) {
this.regulating = regulating;
return this;
}

@Override
public PhaseTapChangerAdder setTerminal(Terminal terminal) {
this.terminal = (TerminalExt) terminal;
public PhaseTapChangerAdder setRegulationTerminal(Terminal regulationTerminal) {
this.regulationTerminal = (TerminalExt) regulationTerminal;
return this;
}

Expand All @@ -166,23 +174,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, regulating, regulationTerminal, getNetwork());
PhaseTapChangerImpl tapChanger
= new PhaseTapChangerImpl(transformer, lowTapPosition, steps, terminal,
tapPosition, regulating, thresholdI);
= new PhaseTapChangerImpl(transformer, lowTapPosition, steps, regulationTerminal, tapPosition, regulating, regulationMode, regulationValue);
transformer.setPhaseTapChanger(tapChanger);
return tapChanger;
}
Expand Down
Expand Up @@ -7,7 +7,9 @@
package eu.itesla_project.iidm.network.impl;

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

import java.util.List;

/**
Expand All @@ -17,18 +19,21 @@
class PhaseTapChangerImpl extends TapChangerImpl<TwoWindingsTransformerImpl, PhaseTapChangerImpl, PhaseTapChangerStepImpl>
implements PhaseTapChanger {

private RegulationMode regulationMode;

// attributes depending on the state

private final TFloatArrayList thresholdI;
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);
List<PhaseTapChangerStepImpl> steps, TerminalExt regulationTerminal,
int tapPosition, boolean regulating, RegulationMode regulationMode, float regulationValue) {
super(parent.getNetwork().getRef(), parent, lowTapPosition, steps, regulationTerminal, tapPosition, regulating);
int stateArraySize = network.get().getStateManager().getStateArraySize();
this.thresholdI = new TFloatArrayList(stateArraySize);
this.regulationMode = regulationMode;
this.regulationValue = new TFloatArrayList(stateArraySize);
for (int i = 0; i < stateArraySize; i++) {
this.thresholdI.add(thresholdI);
this.regulationValue.add(regulationValue);
}
}

Expand All @@ -38,28 +43,35 @@ 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;
}

@Override
public float getThresholdI() {
return thresholdI.get(network.get().getStateIndex());
public PhaseTapChangerImpl setRegulationMode(RegulationMode regulationMode) {
ValidationUtil.checkPhaseTapChangerRegulation(parent, regulationMode, getRegulationValue(), isRegulating(), getRegulationTerminal(), getNetwork());
this.regulationMode = regulationMode;
return this;
}

@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 float getRegulationValue() {
return regulationValue.get(network.get().getStateIndex());
}

@Override
public PhaseTapChangerImpl setRegulationValue(float regulationValue) {
ValidationUtil.checkPhaseTapChangerRegulation(parent, regulationMode, regulationValue, isRegulating(), getRegulationTerminal(), getNetwork());
this.regulationValue.set(network.get().getStateIndex(), regulationValue);
return this;
}

@Override
public PhaseTapChangerImpl setRegulationTerminal(Terminal regulationTerminal) {
ValidationUtil.checkPhaseTapChangerRegulation(parent, regulationMode, getRegulationValue(), isRegulating(), regulationTerminal, getNetwork());
return super.setRegulationTerminal(regulationTerminal);
}

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

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

@Override
Expand All @@ -90,7 +102,7 @@ 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));
regulationValue.set(index, regulationValue.get(sourceIndex));
}
}

Expand Down

0 comments on commit ad60b5b

Please sign in to comment.