Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update WSCC_9bus_mult examples and implement splitting examples in DP and EMT #322

Merged
merged 19 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ec879e1
Implement DP's RXLoad clone method.
pipeacosta Oct 8, 2024
41e7992
Log bus voltages and adapt relative path to work
pipeacosta Oct 8, 2024
7fc21fb
Change domain to DP in reference system.
pipeacosta Oct 8, 2024
91a8e0e
Use one copy in parallel testing Notebook.
pipeacosta Oct 8, 2024
0ea4742
Implement removeComponent method.
pipeacosta Oct 14, 2024
261f3bb
Implement add and remove component functions in dpsimpy.
pipeacosta Oct 14, 2024
177c85d
Update decoupling_9bus_existing python script.
pipeacosta Oct 14, 2024
98e6cb0
Implement SP_Ph1_CurrentSource
pipeacosta Oct 16, 2024
e17a698
Add SP_Ph1_CurrentSource to CMakeLists
pipeacosta Oct 16, 2024
5dd8353
Fix simulation domain in decoupling_9bus_existing
pipeacosta Oct 19, 2024
5085c08
WIP: Improve nine bus parallel Notebook by using the CIMPATH variable
pipeacosta Oct 19, 2024
64f5c21
Implement new tests for the WSCC9bus system with decoupling line
pipeacosta Oct 19, 2024
090454f
Implement new Notebook for the WSCC_9bus system with decoupling line
pipeacosta Oct 19, 2024
898681f
Fix compilation using Clang
pipeacosta Oct 20, 2024
eac8ada
Undo changes to the WSCC-9bus_CIM example.
pipeacosta Oct 24, 2024
1e72e45
Rename split decoupling line examples.
pipeacosta Oct 30, 2024
cf86ca7
Fix path to CIM files in decoupling line diakoptics example.
pipeacosta Oct 30, 2024
47eacf1
Remove SP_Ph1_CurrentSource component.
pipeacosta Oct 30, 2024
7f04b31
Add splitting decoupling line examples to rocky profiling workflow.
pipeacosta Nov 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/build_test_linux_fedora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Configure CMake
shell: bash
working-directory: ${{ github.workspace }}/build
run: cmake -DCIM_VERSION=CGMES_2.4.15_16FEB2016 $GITHUB_WORKSPACE
run: cmake -DCIM_VERSION=CGMES_2.4.15_16FEB2016 $GITHUB_WORKSPACE

- name: Build every target
shell: bash
Expand Down Expand Up @@ -194,12 +194,18 @@ jobs:
run: |
chmod -R +x ./build/dpsim/examples/cxx

- name: Run Binaries 1/2
- name: Run Binaries 1/4
run: ./build/dpsim/examples/cxx/WSCC_9bus_mult_coupled

- name: Run Binaries 2/2
- name: Run Binaries 2/4
run: ./build/dpsim/examples/cxx/WSCC_9bus_mult_decoupled

- name: Run Binaries 3/4
run: ./build/dpsim/examples/cxx/DP_WSCC_9bus_split_decoupled

- name: Run Binaries 4/4
run: ./build/dpsim/examples/cxx/EMT_WSCC_9bus_split_decoupled

cpp-check:
name: Scan Sourcecode with Cppcheck
runs-on: ubuntu-latest
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/build_test_linux_rocky_profiling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,33 @@ jobs:

## Tests ##
test-examples-1:
name: Test Examples 1/2
name: Test Examples 1/4
needs: [profiling]
uses: sogno-platform/dpsim/.github/workflows/run_and_profile_example.yaml@${{github.ref}}
with:
path: ./build/dpsim/examples/cxx/WSCC_9bus_mult_decoupled
name: WSCC_9bus_mult_decoupled

test-examples-2:
name: Test Examples 2/2
name: Test Examples 2/4
needs: [profiling]
uses: sogno-platform/dpsim/.github/workflows/run_and_profile_example.yaml@${{github.ref}}
with:
path: ./build/dpsim/examples/cxx/WSCC_9bus_mult_coupled
name: WSCC_9bus_mult_coupled

test-examples-3:
name: Test Examples 3/4
needs: [profiling]
uses: sogno-platform/dpsim/.github/workflows/run_and_profile_example.yaml@${{github.ref}}
with:
path: ./build/dpsim/examples/cxx/EMT_WSCC_9bus_split_decoupled
name: WSCC_9bus_split_decoupled

