Skip to content

Add test coverage for add_to_expression! paths #134

@luke-kiernan

Description

@luke-kiernan

Three add_to_expression! paths in src/common_models/add_to_expression.jl were latently broken (would error or mis-index) and went undetected because no test system exercises them. They were just fixed on lk/issue-9 (porting PSI fix 22d2059c2 plus a constant-add correction), but we need tests that actually hit them so they can't silently regress again.

1. must-run compact-UC OnVariable

The must_run branch of the compact-UC OnVariable → balance methods called a non-existent 2-arg add_proportional_to_jump_expression!, so it would have thrown a MethodError if ever reached. It's now add_constant_to_jump_expression!(expr, p_min*mult) (must-run units have On ≡ 1, so P_min enters as a constant). No test system contains a must-run compact-UC thermal unit — add one and assert the constant lands in the balance expression.

2. OnVariable / ThermalGen under AreaBalancePowerModel

This method fetched the PSY.ACBus expression container but indexed it by area name, which would KeyError. Fixed to fetch PSY.Area. Needs an AreaBalancePowerModel test with a compact-UC thermal unit.

3. FlowActivePowerToFromVariable / TwoTerminalHVDC under AreaBalancePowerModel

This method referenced an undefined network_reduction (only radial_network_reduction was bound, via a nonexistent get_radial_network_reduction) and an unbound type parameter W, so it would UndefVarError. Fixed to index by PSY.Area and bind HVDCTwoTerminalDispatch. Needs an AreaBalancePowerModel test with a TwoTerminalHVDC line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions