Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigomha committed Nov 5, 2024
1 parent 8446e26 commit c67f721
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/PowerSimulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export HVDCTwoTerminalLossless
export HVDCTwoTerminalDispatch
export HVDCTwoTerminalUnbounded
export PhaseAngleControl
export HVDCTwoTerminalVSCLoss
# export VoltageSourceDC

######## HVDC models ########
Expand Down
65 changes: 65 additions & 0 deletions test/test_device_branch_constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -728,3 +728,68 @@ end
# some relaxations will find a solution with 0.0 slack
@test sum(vars[!, "2"]) >= -1e-6
end

@testset "HVDC VSC Loss Model" begin
c_sys5 = PSB.build_system(PSISystems, "2Area 5 Bus System")
thermal_names = ["Solitude", "Park City", "Alta", "Brighton"]
for name in thermal_names
thermal = get_component(ThermalStandard, c_sys5, name)
op_cost = get_operation_cost(thermal)
new_opcost = ThermalGenerationCost(;
variable = CostCurve(;
value_curve = PSY.QuadraticCurve(
0.0,
get_proportional_term(op_cost.variable.value_curve) / 2.0,
0.0,
),
power_units = UnitSystem.NATURAL_UNITS,
),
fixed = op_cost.fixed,
start_up = op_cost.start_up,
shut_down = op_cost.shut_down,
)
set_operation_cost!(thermal, new_opcost)
end

hvdc = first(get_components(TwoTerminalHVDCLine, c_sys5))

hvdc_new = TwoTerminalHVDCDetailedLine(;
name = get_name(hvdc),
available = get_available(hvdc),
active_power_flow = get_active_power_flow(hvdc),
rating = 2.0,
active_power_limits_from = (min = -2.0, max = 2.0),
active_power_limits_to = (min = -2.0, max = 2.0),
arc = get_arc(hvdc),
converter_loss = QuadraticCurve(0.0001, 0.01, 0.0),
dc_current = 0.0,
max_dc_current = 3.0,
g = 50.0, # r = 0.02
voltage_limits = (min = 0.9, max = 1.1),
)
remove_component!(c_sys5, hvdc)
add_component!(c_sys5, hvdc_new)

template = get_thermal_dispatch_template_network(NetworkModel(PTDFPowerModel))
dev_model = DeviceModel(
TwoTerminalHVDCDetailedLine,
PSI.HVDCTwoTerminalVSCLoss;
attributes = Dict{String, Any}(
"voltage_segments" => 10,
"current_segments" => 10,
"bilinear_segments" => 10,
),
)
set_device_model!(template, dev_model)
ps_model = DecisionModel(
template,
c_sys5;
optimizer = HiGHS_optimizer,
store_variable_names = true,
horizon = Hour(2),
)
@test build!(ps_model; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
moi_tests(ps_model, 268, 0, 152, 148, 62, true)
@test solve!(ps_model) == PSI.RunStatus.SUCCESSFULLY_FINALIZED
end

0 comments on commit c67f721

Please sign in to comment.