Skip to content

Commit

Permalink
Enhance eigenvalue logging
Browse files Browse the repository at this point in the history
-Change level of log messages in MNAEigenvalueLogger from info to debug
-Pass loglevel from Simulation to MNAEigenvalueLogger

Signed-off-by: Georgii Tishenin <[email protected]>
  • Loading branch information
georgii-tishenin committed Feb 5, 2024
1 parent aaee1a1 commit 60f7cd6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dpsim/include/dpsim/MNAEigenvalueExtractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion dpsim/include/dpsim/MNAEigenvalueLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace DPsim
class MNAEigenvalueLogger
{
public:
MNAEigenvalueLogger();
MNAEigenvalueLogger(String name, CPS::Logger::Level logLevel);

void setLogAttributes(CPS::AttributeStatic<MatrixComp>::Ptr eigenvalues, CPS::AttributeStatic<MatrixComp>::Ptr discreteEigenvalues);
template <typename VarType>
Expand Down
2 changes: 1 addition & 1 deletion dpsim/src/MNAEigenvalueExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace DPsim
{
template <typename VarType>
MNAEigenvalueExtractor<VarType>::MNAEigenvalueExtractor()
MNAEigenvalueExtractor<VarType>::MNAEigenvalueExtractor(CPS::Logger::Level logLevel) : mLogger("MNAEigenvalueExtractor", logLevel)
{
mEigenvalues = CPS::AttributeStatic<MatrixComp>::make();
mDiscreteEigenvalues = CPS::AttributeStatic<MatrixComp>::make();
Expand Down
21 changes: 11 additions & 10 deletions dpsim/src/MNAEigenvalueLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand All @@ -16,21 +17,21 @@ namespace DPsim
template <typename VarType>
void MNAEigenvalueLogger::logInitialization(const MatrixVar<VarType> &signMatrix, const MatrixVar<VarType> &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<Real>(const MatrixVar<Real> &signMatrix, const MatrixVar<Real> &discretizationMatrix, const Matrix &branchNodeIncidenceMatrix, const Matrix &nodeBranchIncidenceMatrix);
template void MNAEigenvalueLogger::logInitialization<Complex>(const MatrixVar<Complex> &signMatrix, const MatrixVar<Complex> &discretizationMatrix, const Matrix &branchNodeIncidenceMatrix, const Matrix &nodeBranchIncidenceMatrix);

template <typename VarType>
void MNAEigenvalueLogger::logExtraction(Real time, Int timeStepCount, const MatrixVar<VarType> &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);
Expand Down
2 changes: 1 addition & 1 deletion dpsim/src/MNASolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace DPsim {

template <typename VarType>
MnaSolver<VarType>::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<DataLogger>(name + "_LeftVector", logLevel == CPS::Logger::Level::trace);
Expand Down

0 comments on commit 60f7cd6

Please sign in to comment.