Skip to content

Global state views in PhasorDynamics SystemModel #411

Open
lukelowry wants to merge 1 commit into
developfrom
lukel/perf-sys-dev
Open

Global state views in PhasorDynamics SystemModel #411
lukelowry wants to merge 1 commit into
developfrom
lukel/perf-sys-dev

Conversation

@lukelowry
Copy link
Copy Markdown
Collaborator

Description

This PR updates PhasorDynamics so buses and components use their slices of the SystemModel state vectors directly. This removes the local state copy path and keeps component accessors consistent with the integrator-updated system state.

Partially addresses #96. Related to #145.

Proposed changes

  • Added StateVector support so GridElement can own standalone state or alias SystemModel state.
  • Updated SystemModel allocation to bind each bus/component to global state and verify element sizes remain fixed.
  • Updated Enzyme call sites to use the explicit yData() accessor for live state pointers.
  • Added a PhasorDynamics system test for element/system state aliasing.

Performance was measured with application/PhasorDynamics/PDSim using the app-reported Complete in time. Each row reports the median of 3 trials after rebuilding PDSim on the corresponding branch.

Case develop (s) This branch (s) Improvement
Hawaii 0.201302 0.165187 17.9%
NewEngland 0.272596 0.220406 19.1%
Illinois 0.664262 0.592922 10.7%
WECC 1.203380 1.045540 13.1%
Texas 9.063860 7.515690 17.1%

Checklist

  • All tests pass. (except the known PE failure)
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows GridKit(TM) 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.
  • N/A: no CHANGELOG.md update is needed for this internal PhasorDynamics state-storage change.

Further comments

This work was motivated by the addition of IEEEST stabilizers: adding 333 stabilizers to the Texas case dramatically reduced performance, and this change removes avoidable state-copy overhead in PhasorDynamics system evaluation.

This is not intended to be the final state-vector API design. The cleaner long-term solution would be to update Evaluator so state and residual accessors expose non-owning vector views instead of requiring owned std::vector storage, e.g.

virtual VectorView<ScalarT> y() = 0;
virtual VectorView<ScalarT> yp() = 0;
virtual VectorView<ScalarT> residual() = 0;

This PR keeps the change local to PhasorDynamics while removing the current copy path.

@lukelowry lukelowry requested review from PhilipFackler and pelesh May 22, 2026 03:25
@lukelowry lukelowry added the enhancement New feature or request label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant