Skip to content

Commit

Permalink
#216 Update par for shunts
Browse files Browse the repository at this point in the history
  • Loading branch information
Le Courtois Florent committed Dec 8, 2021
1 parent 837b824 commit 016daf5
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions sources/Outputs/include/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const std::string propSignalNGeneratorFixedPParId{"propSignalNGeneratorFixedP"};
const std::string remoteVControlParId{"remoteVControl"}; ///< PAR id for using remote voltage control
const std::string remoteSignalNGeneratorFixedP{"remoteSignalNFixedP"}; ///< PAR id for using remote signal N with fixed P
const std::string xmlEncoding{"UTF-8"}; ///< Default encoding for XML outputs files
const std::string diagramTableBPu{"tableBPu"};

constexpr double powerValueMax = std::numeric_limits<double>::max(); ///< Maximum value for powers, meaning infinite

Expand Down
3 changes: 3 additions & 0 deletions sources/Outputs/include/Par.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ class Par {
static boost::shared_ptr<parameters::ParametersSet> writeShuntRegulation(const inputs::Shunt::BusId& busId,
const std::vector<std::reference_wrapper<const dfl::inputs::Shunt>>& shunts);

static boost::shared_ptr<parameters::ParametersSet> writeShuntBSection(const inputs::Shunt& shunt, unsigned int index, const std::string& basename,
const boost::filesystem::path& dirname);

/**
* @brief Write remote voltage regulators parameter set
*
Expand Down
2 changes: 1 addition & 1 deletion sources/Outputs/src/Diagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Diagram::writeShunt(const inputs::Shunt& shunt) const {
std::stringstream buffer;
// Modelica requires this file to start with "#1", if it is not present, problems occurs
buffer << "#1" << std::endl;
buffer << "double tableBPu(" << shunt.bSections.size() << ", 2)" << std::endl;
buffer << "double " << constants::diagramTableBPu << "(" << shunt.bSections.size() << ", 2)" << std::endl;

for (auto it = shunt.bSections.begin(); it != shunt.bSections.end(); ++it) {
unsigned int index = it - shunt.bSections.begin();
Expand Down
21 changes: 21 additions & 0 deletions sources/Outputs/src/Par.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ Par::write() const {
auto shuntsByIds = constants::computeFilteredShuntsByIds(def_.shuntsDefinitions);
for (const auto& shuntDefPair : shuntsByIds) {
dynamicModelsToConnect->addParametersSet(writeShuntRegulation(shuntDefPair.first, shuntDefPair.second));
for (auto it = shuntDefPair.second.begin(); it != shuntDefPair.second.end(); ++it) {
unsigned int index = it - shuntDefPair.second.begin();
dynamicModelsToConnect->addParametersSet(writeShuntBSection(*it, index, def_.basename, def_.dirname));
}
}

exporter.exportToFile(dynamicModelsToConnect, def_.filepath.generic_string(), constants::xmlEncoding);
Expand Down Expand Up @@ -551,6 +555,23 @@ Par::writeShuntRegulation(const inputs::Shunt::BusId& busId, const std::vector<s
return set;
}

boost::shared_ptr<parameters::ParametersSet>
Par::writeShuntBSection(const inputs::Shunt& shunt, unsigned int index, const std::string& basename, const boost::filesystem::path& dirname) {
auto set = boost::shared_ptr<parameters::ParametersSet>(new parameters::ParametersSet(shunt.id));

auto tableFilename = dirname;
tableFilename.append(basename + constants::diagramDirectorySuffix).append(constants::diagramFilename(shunt.id));

set->addParameter(helper::buildParameter("shunt_Section0", static_cast<double>(index)));
set->addParameter(helper::buildParameter("shunt_TableBPuName", constants::diagramTableBPu));
set->addParameter(helper::buildParameter("shunt_TableBPuFile", tableFilename.generic_string()));
set->addParameter(helper::buildParameter("shunt_Q0Pu", 0.));
set->addReference(helper::buildReference("shunt_U0Pu", "v_pu", "DOUBLE", shunt.busId));
set->addReference(helper::buildReference("shunt_UPhase0", "angle_pu", "DOUBLE", shunt.busId));

return set;
}

boost::shared_ptr<parameters::ParametersSet>
Par::writeGenerator(const algo::GeneratorDefinition& def, const std::string& basename, const boost::filesystem::path& dirname) {
std::size_t hashId = constants::hash(def.id);
Expand Down
24 changes: 24 additions & 0 deletions tests/outputs/reference/TestParShunts/TestParShunts.par
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<parametersSet xmlns="http://www.rte-france.com/dynawo">
<set id="1">
<par name="shunt_Q0Pu" type="DOUBLE" value="0"/>
<par name="shunt_Section0" type="DOUBLE" value="1"/>
<par name="shunt_TableBPuFile" type="STRING" value="results/TestParShunts_Diagram/1_Diagram.txt"/>
<par name="shunt_TableBPuName" type="STRING" value="tableBPu"/>
<reference type="DOUBLE" name="shunt_U0Pu" origData="IIDM" origName="v_pu" componentId="01"/>
<reference type="DOUBLE" name="shunt_UPhase0" origData="IIDM" origName="angle_pu" componentId="01"/>
</set>
<set id="1.1">
<par name="shunt_Q0Pu" type="DOUBLE" value="0"/>
<par name="shunt_Section0" type="DOUBLE" value="0"/>
<par name="shunt_TableBPuFile" type="STRING" value="results/TestParShunts_Diagram/1.1_Diagram.txt"/>
<par name="shunt_TableBPuName" type="STRING" value="tableBPu"/>
<reference type="DOUBLE" name="shunt_U0Pu" origData="IIDM" origName="v_pu" componentId="01"/>
<reference type="DOUBLE" name="shunt_UPhase0" origData="IIDM" origName="angle_pu" componentId="01"/>
</set>
<set id="2">
<par name="shunt_Q0Pu" type="DOUBLE" value="0"/>
<par name="shunt_Section0" type="DOUBLE" value="0"/>
<par name="shunt_TableBPuFile" type="STRING" value="results/TestParShunts_Diagram/2_Diagram.txt"/>
<par name="shunt_TableBPuName" type="STRING" value="tableBPu"/>
<reference type="DOUBLE" name="shunt_U0Pu" origData="IIDM" origName="v_pu" componentId="02"/>
<reference type="DOUBLE" name="shunt_UPhase0" origData="IIDM" origName="angle_pu" componentId="02"/>
</set>
<set id="GenericRestorativeLoad">
<par name="load_Alpha" type="DOUBLE" value="1.5"/>
<par name="load_Beta" type="DOUBLE" value="2.5"/>
Expand Down

0 comments on commit 016daf5

Please sign in to comment.