Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mb/ward compat #1247

Merged
merged 86 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
1c30601
add PFS deps
jd-lara Jan 9, 2024
0bcb68e
make time_steps consistent
jd-lara Jan 9, 2024
cac31f2
add PowerFlows
jd-lara Jan 9, 2024
1b7d415
add new aux variables for power flow
jd-lara Jan 9, 2024
02c52ed
make time steps consistent
jd-lara Jan 9, 2024
1e71c06
fix failing test
jd-lara Jan 9, 2024
a94defb
add power flow evaluator to model and container
jd-lara Jan 9, 2024
d1336c0
add evaluation in initialization
jd-lara Jan 9, 2024
7d1b0d2
add code for evaluation
jd-lara Jan 9, 2024
c4071f4
add missing kwarg
jd-lara Jan 9, 2024
61ee4b5
fix incorrect var type
jd-lara Jan 9, 2024
3b31d02
fix old bug
jd-lara Jan 9, 2024
347b67c
update aux vars for power flow evaluation
jd-lara Jan 9, 2024
5606f65
WIP: function for the power flow evaluation
jd-lara Jan 9, 2024
e8caaca
whitespace
jd-lara Jan 9, 2024
198e7b4
Merge branch 'main' into jd/pf_integration
jd-lara Jan 23, 2024
bf872ca
bump deps
jd-lara Jan 23, 2024
4e0f8ee
change to varnames
jd-lara Jan 23, 2024
7a2555a
add auxiliary variables
jd-lara Jan 23, 2024
d95ef9e
add wrapper for power flow data
jd-lara Jan 24, 2024
d2b26ac
use wrapper
jd-lara Jan 24, 2024
ddb92e3
add powerflow wrapper
jd-lara Jan 24, 2024
33bd977
power flow rename
jd-lara Jan 24, 2024
2645ced
file rename
jd-lara Jan 24, 2024
c997e2f
add evaluation to the container
jd-lara Jan 25, 2024
1ba76cb
WIP: add functions to map results to pf
jd-lara Jan 25, 2024
c11f4cf
Merge branch 'psy4' into jd/pf_integration
jd-lara Mar 6, 2024
4fcfa16
Merge branch 'main' into jd/pf_integration
GabrielKS Aug 19, 2024
b26e2b0
Remove redundant code
GabrielKS Oct 15, 2024
54e4859
Rewrite power flow evaluation to support more types of power flow
GabrielKS Oct 15, 2024
1e714ac
Support evaluation of multiple power flows in the loop
GabrielKS Oct 15, 2024
508db25
Better accommodate `PSSEExporter` in the loop, reduce duplication
GabrielKS Oct 16, 2024
b6fc453
Trait-based special behavior for power flow aux vars
GabrielKS Oct 17, 2024
eb51cfb
Scaffold subtype-based updating of power flow aux vars
GabrielKS Oct 17, 2024
dfd7405
Update power flow aux vars from `PowerFlowData`
GabrielKS Oct 17, 2024
c0ac0be
Complete prototype power flow in the loop -> export implementation
GabrielKS Oct 17, 2024
9e1f30a
Power flow in the loop: handle load special cases
GabrielKS Oct 28, 2024
1507b14
Power flow in the loop: support multi period export
GabrielKS Oct 28, 2024
9ec1356
Misc code cleanup following self-review
GabrielKS Oct 28, 2024
ad25918
Add basic tests of power flow in the loop
GabrielKS Nov 4, 2024
958e68d
Update `DISABLED_TEST_FILES`
GabrielKS Nov 4, 2024
187f473
Merge branch 'main' into jd/pf_integration
GabrielKS Nov 4, 2024
e016521
PERF: don't use `get_bus(sys, number)`, it's O(n)
GabrielKS Nov 19, 2024
30454e6
Add aux vars, infrastructure to receive results from AC power flow
GabrielKS Jan 16, 2025
a242ddf
Fix `bus_activepower_withdrawals` sign error
GabrielKS Jan 17, 2025
5d9a55f
Update Project.toml
jd-lara Jan 20, 2025
f5eb983
Merge branch 'main' into jd/pf_integration
jd-lara Jan 20, 2025
ebe76d3
Merge pull request #1220 from NREL-Sienna/jd/bump_pnm
jd-lara Jan 20, 2025
670d4fc
Fix merge, update dependencies
GabrielKS Jan 21, 2025
3e091c4
Power flow in the loop: support `exporter` kwarg interface
GabrielKS Jan 21, 2025
d5e6fab
Rewrite PSI -> PF mapping for more flexibility
GabrielKS Jan 22, 2025
b0ba0d6
Add `TimerOutputs.@timeit` for PF in the loop
GabrielKS Jan 22, 2025
8f46584
update cost functions for thermal dispatch no min
rodrigomha Jan 23, 2025
e91e305
Merge pull request #1223 from NREL-Sienna/rh/fix_nomin_cost
jd-lara Jan 24, 2025
1ad5389
update TransmissionInterface to fail with FFs
rodrigomha Jan 24, 2025
9d74043
add test for nomincost
rodrigomha Jan 24, 2025
09deaa6
Merge pull request #1225 from NREL-Sienna/rh/ban_interface_ffs
jd-lara Jan 27, 2025
f5b7cea
Merge pull request #1226 from NREL-Sienna/rh/fix_nomin_cost
jd-lara Jan 27, 2025
7050684
Code cleanup, accommodate fine-tuned exporter interface
GabrielKS Jan 31, 2025
6f8a897
Clean up TODOs
GabrielKS Jan 31, 2025
9d4c2c6
Merge branch 'main' into jd/pf_integration
GabrielKS Jan 31, 2025
59bd254
Update Project.toml
jd-lara Jan 31, 2025
1fe3dcb
bump dependencies
jd-lara Feb 5, 2025
20ac722
Merge branch 'main' into jd/pf_integration
jd-lara Feb 5, 2025
0b88d6f
clean up a test
jd-lara Feb 5, 2025
b48e4bb
Merge pull request #1040 from NREL-Sienna/jd/pf_integration
jd-lara Feb 5, 2025
e498b59
use getters more sensibly
jd-lara Feb 5, 2025
6400f60
use macros in reserves
jd-lara Feb 5, 2025
5465d73
use macro for sum
jd-lara Feb 5, 2025
508c287
improvements to add_to_expression
jd-lara Feb 5, 2025
0a71e98
duration improvements
jd-lara Feb 5, 2025
f76c46a
change to 1.10 LTS
jd-lara Feb 5, 2025
c381b59
add parameters
jd-lara Feb 5, 2025
0d7be60
improve add_to_expression!
jd-lara Feb 5, 2025
f360dc3
update expression addition
jd-lara Feb 5, 2025
58eaf01
avoid using the same var name
jd-lara Feb 5, 2025
7275aa1
change location of multiplier
jd-lara Feb 5, 2025
e845d95
improvements to reserve creation
jd-lara Feb 5, 2025
43480da
Formatted code after running formatter script
jd-lara Feb 5, 2025
2c1cb5c
Merge pull request #1234 from NREL-Sienna/jd/jump_perf
jd-lara Feb 5, 2025
c97f4c2
fixed get_decision_problem_docstring
annacasavant Feb 7, 2025
64ecc31
add new method for copperplate
rodrigomha Feb 7, 2025
cd70b38
Merge pull request #1241 from NREL-Sienna/rh/fix_hvdc_copperplate_bug
jd-lara Feb 7, 2025
6fc3590
Merge pull request #1240 from annacasavant/ac_docstrings
jd-lara Feb 7, 2025
7f6ee7d
PTDF with ward reduction runs
m-bossart Feb 15, 2025
61d9ba1
Merge branch 'jd/transmissions_sc_ptdf' into mb/ward-compat
m-bossart Feb 15, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,13 @@ function _add_pwl_term!(
pwl_cost_expressions = Vector{JuMP.AffExpr}(undef, time_steps[end])
break_points = PSY.get_x_coords(data)
sos_val = _get_sos_value(container, V, component)
temp_cost_function =
create_temporary_cost_function_in_system_per_unit(cost_function, data)
for t in time_steps
_add_pwl_variables!(container, T, name, t, data)
_add_pwl_constraint!(container, component, U(), break_points, sos_val, t)
pwl_cost =
_get_pwl_cost_expression(container, component, t, cost_function, U(), V())
_get_pwl_cost_expression(container, component, t, temp_cost_function, U(), V())
pwl_cost_expressions[t] = pwl_cost
end
return pwl_cost_expressions
Expand Down
17 changes: 17 additions & 0 deletions src/feedforward/feedforward_arguments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ function add_feedforward_arguments!(
return
end

function add_feedforward_arguments!(
::OptimizationContainer,
model::ServiceModel,
::PSY.TransmissionInterface,
)
# Currently we do not support feedforwards for TransmissionInterface
ffs = get_feedforwards(model)
if !isempty(ffs)
throw(
ArgumentError(
"TransmissionInterface data types currently do not support feedforwards.",
),
)
end
return
end

function _add_feedforward_arguments!(
container::OptimizationContainer,
model::DeviceModel{T, U},
Expand Down
7 changes: 4 additions & 3 deletions src/services_models/services_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ function construct_service!(
PSY.get_name.(interfaces),
get_time_steps(container),
)
# TODO:broken
# add_feedforward_arguments!(container, model, interface)

add_feedforward_arguments!(container, model, interface)
return
end

Expand Down Expand Up @@ -641,7 +641,8 @@ function construct_service!(
add_parameters!(container, MaxInterfaceFlowLimitParameter, device, model)
end
end
#add_feedforward_arguments!(container, model, service)
interface = PSY.get_component(T, sys, get_service_name(model))
add_feedforward_arguments!(container, model, interface)
return
end

Expand Down
23 changes: 23 additions & 0 deletions src/utils/powersystems_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,29 @@ function is_time_variant(cost_function::PSY.FuelCurve{PSY.PiecewisePointCurve})
return isa(PSY.get_fuel_cost(cost_function), IS.TimeSeriesKey)
end

function create_temporary_cost_function_in_system_per_unit(
original_cost_function::PSY.CostCurve,
new_data::PSY.PiecewiseLinearData,
)
return PSY.CostCurve(
PSY.PiecewisePointCurve(new_data),
PSY.UnitSystem.SYSTEM_BASE,
PSY.get_vom_cost(original_cost_function),
)
end

function create_temporary_cost_function_in_system_per_unit(
original_cost_function::PSY.FuelCurve,
new_data::PSY.PiecewiseLinearData,
)
return PSY.FuelCurve(
PSY.PiecewisePointCurve(new_data),
PSY.UnitSystem.SYSTEM_BASE,
PSY.get_fuel_cost(original_cost_function),
PSY.get_vom_cost(original_cost_function),
)
end

function get_deterministic_time_series_type(sys::PSY.System)
time_series_types = IS.get_time_series_counts_by_type(sys.data)
existing_types = Set(d["type"] for d in time_series_types)
Expand Down
41 changes: 41 additions & 0 deletions test/test_device_thermal_generation_constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1144,3 +1144,44 @@ end
moi_tests(model, 360, 0, 120, 120, 0, false)
psi_checkobjfun_test(model, GQEVF)
end

@testset "ThermalDispatchNoMin with PWL Costs" begin
sys = build_system(PSISystems, "modified_RTS_GMLC_DA_sys")

template = ProblemTemplate(NetworkModel(PTDFPowerModel))
set_device_model!(template, ThermalStandard, ThermalDispatchNoMin)
set_device_model!(template, Line, StaticBranchBounds)
set_device_model!(template, TapTransformer, StaticBranchBounds)
set_device_model!(template, Transformer2W, StaticBranchBounds)
set_device_model!(template, PowerLoad, StaticPowerLoad)

solver = HiGHS_optimizer
problem = DecisionModel(template, sys;
optimizer = solver,
horizon = Hour(1),
optimizer_solve_log_print = true,
calculate_conflict = true,
store_variable_names = true,
detailed_optimizer_stats = false,
)

build!(problem; output_dir = mktempdir())

solve!(problem)

res = OptimizationProblemResults(problem)

# Test that plant 101_STEAM_3 (using max power) have proper cost expression
cost = read_expression(res, "ProductionCostExpression__ThermalStandard")
p_th = read_variable(res, "ActivePowerVariable__ThermalStandard")
steam3 = get_component(ThermalStandard, sys, "101_STEAM_3")
val_curve = PSY.get_value_curve(PSY.get_variable(PSY.get_operation_cost(steam3)))
io_curve = InputOutputCurve(val_curve)
fuel_cost = PSY.get_fuel_cost(steam3)
x_last = last(io_curve.function_data.points).x
y_last = last(io_curve.function_data.points).y * fuel_cost
p_steam3 = p_th[!, "101_STEAM_3"]
cost_steam3 = cost[!, "101_STEAM_3"]
@test isapprox(p_steam3[1], x_last) # max
@test isapprox(cost_steam3[1], y_last) # last cost
end
64 changes: 64 additions & 0 deletions test/test_services_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -522,3 +522,67 @@ end
PSI.ModelBuildStatus.BUILT
moi_tests(model, 312, 0, 288, 288, 168, false)
end

@testset "Test Transmission Interface with Feedforwards" begin
c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc"; add_reserves = true)
interface = TransmissionInterface(;
name = "west_east",
available = true,
active_power_flow_limits = (min = 0.0, max = 400.0),
)
interface_lines = [
get_component(Line, c_sys5_uc, "1"),
get_component(Line, c_sys5_uc, "2"),
get_component(Line, c_sys5_uc, "6"),
]
add_service!(c_sys5_uc, interface, interface_lines)
c_sys5_uc2 = PSB.build_system(PSITestSystems, "c_sys5_uc"; add_reserves = true)
interface2 = TransmissionInterface(;
name = "west_east",
available = true,
active_power_flow_limits = (min = 0.0, max = 400.0),
)
interface_lines2 = [
get_component(Line, c_sys5_uc2, "1"),
get_component(Line, c_sys5_uc2, "2"),
get_component(Line, c_sys5_uc2, "6"),
]
add_service!(c_sys5_uc2, interface2, interface_lines2)

template = get_thermal_dispatch_template_network(DCPPowerModel)
set_service_model!(
template,
ServiceModel(TransmissionInterface, ConstantMaxInterfaceFlow; use_slacks = true),
)
models = SimulationModels(;
decision_models = [
DecisionModel(template, c_sys5_uc; optimizer = HiGHS_optimizer, name = "Sys1"),
DecisionModel(template, c_sys5_uc2; optimizer = HiGHS_optimizer, name = "Sys2"),
],
)

feedforward = Dict(
"Sys2" => [
FixValueFeedforward(;
component_type = TransmissionInterface,
source = PSI.FlowActivePowerVariable,
affected_values = [PSI.FlowActivePowerVariable],
),
],
)

sequence = SimulationSequence(;
models = models,
ini_cond_chronology = InterProblemChronology(),
feedforwards = feedforward,
)

sim = Simulation(;
name = "interface-fail",
steps = 2,
models = models,
sequence = sequence,
simulation_folder = mktempdir(; cleanup = true),
)
@test_throws ArgumentError build!(sim)
end
Loading