diff --git a/GridKit/Model/PhasorDynamics/Controller/REECB/Reecb.hpp b/GridKit/Model/PhasorDynamics/Controller/REECB/Reecb.hpp index 5cb3d23a9..dbece4fe0 100644 --- a/GridKit/Model/PhasorDynamics/Controller/REECB/Reecb.hpp +++ b/GridKit/Model/PhasorDynamics/Controller/REECB/Reecb.hpp @@ -196,7 +196,9 @@ namespace GridKit ScalarT& Vi(); static constexpr RealT TIME_CONSTANT_MINIMUM = static_cast(1.0e-3); - static constexpr RealT VMEAS_MINIMUM = static_cast(0.01); + static void logTimeConstantWarning(); + + static constexpr RealT VMEAS_MINIMUM = static_cast(0.01); BusT* bus_{nullptr}; diff --git a/GridKit/Model/PhasorDynamics/Controller/REECB/ReecbImpl.hpp b/GridKit/Model/PhasorDynamics/Controller/REECB/ReecbImpl.hpp index 289e4465a..1d8935425 100644 --- a/GridKit/Model/PhasorDynamics/Controller/REECB/ReecbImpl.hpp +++ b/GridKit/Model/PhasorDynamics/Controller/REECB/ReecbImpl.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1428,6 +1429,20 @@ namespace GridKit { return y_.getData()[static_cast(ReecbInternalVariables::PMEAS)]; }); } + /** + * @brief Static method to log time constant warnings + * + * @note Used in combination with static std:once_flag and std:call_once, + * to reduce the number of times the warning is printed. + */ + template + void Reecb::logTimeConstantWarning() + { + Log::warning() << "Reecb: any of Trv, Tp, Tiq, or Tpord below " + << TIME_CONSTANT_MINIMUM + << " s is raised to that floor to keep the controller lags well posed\n"; + } + /** * @brief Resolve parameter-derived constants and selector masks * @@ -1447,9 +1462,9 @@ namespace GridKit if (floor_warning) { - Log::warning() << "Reecb: any of Trv, Tp, Tiq, or Tpord below " - << TIME_CONSTANT_MINIMUM - << " s is raised to that floor to keep the controller lags well posed\n"; + static std::once_flag time_constant_warning_flag_; + std::call_once(time_constant_warning_flag_, + &logTimeConstantWarning); } va_component_base_ = mva_base_ * static_cast(1.0e6); diff --git a/GridKit/Model/PhasorDynamics/Controller/REPCA/Repca.hpp b/GridKit/Model/PhasorDynamics/Controller/REPCA/Repca.hpp index 73213d15d..a008f9ef3 100644 --- a/GridKit/Model/PhasorDynamics/Controller/REPCA/Repca.hpp +++ b/GridKit/Model/PhasorDynamics/Controller/REPCA/Repca.hpp @@ -161,6 +161,7 @@ namespace GridKit ScalarT& Vi(); static constexpr RealT TIME_CONSTANT_MINIMUM = static_cast(1.0e-3); + static void logTimeConstantWarning(); static constexpr RealT INITIALIZATION_LIMIT_OFFSET = static_cast(0.1); diff --git a/GridKit/Model/PhasorDynamics/Controller/REPCA/RepcaImpl.hpp b/GridKit/Model/PhasorDynamics/Controller/REPCA/RepcaImpl.hpp index 74a939ee1..986989776 100644 --- a/GridKit/Model/PhasorDynamics/Controller/REPCA/RepcaImpl.hpp +++ b/GridKit/Model/PhasorDynamics/Controller/REPCA/RepcaImpl.hpp @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include @@ -983,6 +984,20 @@ namespace GridKit { return y_.getData()[static_cast(RepcaInternalVariables::PMEAS)]; }); } + /** + * @brief Static method to log time constant warnings + * + * @note Used in combination with static std:once_flag and std:call_once, + * to reduce the number of times the warning is printed. + */ + template + void Repca::logTimeConstantWarning() + { + Log::warning() << "Repca: Tfltr, Tfv, Tp, and Tlag below " + << TIME_CONSTANT_MINIMUM + << " s are raised to that floor to keep the controller lags well posed\n"; + } + /** * @brief Resolve parameter-derived constants * @@ -1012,9 +1027,9 @@ namespace GridKit if (Tfltr_ < TIME_CONSTANT_MINIMUM || Tfv_ < TIME_CONSTANT_MINIMUM || Tp_ < TIME_CONSTANT_MINIMUM || Tlag_ < TIME_CONSTANT_MINIMUM) { - Log::warning() << "Repca: Tfltr, Tfv, Tp, and Tlag below " - << TIME_CONSTANT_MINIMUM - << " s are raised to that floor to keep the controller lags well posed\n"; + static std::once_flag time_constant_warning_flag_; + std::call_once(time_constant_warning_flag_, + &logTimeConstantWarning); } Tfltr_ = std::max(Tfltr_, TIME_CONSTANT_MINIMUM); diff --git a/GridKit/Model/PhasorDynamics/Converter/REGCA/Regca.hpp b/GridKit/Model/PhasorDynamics/Converter/REGCA/Regca.hpp index 2bfb937ca..1f8ca99ff 100644 --- a/GridKit/Model/PhasorDynamics/Converter/REGCA/Regca.hpp +++ b/GridKit/Model/PhasorDynamics/Converter/REGCA/Regca.hpp @@ -203,6 +203,7 @@ namespace GridKit ScalarT& Ii(); static constexpr RealT TIME_CONSTANT_MINIMUM = static_cast(1.0e-3); + static void logTimeConstantWarning(); BusT* bus_{nullptr}; diff --git a/GridKit/Model/PhasorDynamics/Converter/REGCA/RegcaImpl.hpp b/GridKit/Model/PhasorDynamics/Converter/REGCA/RegcaImpl.hpp index 456e5ef75..ace811d53 100644 --- a/GridKit/Model/PhasorDynamics/Converter/REGCA/RegcaImpl.hpp +++ b/GridKit/Model/PhasorDynamics/Converter/REGCA/RegcaImpl.hpp @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include @@ -60,6 +61,20 @@ namespace GridKit { } + /** + * @brief Static method to log time constant warnings + * + * @note Used in combination with static std:once_flag and std:call_once, + * to reduce the number of times the warning is printed. + */ + template + void Regca::logTimeConstantWarning() + { + Log::warning() << "Regca: Tg and TM below " << TIME_CONSTANT_MINIMUM + << " s are raised to that floor to keep the current-control " + << "and voltage-sensor lags well posed\n"; + } + /** * @brief Resolve parameter-derived constants and limiter selections. * @@ -72,9 +87,9 @@ namespace GridKit { if (Tg_ < TIME_CONSTANT_MINIMUM || TM_ < TIME_CONSTANT_MINIMUM) { - Log::warning() << "Regca: Tg and TM below " << TIME_CONSTANT_MINIMUM - << " s are raised to that floor to keep the current-control " - << "and voltage-sensor lags well posed\n"; + static std::once_flag time_constant_warning_flag_; + std::call_once(time_constant_warning_flag_, + &logTimeConstantWarning); } Tg_ = std::max(Tg_, TIME_CONSTANT_MINIMUM); diff --git a/GridKit/Model/PhasorDynamics/Exciter/ESDC1A/Esdc1a.hpp b/GridKit/Model/PhasorDynamics/Exciter/ESDC1A/Esdc1a.hpp index 5d9e8f36d..3907f616c 100644 --- a/GridKit/Model/PhasorDynamics/Exciter/ESDC1A/Esdc1a.hpp +++ b/GridKit/Model/PhasorDynamics/Exciter/ESDC1A/Esdc1a.hpp @@ -140,6 +140,7 @@ namespace GridKit ScalarT& Vi(); static constexpr RealT TIME_CONSTANT_MINIMUM = static_cast(1.0e-3); + static void logTimeConstantWarning(); BusT* bus_{nullptr}; diff --git a/GridKit/Model/PhasorDynamics/Exciter/ESDC1A/Esdc1aImpl.hpp b/GridKit/Model/PhasorDynamics/Exciter/ESDC1A/Esdc1aImpl.hpp index 4789ad481..7e408e9be 100644 --- a/GridKit/Model/PhasorDynamics/Exciter/ESDC1A/Esdc1aImpl.hpp +++ b/GridKit/Model/PhasorDynamics/Exciter/ESDC1A/Esdc1aImpl.hpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -761,6 +762,20 @@ namespace GridKit { return y_.getData()[static_cast(Esdc1aInternalVariables::VFE)]; }); } + /** + * @brief Static method to log time constant warnings + * + * @note Used in combination with static std:once_flag and std:call_once, + * to reduce the number of times the warning is printed. + */ + template + void Esdc1a::logTimeConstantWarning() + { + Log::warning() << "Esdc1a: Tr, Ta, Tb, Te, and Tf1 below " + << TIME_CONSTANT_MINIMUM + << " s are raised to that floor to keep the exciter lags well posed\n"; + } + /** * @brief Resolve the parameter-derived constants and selector masks * @@ -796,9 +811,9 @@ namespace GridKit || Tb_ < TIME_CONSTANT_MINIMUM || Te_ < TIME_CONSTANT_MINIMUM || Tf1_ < TIME_CONSTANT_MINIMUM) { - Log::warning() << "Esdc1a: Tr, Ta, Tb, Te, and Tf1 below " - << TIME_CONSTANT_MINIMUM - << " s are raised to that floor to keep the exciter lags well posed\n"; + static std::once_flag time_constant_warning_flag_; + std::call_once(time_constant_warning_flag_, + &logTimeConstantWarning); } Tr_ = std::max(Tr_, TIME_CONSTANT_MINIMUM); diff --git a/GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1.hpp b/GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1.hpp index a86518cca..a0746bb85 100644 --- a/GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1.hpp +++ b/GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1.hpp @@ -125,6 +125,7 @@ namespace GridKit private: static constexpr RealT TIME_CONSTANT_MINIMUM = static_cast(1.0e-3); + static void logTimeConstantWarning(); // Signal pointers BusT* bus_; diff --git a/GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1Impl.hpp b/GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1Impl.hpp index 31f2760d5..8395b275a 100644 --- a/GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1Impl.hpp +++ b/GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1Impl.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -491,6 +492,20 @@ namespace GridKit setDerivedParameters(); } + /** + * @brief Static method to log time constant warnings + * + * @note Used in combination with static std:once_flag and std:call_once, + * to reduce the number of times the warning is printed. + */ + template + void Ieeet1::logTimeConstantWarning() + { + Log::warning() << "Ieeet1: Tr, Ta, Te, and Tf below " + << TIME_CONSTANT_MINIMUM + << " s are raised to that floor\n"; + } + /** * @brief Resolve the parameter-derived constants */ @@ -500,9 +515,9 @@ namespace GridKit if (Tr_ < TIME_CONSTANT_MINIMUM || Ta_ < TIME_CONSTANT_MINIMUM || Te_ < TIME_CONSTANT_MINIMUM || Tf_ < TIME_CONSTANT_MINIMUM) { - Log::warning() << "Ieeet1: Tr, Ta, Te, and Tf below " - << TIME_CONSTANT_MINIMUM - << " s are raised to that floor\n"; + static std::once_flag time_constant_warning_flag_; + std::call_once(time_constant_warning_flag_, + &logTimeConstantWarning); } Tr_ = std::max(Tr_, TIME_CONSTANT_MINIMUM); diff --git a/GridKit/Model/PhasorDynamics/Governor/GASTPTI/GastPti.hpp b/GridKit/Model/PhasorDynamics/Governor/GASTPTI/GastPti.hpp index bc824576d..1d593f34e 100644 --- a/GridKit/Model/PhasorDynamics/Governor/GASTPTI/GastPti.hpp +++ b/GridKit/Model/PhasorDynamics/Governor/GASTPTI/GastPti.hpp @@ -122,6 +122,7 @@ namespace GridKit RealT toSystemBase(RealT value) const; static constexpr RealT TIME_CONSTANT_MINIMUM = static_cast(1.0e-3); + static void logTimeConstantWarning(); RealT R_{static_cast(0.05)}; RealT T1_{static_cast(0.4)}; diff --git a/GridKit/Model/PhasorDynamics/Governor/GASTPTI/GastPtiImpl.hpp b/GridKit/Model/PhasorDynamics/Governor/GASTPTI/GastPtiImpl.hpp index 8a58a875a..97f2fe0fd 100644 --- a/GridKit/Model/PhasorDynamics/Governor/GASTPTI/GastPtiImpl.hpp +++ b/GridKit/Model/PhasorDynamics/Governor/GASTPTI/GastPtiImpl.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -712,6 +713,20 @@ namespace GridKit { return y_.getData()[static_cast(GastPtiInternalVariables::VTEMP)]; }); } + /** + * @brief Static method to log time constant warnings + * + * @note Used in combination with static std:once_flag and std:call_once, + * to reduce the number of times the warning is printed. + */ + template + void GastPti::logTimeConstantWarning() + { + Log::warning() << "GastPti: T1, T2, and T3 below " + << TIME_CONSTANT_MINIMUM + << " s are raised to that floor to keep the turbine lags well posed\n"; + } + /** * @brief Resolve the parameter-derived constants * @@ -735,9 +750,9 @@ namespace GridKit if (floor_warning) { - Log::warning() << "GastPti: T1, T2, and T3 below " - << TIME_CONSTANT_MINIMUM - << " s are raised to that floor to keep the turbine lags well posed\n"; + static std::once_flag time_constant_warning_flag_; + std::call_once(time_constant_warning_flag_, + &logTimeConstantWarning); } va_component_base_ = ZERO; diff --git a/GridKit/Model/PhasorDynamics/Governor/HYGOV/Hygov.hpp b/GridKit/Model/PhasorDynamics/Governor/HYGOV/Hygov.hpp index 9844dffd3..8714b691b 100644 --- a/GridKit/Model/PhasorDynamics/Governor/HYGOV/Hygov.hpp +++ b/GridKit/Model/PhasorDynamics/Governor/HYGOV/Hygov.hpp @@ -152,6 +152,7 @@ namespace GridKit ScalarT toSystemBase(ScalarT value) const; static constexpr RealT TIME_CONSTANT_MINIMUM = static_cast(1.0e-3); + static void logTimeConstantWarning(); /// Accepted seed distance beyond the achievable-power range edge. static constexpr RealT INITIALIZATION_TOLERANCE = diff --git a/GridKit/Model/PhasorDynamics/Governor/HYGOV/HygovImpl.hpp b/GridKit/Model/PhasorDynamics/Governor/HYGOV/HygovImpl.hpp index 9761ca9c6..5f8dc5ff1 100644 --- a/GridKit/Model/PhasorDynamics/Governor/HYGOV/HygovImpl.hpp +++ b/GridKit/Model/PhasorDynamics/Governor/HYGOV/HygovImpl.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -764,6 +765,20 @@ namespace GridKit { return y_.getData()[static_cast(HygovInternalVariables::H)]; }); } + /** + * @brief Static method to log time constant warnings + * + * @note Used in combination with static std:once_flag and std:call_once, + * to reduce the number of times the warning is printed. + */ + template + void Hygov::logTimeConstantWarning() + { + Log::warning() << "Hygov: Tr, Tf, Tg, Tw, and Tnp below " + << TIME_CONSTANT_MINIMUM + << " s are raised to preserve Hessenberg form\n"; + } + /** * @brief Resolve the parameter-derived constants * @@ -816,9 +831,9 @@ namespace GridKit || Tg_ < TIME_CONSTANT_MINIMUM || Tw_ < TIME_CONSTANT_MINIMUM || Tnp_ < TIME_CONSTANT_MINIMUM) { - Log::warning() << "Hygov: Tr, Tf, Tg, Tw, and Tnp below " - << TIME_CONSTANT_MINIMUM - << " s are raised to preserve Hessenberg form\n"; + static std::once_flag time_constant_warning_flag_; + std::call_once(time_constant_warning_flag_, + &logTimeConstantWarning); } // HYGOV residuals solve explicitly for the state derivatives to preserve diff --git a/GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1.hpp b/GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1.hpp index 89ce12994..90b2ef79d 100644 --- a/GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1.hpp +++ b/GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1.hpp @@ -142,6 +142,7 @@ namespace GridKit ScalarT toSystemBase(ScalarT value) const; static constexpr RealT TIME_CONSTANT_MINIMUM = static_cast(1.0e-3); + static void logTimeConstantWarning(); /* Local copies of signal variables */ std::vector ws_; diff --git a/GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1Impl.hpp b/GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1Impl.hpp index e7210b462..f1c4360ef 100644 --- a/GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1Impl.hpp +++ b/GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1Impl.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -128,13 +129,27 @@ namespace GridKit } } + /** + * @brief Static method to log time constant warnings + * + * @note Used in combination with static std:once_flag and std:call_once, + * to reduce the number of times the warning is printed. + */ + template + void Tgov1::logTimeConstantWarning() + { + Log::warning() << "Tgov1: T1 and T3 below " << TIME_CONSTANT_MINIMUM + << " s are raised to that floor\n"; + } + template void Tgov1::setDerivedParams() { if (T1_ < TIME_CONSTANT_MINIMUM || T3_ < TIME_CONSTANT_MINIMUM) { - Log::warning() << "Tgov1: T1 and T3 below " << TIME_CONSTANT_MINIMUM - << " s are raised to that floor\n"; + static std::once_flag time_constant_warning_flag_; + std::call_once(time_constant_warning_flag_, + &logTimeConstantWarning); } T1_ = std::max(T1_, TIME_CONSTANT_MINIMUM);