forked from sogno-platform/dpsim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update WSCC_9bus_mult examples and implement splitting examples in DP…
… and EMT (sogno-platform#322) Currently, the examples `WSCC_9bus_mult_coupled.cpp` and `WSCC_9bus_mult_decoupled.cpp` don't work when the `copies` option is greater than zero, due to `clone()` methods missing in some components. Additionally, the `WSCC_9bus_parallel.ipynb` Notebook must be fixed because it does not find the CIM files of the scenario. Finally, we want to implement a similar Noteboook, based on the python script [decoupling_9bus_existing.py](https://github.com/sogno-platform/dpsim/blob/master/examples/Python/RuntimeMeas/decoupling_9bus_existing.py) for testing the process for splitting the WSCC 9 bus system using a decoupling line in both the DP and the EMT domains.
- Loading branch information
Showing
17 changed files
with
567 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
dpsim/examples/cxx/CIM/DP_WSCC_9bus_split_decoupled.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* Copyright 2017-2021 Institute for Automation of Complex Power Systems, | ||
* EONERC, RWTH Aachen University | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*********************************************************************************/ | ||
|
||
#include <fstream> | ||
#include <iostream> | ||
#include <list> | ||
|
||
#include <DPsim.h> | ||
#include <dpsim/ThreadLevelScheduler.h> | ||
|
||
using namespace DPsim; | ||
using namespace CPS; | ||
|
||
String decoupleLine(SystemTopology &sys, const String &lineName, const String &node1, const String node2) { | ||
auto origLine = sys.component<DP::Ph1::PiLine>(lineName); | ||
Real Rline = origLine->attributeTyped<Real>("R_series")->get(); | ||
Real Lline = origLine->attributeTyped<Real>("L_series")->get(); | ||
Real Cline = origLine->attributeTyped<Real>("C_parallel")->get(); | ||
|
||
sys.removeComponent(lineName); | ||
|
||
String dline_name = "dline_" + node1 + "_" + node2; | ||
|
||
auto line = Signal::DecouplingLine::make( | ||
"dline_" + node1 + "_" + node2, sys.node<DP::SimNode>(node1), | ||
sys.node<DP::SimNode>(node2), Rline, Lline, Cline, Logger::Level::debug | ||
); | ||
sys.addComponent(line); | ||
sys.addComponents(line->getLineComponents()); | ||
|
||
return dline_name; | ||
} | ||
|
||
void doSim(String &name, SystemTopology &sys, Int threads) { | ||
|
||
// Logging | ||
auto logger = DataLogger::make(name); | ||
// logger->logAttribute("BUS5.v", sys.node<DP::SimNode>("BUS5")->attribute("v")); | ||
// logger->logAttribute("BUS6.v", sys.node<DP::SimNode>("BUS6")->attribute("v")); | ||
// logger->logAttribute("BUS8.v", sys.node<DP::SimNode>("BUS8")->attribute("v")); | ||
for (Int bus = 1; bus <= 9; bus++) { | ||
String attrName = "v" + std::to_string(bus); | ||
String nodeName = "BUS" + std::to_string(bus); | ||
logger->logAttribute(attrName, sys.node<DP::SimNode>(nodeName)->attribute("v")); | ||
} | ||
|
||
Simulation sim(name, Logger::Level::debug); | ||
sim.setSystem(sys); | ||
sim.setTimeStep(0.0001); | ||
sim.setFinalTime(0.5); | ||
sim.setDomain(Domain::DP); | ||
sim.doSplitSubnets(true); | ||
sim.doInitFromNodesAndTerminals(true); | ||
sim.addLogger(logger); | ||
if (threads > 0) | ||
sim.setScheduler(std::make_shared<OpenMPLevelScheduler>(threads)); | ||
|
||
//std::ofstream of1("topology_graph.svg"); | ||
//sys.topologyGraph().render(of1)); | ||
|
||
sim.run(); | ||
sim.logStepTimes(name + "_step_times"); | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
CommandLineArgs args(argc, argv); | ||
|
||
std::list<fs::path> filenames; | ||
filenames = DPsim::Utils::findFiles( | ||
{"WSCC-09_DI.xml", "WSCC-09_EQ.xml", "WSCC-09_SV.xml", | ||
"WSCC-09_TP.xml"}, | ||
"build/_deps/cim-data-src/WSCC-09/WSCC-09", "CIMPATH"); | ||
|
||
Int numThreads = 0; | ||
Int numSeq = 0; | ||
|
||
if (args.options.find("threads") != args.options.end()) | ||
numThreads = args.getOptionInt("threads"); | ||
if (args.options.find("seq") != args.options.end()) | ||
numSeq = args.getOptionInt("seq"); | ||
|
||
std::cout << "Simulate with " << numThreads | ||
<< " threads, sequence number " << numSeq << std::endl; | ||
|
||
// Monolithic Simulation | ||
String simNameMonolithic = "WSCC-9bus_monolithic_DP"; | ||
Logger::setLogDir("logs/" + simNameMonolithic); | ||
CIM::Reader readerMonolithic(simNameMonolithic, Logger::Level::debug, Logger::Level::debug); | ||
SystemTopology systemMonolithic = | ||
readerMonolithic.loadCIM(60, filenames, Domain::DP, PhaseType::Single, | ||
CPS::GeneratorType::IdealVoltageSource); | ||
|
||
doSim(simNameMonolithic, systemMonolithic, 0); | ||
|
||
// Decoupled Simulation | ||
String simNameDecoupled = "WSCC_9bus_split_decoupled_DP_" + std::to_string(numThreads) + "_" + std::to_string(numSeq); | ||
Logger::setLogDir("logs/" + simNameDecoupled); | ||
CIM::Reader readerDecoupled(simNameDecoupled, Logger::Level::debug, Logger::Level::debug); | ||
SystemTopology systemDecoupled = readerDecoupled.loadCIM(60, filenames, Domain::DP, PhaseType::Single, | ||
CPS::GeneratorType::IdealVoltageSource); | ||
|
||
String dline_75 = decoupleLine(systemDecoupled, "LINE75", "BUS5", "BUS7"); | ||
// decouple_line(system, "LINE78", "BUS7", "BUS8"); | ||
String dline_64 = decoupleLine(systemDecoupled, "LINE64", "BUS6", "BUS4"); | ||
String dline_89 = decoupleLine(systemDecoupled, "LINE89", "BUS8", "BUS9"); | ||
|
||
doSim(simNameDecoupled, systemDecoupled, numThreads); | ||
} |
121 changes: 121 additions & 0 deletions
121
dpsim/examples/cxx/CIM/EMT_WSCC_9bus_split_decoupled.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* Copyright 2017-2021 Institute for Automation of Complex Power Systems, | ||
* EONERC, RWTH Aachen University | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*********************************************************************************/ | ||
|
||
#include <fstream> | ||
#include <iostream> | ||
#include <list> | ||
|
||
#include <DPsim.h> | ||
#include <dpsim/ThreadLevelScheduler.h> | ||
|
||
using namespace DPsim; | ||
using namespace CPS; | ||
|
||
String decoupleLine(SystemTopology &sys, const String &lineName, const String &node1, const String node2) { | ||
auto origLine = sys.component<EMT::Ph3::PiLine>(lineName); | ||
Matrix Rline = origLine->attributeTyped<Matrix>("R_series")->get(); | ||
Matrix Lline = origLine->attributeTyped<Matrix>("L_series")->get(); | ||
Matrix Cline = origLine->attributeTyped<Matrix>("C_parallel")->get(); | ||
|
||
sys.removeComponent(lineName); | ||
|
||
String dline_name = "dline_" + node1 + "_" + node2; | ||
|
||
auto line = Signal::DecouplingLineEMT::make( | ||
"dline_" + node1 + "_" + node2, | ||
Logger::Level::debug | ||
); | ||
|
||
Real Rline_scalar = Rline(0,0); | ||
Real Lline_scalar = Lline(0,0); | ||
Real Cline_scalar = Cline(0,0); | ||
|
||
line->setParameters( | ||
sys.node<EMT::SimNode>(node1), sys.node<EMT::SimNode>(node2), | ||
Rline_scalar, Lline_scalar, Cline_scalar); | ||
sys.addComponent(line); | ||
sys.addComponents(line->getLineComponents()); | ||
|
||
return dline_name; | ||
} | ||
|
||
void doSim(String &name, SystemTopology &sys, Int threads) { | ||
|
||
// Logging | ||
auto logger = DataLogger::make(name); | ||
// logger->logAttribute("BUS5.v", sys.node<EMT::SimNode>("BUS5")->attribute("v")); | ||
// logger->logAttribute("BUS6.v", sys.node<EMT::SimNode>("BUS6")->attribute("v")); | ||
// logger->logAttribute("BUS8.v", sys.node<EMT::SimNode>("BUS8")->attribute("v")); | ||
for (Int bus = 1; bus <= 9; bus++) { | ||
String attrName = "v" + std::to_string(bus); | ||
String nodeName = "BUS" + std::to_string(bus); | ||
logger->logAttribute(attrName, sys.node<EMT::SimNode>(nodeName)->attribute("v")); | ||
} | ||
|
||
Simulation sim(name, Logger::Level::debug); | ||
sim.setSystem(sys); | ||
sim.setTimeStep(0.0001); | ||
sim.setFinalTime(0.5); | ||
sim.setDomain(Domain::EMT); | ||
sim.doSplitSubnets(true); | ||
sim.doInitFromNodesAndTerminals(true); | ||
sim.addLogger(logger); | ||
if (threads > 0) | ||
sim.setScheduler(std::make_shared<OpenMPLevelScheduler>(threads)); | ||
|
||
//std::ofstream of1("topology_graph.svg"); | ||
//sys.topologyGraph().render(of1)); | ||
|
||
sim.run(); | ||
sim.logStepTimes(name + "_step_times"); | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
CommandLineArgs args(argc, argv); | ||
|
||
std::list<fs::path> filenames; | ||
filenames = DPsim::Utils::findFiles( | ||
{"WSCC-09_DI.xml", "WSCC-09_EQ.xml", "WSCC-09_SV.xml", | ||
"WSCC-09_TP.xml"}, | ||
"build/_deps/cim-data-src/WSCC-09/WSCC-09", "CIMPATH"); | ||
|
||
Int numThreads = 0; | ||
Int numSeq = 0; | ||
|
||
if (args.options.find("threads") != args.options.end()) | ||
numThreads = args.getOptionInt("threads"); | ||
if (args.options.find("seq") != args.options.end()) | ||
numSeq = args.getOptionInt("seq"); | ||
|
||
std::cout << "Simulate with " << numThreads | ||
<< " threads, sequence number " << numSeq << std::endl; | ||
|
||
// Monolithic Simulation | ||
String simNameMonolithic = "WSCC-9bus_monolithic_EMT"; | ||
Logger::setLogDir("logs/" + simNameMonolithic); | ||
CIM::Reader readerMonolithic(simNameMonolithic, Logger::Level::debug, Logger::Level::debug); | ||
SystemTopology systemMonolithic = | ||
readerMonolithic.loadCIM(60, filenames, Domain::EMT, PhaseType::ABC, | ||
CPS::GeneratorType::IdealVoltageSource); | ||
|
||
doSim(simNameMonolithic, systemMonolithic, 0); | ||
|
||
// Decoupled Simulation | ||
String simNameDecoupled = "WSCC_9bus_split_decoupled_EMT_" + std::to_string(numThreads) + "_" + std::to_string(numSeq); | ||
Logger::setLogDir("logs/" + simNameDecoupled); | ||
CIM::Reader readerDecoupled(simNameDecoupled, Logger::Level::debug, Logger::Level::debug); | ||
SystemTopology systemDecoupled = readerDecoupled.loadCIM(60, filenames, Domain::EMT, PhaseType::ABC, | ||
CPS::GeneratorType::IdealVoltageSource); | ||
|
||
String dline_75 = decoupleLine(systemDecoupled, "LINE75", "BUS5", "BUS7"); | ||
// decouple_line(system, "LINE78", "BUS7", "BUS8"); | ||
String dline_64 = decoupleLine(systemDecoupled, "LINE64", "BUS6", "BUS4"); | ||
String dline_89 = decoupleLine(systemDecoupled, "LINE89", "BUS8", "BUS9"); | ||
|
||
doSim(simNameDecoupled, systemDecoupled, numThreads); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.