Skip to content

Remove external variable copy for PowerElectronics#508

Draft
alexander-novo wants to merge 3 commits into
developfrom
alex/pow-elec-remove-ext-copy
Draft

Remove external variable copy for PowerElectronics#508
alexander-novo wants to merge 3 commits into
developfrom
alex/pow-elec-remove-ext-copy

Conversation

@alexander-novo

@alexander-novo alexander-novo commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Description

Removes PowerElectronicsModel::distributeVectors() by giving components access to pointers directly to external variable in the system vector.

Speedup (develop v.s. this PR):

1000 IBRs

Benchmark 1: InstallBench/examples/PowerElectronics/ScaleMicrogrid/scalemicrogridarbitrary 500
  Time (mean ± σ):      2.471 s ±  0.012 s    [User: 2.451 s, System: 0.018 s]
  Range (min … max):    2.456 s …  2.498 s    10 runs
 
Benchmark 2: Install/examples/PowerElectronics/ScaleMicrogrid/scalemicrogridarbitrary 500
  Time (mean ± σ):      1.339 s ±  0.012 s    [User: 1.320 s, System: 0.018 s]
  Range (min … max):    1.322 s …  1.355 s    10 runs
 
Summary
  Install/examples/PowerElectronics/ScaleMicrogrid/scalemicrogridarbitrary 500 ran
    1.84 ± 0.02 times faster than InstallBench/examples/PowerElectronics/ScaleMicrogrid/scalemicrogridarbitrary 500

4000 IBRs

Benchmark 1: InstallBench/examples/PowerElectronics/ScaleMicrogrid/scalemicrogridarbitrary 2000
  Time (mean ± σ):     21.007 s ±  0.209 s    [User: 20.933 s, System: 0.064 s]
  Range (min … max):   20.590 s … 21.306 s    10 runs
 
Benchmark 2: Install/examples/PowerElectronics/ScaleMicrogrid/scalemicrogridarbitrary 2000
  Time (mean ± σ):      6.417 s ±  0.052 s    [User: 6.357 s, System: 0.056 s]
  Range (min … max):    6.323 s …  6.524 s    10 runs
 
Summary
  Install/examples/PowerElectronics/ScaleMicrogrid/scalemicrogridarbitrary 2000 ran
    3.27 ± 0.04 times faster than InstallBench/examples/PowerElectronics/ScaleMicrogrid/scalemicrogridarbitrary 2000

10,000 IBRs

Benchmark 1: InstallBench/examples/PowerElectronics/ScaleMicrogrid/scalemicrogridarbitrary 5000
  Time (mean ± σ):     74.876 s ±  0.181 s    [User: 74.715 s, System: 0.129 s]
  Range (min … max):   74.653 s … 75.276 s    10 runs
 
Benchmark 2: Install/examples/PowerElectronics/ScaleMicrogrid/scalemicrogridarbitrary 5000
  Time (mean ± σ):     23.310 s ±  0.182 s    [User: 23.174 s, System: 0.124 s]
  Range (min … max):   23.060 s … 23.687 s    10 runs
 
Summary
  Install/examples/PowerElectronics/ScaleMicrogrid/scalemicrogridarbitrary 5000 ran
    3.21 ± 0.03 times faster than InstallBench/examples/PowerElectronics/ScaleMicrogrid/scalemicrogridarbitrary 5000

Proposed changes

Each component keeps track of y_ext_, yp_ext_, and f_ext_, which are arrays of pointers to the values of external variables, their derivatives, and their residuals.

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

@pelesh
pelesh requested review from lukelowry and pelesh July 24, 2026 21:03
@pelesh pelesh added this to the Release 0.2 milestone Jul 24, 2026
@pelesh pelesh added the enhancement New feature or request label Jul 24, 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.

2 participants