Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"

[sources]
InfrastructureSystems = {url = "https://github.com/NREL-Sienna/InfrastructureSystems.jl", rev = "IS4"}
PowerFlowFileParser = {url = "https://github.com/NREL-Sienna/PowerFlowFileParser.jl", rev = "main"}
PowerSystems = {url = "https://github.com/NREL-Sienna/PowerSystems.jl", rev = "psy6"}
InfrastructureSystems = {url = "https://github.com/NREL-Sienna/InfrastructureSystems.jl", rev = "lk/units-domain-agnostic-is4"}
PowerFlowFileParser = {url = "https://github.com/luke-kiernan/PowerFlowFileParser.jl", rev = "lk/units-fixes"}
PowerSystems = {url = "https://github.com/NREL-Sienna/PowerSystems.jl", rev = "lk/units-fold-psu"}
PowerTableDataParser = {url = "https://github.com/NLR-Sienna/PowerTableDataParser.jl", rev = "main"}

[compat]
Expand Down
40 changes: 23 additions & 17 deletions src/library/psi_library.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ function build_c_sys5_pjm(; add_forecasts, raw_data, sys_kwargs...)
peak_load = maximum(da_load_time_series_val)
if add_forecasts
for (ix, l) in enumerate(PSY.get_components(PowerLoad, c_sys5))
set_max_active_power!(l, bus_dist_fact[PSY.get_name(l)] * peak_load / 100)
set_max_active_power!(
l,
bus_dist_fact[PSY.get_name(l)] * peak_load / 100 * IS.SU,
)
add_time_series!(
c_sys5,
l,
Expand Down Expand Up @@ -209,7 +212,10 @@ function build_c_sys5_pjm_rt(; add_forecasts, raw_data, sys_kwargs...)
peak_load = maximum(rt_load_time_series_val)
if add_forecasts
for (ix, l) in enumerate(PSY.get_components(PowerLoad, c_sys5))
set_max_active_power!(l, bus_dist_fact[PSY.get_name(l)] * peak_load / 100)
set_max_active_power!(
l,
bus_dist_fact[PSY.get_name(l)] * peak_load / 100 * IS.SU,
)
rt_timearray =
TimeArray(rt_load_time_series, rt_load_time_series_val ./ peak_load)
rt_timearray = collapse(rt_timearray, Minute(5), first, TimeSeries.mean)
Expand Down Expand Up @@ -514,7 +520,7 @@ function make_modified_RTS_GMLC_sys(
PSY.get_operation_cost(g),
PSY.get_start_up(PSY.get_operation_cost(g)) / 2.0,
)
if PSY.get_base_power(g) > 3
if PSY.get_base_power(g, IS.DU) > 3
continue
end
PSY.clear_services!(g)
Expand Down Expand Up @@ -545,7 +551,7 @@ function make_modified_RTS_GMLC_sys(
sys,
)
PSY.get_fuel(d) == PSY.ThermalFuels.COAL &&
(PSY.set_ramp_limits!(d, (up = 0.001, down = 0.001)))
(PSY.set_ramp_limits!(d, (up = 0.001 * IS.DU, down = 0.001 * IS.DU)))
if PSY.get_fuel(d) == PSY.ThermalFuels.DISTILLATE_FUEL_OIL
PSY.remove_component!(sys, d)
continue
Expand All @@ -554,10 +560,10 @@ function make_modified_RTS_GMLC_sys(
PSY.get_operation_cost(d),
PSY.get_start_up(PSY.get_operation_cost(d)) / 2.0,
)
if PSY.get_rating(d) < 3
if PSY.get_rating(d, IS.DU) < 3
PSY.set_status!(d, false)
PSY.set_status!(d, false)
PSY.set_active_power!(d, 0.0)
PSY.set_active_power!(d, 0.0 * IS.DU)
continue
end
PSY.clear_services!(d)
Expand Down Expand Up @@ -587,17 +593,17 @@ function make_modified_RTS_GMLC_sys(
PSY.RenewableDispatch,
sys,
)
rat_ = PSY.get_rating(g)
PSY.set_rating!(g, DISPATCH_INCREASE * rat_)
rat_ = PSY.get_rating(g, IS.DU)
PSY.set_rating!(g, DISPATCH_INCREASE * rat_ * IS.DU)
end

for g in PSY.get_components(
x -> PSY.get_prime_mover_type(x) == PSY.PrimeMovers.PVe,
PSY.RenewableNonDispatch,
sys,
)
rat_ = PSY.get_rating(g)
PSY.set_rating!(g, FIX_DECREASE * rat_)
rat_ = PSY.get_rating(g, IS.DU)
PSY.set_rating!(g, FIX_DECREASE * rat_ * IS.DU)
end

### Update Buses to PQ that got devices removed ###
Expand Down Expand Up @@ -1455,11 +1461,11 @@ function _duplicate_system(main_sys::PSY.System, twin_sys::PSY.System, HVDC_line
end
# change scale
if typeof(b) <: RenewableGen
PSY.set_base_power!(b, 1.2 * PSY.get_base_power(b))
PSY.set_base_power!(main_comp, 0.9 * PSY.get_base_power(b))
PSY.set_base_power!(b, 1.2 * PSY.get_base_power(b, IS.SU) * IS.SU)
PSY.set_base_power!(main_comp, 0.9 * PSY.get_base_power(b, IS.SU) * IS.SU)
end
if typeof(b) <: PowerLoad
PSY.set_base_power!(main_comp, 1.2 * PSY.get_base_power(b))
PSY.set_base_power!(main_comp, 1.2 * PSY.get_base_power(b, IS.SU) * IS.SU)
end
end

Expand Down Expand Up @@ -1511,7 +1517,7 @@ function _duplicate_system(main_sys::PSY.System, twin_sys::PSY.System, HVDC_line
end

for bat in get_components(EnergyReservoirStorage, main_sys)
set_base_power!(bat, get_base_power(bat) * 10)
set_base_power!(bat, get_base_power(bat, IS.SU) * 10 * IS.SU)
end

for r in get_components(
Expand Down Expand Up @@ -1559,10 +1565,10 @@ function _duplicate_system(main_sys::PSY.System, twin_sys::PSY.System, HVDC_line
get_initial_input(old_value_curve)
old_y =
get_initial_input(old_value_curve) /
(get_active_power_limits(g).min * get_base_power(g))
(get_active_power_limits(g, IS.SU).min * PSY.get_base_power(g, IS.SU))
new_first_input =
(old_y + direction * cost_noise) * get_active_power_limits(g).min *
get_base_power(g)
(old_y + direction * cost_noise) * get_active_power_limits(g, IS.SU).min *
PSY.get_base_power(g, IS.SU)
new_slopes[1] = old_slopes[1] + direction * cost_noise
@assert new_slopes[1] > 0.0
for ix in 2:length(old_slopes)
Expand Down
16 changes: 8 additions & 8 deletions src/library/psid_library.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ function build_psid_wecc_9_dynamic(; raw_data, kwargs...)
sys = make_system(pm_data; runchecks = false, sys_kwargs...)

# Manually change reactance of three branches to match Sauer & Pai (2007) Figure 7.4
set_x!(get_component(Branch, sys, "Bus 5-Bus 4-i_1"), 0.085)
set_x!(get_component(Branch, sys, "Bus 9-Bus 6-i_1"), 0.17)
set_x!(get_component(Branch, sys, "Bus 7-Bus 8-i_1"), 0.072)
set_x!(get_component(Branch, sys, "Bus 5-Bus 4-i_1"), 0.085 * IS.SU)
set_x!(get_component(Branch, sys, "Bus 9-Bus 6-i_1"), 0.17 * IS.SU)
set_x!(get_component(Branch, sys, "Bus 7-Bus 8-i_1"), 0.072 * IS.SU)

# Loads from raw file are constant power, consistent with Sauer & Pai (p169)

Expand Down Expand Up @@ -169,13 +169,13 @@ function build_psid_load_tutorial_omib(; raw_data, kwargs...)
name = PSY.get_name(l),
available = PSY.get_available(l),
bus = PSY.get_bus(l),
active_power = PSY.get_constant_active_power(l),
reactive_power = PSY.get_constant_reactive_power(l),
active_power = PSY.get_constant_active_power(l, IS.SU),
reactive_power = PSY.get_constant_reactive_power(l, IS.SU),
α = 0.0, # Constant Power
β = 0.0, # Constant Power
base_power = PSY.get_base_power(l),
max_active_power = PSY.get_max_constant_active_power(l),
max_reactive_power = PSY.get_max_constant_reactive_power(l),
base_power = PSY.get_base_power(l, IS.SU),
max_active_power = PSY.get_max_constant_active_power(l, IS.SU),
max_reactive_power = PSY.get_max_constant_reactive_power(l, IS.SU),
)
remove_component!(sys, l)
add_component!(sys, exp_load)
Expand Down
58 changes: 29 additions & 29 deletions src/library/psidtest_library.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@ function transform_load_to_constant_impedance(load::PSY.StandardLoad)
active_power, reactive_power, max_active_power, max_reactive_power =
_compute_total_load_parameters(load)
# Set Impedance Power
PSY.set_impedance_active_power!(load, active_power)
PSY.set_impedance_reactive_power!(load, reactive_power)
PSY.set_max_impedance_active_power!(load, max_active_power)
PSY.set_max_impedance_reactive_power!(load, max_reactive_power)
PSY.set_impedance_active_power!(load, active_power * IS.SU)
PSY.set_impedance_reactive_power!(load, reactive_power * IS.SU)
PSY.set_max_impedance_active_power!(load, max_active_power * IS.SU)
PSY.set_max_impedance_reactive_power!(load, max_reactive_power * IS.SU)
# Set everything else to zero
PSY.set_constant_active_power!(load, 0.0)
PSY.set_constant_reactive_power!(load, 0.0)
PSY.set_max_constant_active_power!(load, 0.0)
PSY.set_max_constant_reactive_power!(load, 0.0)
PSY.set_current_active_power!(load, 0.0)
PSY.set_current_reactive_power!(load, 0.0)
PSY.set_max_current_active_power!(load, 0.0)
PSY.set_max_current_reactive_power!(load, 0.0)
PSY.set_constant_active_power!(load, 0.0 * IS.SU)
PSY.set_constant_reactive_power!(load, 0.0 * IS.SU)
PSY.set_max_constant_active_power!(load, 0.0 * IS.SU)
PSY.set_max_constant_reactive_power!(load, 0.0 * IS.SU)
PSY.set_current_active_power!(load, 0.0 * IS.SU)
PSY.set_current_reactive_power!(load, 0.0 * IS.SU)
PSY.set_max_current_active_power!(load, 0.0 * IS.SU)
PSY.set_max_current_reactive_power!(load, 0.0 * IS.SU)
return
end

function _compute_total_load_parameters(load::PSY.StandardLoad)
@warn "Load data is transformed under the assumption of a 1.0 p.u. Voltage Magnitude"
# Constant Power Data
constant_active_power = PSY.get_constant_active_power(load)
constant_reactive_power = PSY.get_constant_reactive_power(load)
max_constant_active_power = PSY.get_max_constant_active_power(load)
max_constant_reactive_power = PSY.get_max_constant_reactive_power(load)
constant_active_power = PSY.get_constant_active_power(load, IS.SU)
constant_reactive_power = PSY.get_constant_reactive_power(load, IS.SU)
max_constant_active_power = PSY.get_max_constant_active_power(load, IS.SU)
max_constant_reactive_power = PSY.get_max_constant_reactive_power(load, IS.SU)
# Constant Current Data
current_active_power = PSY.get_current_active_power(load)
current_reactive_power = PSY.get_current_reactive_power(load)
max_current_active_power = PSY.get_max_current_active_power(load)
max_current_reactive_power = PSY.get_max_current_reactive_power(load)
current_active_power = PSY.get_current_active_power(load, IS.SU)
current_reactive_power = PSY.get_current_reactive_power(load, IS.SU)
max_current_active_power = PSY.get_max_current_active_power(load, IS.SU)
max_current_reactive_power = PSY.get_max_current_reactive_power(load, IS.SU)
# Constant Admittance Data
impedance_active_power = PSY.get_impedance_active_power(load)
impedance_reactive_power = PSY.get_impedance_reactive_power(load)
max_impedance_active_power = PSY.get_max_impedance_active_power(load)
max_impedance_reactive_power = PSY.get_max_impedance_reactive_power(load)
impedance_active_power = PSY.get_impedance_active_power(load, IS.SU)
impedance_reactive_power = PSY.get_impedance_reactive_power(load, IS.SU)
max_impedance_active_power = PSY.get_max_impedance_active_power(load, IS.SU)
max_impedance_reactive_power = PSY.get_max_impedance_reactive_power(load, IS.SU)
# Total Load Calculations
active_power = constant_active_power + current_active_power + impedance_active_power
reactive_power =
Expand Down Expand Up @@ -894,13 +894,13 @@ function build_psid_psse_test_exp_load(; kwargs...)
name = PSY.get_name(l),
available = PSY.get_available(l),
bus = PSY.get_bus(l),
active_power = PSY.get_active_power(l),
reactive_power = PSY.get_reactive_power(l),
active_power = PSY.get_active_power(l, IS.SU),
reactive_power = PSY.get_reactive_power(l, IS.SU),
active_power_coefficient = 0.0, # Constant Power
reactive_power_coefficient = 0.0, # Constant Power
base_power = PSY.get_base_power(l),
max_active_power = PSY.get_max_active_power(l),
max_reactive_power = PSY.get_max_reactive_power(l),
base_power = PSY.get_base_power(l, IS.SU),
max_active_power = PSY.get_max_active_power(l, IS.SU),
max_reactive_power = PSY.get_max_reactive_power(l, IS.SU),
)
PSY.remove_component!(sys, l)
PSY.add_component!(sys, exp_load)
Expand Down
27 changes: 18 additions & 9 deletions src/library/psitest_library.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,10 @@ function build_c_sys5_events(; add_forecasts, raw_data, sys_kwargs...)
peak_load = maximum(da_load_time_series_val)
if add_forecasts
for (ix, l) in enumerate(PSY.get_components(PowerLoad, c_sys5))
set_max_active_power!(l, bus_dist_fact[PSY.get_name(l)] * peak_load / 100)
set_max_active_power!(
l,
bus_dist_fact[PSY.get_name(l)] * peak_load / 100 * IS.SU,
)
add_time_series!(
c_sys5,
l,
Expand Down Expand Up @@ -2318,7 +2321,10 @@ function build_c_sys5_events_rt(; add_forecasts, raw_data, sys_kwargs...)
peak_load = maximum(rt_load_time_series_val)
if add_forecasts
for (ix, l) in enumerate(PSY.get_components(PowerLoad, c_sys5))
set_max_active_power!(l, bus_dist_fact[PSY.get_name(l)] * peak_load / 100)
set_max_active_power!(
l,
bus_dist_fact[PSY.get_name(l)] * peak_load / 100 * IS.SU,
)
rt_timearray =
TimeArray(rt_load_time_series, rt_load_time_series_val ./ peak_load)
rt_timearray = collapse(rt_timearray, Minute(5), first, TimeSeries.mean)
Expand Down Expand Up @@ -2415,9 +2421,9 @@ function build_c_sys5_reg(; add_forecasts, raw_data, kwargs...)
for g in PSY.get_components(PSY.Generator, c_sys5_reg)
droop =
if isa(g, PSY.ThermalStandard)
0.04 * PSY.get_base_power(g)
0.04 * PSY.get_base_power(g, IS.SU)
else
0.05 * PSY.get_base_power(g)
0.05 * PSY.get_base_power(g, IS.SU)
end
p_factor = (up = 1.0, dn = 1.0)
t = PSY.RegulationDevice(g; participation_factor = p_factor, droop = droop)
Expand Down Expand Up @@ -6289,10 +6295,10 @@ function build_c_sys5_radial(; raw_data, kwargs...)
copy_time_series!(load_ext1, load_bus3)
copy_time_series!(load_ext2, load_bus3)

set_active_power!(load_bus3, 1.0)
set_max_active_power!(load_bus3, 1.0)
set_reactive_power!(load_bus3, 0.3287)
set_max_reactive_power!(load_bus3, 0.3287)
set_active_power!(load_bus3, 1.0 * IS.SU)
set_max_active_power!(load_bus3, 1.0 * IS.SU)
set_reactive_power!(load_bus3, 0.3287 * IS.SU)
set_max_reactive_power!(load_bus3, 0.3287 * IS.SU)
return new_sys
end

Expand Down Expand Up @@ -6479,7 +6485,10 @@ function build_two_area_pjm_DA(; add_forecasts, add_reserves, raw_data, sys_kwar
peak_load = maximum(da_load_time_series_val)
if add_forecasts
for (ix, l) in enumerate(PSY.get_components(PowerLoad, sys))
set_max_active_power!(l, bus_dist_fact[PSY.get_name(l)] * peak_load / 100)
set_max_active_power!(
l,
bus_dist_fact[PSY.get_name(l)] * peak_load / 100 * IS.SU,
)
add_time_series!(
sys,
l,
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/power_models_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ function make_vscline(name::String, d::Dict, bus_f::ACBus, bus_t::ACBus)
ac_voltage_control_from = d["ac_voltage_control_from"],
dc_setpoint_from = d["dc_setpoint_from"],
ac_setpoint_from = d["ac_setpoint_from"],
converter_loss_from = LinearCurve(d["converter_loss_from"]...),
converter_loss_from = d["converter_loss_from"],
max_dc_current_from = d["max_dc_current_from"],
rating_from = d["rating_from"],
reactive_power_limits_from = (min = d["qminf"], max = d["qmaxf"]),
Expand All @@ -1885,7 +1885,7 @@ function make_vscline(name::String, d::Dict, bus_f::ACBus, bus_t::ACBus)
ac_voltage_control_to = d["ac_voltage_control_to"],
dc_setpoint_to = d["dc_setpoint_to"],
ac_setpoint_to = d["ac_setpoint_to"],
converter_loss_to = LinearCurve(d["converter_loss_to"]...),
converter_loss_to = d["converter_loss_to"],
max_dc_current_to = d["max_dc_current_to"],
rating_to = d["rating_to"],
reactive_power_limits_to = (min = d["qmint"], max = d["qmaxt"]),
Expand Down
22 changes: 11 additions & 11 deletions src/parsers/power_system_table_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,10 @@ function make_generator(
@error "Skipping unsupported generator" gen.name gen_type
end

if abs(get_base_power(generator)) <= 1e-6
if abs(get_base_power(generator, IS.DU)) <= 1e-6
@warn "Generator $(summary(generator)) has base power of zero: changing device " *
"base power to match system base power, $(data.base_power)"
set_base_power!(generator, data.base_power)
set_base_power!(generator, data.base_power * IS.DU)
end

return generator, reservoirs
Expand Down Expand Up @@ -766,7 +766,7 @@ function make_cost(
op_cost = ThermalGenerationCost(
CostCurve(;
value_curve = var_cost,
power_units = UnitSystem.NATURAL_UNITS,
power_units = IS.NU,
vom_cost = vom_data,
),
gen.fixed_cost,
Expand Down Expand Up @@ -818,7 +818,7 @@ function make_cost(
vom_data = LinearCurve(vom_cost)
var_cost = CostCurve(;
value_curve = LinearCurve(0.0),
power_units = UnitSystem.NATURAL_UNITS,
power_units = IS.NU,
vom_cost = vom_data,
)
op_cost = RenewableGenerationCost(var_cost)
Expand All @@ -838,7 +838,7 @@ function make_cost(
vom_data = LinearCurve(vom_cost)
var_cost = CostCurve(;
value_curve = cost_pairs,
power_units = UnitSystem.NATURAL_UNITS,
power_units = IS.NU,
vom_cost = vom_data,
)
op_cost = RenewableGenerationCost(var_cost)
Expand Down Expand Up @@ -1160,20 +1160,20 @@ function make_thermal_generator_multistart(
available = get_available(thermal_gen),
status = get_status(thermal_gen),
bus = get_bus(thermal_gen),
active_power = get_active_power(thermal_gen),
reactive_power = get_reactive_power(thermal_gen),
rating = get_rating(thermal_gen),
active_power = get_active_power(thermal_gen, IS.DU),
reactive_power = get_reactive_power(thermal_gen, IS.DU),
rating = get_rating(thermal_gen, IS.DU),
prime_mover_type = get_prime_mover_type(thermal_gen),
fuel = get_fuel(thermal_gen),
active_power_limits = get_active_power_limits(thermal_gen),
reactive_power_limits = get_reactive_power_limits(thermal_gen),
active_power_limits = get_active_power_limits(thermal_gen, IS.DU),
reactive_power_limits = get_reactive_power_limits(thermal_gen, IS.DU),
ramp_limits = get_ramp_limits(thermal_gen),
power_trajectory = power_trajectory,
time_limits = get_time_limits(thermal_gen),
start_time_limits = startup_timelimits,
start_types = start_types,
operation_cost = op_cost,
base_power = get_base_power(thermal_gen),
base_power = get_base_power(thermal_gen, IS.DU),
time_at_status = get_time_at_status(thermal_gen),
must_run = get_must_run(thermal_gen),
)
Expand Down
Loading
Loading