Skip to content

Commit

Permalink
#3228 CentralizedShuntsSectionControl model takes into account the
Browse files Browse the repository at this point in the history
running status of the connected shunts
closes #3228

Signed-off-by: Florentine Rosiere <florentine.rosiere@rte-france.com>
  • Loading branch information
rosiereflo authored and marcochiaramello committed Jun 14, 2024
1 parent b4193dc commit f3a4524
Show file tree
Hide file tree
Showing 11 changed files with 383 additions and 177 deletions.
3 changes: 3 additions & 0 deletions dynawo/sources/Common/Dictionaries/DYNTimeline_en_GB.dic
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ IECProtectionUUnder = IEC WT disconnected due to undervoltag
// --> Motor
MotorConnected = Motor : connecting
MotorDisconnected = Motor : disconnecting
// --> DYNCentralizedShuntsSectionControl Model
CSSCSectionUp = Section of shunt %1% +1
CSSCSectionDown = Section of shunt %1% -1
//------------- C++ models ----------------------------------------------
// --> BUS
NodeOff = BUS : switch off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ namespace DYN {
sectionName << "section_" << s << "_value";
variables.push_back(VariableNativeFactory::createState(sectionName.str(), DISCRETE));
}
for (int s = 0; s < nbShunts_; ++s) {
sectionName.str(std::string());
sectionName.clear();
sectionName << "running_" << s << "_value";
variables.push_back(VariableNativeFactory::createState(sectionName.str(), BOOLEAN));
}
}

void
Expand All @@ -154,7 +160,8 @@ namespace DYN {
ModelCentralizedShuntsSectionControl::getSize() {
sizeF_ = 0;
sizeY_ = 1; // UMonitoredPu
sizeZ_ = nbShunts_ + 1; // URefPu value is stored at index 0, sections are stored at [1, nbShunts[
sizeZ_ = 2*nbShunts_ + 1; // URefPu value is stored at index 0,
// sections are stored at [1, nbShunts[, running status of shunts are stored at [nbShunts, 2*nbShunts [
sizeG_ = 4;
sizeMode_ = 0;
calculatedVars_.assign(nbCalculatedVariables_, 0);
Expand Down Expand Up @@ -182,6 +189,14 @@ namespace DYN {
double minValue;
double maxValue;
for (int s = 0; s < nbShunts_; ++s) {
if (zLocal_[nbShunts_ + s + 1] <= 0) {
gLocal_[0] = ROOT_DOWN;
gLocal_[1] = ROOT_DOWN;
gLocal_[2] = ROOT_DOWN;
gLocal_[3] = ROOT_DOWN;
changingShunt = -1;
continue;
}
minValue = URefPu - deadBandsUPu_[s];
maxValue = URefPu + deadBandsUPu_[s];
if (isSelf_[s]) {
Expand All @@ -208,6 +223,7 @@ namespace DYN {
gLocal_[1] = ROOT_DOWN;
gLocal_[2] = ROOT_DOWN;
gLocal_[3] = ROOT_DOWN;
changingShunt = -1;
}
} else {
if (doubleNotEquals(UMonitoredPu, minValue) &&
Expand All @@ -233,6 +249,7 @@ namespace DYN {
gLocal_[1] = ROOT_DOWN;
gLocal_[2] = ROOT_DOWN;
gLocal_[3] = ROOT_DOWN;
changingShunt = -1;
}
}
}
Expand All @@ -254,11 +271,13 @@ namespace DYN {
if (gLocal_[2] == ROOT_UP && doubleNotEquals(lastTime_, t)) {
zLocal_[changingShunt + 1] = sections0_[changingShunt] - 1;
sections0_[changingShunt] -= 1;
DYNAddTimelineEvent(this, name(), CSSCSectionDown, changingShunt);
changingShunt = -1;
lastTime_ = t;
} else if (gLocal_[3] == ROOT_UP && doubleNotEquals(lastTime_, t)) {
zLocal_[changingShunt + 1] = sections0_[changingShunt] + 1;
sections0_[changingShunt] += 1;
DYNAddTimelineEvent(this, name(), CSSCSectionUp, changingShunt);
changingShunt = -1;
lastTime_ = t;
}
Expand All @@ -275,11 +294,13 @@ namespace DYN {
if (gLocal_[2] == ROOT_UP && doubleNotEquals(lastTime_, t)) {
zLocal_[changingShunt + 1] = sections0_[changingShunt] + 1;
sections0_[changingShunt] += 1;
DYNAddTimelineEvent(this, name(), CSSCSectionUp, changingShunt);
changingShunt = -1;
lastTime_ = t;
} else if (gLocal_[3] == ROOT_UP && doubleNotEquals(lastTime_, t)) {
zLocal_[changingShunt + 1] = sections0_[changingShunt] - 1;
sections0_[changingShunt] -= 1;
DYNAddTimelineEvent(this, name(), CSSCSectionDown, changingShunt);
changingShunt = -1;
lastTime_ = t;
}
Expand All @@ -304,6 +325,9 @@ namespace DYN {
for (int s = 0; s < nbShunts_; ++s) {
zLocal_[s + 1] = sections0_[s];
}
for (int s = 0; s < nbShunts_; ++s) {
zLocal_[nbShunts_ + s + 1] = 1.;
}
}

void
Expand Down Expand Up @@ -349,6 +373,12 @@ namespace DYN {
sectionName << "section_" << s;
addElement(sectionName.str(), Element::STRUCTURE, elements, mapElement);
addSubElement("value", sectionName.str(), Element::TERMINAL, name(), modelType(), elements, mapElement);

sectionName.str(std::string());
sectionName.clear();
sectionName << "running_" << s;
addElement(sectionName.str(), Element::STRUCTURE, elements, mapElement);
addSubElement("value", sectionName.str(), Element::TERMINAL, name(), modelType(), elements, mapElement);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ TEST(ModelsCentralizedShuntsSectionControl, ModelCentralizedShuntsSectionControl
ASSERT_NO_THROW(modelShunt->setSubModelParameters());
std::vector<boost::shared_ptr<Variable> > variables;
modelShunt->defineVariables(variables);
ASSERT_EQ(variables.size(), 3);
ASSERT_EQ(variables.size(), 4);
std::vector<Element> elements;
std::map<std::string, int> mapElements;
modelShunt->defineElements(elements, mapElements);
ASSERT_EQ(elements.size(), mapElements.size());
ASSERT_EQ(elements.size(), 6);
ASSERT_EQ(elements.size(), 8);

boost::shared_ptr<SubModel> modelShunt_missingPar =
SubModelFactory::createSubModelFromLib("../DYNModelCentralizedShuntsSectionControl" + std::string(sharedLibraryExtension()));
Expand All @@ -118,7 +118,7 @@ TEST(ModelsCentralizedShuntsSectionControl, ModelCentralizedShuntsSectionControl
boost::shared_ptr<SubModel> modelShunt = initModelShunt(nbShunts);
unsigned nbY = 1;
unsigned nbF = 0;
unsigned nbZ = nbShunts + 1;
unsigned nbZ = 2*nbShunts + 1;
unsigned nbG = 4;
unsigned nbMode = 0;
std::vector<propertyContinuousVar_t> yTypes(nbY, UNDEFINED_PROPERTY);
Expand Down Expand Up @@ -326,4 +326,65 @@ TEST(ModelsCentralizedShuntsSectionControl, ModelCentralizedShuntsSectionControl
ASSERT_NO_THROW(modelShuntSelf->evalZ(20));
ASSERT_EQ(zSelf[1], 1);
}



TEST(ModelsCentralizedShuntsSectionControl, ModelCentralizedShuntsSectionControlContinuousAndDiscreteMethodsDisabledShunt) {
// isSelf = false
int nbShunts = 2;
boost::shared_ptr<SubModel> modelShuntCond = initModelShunt(nbShunts, 1);
std::vector<double> y(modelShuntCond->sizeY(), 0);
std::vector<double> yp(modelShuntCond->sizeY(), 0);
modelShuntCond->setBufferY(&y[0], &yp[0], 0.);
std::vector<double> z(modelShuntCond->sizeZ(), 0);
bool* zConnected = new bool[modelShuntCond->sizeZ()];
for (size_t i = 0; i < modelShuntCond->sizeZ(); ++i)
zConnected[i] = true;
modelShuntCond->setBufferZ(&z[0], zConnected, 0);
BitMask* silentZ = new BitMask[modelShuntCond->sizeZ()];
ASSERT_NO_THROW(modelShuntCond->init(0));
ASSERT_NO_THROW(modelShuntCond->getY0());
ASSERT_NO_THROW(modelShuntCond->setFequations());
ASSERT_NO_THROW(modelShuntCond->collectSilentZ(silentZ));
ASSERT_NO_THROW(modelShuntCond->evalF(0, UNDEFINED_EQ));
SparseMatrix smj;
ASSERT_NO_THROW(modelShuntCond->evalJt(0, 0, smj, 0));
ASSERT_NO_THROW(modelShuntCond->evalJtPrim(0, 0, smj, 0));
ASSERT_NO_THROW(modelShuntCond->evalMode(0));
ASSERT_NO_THROW(modelShuntCond->evalCalculatedVarI(0));
std::vector<int> indexes;
ASSERT_NO_THROW(modelShuntCond->getIndexesOfVariablesUsedForCalculatedVarI(0, indexes));
std::vector<double> res;
ASSERT_NO_THROW(modelShuntCond->evalJCalculatedVarI(0, res));
ASSERT_NO_THROW(modelShuntCond->evalCalculatedVars());
std::vector<state_g> g(modelShuntCond->sizeG(), ROOT_DOWN);
modelShuntCond->setBufferG(&g[0], 0);
ASSERT_NO_THROW(modelShuntCond->setGequations());

// Disable a shunt
z[3] = -1;

// UMonitored < URef
y[0] = 0.8;
ASSERT_NO_THROW(modelShuntCond->evalG(0));
ASSERT_EQ(g[0], ROOT_UP);
ASSERT_EQ(g[1], ROOT_DOWN);
ASSERT_EQ(g[2], ROOT_DOWN);
ASSERT_EQ(g[3], ROOT_DOWN);
ASSERT_NO_THROW(modelShuntCond->evalZ(0));
ASSERT_NO_THROW(modelShuntCond->evalZ(5));
ASSERT_NO_THROW(modelShuntCond->evalG(5));
ASSERT_EQ(g[0], ROOT_UP);
ASSERT_EQ(g[1], ROOT_DOWN);
ASSERT_EQ(g[2], ROOT_DOWN);
ASSERT_EQ(g[3], ROOT_DOWN);
ASSERT_NO_THROW(modelShuntCond->evalG(10));
ASSERT_EQ(g[0], ROOT_UP);
ASSERT_EQ(g[1], ROOT_DOWN);
ASSERT_EQ(g[2], ROOT_UP);
ASSERT_EQ(g[3], ROOT_DOWN);
ASSERT_NO_THROW(modelShuntCond->evalZ(10));
ASSERT_EQ(z[1], 1);
ASSERT_EQ(z[2], 2);
}
} // namespace DYN
Loading

0 comments on commit f3a4524

Please sign in to comment.