diff --git a/sources/Algo/include/GeneratorDefinitionAlgorithm.h b/sources/Algo/include/GeneratorDefinitionAlgorithm.h index f9e40787..4635bc1a 100644 --- a/sources/Algo/include/GeneratorDefinitionAlgorithm.h +++ b/sources/Algo/include/GeneratorDefinitionAlgorithm.h @@ -165,12 +165,13 @@ class GeneratorDefinition { * @param targetP target active power of the generator * @param regulatedBusId the Bus Id this generator is regulating * @param isNuclear true if the energy source of this generator is nuclear + * @param hasActivePowerControl true if the generator has active power control information */ GeneratorDefinition(const inputs::Generator::GeneratorId &genId, ModelType type, const inputs::Node::NodeId &nodeId, const std::vector &curvePoints, double qmin, double qmax, double pmin, double pmax, double q, double targetP, - const BusId ®ulatedBusId, bool isNuclear = false) - : id{genId}, model{type}, nodeId{nodeId}, - points(curvePoints), qmin{qmin}, qmax{qmax}, pmin{pmin}, pmax{pmax}, q{q}, targetP{targetP}, regulatedBusId{regulatedBusId}, isNuclear{isNuclear} {} + const BusId ®ulatedBusId, bool isNuclear = false, bool hasActivePowerControl = false) + : id{genId}, model{type}, nodeId{nodeId}, points(curvePoints), qmin{qmin}, qmax{qmax}, pmin{pmin}, pmax{pmax}, q{q}, targetP{targetP}, + regulatedBusId{regulatedBusId}, isNuclear{isNuclear}, hasActivePowerControl{hasActivePowerControl} {} inputs::Generator::GeneratorId id; ///< generator id ModelType model; ///< model @@ -184,6 +185,7 @@ class GeneratorDefinition { double targetP; ///< target active power of the generator const BusId regulatedBusId; ///< regulated Bus Id const bool isNuclear; ///< true if the energy source of this generator is nuclear + const bool hasActivePowerControl; ///< true if the generator has active power control information }; /** diff --git a/sources/Algo/src/GeneratorDefinitionAlgorithm.cpp b/sources/Algo/src/GeneratorDefinitionAlgorithm.cpp index 9e3e9cc1..3673f037 100644 --- a/sources/Algo/src/GeneratorDefinitionAlgorithm.cpp +++ b/sources/Algo/src/GeneratorDefinitionAlgorithm.cpp @@ -171,7 +171,7 @@ void GeneratorDefinitionAlgorithm::operator()(const NodePtr &node, std::shared_p } } generators_.emplace_back(generator.id, model, node->id, generator.points, generator.qmin, generator.qmax, generator.pmin, generator.pmax, generator.q, - generator.targetP, generator.regulatedBusId, generator.isNuclear); + generator.targetP, generator.regulatedBusId, generator.isNuclear, generator.hasActivePowerControl); } } diff --git a/sources/Inputs/include/Behaviours.h b/sources/Inputs/include/Behaviours.h index b81b7060..953d6ca0 100644 --- a/sources/Inputs/include/Behaviours.h +++ b/sources/Inputs/include/Behaviours.h @@ -69,13 +69,14 @@ struct Generator { * @param regulatedBusId the Bus Id this generator is regulating * @param connectedBusId the Bus Id this generator is connected to * @param isNuclear true if the energy source of this generator is nuclear + * @param hasActivePowerControl true if the generator has active power control information */ explicit Generator(const GeneratorId &genId, const bool isVoltageRegulationOn, const std::vector &curvePoints, double qmin, double qmax, double pmin, double pmax, double q, double targetP, double VNom, const BusId ®ulatedBusId, const BusId &connectedBusId, - bool isNuclear = false) + bool isNuclear = false, bool hasActivePowerControl = false) : id{genId}, isVoltageRegulationOn{isVoltageRegulationOn}, points(curvePoints), qmin{qmin}, qmax{qmax}, pmin{pmin}, pmax{pmax}, q{q}, targetP{targetP}, VNom{VNom}, regulatedBusId{regulatedBusId}, - connectedBusId{connectedBusId}, isNuclear{isNuclear} {} + connectedBusId{connectedBusId}, isNuclear{isNuclear}, hasActivePowerControl{hasActivePowerControl} {} GeneratorId id; ///< generator id const bool isVoltageRegulationOn; ///< determines if generator is regulating voltage or not @@ -90,6 +91,7 @@ struct Generator { const BusId regulatedBusId; ///< regulated Bus Id const BusId connectedBusId; ///< connected Bus Id const bool isNuclear; ///< true if the energy source of this generator is nuclear + const bool hasActivePowerControl; ///< true if the generator has active power control information }; class HvdcLine; diff --git a/sources/Inputs/src/NetworkManager.cpp b/sources/Inputs/src/NetworkManager.cpp index eb5c74ac..4c31932f 100644 --- a/sources/Inputs/src/NetworkManager.cpp +++ b/sources/Inputs/src/NetworkManager.cpp @@ -38,7 +38,6 @@ #include #include - namespace dfl { namespace inputs { @@ -168,7 +167,7 @@ void NetworkManager::buildTree() { nodes_[nodeid]->generators.emplace_back(generator->getID(), generator->isVoltageRegulationOn(), generator->getReactiveCurvesPoints(), generator->getQMin(), generator->getQMax(), pmin, pmax, -generator->getQ(), targetP, generator->getBusInterface()->getVNom(), regulatedBusId, nodeid, - generator->getEnergySource() == DYN::GeneratorInterface::SOURCE_NUCLEAR); + generator->getEnergySource() == DYN::GeneratorInterface::SOURCE_NUCLEAR, generator->hasActivePowerControl()); LOG(debug, NodeContainsGen, nodeid, generator->getID()); } diff --git a/sources/Outputs/include/ParGenerator.h b/sources/Outputs/include/ParGenerator.h index d044b004..912d7c71 100644 --- a/sources/Outputs/include/ParGenerator.h +++ b/sources/Outputs/include/ParGenerator.h @@ -41,7 +41,7 @@ class ParGenerator { * * @param generatorDefinitions reference to the list of generator definitions */ - explicit ParGenerator(const std::vector& generatorDefinitions) : generatorDefinitions_(generatorDefinitions) {} + explicit ParGenerator(const std::vector &generatorDefinitions) : generatorDefinitions_(generatorDefinitions) {} /** * @brief enrich the parameter set collection for generators @@ -53,13 +53,9 @@ class ParGenerator { * @param startingPointMode starting point mode * @param dynamicDataBaseManager the dynamic DB manager to use */ - void - write(boost::shared_ptr& paramSetCollection, - ActivePowerCompensation activePowerCompensation, - const std::string& basename, - const boost::filesystem::path& dirname, - StartingPointMode startingPointMode, - const inputs::DynamicDataBaseManager& dynamicDataBaseManager); + void write(boost::shared_ptr ¶mSetCollection, ActivePowerCompensation activePowerCompensation, + const std::string &basename, const boost::filesystem::path &dirname, StartingPointMode startingPointMode, + const inputs::DynamicDataBaseManager &dynamicDataBaseManager); private: /** @@ -80,7 +76,7 @@ class ParGenerator { * @param startingPointMode starting point mode * @return the new macro parameter set */ - boost::shared_ptr buildGeneratorMacroParameterSet(const algo::GeneratorDefinition& def, + boost::shared_ptr buildGeneratorMacroParameterSet(const algo::GeneratorDefinition &def, ActivePowerCompensation activePowerCompensation, double targetP, StartingPointMode startingPointMode); @@ -94,7 +90,7 @@ class ParGenerator { * @returns the parameter set */ std::shared_ptr writeConstantGeneratorsSets(ActivePowerCompensation activePowerCompensation, - const algo::GeneratorDefinition& generator, StartingPointMode startingPointMode); + const algo::GeneratorDefinition &generator, StartingPointMode startingPointMode); /** * @brief Update parameter set with SignalN generator parameters and references @@ -103,9 +99,10 @@ class ParGenerator { * @param activePowerCompensation the type of active power compensation * @param targetP generator targetP value * @param startingPointMode starting point mode + * @param hasActivePowerControl true if the generator has active power control information */ void updateSignalNGenerator(std::shared_ptr set, dfl::inputs::Configuration::ActivePowerCompensation activePowerCompensation, - double targetP, StartingPointMode startingPointMode); + double targetP, StartingPointMode startingPointMode, bool hasActivePowerControl); /** * @brief Update parameter set with transformer parameters @@ -123,7 +120,7 @@ class ParGenerator { * @param databaseSetting the settings found in setting file * @param Rcpl2 true if the model used is RPCL2, false otherwise */ - void updateRpclParameters(std::shared_ptr set, const std::string& genId, const inputs::SettingDataBase::Set& databaseSetting, + void updateRpclParameters(std::shared_ptr set, const std::string &genId, const inputs::SettingDataBase::Set &databaseSetting, bool Rcpl2); /** @@ -135,18 +132,17 @@ class ParGenerator { * * @returns the parameter set */ - std::shared_ptr writeGenerator(const algo::GeneratorDefinition& def, const std::string& basename, - const boost::filesystem::path& dirname); + std::shared_ptr writeGenerator(const algo::GeneratorDefinition &def, const std::string &basename, + const boost::filesystem::path &dirname); /** - * @brief determine value of kGover based on generator targetP value + * @brief * + * @param set the parameter set to update + * @param hasActivePowerControl if the generator has active power control information * @param targetP generator targetP value - * @returns kGover value */ - inline double getKGoverValue(double targetP) { - return DYN::doubleIsZero(targetP) ? constants::kGoverNullValue_ : constants::kGoverDefaultValue_; - } + template void setKGover(T &set, const bool hasActivePowerControl, const double targetP); /** * @brief update a parameter set with information specific to remote voltage regulation for a generator @@ -155,10 +151,10 @@ class ParGenerator { * @param def the generator definition to use * @param set the parameter set to be updated */ - void updateRemoteRegulationParameters(const algo::GeneratorDefinition& def, std::shared_ptr set); + void updateRemoteRegulationParameters(const algo::GeneratorDefinition &def, std::shared_ptr set); private: - const std::vector& generatorDefinitions_; ///< list of generators definitions + const std::vector &generatorDefinitions_; ///< list of generators definitions }; } // namespace outputs diff --git a/sources/Outputs/src/ParGenerator.cpp b/sources/Outputs/src/ParGenerator.cpp index 072736e4..a2d7d6c4 100644 --- a/sources/Outputs/src/ParGenerator.cpp +++ b/sources/Outputs/src/ParGenerator.cpp @@ -44,7 +44,7 @@ void ParGenerator::write(boost::shared_ptr dynamicDataBaseManager.setting().getSet(dynamicDataBaseManager.assembling().getSingleAssociationFromGenerator(generator.id)), generator.hasRpcl2()); if (!generator.isUsingDiagram()) { - updateSignalNGenerator(paramSet, activePowerCompensation, generator.targetP, startingPointMode); + updateSignalNGenerator(paramSet, activePowerCompensation, generator.targetP, startingPointMode, generator.hasActivePowerControl); } } if (paramSet && generator.hasTransformer()) { @@ -122,7 +122,7 @@ boost::shared_ptr ParGenerator::buildGeneratorMac } macroParameterSet->addReference(helper::buildReference("generator_PRef0Pu", "targetP_pu", "DOUBLE")); - macroParameterSet->addParameter(helper::buildParameter("generator_KGover", getKGoverValue(targetP))); + setKGover(macroParameterSet, def.hasActivePowerControl, targetP); switch (activePowerCompensation) { case ActivePowerCompensation::P: @@ -192,8 +192,8 @@ boost::shared_ptr ParGenerator::buildGeneratorMac } void ParGenerator::updateSignalNGenerator(std::shared_ptr set, ActivePowerCompensation activePowerCompensation, double targetP, - StartingPointMode startingPointMode) { - set->addParameter(helper::buildParameter("generator_KGover", getKGoverValue(targetP))); + StartingPointMode startingPointMode, bool hasActivePowerControl) { + setKGover(set, hasActivePowerControl, targetP); set->addParameter(helper::buildParameter("generator_QMin", -constants::powerValueMax)); set->addParameter(helper::buildParameter("generator_QMax", constants::powerValueMax)); set->addParameter(helper::buildParameter("generator_PMin", -constants::powerValueMax)); @@ -240,7 +240,7 @@ std::shared_ptr ParGenerator::writeConstantGenerators const algo::GeneratorDefinition &generator, StartingPointMode startingPointMode) { auto set = parameters::ParametersSetFactory::newParametersSet(helper::getGeneratorParameterSetId(generator)); - updateSignalNGenerator(set, activePowerCompensation, generator.targetP, startingPointMode); + updateSignalNGenerator(set, activePowerCompensation, generator.targetP, startingPointMode, generator.hasActivePowerControl); switch (generator.model) { case ModelType::PROP_SIGNALN_INFINITE: case ModelType::PROP_DIAGRAM_PQ_SIGNALN: @@ -323,5 +323,17 @@ void ParGenerator::updateRpclParameters(std::shared_ptr void ParGenerator::setKGover(T &set, const bool hasActivePowerControl, const double targetP) { + if (DYN::doubleIsZero(targetP)) { + set->addParameter(helper::buildParameter("generator_KGover", constants::kGoverNullValue_)); + } else { + if (hasActivePowerControl) { + set->addReference(helper::buildReference("generator_KGover", "kGover", "DOUBLE")); + } else { + set->addParameter(helper::buildParameter("generator_KGover", constants::kGoverDefaultValue_)); + } + } +} + } // namespace outputs } // namespace dfl