Skip to content

IEEEST Stabilizer Improvements/Corrections - #460

Open
lukelowry wants to merge 9 commits into
developfrom
lukel/ieeest-dev
Open

IEEEST Stabilizer Improvements/Corrections#460
lukelowry wants to merge 9 commits into
developfrom
lukel/ieeest-dev

Conversation

@lukelowry

@lukelowry lukelowry commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Description

Fixes and cleans up the IEEEST stabilizer implementation and documentation.

This updates the older initial implementation style so that reduced-order notch filters and zero denominator time constants are handled consistently

Proposed changes

  • Replace the branchy/safe-inverse notch logic with a fixed DAE form using differential tags.
  • Initialize IEEEST from the attached input signal instead of forcing all states to zero.
  • Document the implemented equations, initialization, derived parameters, and unsupported compatibility parameters.
  • Tests for initialization, residuals, invalid wiring, invalid notch parameters, zero time constants, and Jacobian consistency.

Checklist

  • All tests pass for the focused PhasorDynamics coverage.
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows GridKit™ style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.

Changelog changes N/A

Further comments

This is cleanup/correction work for the existing IEEEST model, not a new model

@lukelowry
lukelowry marked this pull request as ready for review June 22, 2026 18:43
@lukelowry

Copy link
Copy Markdown
Collaborator Author

@pelesh this fix is also ready to be merged I forgot to make a PR for this one.

@lukelowry lukelowry mentioned this pull request Jun 23, 2026
7 tasks

@pelesh pelesh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic governing changing differential into algebraic equations and vice versa does not seem to be sustainable. This requires more offline discussion.

Comment thread GridKit/Model/PhasorDynamics/Stabilizer/IEEEST/IeeestImpl.hpp Outdated
Comment thread GridKit/Model/PhasorDynamics/Stabilizer/IEEEST/IeeestImpl.hpp Outdated
Comment thread GridKit/Model/PhasorDynamics/Stabilizer/IEEEST/IeeestImpl.hpp Outdated
@lukelowry
lukelowry force-pushed the lukel/ieeest-dev branch 2 times, most recently from 8bbbad6 to 090289b Compare June 26, 2026 11:02
@lukelowry

Copy link
Copy Markdown
Collaborator Author

I have rebased and adjusted the formulation to align with #463 .

@nkoukpaizan nkoukpaizan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few comments here. Perhaps worth discussing at our next meeting.

Comment thread GridKit/Model/PhasorDynamics/Stabilizer/IEEEST/IeeestImpl.hpp Outdated
Comment thread GridKit/Model/PhasorDynamics/Stabilizer/IEEEST/IeeestImpl.hpp Outdated
Comment thread tests/UnitTests/PhasorDynamics/StabilizerIeeestTests.hpp Outdated
Comment thread GridKit/Model/PhasorDynamics/Stabilizer/IEEEST/IeeestImpl.hpp Outdated
const auto U = static_cast<size_t>(IeeestExternalVariables::U);

const ScalarT x1 = y[X1];
const ScalarT x2 = y[X2];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, the indirection from the enum is less readable to me. We should discuss a sustainable way to use the enums.

using Variable = typename ModelDataT::MonitorableVariables;
monitor_->set(Variable::vss, [this]
{ return y_[11]; });
auto index = [](IeeestInternalVariables variable)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen this pattern a few times. Consider defining once if it is really needed. I would argue it's less readable.

Comment thread tests/UnitTests/PhasorDynamics/runStabilizerIeeestTests.cpp
Comment thread GridKit/Model/PhasorDynamics/Stabilizer/IEEEST/Ieeest.hpp
Comment thread GridKit/Model/PhasorDynamics/Stabilizer/IEEEST/IeeestImpl.hpp Outdated
Comment thread tests/UnitTests/PhasorDynamics/StabilizerIeeestTests.hpp Outdated
@lukelowry

Copy link
Copy Markdown
Collaborator Author

Testing Ground for template parameters <Order N>

@lukelowry lukelowry added this to the WECC Completion milestone Jul 2, 2026
@lukelowry

Copy link
Copy Markdown
Collaborator Author

general implementation of the template parameter done

@nkoukpaizan nkoukpaizan added enhancement New feature or request cleanup labels Jul 10, 2026
@lukelowry
lukelowry force-pushed the lukel/ieeest-dev branch 4 times, most recently from d0dc95a to d2be200 Compare July 17, 2026 21:58
@lukelowry

