Skip to content

Add node objects to PowerElectronics module#367

Open
alexander-novo wants to merge 25 commits intodevelopfrom
alex/pow-elec-node-objects
Open

Add node objects to PowerElectronics module#367
alexander-novo wants to merge 25 commits intodevelopfrom
alex/pow-elec-node-objects

Conversation

@alexander-novo
Copy link
Copy Markdown
Collaborator

Description

Partially addresses #353

Adds node objects to system so the system can calculate the optimal variable mappings itself. Right now, these node objects consist of:

  • Bus (single voltage bus)
  • MicrogridBus (two voltage bus)
  • InfiniteBus (single voltage reference bus)
  • SignalNode (single-variable signal node)

All of the PowerElectronics examples have been updated to use these nodes, and there original logic for creating variable mappings has been removed. Since the RLCircuit example didn't have the correct mapping, some of its variables have been re-arranged.

As well, all component models included in these examples have been updated. Other component models can also be updated, since I feel fairly confident that I should be able to update them correctly... I just don't have tests to verify.

Proposed changes

Node objects work fairly similarly to components:

  • they have an internal size, which contributes to the overall system size
  • they have an external size (for e.g. reference nodes)
  • they have a mapping from these variables to system variables

The system adds up the internal sizes for all of the nodes and components to get its own internal size, and then is able to form mappings for all of the node and component internal variables - putting the node variables at the end of the system vector for correct Jacobian sparsity.

Components with external variables take node pointers in their constructor, and in the allocate() function will query the mapping of the node variables to properly construct the mapping for their own external variables. Reference variable mappings are also set here.

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

@alexander-novo alexander-novo requested a review from pelesh April 9, 2026 14:53
@alexander-novo alexander-novo added enhancement New feature or request labels Apr 10, 2026
@alexander-novo alexander-novo force-pushed the alex/pow-elec-node-objects branch from d7e722d to aa15560 Compare April 13, 2026 16:50
Copy link
Copy Markdown
Collaborator

@pelesh pelesh left a comment

Choose a reason for hiding this comment

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

Greta work!

Before we merge, I suggest following minor changes:

  • Remove infinite bus. We should not be using that approach in EMT simulations.
  • Signal note should not inherit from the same base class as electrical bus.
  • Address some nitpicking comments below.
  • Rebase to develop.

Comment thread examples/PowerElectronics/Microgrid/Microgrid.cpp Outdated
Comment thread examples/PowerElectronics/Microgrid/Microgrid.cpp Outdated
Comment thread examples/PowerElectronics/RLCircuit/RLCircuit.cpp Outdated
@alexander-novo
Copy link
Copy Markdown
Collaborator Author

Renaming infinite bus to grounded bus.

@alexander-novo alexander-novo force-pushed the alex/pow-elec-node-objects branch from 24e47ba to 77f6cc9 Compare April 27, 2026 19:20
These variables don't need to be unique pointers, they can just be on the stack.
@alexander-novo alexander-novo force-pushed the alex/pow-elec-node-objects branch from 77f6cc9 to dd14000 Compare April 27, 2026 19:29
@alexander-novo
Copy link
Copy Markdown
Collaborator Author

@pelesh Right now we don't have any examples of signal nodes being used differently than buses. I can make it so that SignalNode doesn't inherit from NodeBase but then I'd just have to duplicate the code in NodeBase for SignalNode. Maybe it'd be better to punt this down the road for when we have an actual example that uses the functionality?

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.

2 participants