Skip to content

Commit

Permalink
#582 properly connect hvdc's limUQUp/Down to VRRemote
Browse files Browse the repository at this point in the history
closes #582

Signed-off-by: Florentine Rosiere <[email protected]>
  • Loading branch information
rosiereflo committed Oct 12, 2023
1 parent 480acb6 commit e77e617
Show file tree
Hide file tree
Showing 12 changed files with 533 additions and 509 deletions.
1 change: 1 addition & 0 deletions scripts/envDFL.sh
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ cmake_configure() {
-DCMAKE_INSTALL_PREFIX:STRING=$DYNAFLOW_LAUNCHER_INSTALL_DIR \
-DDYNAWO_HOME:STRING=$DYNAWO_HOME \
-DDYNAWO_ALGORITHMS_HOME:STRING=$DYNAWO_ALGORITHMS_HOME \
-DDYNAWO_PYTHON_COMMAND:STIONG=${DYNAWO_PYTHON_COMMAND} \
-DDYNAFLOW_LAUNCHER_THIRD_PARTY_DIR=$DYNAFLOW_LAUNCHER_THIRD_PARTY_INSTALL_DIR \
-DBOOST_ROOT:STRING=$DYNAWO_HOME \
-DDYNAFLOW_LAUNCHER_LOCALE:STRING=$DYNAFLOW_LAUNCHER_LOCALE \
Expand Down
2 changes: 2 additions & 0 deletions sources/Outputs/include/DydVRRemote.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class DydVRRemote {
void writeConnections(boost::shared_ptr<dynamicdata::DynamicModelsCollection>& dynamicModelsToConnect);

const std::string macroConnectorGenVRRemoteName_{"GEN_VRREMOTE_CONNECTOR"}; ///< name for the macro connector for generators
const std::string macroConnectorHvdcVRRemoteSide1Name_{"HVDC_VRREMOTE_CONNECTOR_SIDE1"}; ///< name for the macro connector for side 1 of hvdcs
const std::string macroConnectorHvdcVRRemoteSide2Name_{"HVDC_VRREMOTE_CONNECTOR_SIDE2"}; ///< name for the macro connector for side 2 of hvdcs
const std::vector<algo::GeneratorDefinition>& generatorDefinitions_; ///< list of generators definitions
const algo::GeneratorDefinitionAlgorithm::BusGenMap& busesRegulatedBySeveralGenerators_; ///< map of bus ids to a generator that regulates them
const algo::HVDCLineDefinitions& hvdcDefinitions_; ///< list of Hvdc definitions
Expand Down
61 changes: 41 additions & 20 deletions sources/Outputs/src/DydVRRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,22 @@
#include "DydCommon.h"
#include "OutputsConstants.h"

#include <DYDMacroConnectorFactory.h>
#include <DYDMacroConnectFactory.h>
#include <DYDMacroConnectorFactory.h>
#include <set>

namespace dfl {
namespace outputs {

void
DydVRRemote::writeVRRemotes(boost::shared_ptr<dynamicdata::DynamicModelsCollection>& dynamicModelsToConnect,
const std::string& basename) {
void DydVRRemote::writeVRRemotes(boost::shared_ptr<dynamicdata::DynamicModelsCollection> &dynamicModelsToConnect, const std::string &basename) {
using BusId = std::string;
std::set<BusId> regulatedBusIds;
for (const auto& busToGenerator : busesRegulatedBySeveralGenerators_)
for (const auto &busToGenerator : busesRegulatedBySeveralGenerators_)
regulatedBusIds.insert(busToGenerator.first);
for (const auto& busToVSC : hvdcDefinitions_.vscBusVSCDefinitionsMap)
for (const auto &busToVSC : hvdcDefinitions_.vscBusVSCDefinitionsMap)
regulatedBusIds.insert(busToVSC.first);

for (const BusId& regulatedBusId : regulatedBusIds) {
for (const BusId &regulatedBusId : regulatedBusIds) {
std::string id = constants::modelSignalNQprefix_ + regulatedBusId;
boost::shared_ptr<dynamicdata::BlackBoxModel> blackBoxModelVRRemote = helper::buildBlackBox(id, "VRRemote", basename + ".par", id);
dynamicModelsToConnect->addModel(blackBoxModelVRRemote);
Expand All @@ -41,44 +39,67 @@ DydVRRemote::writeVRRemotes(boost::shared_ptr<dynamicdata::DynamicModelsCollecti
writeConnections(dynamicModelsToConnect);
}

void
DydVRRemote::writeMacroConnector(boost::shared_ptr<dynamicdata::DynamicModelsCollection>& dynamicModelsToConnect) {
void DydVRRemote::writeMacroConnector(boost::shared_ptr<dynamicdata::DynamicModelsCollection> &dynamicModelsToConnect) {
if (!generatorDefinitions_.empty()) {
auto connector = dynamicdata::MacroConnectorFactory::newMacroConnector(macroConnectorGenVRRemoteName_);
connector->addConnect("generator_NQ", "vrremote_NQ");
connector->addConnect("generator_limUQUp", "vrremote_limUQUp_@INDEX@_");
connector->addConnect("generator_limUQDown", "vrremote_limUQDown_@INDEX@_");
dynamicModelsToConnect->addMacroConnector(connector);
}
for (const auto &keyValue : hvdcDefinitions_.hvdcLines) {
algo::HVDCDefinition hvdcLine = keyValue.second;
if (hvdcLine.hasPQPropModel()) {
auto connector = dynamicdata::MacroConnectorFactory::newMacroConnector(macroConnectorHvdcVRRemoteSide1Name_);
connector->addConnect("hvdc_NQ1", "vrremote_NQ");
connector->addConnect("hvdc_limUQUp1", "vrremote_limUQUp_@INDEX@_");
connector->addConnect("hvdc_limUQDown1", "vrremote_limUQDown_@INDEX@_");
dynamicModelsToConnect->addMacroConnector(connector);

connector = dynamicdata::MacroConnectorFactory::newMacroConnector(macroConnectorHvdcVRRemoteSide2Name_);
connector->addConnect("hvdc_NQ2", "vrremote_NQ");
connector->addConnect("hvdc_limUQUp2", "vrremote_limUQUp_@INDEX@_");
connector->addConnect("hvdc_limUQDown2", "vrremote_limUQDown_@INDEX@_");
dynamicModelsToConnect->addMacroConnector(connector);
break;
}
}
}

void
DydVRRemote::writeConnections(boost::shared_ptr<dynamicdata::DynamicModelsCollection>& dynamicModelsToConnect) {
void DydVRRemote::writeConnections(boost::shared_ptr<dynamicdata::DynamicModelsCollection> &dynamicModelsToConnect) {
std::unordered_map<std::string, unsigned int> modelNQIdGenNumber;
for (auto it = generatorDefinitions_.cbegin(); it != generatorDefinitions_.cend(); ++it) {
if (it->isNetwork()) {
continue;
}
if (it->model == algo::GeneratorDefinition::ModelType::PROP_SIGNALN_INFINITE ||
it->model == algo::GeneratorDefinition::ModelType::PROP_DIAGRAM_PQ_SIGNALN ||
it->model == algo::GeneratorDefinition::ModelType::PROP_SIGNALN_RECTANGULAR) {
it->model == algo::GeneratorDefinition::ModelType::PROP_DIAGRAM_PQ_SIGNALN ||
it->model == algo::GeneratorDefinition::ModelType::PROP_SIGNALN_RECTANGULAR) {
std::string modelNQId = constants::modelSignalNQprefix_ + it->regulatedBusId;
++modelNQIdGenNumber[modelNQId];
auto connection = dynamicdata::MacroConnectFactory::newMacroConnect(macroConnectorGenVRRemoteName_, it->id, modelNQId);
connection->setIndex2(std::to_string(modelNQIdGenNumber[modelNQId]));
++modelNQIdGenNumber[modelNQId];
dynamicModelsToConnect->addMacroConnect(connection);
}
}

const std::string vrremoteNqValue("vrremote_NQ");
for (const auto& keyValue : hvdcDefinitions_.hvdcLines) {
for (const auto &keyValue : hvdcDefinitions_.hvdcLines) {
algo::HVDCDefinition hvdcLine = keyValue.second;
if (hvdcLine.hasPQPropModel()) {
const algo::HVDCDefinition::BusId& busId1 =
(hvdcLine.position == algo::HVDCDefinition::Position::SECOND_IN_MAIN_COMPONENT) ? hvdcLine.converter2BusId : hvdcLine.converter1BusId;
dynamicModelsToConnect->addConnect(hvdcLine.id, "hvdc_NQ1", constants::modelSignalNQprefix_ + busId1, vrremoteNqValue);
const algo::HVDCDefinition::BusId &busId1 =
(hvdcLine.position == algo::HVDCDefinition::Position::SECOND_IN_MAIN_COMPONENT) ? hvdcLine.converter2BusId : hvdcLine.converter1BusId;
std::string modelNQId = constants::modelSignalNQprefix_ + busId1;
auto connection = dynamicdata::MacroConnectFactory::newMacroConnect(macroConnectorHvdcVRRemoteSide1Name_, hvdcLine.id, modelNQId);
connection->setIndex2(std::to_string(modelNQIdGenNumber[modelNQId]));
++modelNQIdGenNumber[modelNQId];
dynamicModelsToConnect->addMacroConnect(connection);

if (hvdcLine.position == algo::HVDCDefinition::Position::BOTH_IN_MAIN_COMPONENT) {
dynamicModelsToConnect->addConnect(hvdcLine.id, "hvdc_NQ2", constants::modelSignalNQprefix_ + hvdcLine.converter2BusId, vrremoteNqValue);
modelNQId = constants::modelSignalNQprefix_ + hvdcLine.converter2BusId;
auto connection = dynamicdata::MacroConnectFactory::newMacroConnect(macroConnectorHvdcVRRemoteSide2Name_, hvdcLine.id, modelNQId);
connection->setIndex2(std::to_string(modelNQIdGenNumber[modelNQId]));
++modelNQIdGenNumber[modelNQId];
dynamicModelsToConnect->addMacroConnect(connection);
}
}
}
Expand Down
Loading

0 comments on commit e77e617

Please sign in to comment.