Copy link
Copy Markdown
Collaborator Author

@nkoukpaizan what are your thoughts on my template implementation?

@nkoukpaizan

Copy link
Copy Markdown
Collaborator

@nkoukpaizan what are your thoughts on my template implementation?

The model implementation is cleaner with the order as a template parameter. However, the order remains a runtime selection based on floating point comparisons, which is what I wanted to avoid.

@lukelowry

Copy link
Copy Markdown
Collaborator Author

@nkoukpaizan we could possibly require the order to be passed as a parameter of IEEEST model, would that resolve your concern?

"Order" is not usually directly exposed as a model parameter and so would require some knowledge of how IEEEST works to pass valid parameters.

Can you give an example where the runtime comparison is bad/fails? I might be able to resolve both our concerns if I understand better.

@nkoukpaizan

Copy link
Copy Markdown
Collaborator

@nkoukpaizan we could possibly require the order to be passed as a parameter of IEEEST model, would that resolve your concern?

"Order" is not usually directly exposed as a model parameter and so would require some knowledge of how IEEEST works to pass valid parameters.

Can you give an example where the runtime comparison is bad/fails? I might be able to resolve both our concerns if I understand better.

Yes, exposing the order as a parameter to the model is what I had in mind. Understood that that's not the domain practice. That's why as was asking whether this is possible as a question.

Floating point values are stored with limited precision. We'd have to guarantee that the value returned by the parser is bit-for-bit equal to zero. That may be the case for nlohmann-json, but considering #227 and the possibility of using a different parser, that's not guaranteed.

@lukelowry

Copy link
Copy Markdown
Collaborator Author

@nkoukpaizan i see the issue now thank you, that was very clarifying. After reflecting on my past experience and discussing with others at TAMU, I think deriving the order from the parameters alone is not intuitive or safe, either.

As discussed, we should add an integer parameter to the IEEEST model, "order" and use that for the StabilizerFactory (rename to IeeestFactory). Then, our parameter validation can gate for zero division relevant to each static order (e.g. $A_2 + A_3&gt;0$). Additionally the model json may then contain some coefficients that are only used at a certain "order", which would be a feature IMO since you can retain information needed for higher order but choose to operate at smaller order.

I will make this change then we can reasess.

@lukelowry

Copy link
Copy Markdown
Collaborator Author

@nkoukpaizan I have made the proposed edits. For future models with many different "orders" for subsystems the template arguments might get long, but it works well for one argument here

@nkoukpaizan nkoukpaizan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template for the stabilizer object looks a lot cleaner to me!

I'm having a hard time reading the StabilizerIeeestTests at the moment, especially where multiple cases are defined as vectors of arrays. I would split the cases into separate tests and implement specific, reusable private methods.

/// (a1 = a3 = 0)
///
/// The Enzyme-vs-dependency-tracking Jacobian comparison is not run for
/// this configuration: Enzyme's `sparse_store` drops exact-zero entries

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enzyme should not drop non-structural zeros. May be worth looking into it if the Jacobians differ. I recommend starting with an implementation of the test with an expectFailure outcome.

int ret = 0;

if (signals_.template isAttached<IeeestExternalVariables::U>())
if (value != ZERO<RealT>)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think isEqual would be appropriate here. I recommend a PR that moves it from the Testing namespace to, e.g., Math. @lukelowry Let me know if you can do that or if you'd rather me to.

* @brief Compare DependencyTracking Jacobian against Enzyme Jacobian.
*/
TestOutcome jacobian()
TestOutcome verify()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify currently logs some errors. Make sure to message the user about expected errors, similar to #500.

result += test.zeroInitialResidual();
result += test.residual();

result += test.init<0>();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be cleaner to template the test class rather than individual member functions.

If I understand correctly, some tests are manipulating stabilizer objects of different orders. Consider two test objects:

  • One templated to check all orders
  • Another one that manipulates/compares objects of different orders.

@@ -19,10 +19,11 @@ namespace GridKit
*
* @tparam ScalarT - Scalar data type
* @tparam IdxT - Index data type

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the changes in templating style in #410 and #505. Something to be careful with when rebasing. We'll have to make sure new instances of the old format are not introduced in new PRs.

using Params = PhasorDynamics::Stabilizer::IeeestParameters;

// The second case exercises the TIME_CONSTANT_MINIMUM flooring.
const std::vector<std::array<RealT, 3>> time_constant_cases = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would split into two different tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants