Skip to content

Collapse enzyme wb, ws, h - #511

Draft
lukelowry wants to merge 3 commits into
developfrom
lukel/unify-components-dev
Draft

Collapse enzyme wb, ws, h#511
lukelowry wants to merge 3 commits into
developfrom
lukel/unify-components-dev

Conversation

@lukelowry

Copy link
Copy Markdown
Collaborator

Description

Refactors PhasorDynamics components to use a consistent internal/external variable and residual interface (thank you for the inspo @alexander-novo). This removes the separate wb, ws, and h paths, simplifies Enzyme Jacobian generation, and makes residual ownership clearer without changing model behavior.

Proposed changes

  • Add shared external variable and residual storage to Component.
  • Split residual evaluation into internal equations and external contributions.
  • Consolidate the specialized Enzyme derivative wrappers into generic internal/external forms.
  • Update the affected PhasorDynamics models and Jacobian assembly.
  • Ignore invalid row and column mappings during sparse Jacobian storage.

Checklist

  • All tests pass.
  • 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.
  • I have updated CHANGELOG.md to reflect the changes in this PR. If this is a minor PR that is part of a larger fix already included in the file, state so.

Further comments

This demonstrates that we don't need to give special treatment to Bus, and we can have Bus inherit from Component, which dramatically simplifies SystemModel and signal orchestration. Personally, this is much easier to document and implement. MOST IMPORTANTLY: this internal/external formulation can allow us to make the residual evaluation order independent, which (I think) is better for partitioning and parallelization.

cc @nkoukpaizan

Draft just so others can see, I may need to break this up

@lukelowry

Copy link
Copy Markdown
Collaborator Author

@Steven-Roberts this representation might make partitioning easier aswell

@nkoukpaizan

Copy link
Copy Markdown
Collaborator

Thanks @lukelowry for looking at this. Updating these local vector is on our todo list, and this should work, now that we are storing the current injections as local variables. I would still prioritize merging the models you need for the 10K over this change.

@lukelowry

Copy link
Copy Markdown
Collaborator Author

Thanks @lukelowry for looking at this. Updating these local vector is on our todo list, and this should work, now that we are storing the current injections as local variables. I would still prioritize merging the models you need for the 10K over this change.

I agree, definitely

@lukelowry

Copy link
Copy Markdown
Collaborator Author

@pelesh I believe this formulation of the system gives me the most flexibility in EMT models. On my end, I would be okay with splitting off from Phasor Dynamics after this.

@lukelowry
lukelowry force-pushed the lukel/unify-components-dev branch from 04b5ede to fe25d96 Compare August 4, 2026 20:21
@lukelowry
lukelowry force-pushed the lukel/unify-components-dev branch from fe25d96 to f118e08 Compare August 6, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants