From 60f7cd6faee77725f003f9512ad8414a857e8959 Mon Sep 17 00:00:00 2001 From: Georgii Tishenin Date: Mon, 5 Feb 2024 16:07:17 +0100 Subject: [PATCH] Enhance eigenvalue logging -Change level of log messages in MNAEigenvalueLogger from info to debug -Pass loglevel from Simulation to MNAEigenvalueLogger Signed-off-by: Georgii Tishenin --- dpsim/include/dpsim/MNAEigenvalueExtractor.h | 2 +- dpsim/include/dpsim/MNAEigenvalueLogger.h | 2 +- dpsim/src/MNAEigenvalueExtractor.cpp | 2 +- dpsim/src/MNAEigenvalueLogger.cpp | 21 ++++++++++---------- dpsim/src/MNASolver.cpp | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/dpsim/include/dpsim/MNAEigenvalueExtractor.h b/dpsim/include/dpsim/MNAEigenvalueExtractor.h index 382d4d0d6c..4aaa240869 100644 --- a/dpsim/include/dpsim/MNAEigenvalueExtractor.h +++ b/dpsim/include/dpsim/MNAEigenvalueExtractor.h @@ -11,7 +11,7 @@ namespace DPsim class MNAEigenvalueExtractor { public: - MNAEigenvalueExtractor(); + MNAEigenvalueExtractor(CPS::Logger::Level logLevel); void initialize(const CPS::SystemTopology &topology, UInt numMatrixNodeIndices, Real timeStep); void extractEigenvalues(const Matrix &powerSystemMatrix, Real time, Int timeStepCount); diff --git a/dpsim/include/dpsim/MNAEigenvalueLogger.h b/dpsim/include/dpsim/MNAEigenvalueLogger.h index 154ecaefe8..80e11e9163 100644 --- a/dpsim/include/dpsim/MNAEigenvalueLogger.h +++ b/dpsim/include/dpsim/MNAEigenvalueLogger.h @@ -8,7 +8,7 @@ namespace DPsim class MNAEigenvalueLogger { public: - MNAEigenvalueLogger(); + MNAEigenvalueLogger(String name, CPS::Logger::Level logLevel); void setLogAttributes(CPS::AttributeStatic::Ptr eigenvalues, CPS::AttributeStatic::Ptr discreteEigenvalues); template diff --git a/dpsim/src/MNAEigenvalueExtractor.cpp b/dpsim/src/MNAEigenvalueExtractor.cpp index 888938ac1a..d703c4f121 100644 --- a/dpsim/src/MNAEigenvalueExtractor.cpp +++ b/dpsim/src/MNAEigenvalueExtractor.cpp @@ -3,7 +3,7 @@ namespace DPsim { template - MNAEigenvalueExtractor::MNAEigenvalueExtractor() + MNAEigenvalueExtractor::MNAEigenvalueExtractor(CPS::Logger::Level logLevel) : mLogger("MNAEigenvalueExtractor", logLevel) { mEigenvalues = CPS::AttributeStatic::make(); mDiscreteEigenvalues = CPS::AttributeStatic::make(); diff --git a/dpsim/src/MNAEigenvalueLogger.cpp b/dpsim/src/MNAEigenvalueLogger.cpp index 5b913a8043..403edc4559 100644 --- a/dpsim/src/MNAEigenvalueLogger.cpp +++ b/dpsim/src/MNAEigenvalueLogger.cpp @@ -2,8 +2,9 @@ namespace DPsim { - MNAEigenvalueLogger::MNAEigenvalueLogger() : mSLog(CPS::Logger::get("MNAEigenvalueExtractor", CPS::Logger::Level::info, CPS::Logger::Level::info)), - mEigenvaluesLogger("eigenvalues", true, 1), mDiscreteEigenvaluesLogger("discreteEigenvalues", true, 1) + MNAEigenvalueLogger::MNAEigenvalueLogger(String name, CPS::Logger::Level logLevel) : mSLog(CPS::Logger::get(name, logLevel, logLevel)), + mEigenvaluesLogger("eigenvalues", true, 1), + mDiscreteEigenvaluesLogger("discreteEigenvalues", true, 1) { } @@ -16,11 +17,11 @@ namespace DPsim template void MNAEigenvalueLogger::logInitialization(const MatrixVar &signMatrix, const MatrixVar &discretizationMatrix, const Matrix &branchNodeIncidenceMatrix, const Matrix &nodeBranchIncidenceMatrix) { - SPDLOG_LOGGER_INFO(mSLog, "---- Initialize ----"); - SPDLOG_LOGGER_INFO(mSLog, "sign matrix: {}", CPS::Logger::matrixVarToString(signMatrix)); - SPDLOG_LOGGER_INFO(mSLog, "discretization matrix: {}", CPS::Logger::matrixVarToString(discretizationMatrix)); - SPDLOG_LOGGER_INFO(mSLog, "branch <-> node incidence matrix: {}", CPS::Logger::matrixToString(branchNodeIncidenceMatrix)); - SPDLOG_LOGGER_INFO(mSLog, "node <-> branch incidence matrix: {}", CPS::Logger::matrixToString(nodeBranchIncidenceMatrix)); + SPDLOG_LOGGER_DEBUG(mSLog, "---- Initialize ----"); + SPDLOG_LOGGER_DEBUG(mSLog, "sign matrix: {}", CPS::Logger::matrixVarToString(signMatrix)); + SPDLOG_LOGGER_DEBUG(mSLog, "discretization matrix: {}", CPS::Logger::matrixVarToString(discretizationMatrix)); + SPDLOG_LOGGER_DEBUG(mSLog, "branch <-> node incidence matrix: {}", CPS::Logger::matrixToString(branchNodeIncidenceMatrix)); + SPDLOG_LOGGER_DEBUG(mSLog, "node <-> branch incidence matrix: {}", CPS::Logger::matrixToString(nodeBranchIncidenceMatrix)); } template void MNAEigenvalueLogger::logInitialization(const MatrixVar &signMatrix, const MatrixVar &discretizationMatrix, const Matrix &branchNodeIncidenceMatrix, const Matrix &nodeBranchIncidenceMatrix); template void MNAEigenvalueLogger::logInitialization(const MatrixVar &signMatrix, const MatrixVar &discretizationMatrix, const Matrix &branchNodeIncidenceMatrix, const Matrix &nodeBranchIncidenceMatrix); @@ -28,9 +29,9 @@ namespace DPsim template void MNAEigenvalueLogger::logExtraction(Real time, Int timeStepCount, const MatrixVar &stateMatrix) { - SPDLOG_LOGGER_INFO(mSLog, "---- Extract eigenvalues ----"); - SPDLOG_LOGGER_INFO(mSLog, "time: {}", CPS::Logger::realToString(time)); - SPDLOG_LOGGER_INFO(mSLog, "discretized state matrix: {}", CPS::Logger::matrixVarToString(stateMatrix)); + SPDLOG_LOGGER_DEBUG(mSLog, "---- Extract eigenvalues ----"); + SPDLOG_LOGGER_DEBUG(mSLog, "time: {}", CPS::Logger::realToString(time)); + SPDLOG_LOGGER_DEBUG(mSLog, "discretized state matrix: {}", CPS::Logger::matrixVarToString(stateMatrix)); mEigenvaluesLogger.log(time, timeStepCount); mDiscreteEigenvaluesLogger.log(time, timeStepCount); diff --git a/dpsim/src/MNASolver.cpp b/dpsim/src/MNASolver.cpp index b1b65d0a09..d50a44da9f 100644 --- a/dpsim/src/MNASolver.cpp +++ b/dpsim/src/MNASolver.cpp @@ -19,7 +19,7 @@ namespace DPsim { template MnaSolver::MnaSolver(String name, CPS::Domain domain, CPS::Logger::Level logLevel) : - Solver(name, logLevel), mDomain(domain) { + Solver(name, logLevel), mDomain(domain), mMNAEigenvalueExtractor(logLevel) { // Raw source and solution vector logging mLeftVectorLog = std::make_shared(name + "_LeftVector", logLevel == CPS::Logger::Level::trace);