Skip to content

add power-flow static VAR compensator in SP domain - #656

Draft
leonardocarreras wants to merge 7 commits into
masterfrom
feature/pf-statcom-svc
Draft

add power-flow static VAR compensator in SP domain#656
leonardocarreras wants to merge 7 commits into
masterfrom
feature/pf-statcom-svc

Conversation

@leonardocarreras

Copy link
Copy Markdown
Contributor

Voltage-controlling shunt reactive device modelled as a PQ bus, to be driven by the SVC outer control loop. No active power, no admittance stamp; participates via bus classification and reactive setpoint. Reuses the SynchronGenerator per-unit/attribute pattern (V_set_pu, Q_max_pu, Q_min_pu).

The solver-side outer loop that makes this usable is the pull request above it in the stack.

Signed-off-by: Leonardo Carreras <leonardo.carreras@eonerc.rwth-aachen.de>
…version

Signed-off-by: Leonardo Carreras <leonardo.carreras@eonerc.rwth-aachen.de>
Signed-off-by: Leonardo Carreras <leonardo.carreras@eonerc.rwth-aachen.de>
Signed-off-by: Leonardo Carreras <leonardo.carreras@eonerc.rwth-aachen.de>
Signed-off-by: Leonardo Carreras <leonardo.carreras@eonerc.rwth-aachen.de>
Signed-off-by: Leonardo Carreras <leonardo.carreras@eonerc.rwth-aachen.de>
Signed-off-by: Leonardo Carreras <leonardo.carreras@eonerc.rwth-aachen.de>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DPsim LLM review

Claim vs. code: matches the description.

Found 5 high, 10 medium, 1 low (0 anchored to lines below).

