Skip to content

Commit

Permalink
Add extractEigenvalues() function to Simulation
Browse files Browse the repository at this point in the history
Signed-off-by: Georgii Tishenin <[email protected]>
  • Loading branch information
georgii-tishenin committed Nov 15, 2023
1 parent 2882ce9 commit c3b062e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dpsim/examples/cxx/Circuits/EMT_SinglePhaseRLC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 4 additions & 0 deletions dpsim/include/dpsim/Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions dpsim/src/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<DPsim::MnaSolver<Real>>(mSolvers[0]);
if (mnaSolver)
{
mnaSolver->extractEigenvalues();
}
}
}

void Simulation::logStepTimes(String logName) {
auto stepTimeLog = Logger::get(logName, Logger::Level::info);
Logger::setLogPattern(stepTimeLog, "%v");
Expand Down

0 comments on commit c3b062e

Please sign in to comment.