From 3ff0ad07f1409f8cd9132d01d6a185a8c25ba3c7 Mon Sep 17 00:00:00 2001 From: Le Courtois Florent Date: Fri, 1 Oct 2021 13:38:22 +0200 Subject: [PATCH] #216 Rename shunt definitions algorithm --- sources/Algo/include/Algo.h | 10 +++++----- sources/Algo/src/Algo.cpp | 6 +++--- sources/Context.cpp | 4 ++-- sources/Context.h | 2 +- sources/Inputs/include/Node.h | 6 +++++- sources/Outputs/include/Par.h | 18 ++++++++---------- sources/Outputs/src/Par.cpp | 8 ++++---- tests/algo/TestAlgo.cpp | 4 ++-- tests/outputs/TestPar.cpp | 2 +- 9 files changed, 31 insertions(+), 29 deletions(-) diff --git a/sources/Algo/include/Algo.h b/sources/Algo/include/Algo.h index a27322bbe..e8e4197e8 100644 --- a/sources/Algo/include/Algo.h +++ b/sources/Algo/include/Algo.h @@ -864,22 +864,22 @@ class DynModelAlgorithm : public NodeAlgorithm { }; /** - * @brief Shunt counter definition + * @brief Shunt definitions */ -struct ShuntCounterDefinitions { +struct ShuntDefinitions { std::unordered_map nbShunts; ///< Number of shunts by voltage level }; /** * @brief Counter of shunts by voltage levels */ -class ShuntCounterAlgorithm : public NodeAlgorithm { +class ShuntDefinitionAlgorithm : public NodeAlgorithm { public: /** * @brief Constructor * @param shuntCounterDefs the counter definitions to update */ - explicit ShuntCounterAlgorithm(ShuntCounterDefinitions& shuntCounterDefs); + explicit ShuntDefinitionAlgorithm(ShuntDefinitions& shuntCounterDefs); /** * @brief Performs the algorithm @@ -891,7 +891,7 @@ class ShuntCounterAlgorithm : public NodeAlgorithm { void operator()(const NodePtr& node); private: - ShuntCounterDefinitions& shuntCounterDefs_; ///< the counter definitions to update + ShuntDefinitions& shuntDefs_; ///< the counter definitions to update }; /** diff --git a/sources/Algo/src/Algo.cpp b/sources/Algo/src/Algo.cpp index 750c8f3cb..295d1f116 100644 --- a/sources/Algo/src/Algo.cpp +++ b/sources/Algo/src/Algo.cpp @@ -644,12 +644,12 @@ DynModelAlgorithm::MacroConnectHash::operator()(const MacroConnect& connect) con ///////////////////////////////////////////////////////////////////////////////// -ShuntCounterAlgorithm::ShuntCounterAlgorithm(ShuntCounterDefinitions& defs) : shuntCounterDefs_(defs) {} +ShuntDefinitionAlgorithm::ShuntDefinitionAlgorithm(ShuntDefinitions& defs) : shuntDefs_(defs) {} void -ShuntCounterAlgorithm::operator()(const NodePtr& node) { +ShuntDefinitionAlgorithm::operator()(const NodePtr& node) { auto vl = node->voltageLevel.lock(); - shuntCounterDefs_.nbShunts[vl->id] += node->shunts.size(); + shuntDefs_.nbShunts[vl->id] += node->shunts.size(); } ////////////////////////////////////////////////////////////////////////////////// diff --git a/sources/Context.cpp b/sources/Context.cpp index 83266e8be..4b0e46207 100644 --- a/sources/Context.cpp +++ b/sources/Context.cpp @@ -66,7 +66,7 @@ Context::Context(const ContextDef& def, const inputs::Configuration& config) : networkManager_.onNode(algo::MainConnexComponentAlgorithm(mainConnexNodes_)); networkManager_.onNode(algo::DynModelAlgorithm(dynamicModels_, dynamicDataBaseManager_)); - networkManager_.onNode(algo::ShuntCounterAlgorithm(counters_)); + networkManager_.onNode(algo::ShuntDefinitionAlgorithm(shunts_)); networkManager_.onNode(algo::LinesByIdAlgorithm(linesById_)); } @@ -175,7 +175,7 @@ Context::exportOutputs() { file::path parOutput(config_.outputDir()); parOutput.append(basename_ + ".par"); outputs::Par parWriter(outputs::Par::ParDefinition(basename_, config_.outputDir(), parOutput, generators_, hvdcLineDefinitions_, - config_.getActivePowerCompensation(), busesWithDynamicModel_, dynamicDataBaseManager_, counters_, + config_.getActivePowerCompensation(), busesWithDynamicModel_, dynamicDataBaseManager_, shunts_, dynamicModels_, linesById_, svarcsDefinitions_)); parWriter.write(); diff --git a/sources/Context.h b/sources/Context.h index d25dadf2c..67ea96a5c 100644 --- a/sources/Context.h +++ b/sources/Context.h @@ -147,7 +147,7 @@ class Context { algo::HVDCLineDefinitions hvdcLineDefinitions_; ///< hvdc definitions algo::GeneratorDefinitionAlgorithm::BusGenMap busesWithDynamicModel_; ///< map of bus ids to a generator that regulates them algo::DynamicModelDefinitions dynamicModels_; ///< model definitions - algo::ShuntCounterDefinitions counters_; ///< shunt counters definitions + algo::ShuntDefinitions shunts_; ///< shunt counters definitions algo::LinesByIdDefinitions linesById_; ///< Lines by ids definition algo::StaticVarCompensatorDefinitions svarcsDefinitions_; ///< Static var compensators definitions to use diff --git a/sources/Inputs/include/Node.h b/sources/Inputs/include/Node.h index 47b58a7cb..f635940e5 100644 --- a/sources/Inputs/include/Node.h +++ b/sources/Inputs/include/Node.h @@ -149,6 +149,10 @@ struct Shunt { */ explicit Shunt(const ShuntId& id) : id(id) {} + bool operator==(const Shunt& other) const { + return id == other.id; + } + const ShuntId id; ///< Shunt id }; @@ -185,7 +189,7 @@ class Node { std::vector loads; ///< list of loads associated to this node std::vector generators; ///< list of generators associated to this node std::vector> converters; ///< list of converter associated to this node - std::vector svarcs; ///< List of static var compensators + std::vector svarcs; ///< List of static var compensators private: /** diff --git a/sources/Outputs/include/Par.h b/sources/Outputs/include/Par.h index 5768e7446..e49195828 100644 --- a/sources/Outputs/include/Par.h +++ b/sources/Outputs/include/Par.h @@ -54,7 +54,7 @@ class Par { * @param activePowerCompensation the type of active power compensation * @param busesWithDynamicModel map of bus ids to a generator that regulates them * @param dynamicDataBaseManager dynamic database manager to use - * @param counters the counters definitions to use + * @param shunts the shunts definitions to use * @param models list of dynamic models definitions * @param linesById the lines to use * @param svarcsDefinitions the SVarC definitions to use @@ -63,7 +63,7 @@ class Par { const std::vector& gens, const algo::HVDCLineDefinitions& hvdcDefinitions, inputs::Configuration::ActivePowerCompensation activePowerCompensation, const algo::GeneratorDefinitionAlgorithm::BusGenMap& busesWithDynamicModel, const inputs::DynamicDataBaseManager& dynamicDataBaseManager, - const algo::ShuntCounterDefinitions& counters, const algo::DynamicModelDefinitions& models, const algo::LinesByIdDefinitions& linesById, + const algo::ShuntDefinitions& shunts, const algo::DynamicModelDefinitions& models, const algo::LinesByIdDefinitions& linesById, const algo::StaticVarCompensatorDefinitions& svarcsDefinitions) : basename(base), dirname(dir), @@ -73,7 +73,7 @@ class Par { activePowerCompensation(activePowerCompensation), busesWithDynamicModel(busesWithDynamicModel), dynamicDataBaseManager(dynamicDataBaseManager), - shuntCounters(counters), + shuntsDefinitions(shunts), dynamicModelsDefinitions(models), linesByIdDefinitions(linesById), svarcsDefinitions(svarcsDefinitions) {} @@ -86,7 +86,7 @@ class Par { dfl::inputs::Configuration::ActivePowerCompensation activePowerCompensation; ///< the type of active power compensation const algo::GeneratorDefinitionAlgorithm::BusGenMap& busesWithDynamicModel; ///< map of bus ids to a generator that regulates them const inputs::DynamicDataBaseManager& dynamicDataBaseManager; ///< dynamic database manager - const algo::ShuntCounterDefinitions& shuntCounters; ///< Shunt counters to use + const algo::ShuntDefinitions& shuntsDefinitions; ///< Shunt shunts to use const algo::DynamicModelDefinitions& dynamicModelsDefinitions; ///< list of defined dynamic models const algo::LinesByIdDefinitions& linesByIdDefinitions; ///< lines by id to use const algo::StaticVarCompensatorDefinitions& svarcsDefinitions; ///< the SVarC definitions to use @@ -179,17 +179,15 @@ class Par { * * @param set the configuration set to write * @param assemblingDoc the corresponding assembling document handler - * @param counters the counters to use + * @param shunts the shunts to use * @param models the models definitions to use * @param linesById lines by id to use * * @returns the parameter set to add */ - static boost::shared_ptr writeDynamicModelParameterSet(const inputs::SettingXmlDocument::Set& set, - const inputs::AssemblingXmlDocument& assemblingDoc, - const algo::ShuntCounterDefinitions& counters, - const algo::DynamicModelDefinitions& models, - const algo::LinesByIdDefinitions& linesById); + static boost::shared_ptr + writeDynamicModelParameterSet(const inputs::SettingXmlDocument::Set& set, const inputs::AssemblingXmlDocument& assemblingDoc, + const algo::ShuntDefinitions& shunts, const algo::DynamicModelDefinitions& models, const algo::LinesByIdDefinitions& linesById); /** * @brief Retrieves the first component connected through the dynamic model to a transformer diff --git a/sources/Outputs/src/Par.cpp b/sources/Outputs/src/Par.cpp index 719b2cc8b..4aadd7227 100644 --- a/sources/Outputs/src/Par.cpp +++ b/sources/Outputs/src/Par.cpp @@ -222,7 +222,7 @@ Par::write() const { const auto& sets = def_.dynamicDataBaseManager.settingDocument().sets(); for (const auto& set : sets) { - auto new_set = writeDynamicModelParameterSet(set, def_.dynamicDataBaseManager.assemblingDocument(), def_.shuntCounters, def_.dynamicModelsDefinitions, + auto new_set = writeDynamicModelParameterSet(set, def_.dynamicDataBaseManager.assemblingDocument(), def_.shuntsDefinitions, def_.dynamicModelsDefinitions, def_.linesByIdDefinitions); if (new_set) { dynamicModelsToConnect->addParametersSet(new_set); @@ -245,7 +245,7 @@ Par::getTransformerComponentId(const algo::DynamicModelDefinition& dynModelDef) boost::shared_ptr Par::writeDynamicModelParameterSet(const inputs::SettingXmlDocument::Set& set, const inputs::AssemblingXmlDocument& assemblingDoc, - const algo::ShuntCounterDefinitions& counters, const algo::DynamicModelDefinitions& models, + const algo::ShuntDefinitions& shunts, const algo::DynamicModelDefinitions& models, const algo::LinesByIdDefinitions& linesById) { if (models.models.count(set.id) == 0) { // model is not connected : ignore corresponding set @@ -263,11 +263,11 @@ Par::writeDynamicModelParameterSet(const inputs::SettingXmlDocument::Set& set, c LOG(debug) << "Count id " << count.id << " not found as a multiple association in assembling: Configuration error" << LOG_ENDL; continue; } - if (counters.nbShunts.count(found->second.shunt.voltageLevel) == 0) { + if (shunts.nbShunts.count(found->second.shunt.voltageLevel) == 0) { // case voltage level not in network, skip continue; } - new_set->addParameter(helper::buildParameter(count.name, static_cast(counters.nbShunts.at(found->second.shunt.voltageLevel)))); + new_set->addParameter(helper::buildParameter(count.name, static_cast(shunts.nbShunts.at(found->second.shunt.voltageLevel)))); } for (const auto& param : set.boolParameters) { diff --git a/tests/algo/TestAlgo.cpp b/tests/algo/TestAlgo.cpp index e1fe9d09f..c928bd57e 100644 --- a/tests/algo/TestAlgo.cpp +++ b/tests/algo/TestAlgo.cpp @@ -708,8 +708,8 @@ TEST(Counter, base) { dfl::inputs::Node::build("6", vl2, 0.0, shunts6), }; - dfl::algo::ShuntCounterDefinitions defs; - dfl::algo::ShuntCounterAlgorithm algo(defs); + dfl::algo::ShuntDefinitions defs; + dfl::algo::ShuntDefinitionAlgorithm algo(defs); std::for_each(nodes.begin(), nodes.end(), algo); diff --git a/tests/outputs/TestPar.cpp b/tests/outputs/TestPar.cpp index 9e3291ff6..f59a2fa92 100644 --- a/tests/outputs/TestPar.cpp +++ b/tests/outputs/TestPar.cpp @@ -186,7 +186,7 @@ TEST(TestPar, DynModel) { boost::filesystem::create_directories(outputPath); } - dfl::algo::ShuntCounterDefinitions counters; + dfl::algo::ShuntDefinitions counters; counters.nbShunts["VL"] = 2; counters.nbShunts["VL2"] = 1;