Rename Unit to ThermalUnit

This commit is contained in:
2023-04-04 15:40:44 -05:00
parent 51f6aa9a80
commit 19534a128f
30 changed files with 107 additions and 99 deletions

View File

@@ -9,14 +9,14 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test length(instance.scenarios) == 1
sc = instance.scenarios[1]
@test length(sc.reserves_by_name["r1"].amount) == 4
@test sc.units_by_name["g2"].reserves[1].name == "r1"
@test sc.thermal_units_by_name["g2"].reserves[1].name == "r1"
end
@testset "read v0.3" begin
instance = UnitCommitment.read("$FIXTURES/ucjl-0.3.json.gz")
@test length(instance.scenarios) == 1
sc = instance.scenarios[1]
@test length(sc.units) == 6
@test length(sc.thermal_units) == 6
@test length(sc.buses) == 14
@test length(sc.lines) == 20
end

View File

@@ -8,15 +8,15 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
instance = UnitCommitment.read("$FIXTURES/case14.json.gz")
@test repr(instance) == (
"UnitCommitmentInstance(1 scenarios, 6 units, 14 buses, " *
"20 lines, 19 contingencies, 1 price sensitive loads, 0 profiled units, 4 time steps)"
"UnitCommitmentInstance(1 scenarios, 6 thermal units, 0 profiled units, 14 buses, " *
"20 lines, 19 contingencies, 1 price sensitive loads, 4 time steps)"
)
@test length(instance.scenarios) == 1
sc = instance.scenarios[1]
@test length(sc.lines) == 20
@test length(sc.buses) == 14
@test length(sc.units) == 6
@test length(sc.thermal_units) == 6
@test length(sc.contingencies) == 19
@test length(sc.price_sensitive_loads) == 1
@test instance.time == 4
@@ -49,7 +49,7 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test sc.reserves[1].amount == [100.0, 100.0, 100.0, 100.0]
@test sc.reserves_by_name["r1"].name == "r1"
unit = sc.units[1]
unit = sc.thermal_units[1]
@test unit.name == "g1"
@test unit.bus.name == "b1"
@test unit.ramp_up_limit == 1e6
@@ -76,14 +76,14 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test unit.startup_categories[2].cost == 1500.0
@test unit.startup_categories[3].cost == 2000.0
@test length(unit.reserves) == 0
@test sc.units_by_name["g1"].name == "g1"
@test sc.thermal_units_by_name["g1"].name == "g1"
unit = sc.units[2]
unit = sc.thermal_units[2]
@test unit.name == "g2"
@test unit.must_run == [false for t in 1:4]
@test length(unit.reserves) == 1
unit = sc.units[3]
unit = sc.thermal_units[3]
@test unit.name == "g3"
@test unit.bus.name == "b3"
@test unit.ramp_up_limit == 70.0
@@ -106,7 +106,7 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test unit.reserves[1].name == "r1"
@test sc.contingencies[1].lines == [sc.lines[1]]
@test sc.contingencies[1].units == []
@test sc.contingencies[1].thermal_units == []
@test sc.contingencies[1].name == "c1"
@test sc.contingencies_by_name["c1"].name == "c1"
@@ -121,7 +121,7 @@ end
@testset "read_benchmark sub-hourly" begin
instance = UnitCommitment.read("$FIXTURES/case14-sub-hourly.json.gz")
@test instance.time == 4
unit = instance.scenarios[1].units[1]
unit = instance.scenarios[1].thermal_units[1]
@test unit.name == "g1"
@test unit.min_uptime == 2
@test unit.min_downtime == 2

View File

@@ -10,7 +10,7 @@ using UnitCommitment, Cbc, JuMP
optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0)
sc = instance.scenarios[1]
# All units should have unknown initial conditions
for g in sc.units
for g in sc.thermal_units
@test g.initial_power === nothing
@test g.initial_status === nothing
end
@@ -19,7 +19,7 @@ using UnitCommitment, Cbc, JuMP
UnitCommitment.generate_initial_conditions!(sc, optimizer)
# All units should now have known initial conditions
for g in sc.units
for g in sc.thermal_units
@test g.initial_power !== nothing
@test g.initial_status !== nothing
end

View File

@@ -21,7 +21,7 @@ test_approx(x, y) = @test isapprox(x, y, atol = 1e-3)
@testset "cost and load share" begin
sc = get_scenario()
# Check original costs
unit = sc.units[10]
unit = sc.thermal_units[10]
test_approx(unit.min_power_cost[1], 825.023)
test_approx(unit.cost_segments[1].cost[1], 36.659)
test_approx(unit.startup_categories[1].cost[1], 7570.42)

View File

@@ -13,7 +13,7 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test modified.time == 2
@test length(sc.power_balance_penalty) == 2
@test length(sc.reserves_by_name["r1"].amount) == 2
for u in sc.units
for u in sc.thermal_units
@test length(u.max_power) == 2
@test length(u.min_power) == 2
@test length(u.must_run) == 2