Skip to content

Commit

Permalink
#216 Rename shunt definitions algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
Le Courtois Florent committed Oct 1, 2021
1 parent 0268d20 commit 3ff0ad0
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 29 deletions.
10 changes: 5 additions & 5 deletions sources/Algo/include/Algo.h
Original file line number Diff line number Diff line change
Expand Up @@ -864,22 +864,22 @@ class DynModelAlgorithm : public NodeAlgorithm {
};

/**
* @brief Shunt counter definition
* @brief Shunt definitions
*/
struct ShuntCounterDefinitions {
struct ShuntDefinitions {
std::unordered_map<inputs::VoltageLevel::VoltageLevelId, unsigned int> 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
Expand All @@ -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
};

/**
Expand Down
6 changes: 3 additions & 3 deletions sources/Algo/src/Algo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

//////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions sources/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_));
}

Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion sources/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion sources/Inputs/include/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down Expand Up @@ -185,7 +189,7 @@ class Node {
std::vector<Load> loads; ///< list of loads associated to this node
std::vector<Generator> generators; ///< list of generators associated to this node
std::vector<std::weak_ptr<Converter>> converters; ///< list of converter associated to this node
std::vector<StaticVarCompensator> svarcs; ///< List of static var compensators
std::vector<StaticVarCompensator> svarcs; ///< List of static var compensators

private:
/**
Expand Down
18 changes: 8 additions & 10 deletions sources/Outputs/include/Par.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -63,7 +63,7 @@ class Par {
const std::vector<algo::GeneratorDefinition>& 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),
Expand All @@ -73,7 +73,7 @@ class Par {
activePowerCompensation(activePowerCompensation),
busesWithDynamicModel(busesWithDynamicModel),
dynamicDataBaseManager(dynamicDataBaseManager),
shuntCounters(counters),
shuntsDefinitions(shunts),
dynamicModelsDefinitions(models),
linesByIdDefinitions(linesById),
svarcsDefinitions(svarcsDefinitions) {}
Expand All @@ -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
Expand Down Expand Up @@ -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<parameters::ParametersSet> 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<parameters::ParametersSet>
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
Expand Down
8 changes: 4 additions & 4 deletions sources/Outputs/src/Par.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -245,7 +245,7 @@ Par::getTransformerComponentId(const algo::DynamicModelDefinition& dynModelDef)

boost::shared_ptr<parameters::ParametersSet>
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
Expand All @@ -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<int>(counters.nbShunts.at(found->second.shunt.voltageLevel))));
new_set->addParameter(helper::buildParameter(count.name, static_cast<int>(shunts.nbShunts.at(found->second.shunt.voltageLevel))));
}

for (const auto& param : set.boolParameters) {
Expand Down
4 changes: 2 additions & 2 deletions tests/algo/TestAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion tests/outputs/TestPar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 3ff0ad0

Please sign in to comment.