🔵 Optional / low-confidence (16)
  • Add virtual destructor to polymorphic base class [high · 35% confidence · unconfirmed] in dpsim-models/include/dpsim-models/SP/SP_Ph1_SVC.h:16
  • Missing validation of input parameters in setParameters [high · 35% confidence · unconfirmed] in dpsim-models/include/dpsim-models/SP/SP_Ph1_SVC.h:49
  • Missing override specifiers on virtual interface methods [high · 35% confidence · unconfirmed] in dpsim-models/include/dpsim-models/SP/SP_Ph1_SVC.h:61
  • Missing scheduler dependency for updateReactivePowerInjection [high · 34% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:99
  • getApparentPower returns a value that is never consumed by the power-flow solver [high · 28% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:113
  • Unnecessary flush after logger call in constructor [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:24
  • Provide default argument for ratedVoltage in setParameters [medium · 35% confidence · unconfirmed] in dpsim-models/include/dpsim-models/SP/SP_Ph1_SVC.h:49
  • Incorrect comment for member variable mBaseVoltage [medium · 35% confidence · unconfirmed] in dpsim-models/include/dpsim-models/SP/SP_Ph1_SVC.h:20
  • Use DEBUG level for component creation log [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:23
  • Demote noisy INFO logs in setParameters to DEBUG [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:38
  • Demote power-flow section header log to DEBUG [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:56
  • Use DEBUG level for constructor log [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:23
  • Parameter‑setting logs should be DEBUG [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:38
  • Per‑unit calculation logs should be DEBUG [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:56
  • No unit test exercising SP::Ph1::SVC behavior [medium · 30% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp
  • Duplicated per‑unit conversion logic [low · 20% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:15
Claim vs. implementation
  • Claimed: Add a power-flow SP-domain static VAR compensator model as a PQ bus with reactive setpoint/limits, plus docs and solver base-voltage handling.
  • Done: Introduced a new SP::Ph1::SVC class with PQ-only power-flow behavior, reactive setpoint/limits and per-unit conversion, wired it into the solver, pybind, build, and documentation.
  • Difference: none
How this review was produced

13 specialized finder passes raised 63 findings over the diff and the full changed sources. After de-duplication, 61 were re-checked against the current file and the base-class / interface headers it inherits (code as truth), escalating survivors to a stronger model: 45 refuted as unsupported, 16 kept (16 tentative).

Refuted by verification:

  • Incorrect extraction of reactive power from Complex injection (dpsim-models/src/SP/SP_Ph1_SVC.cpp): updateReactivePowerInjection intentionally stores powerInj.imag() as the reactive power setpoint, and the header documents Q_set as reactive power injection
  • Apparent power representation does not match power-flow convention (dpsim-models/src/SP/SP_Ph1_SVC.cpp): getApparentPower() is documented to return apparent power with P always 0, and the implementation matches that contract
  • Incomplete explanation of the power-flow SVC boundary condition (docs/hugo/content/en/docs/Concepts/Models/network-injection-and-compensation.md): The added section already explains that fixing reactive power uses constant-power equations and an outer loop, which is the PQ-bus modeling choice.
  • Incomplete documentation of the power-flow SVC interface (docs/hugo/content/en/docs/Developer Guide/Model Implementations/network-injection-and-compensation.md): The added power-flow section explicitly says it stamps nothing into the admittance matrix and that updateReactivePowerInjection is the setter that moves the injection.
  • Incorrect apparent power return type for SP::Ph1::SVC (dpsim-models/src/SP/SP_Ph1_SVC.cpp): the SP header says P is always 0, so returning Complex(0., **mSetPointReactivePower) is the intended convention
  • Use DOUBLE_EPSILON instead of ad-hoc 1e-6 tolerance (dpsim-models/src/SP/SP_Ph1_SVC.cpp): the file explicitly uses Math::isFinite and a positivity check; the complaint is about a different tolerance policy, not a defect
  • Validate base apparent power before division in updateReactivePowerInjection (dpsim-models/src/SP/SP_Ph1_SVC.cpp): updateReactivePowerInjection checks mBaseApparentPower for finiteness and positivity before dividing
  • Per-unit division by base voltage lacks explicit non-zero check (dpsim-models/src/SP/SP_Ph1_SVC.cpp): the guard already rejects zero and negative base voltage with mBaseVoltage <= 0
  • getApparentPower returns Complex with zero real part (dpsim-models/src/SP/SP_Ph1_SVC.cpp): returning zero real power is documented in the header as correct for an SVC
  • Attribute usage: ratedVoltage parameter is unused (dpsim-models/src/SP/SP_Ph1_SVC.cpp): ratedApparentPower and ratedVoltage are intentionally logged only, as the header comment states
  • Inconsistent guard against non-finite base apparent power (dpsim-models/src/SP/SP_Ph1_SVC.cpp): the downstream division is guarded by the same finiteness/positivity check in updateReactivePowerInjection
  • Guard against division by zero in updateReactivePowerInjection (dpsim-models/src/SP/SP_Ph1_SVC.cpp): the code checks mBaseApparentPower before dividing by it
  • Use Math::isPositive instead of manual comparison (dpsim-models/src/SP/SP_Ph1_SVC.cpp): manual comparison mBaseVoltage <= 0 is already the explicit positivity check
  • Use Math::isPositive for base apparent power guard (dpsim-models/src/SP/SP_Ph1_SVC.cpp): manual comparison mBaseApparentPower <= 0 is already the explicit positivity check
  • Remove redundant semicolon after setTerminalNumber (dpsim-models/src/SP/SP_Ph1_SVC.cpp): the semicolon after setTerminalNumber(1) is present in the source but is harmless style, not a defect

Automated, non-blocking review. May be wrong. Models: find mistral-small-4-119b-2603, gpt-oss-120b → verify gpt-5.4-mini → final gpt-5.5.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DPsim LLM review

Claim vs. code: matches the description.

Found 1 critical, 9 high, 20 medium (0 anchored to lines below).

🔵 Optional / low-confidence (30)
  • SVC per‑unit parameters never computed during initialization [critical · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:54
  • Incorrect reactive power injection extraction from Complex argument [high · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:108
  • Incorrect apparent power representation in SP domain [high · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:113
  • getApparentPower returns Complex with zero real part instead of RMS3PH convention [high · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:113
  • Add virtual destructor to polymorphic base class [high · 35% confidence · unconfirmed] in dpsim-models/include/dpsim-models/SP/SP_Ph1_SVC.h:16
  • Missing override specifier on virtual method [high · 35% confidence · unconfirmed] in dpsim-models/include/dpsim-models/SP/SP_Ph1_SVC.h:61
  • Expose SVC per-unit attributes to Python [high · 35% confidence · unconfirmed] in dpsim/src/pybind/SPComponents.cpp:166
  • Missing validation of ratedApparentPower and ratedVoltage in setParameters [high · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:32
  • Inconsistent guard between updateReactivePowerInjection and calculatePerUnitParameters [high · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:100
  • Missing override specifier on virtual methods [high · 35% confidence · unconfirmed] in dpsim-models/include/dpsim-models/SP/SP_Ph1_SVC.h:55
  • Inconsistent description of power-flow SVC boundary condition [medium · 35% confidence · unconfirmed] in docs/hugo/content/en/docs/Concepts/Models/network-injection-and-compensation.md:67
  • Inconsistent per-unit parameter calculation description [medium · 35% confidence · unconfirmed] in docs/hugo/content/en/docs/Developer Guide/Model Implementations/network-injection-and-compensation.md:71
  • Unnecessary semicolon after constructor initializer list [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:27
  • Inconsistent switch-case indentation [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:82
  • Missing override specifier on virtual method [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:99
  • Redundant check of mBaseApparentPower positivity [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:100
  • Inconsistent comment style for SVC base voltage handling [medium · 35% confidence · unconfirmed] in dpsim/src/PFSolver.cpp:334
  • Inconsistent comment style for SVC base voltage propagation [medium · 35% confidence · unconfirmed] in dpsim/src/PFSolver.cpp:456
  • Use DEBUG level for component creation log [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:23
  • Use DEBUG level for rated parameter logging [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:38
  • Use DEBUG level for per-unit calculation log [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:56
  • Incomplete validation of powerInj in updateReactivePowerInjection [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:104
  • Add new SP_Ph1_SVC.cpp to the build list [medium · 35% confidence · unconfirmed] in dpsim-models/src/CMakeLists.txt:182
  • Include new SP_Ph1_SVC.h header in Components.h [medium · 35% confidence · unconfirmed] in dpsim-models/include/dpsim-models/Components.h:25
  • Expose SP::Ph1::SVC to Python bindings [medium · 35% confidence · unconfirmed] in dpsim/src/pybind/SPComponents.cpp:166
  • Add a test or example exercising SP::Ph1::SVC in Python [medium · 35% confidence · unconfirmed] in docs/hugo/content/en/docs/Developer Guide/Model Implementations/network-injection-and-compensation.md:58
  • SVC attributes not exposed to Python [medium · 35% confidence · unconfirmed] in dpsim/src/pybind/SPComponents.cpp:166
  • Missing finiteness checks for set‑point attributes before per‑unit conversion [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp:71
  • Missing dedicated model documentation page for SP::Ph1::SVC [medium · 35% confidence · unconfirmed] in docs/hugo/content/en/docs/Concepts/Models/network-injection-and-compensation.md:61
  • Missing unit test for SP::Ph1::SVC power‑flow behavior [medium · 35% confidence · unconfirmed] in dpsim-models/src/SP/SP_Ph1_SVC.cpp
Claim vs. implementation
  • Claimed: Add a power-flow static VAR compensator in the SP domain as a PQ-bus, zero-active-power, no-admittance-stamp component with per-unit reactive setpoint/limits and solver-driven base-voltage handling.
  • Done: Adds a new SP::Ph1::SVC class, exposes it to Python, integrates it into build/docs, and makes the power-flow solver assign its base voltage from the resolved node zone.
  • Difference: none
How this review was produced

13 specialized finder passes raised 31 findings over the diff and the full changed sources. After de-duplication, 31 were re-checked against the current file and the base-class / interface headers it inherits (code as truth), escalating survivors to a stronger model: 1 refuted as unsupported, 30 kept (30 tentative).

Refuted by verification:

  • SVC source not listed in TEST_SOURCES for CI test builds (dpsim-models/src/CMakeLists.txt): The file only adds SP/SP_Ph1_SVC.cpp to MODELS_SOURCES; there is no TEST_SOURCES mechanism in this CMakeLists.txt to satisfy the claim

Automated, non-blocking review. May be wrong. Models: find mistral-small-4-119b-2603, gpt-oss-120b → verify gpt-5.4-mini → final gpt-5.5.

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 22.22222% with 70 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.69%. Comparing base (5564723) to head (8326843).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
dpsim-models/src/SP/SP_Ph1_SVC.cpp 0.00% 65 Missing ⚠️
dpsim-models/include/dpsim-models/SP/SP_Ph1_SVC.h 0.00% 2 Missing ⚠️
dpsim/src/PFSolver.cpp 77.77% 2 Missing ⚠️
dpsim/src/pybind/SPComponents.cpp 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #656      +/-   ##
==========================================
- Coverage   72.72%   72.69%   -0.03%     
==========================================
  Files         512      514       +2     
  Lines       33219    33278      +59     
  Branches    18017    17986      -31     
==========================================
+ Hits        24158    24193      +35     
- Misses       9000     9084      +84     
+ Partials       61        1      -60     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

sonarqubecloud Bot commented Aug 7, 2026

Copy link
Copy Markdown

@leonardocarreras
leonardocarreras marked this pull request as draft August 11, 2026 07:44
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.

1 participant