test-examples-4:
name: Test Examples 4/4
needs: [profiling]
uses: sogno-platform/dpsim/.github/workflows/run_and_profile_example.yaml@${{github.ref}}
with:
path: ./build/dpsim/examples/cxx/DP_WSCC_9bus_split_decoupled
name: WSCC_9bus_split_decoupled
2 changes: 2 additions & 0 deletions dpsim-models/include/dpsim-models/DP/DP_Ph1_RXLoad.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class RXLoad : public CompositePowerComp<Complex>,
/// Defines name, component parameters and logging level
RXLoad(String name, Logger::Level logLevel = Logger::Level::off);

SimPowerComp<Complex>::Ptr clone(String name) override;

// #### General ####
/// Initialize component from power flow data
void initializeFromNodesAndTerminals(Real frequency) override;
Expand Down
4 changes: 4 additions & 0 deletions dpsim-models/include/dpsim-models/SystemTopology.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ class SystemTopology {
/// Copy the whole topology the given number of times and add the resulting components and nodes to the topology.
void multiply(Int numberCopies);

/// @brief Remove system component
/// @param name name of the component
void removeComponent(const String &name);

///
template <typename VarType>
int checkTopologySubnets(
Expand Down
6 changes: 6 additions & 0 deletions dpsim-models/src/DP/DP_Ph1_RXLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ DP::Ph1::RXLoad::RXLoad(String uid, String name, Logger::Level logLevel)
DP::Ph1::RXLoad::RXLoad(String name, Logger::Level logLevel)
: RXLoad(name, name, logLevel) {}

SimPowerComp<Complex>::Ptr DP::Ph1::RXLoad::clone(String name) {
auto copy = RXLoad::make(name, mLogLevel);
copy->setParameters(**mActivePower, **mReactivePower, **mNomVoltage);
return copy;
}

void DP::Ph1::RXLoad::initializeFromNodesAndTerminals(Real frequency) {

if (!mParametersSet) {
Expand Down
8 changes: 8 additions & 0 deletions dpsim-models/src/SystemTopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,14 @@ void SystemTopology::reset() {
// }
}

void SystemTopology::removeComponent(const String &name) {
for (auto it = mComponents.begin(); it != mComponents.end(); ++it) {
if ((*it)->name() == name) {
mComponents.erase(it);
}
}
}

template <typename VarType>
void SystemTopology::splitSubnets(std::vector<SystemTopology> &splitSystems) {
std::unordered_map<typename SimNode<VarType>::Ptr, int> subnet;
Expand Down
113 changes: 113 additions & 0 deletions dpsim/examples/cxx/CIM/DP_WSCC_9bus_split_decoupled.cpp
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 dpsim/examples/cxx/CIM/EMT_WSCC_9bus_split_decoupled.cpp
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);
}
2 changes: 1 addition & 1 deletion dpsim/examples/cxx/CIM/WSCC-9bus_CIM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) {
SystemTopology sys =
reader2.loadCIM(60, filenames, Domain::DP, PhaseType::Single,
CPS::GeneratorType::IdealVoltageSource);
sys.initWithPowerflow(systemPF, CPS::Domain::EMT);
sys.initWithPowerflow(systemPF, CPS::Domain::DP);

// Logging
auto logger = DataLogger::make(simName);
Expand Down
26 changes: 13 additions & 13 deletions dpsim/examples/cxx/CIM/WSCC_9bus_mult_coupled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ void simulateCoupled(std::list<fs::path> filenames, CommandLineArgs &args,
sim.setScheduler(std::make_shared<OpenMPLevelScheduler>(threads));

// Logging
//auto logger = DataLogger::make(simName);
//for (Int cop = 1; cop <= copies; cop++) {
// for (Int bus = 1; bus <= 9; bus++) {
// String attrName = "v" + std::to_string(bus) + "_" + std::to_string(cop);
// String nodeName = "BUS" + std::to_string(bus) + "_" + std::to_string(cop);
// if (cop == 1) {
// attrName = "v" + std::to_string(bus);
// nodeName = "BUS" + std::to_string(bus);
// }
// logger->logAttribute(attrName, sys.node<DP::SimNode>(nodeName)->attribute("v"));
// }
//}
//sim.addLogger(logger);
auto logger = DataLogger::make(simName);
for (Int cop = 1; cop <= copies; cop++) {
for (Int bus = 1; bus <= 9; bus++) {
String attrName = "v" + std::to_string(bus) + "_" + std::to_string(cop);
String nodeName = "BUS" + std::to_string(bus) + "_" + std::to_string(cop);
if (cop == 1) {
attrName = "v" + std::to_string(bus);
nodeName = "BUS" + std::to_string(bus);
}
logger->logAttribute(attrName, sys.node<DP::SimNode>(nodeName)->attribute("v"));
}
}
sim.addLogger(logger);

sim.run();
sim.logStepTimes(simName + "_step_times");
Expand Down
Loading
Loading