From c3b062eb849710fa8cac31bb7a1e32e843aba282 Mon Sep 17 00:00:00 2001 From: Georgii Tishenin Date: Tue, 31 Oct 2023 19:01:58 +0100 Subject: [PATCH] Add extractEigenvalues() function to Simulation Signed-off-by: Georgii Tishenin --- .../cxx/Circuits/EMT_SinglePhaseRLC.cpp | 2 +- dpsim/include/dpsim/Simulation.h | 4 ++++ dpsim/src/Simulation.cpp | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/dpsim/examples/cxx/Circuits/EMT_SinglePhaseRLC.cpp b/dpsim/examples/cxx/Circuits/EMT_SinglePhaseRLC.cpp index f9e9ccde0b..03789387b0 100644 --- a/dpsim/examples/cxx/Circuits/EMT_SinglePhaseRLC.cpp +++ b/dpsim/examples/cxx/Circuits/EMT_SinglePhaseRLC.cpp @@ -48,7 +48,7 @@ int main(int argc, char* argv[]) { sim.setFinalTime(finalTime); sim.setDomain(Domain::EMT); sim.addLogger(logger); - // sim.extractEigenvalues(); + sim.extractEigenvalues(); sim.run(); diff --git a/dpsim/include/dpsim/Simulation.h b/dpsim/include/dpsim/Simulation.h index 9e50411f64..a2feef103c 100644 --- a/dpsim/include/dpsim/Simulation.h +++ b/dpsim/include/dpsim/Simulation.h @@ -224,6 +224,10 @@ namespace DPsim { /// Create the schedule for the independent tasks void schedule(); + // ### Eigenvalue extraction ### + /// Extract eigenvalues from power system conductance matrix + void extractEigenvalues(); + /// Schedule an event in the simulation void addEvent(Event::Ptr e) { mEvents.addEvent(e); diff --git a/dpsim/src/Simulation.cpp b/dpsim/src/Simulation.cpp index a1c94d00c0..ebbeb79c27 100644 --- a/dpsim/src/Simulation.cpp +++ b/dpsim/src/Simulation.cpp @@ -403,6 +403,23 @@ Real Simulation::step() { return mTime; } +void Simulation::extractEigenvalues() +{ + if (!mInitialized) + { + initialize(); + } + // TODO: [Georgii] throw exceptions for multiple solvers and for non-supported solver types + if (mSolvers.size() == 1) + { + auto mnaSolver = std::dynamic_pointer_cast>(mSolvers[0]); + if (mnaSolver) + { + mnaSolver->extractEigenvalues(); + } + } +} + void Simulation::logStepTimes(String logName) { auto stepTimeLog = Logger::get(logName, Logger::Level::info); Logger::setLogPattern(stepTimeLog, "%v");