Skip to content

Commit

Permalink
#814 get kGover information from dataInterface and use it when available
Browse files Browse the repository at this point in the history
Signed-off-by: CHIARAMELLO Marco <[email protected]>
  • Loading branch information
marcochiaramello committed Dec 20, 2024
1 parent 7e33950 commit 7082622
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 34 deletions.
8 changes: 5 additions & 3 deletions sources/Algo/include/GeneratorDefinitionAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReactiveCurvePoint> &curvePoints, double qmin, double qmax, double pmin, double pmax, double q, double targetP,
const BusId &regulatedBusId, 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 &regulatedBusId, 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
Expand All @@ -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
};

/**
Expand Down
2 changes: 1 addition & 1 deletion sources/Algo/src/GeneratorDefinitionAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
6 changes: 4 additions & 2 deletions sources/Inputs/include/Behaviours.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReactiveCurvePoint> &curvePoints, double qmin, double qmax,
double pmin, double pmax, double q, double targetP, double VNom, const BusId &regulatedBusId, 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
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions sources/Inputs/src/NetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <DYNVoltageLevelInterface.h>
#include <DYNVscConverterInterface.h>


namespace dfl {
namespace inputs {

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

Expand Down
38 changes: 17 additions & 21 deletions sources/Outputs/include/ParGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ParGenerator {
*
* @param generatorDefinitions reference to the list of generator definitions
*/
explicit ParGenerator(const std::vector<algo::GeneratorDefinition>& generatorDefinitions) : generatorDefinitions_(generatorDefinitions) {}
explicit ParGenerator(const std::vector<algo::GeneratorDefinition> &generatorDefinitions) : generatorDefinitions_(generatorDefinitions) {}

/**
* @brief enrich the parameter set collection for generators
Expand All @@ -53,13 +53,9 @@ class ParGenerator {
* @param startingPointMode starting point mode
* @param dynamicDataBaseManager the dynamic DB manager to use
*/
void
write(boost::shared_ptr<parameters::ParametersSetCollection>& paramSetCollection,
ActivePowerCompensation activePowerCompensation,
const std::string& basename,
const boost::filesystem::path& dirname,
StartingPointMode startingPointMode,
const inputs::DynamicDataBaseManager& dynamicDataBaseManager);
void write(boost::shared_ptr<parameters::ParametersSetCollection> &paramSetCollection, ActivePowerCompensation activePowerCompensation,
const std::string &basename, const boost::filesystem::path &dirname, StartingPointMode startingPointMode,
const inputs::DynamicDataBaseManager &dynamicDataBaseManager);

private:
/**
Expand All @@ -80,7 +76,7 @@ class ParGenerator {
* @param startingPointMode starting point mode
* @return the new macro parameter set
*/
boost::shared_ptr<parameters::MacroParameterSet> buildGeneratorMacroParameterSet(const algo::GeneratorDefinition& def,
boost::shared_ptr<parameters::MacroParameterSet> buildGeneratorMacroParameterSet(const algo::GeneratorDefinition &def,
ActivePowerCompensation activePowerCompensation, double targetP,
StartingPointMode startingPointMode);

Expand All @@ -94,7 +90,7 @@ class ParGenerator {
* @returns the parameter set
*/
std::shared_ptr<parameters::ParametersSet> 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
Expand All @@ -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<parameters::ParametersSet> set, dfl::inputs::Configuration::ActivePowerCompensation activePowerCompensation,
double targetP, StartingPointMode startingPointMode);
double targetP, StartingPointMode startingPointMode, bool hasActivePowerControl);

/**
* @brief Update parameter set with transformer parameters
Expand All @@ -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<parameters::ParametersSet> set, const std::string& genId, const inputs::SettingDataBase::Set& databaseSetting,
void updateRpclParameters(std::shared_ptr<parameters::ParametersSet> set, const std::string &genId, const inputs::SettingDataBase::Set &databaseSetting,
bool Rcpl2);

/**
Expand All @@ -135,18 +132,17 @@ class ParGenerator {
*
* @returns the parameter set
*/
std::shared_ptr<parameters::ParametersSet> writeGenerator(const algo::GeneratorDefinition& def, const std::string& basename,
const boost::filesystem::path& dirname);
std::shared_ptr<parameters::ParametersSet> 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 <class T> 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
Expand All @@ -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<parameters::ParametersSet> set);
void updateRemoteRegulationParameters(const algo::GeneratorDefinition &def, std::shared_ptr<parameters::ParametersSet> set);

private:
const std::vector<algo::GeneratorDefinition>& generatorDefinitions_; ///< list of generators definitions
const std::vector<algo::GeneratorDefinition> &generatorDefinitions_; ///< list of generators definitions
};

} // namespace outputs
Expand Down
22 changes: 17 additions & 5 deletions sources/Outputs/src/ParGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void ParGenerator::write(boost::shared_ptr<parameters::ParametersSetCollection>
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()) {
Expand Down Expand Up @@ -122,7 +122,7 @@ boost::shared_ptr<parameters::MacroParameterSet> 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:
Expand Down Expand Up @@ -192,8 +192,8 @@ boost::shared_ptr<parameters::MacroParameterSet> ParGenerator::buildGeneratorMac
}

void ParGenerator::updateSignalNGenerator(std::shared_ptr<parameters::ParametersSet> 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));
Expand Down Expand Up @@ -240,7 +240,7 @@ std::shared_ptr<parameters::ParametersSet> 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:
Expand Down Expand Up @@ -323,5 +323,17 @@ void ParGenerator::updateRpclParameters(std::shared_ptr<parameters::ParametersSe
}
}

template <class T> 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

0 comments on commit 7082622

Please sign in to comment.