Skip to content

Commit

Permalink
Max transmission targets (#1069)
Browse files Browse the repository at this point in the history
  • Loading branch information
anamileva authored Feb 14, 2024
1 parent fa19a6e commit 4152f4b
Show file tree
Hide file tree
Showing 16 changed files with 490 additions and 293 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
transmission_target_zone,subproblem_id,stage_id,balancing_type,horizon,transmission_target_positive_direction_mwh,transmission_target_negative_direction_mwh
TxTargetZone1,1,1,period,2020,,2
TxTargetZone1,1,1,period,2030,,2
TxTargetZone2,1,1,period,2020,2,
TxTargetZone2,1,1,period,2030,2,
,,,
,,,
transmission_target_zone,subproblem_id,stage_id,balancing_type,horizon,transmission_target_pos_dir_min_mwh,transmission_target_pos_dir_max_mwh,transmission_target_neg_dir_min_mwh,transmission_target_neg_dir_max_mwh
TxTargetZone1,1,1,period,2020,,,2,
TxTargetZone1,1,1,period,2030,,,2,
TxTargetZone2,1,1,period,2020,2,,,
TxTargetZone2,1,1,period,2030,2,,,
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
transmission_target_zone,subproblem_id,stage_id,balancing_type,horizon,transmission_target_pos_dir_min_mwh,transmission_target_pos_dir_max_mwh,transmission_target_neg_dir_min_mwh,transmission_target_neg_dir_max_mwh
TxTargetZone1,1,1,period,2020,,,,0.01
TxTargetZone1,1,1,period,2030,,,,0.01
TxTargetZone2,1,1,period,2020,,,,4
TxTargetZone2,1,1,period,2030,,,,4
252 changes: 126 additions & 126 deletions db/csvs_test_examples/scenarios.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
balancing_type_horizon,horizon,boundary
day,202001,circular
period,2020,circular
balancing_type_horizon,horizon,boundary
day,202001,circular
period,2020,circular
140 changes: 74 additions & 66 deletions db/db_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3440,14 +3440,16 @@ CREATE TABLE subscenarios_system_transmission_targets
DROP TABLE IF EXISTS inputs_system_transmission_targets;
CREATE TABLE inputs_system_transmission_targets
(
transmission_target_scenario_id INTEGER,
transmission_target_zone VARCHAR(32),
subproblem_id INTEGER,
stage_id INTEGER,
balancing_type VARCHAR(32),
horizon INTEGER,
transmission_target_positive_direction_mwh FLOAT,
transmission_target_negative_direction_mwh FLOAT,
transmission_target_scenario_id INTEGER,
transmission_target_zone VARCHAR(32),
subproblem_id INTEGER,
stage_id INTEGER,
balancing_type VARCHAR(32),
horizon INTEGER,
transmission_target_pos_dir_min_mwh FLOAT,
transmission_target_pos_dir_max_mwh FLOAT,
transmission_target_neg_dir_min_mwh FLOAT,
transmission_target_neg_dir_max_mwh FLOAT,
PRIMARY KEY (transmission_target_scenario_id, transmission_target_zone,
subproblem_id, stage_id, balancing_type, horizon)
);
Expand Down Expand Up @@ -5031,21 +5033,27 @@ CREATE TABLE results_system_horizon_energy_target
DROP TABLE IF EXISTS results_system_transmission_targets;
CREATE TABLE results_system_transmission_targets
(
scenario_id INTEGER,
transmission_target_zone VARCHAR(64),
subproblem_id INTEGER,
stage_id INTEGER,
balancing_type VARCHAR(32),
horizon INTEGER,
hrz_objective_coefficient FLOAT,
transmission_target_pos_dir_mwh FLOAT,
total_transmission_target_energy_positive_direction_mwh FLOAT,
fraction_of_transmission_target_positive_direction_met FLOAT,
transmission_target_shortage_positive_direction_mwh FLOAT,
transmission_target_neg_dir_mwh FLOAT,
total_transmission_target_energy_negative_direction_mwh FLOAT,
fraction_of_transmission_target_negative_direction_met FLOAT,
transmission_target_shortage_negative_direction_mwh FLOAT,
scenario_id INTEGER,
transmission_target_zone VARCHAR(64),
subproblem_id INTEGER,
stage_id INTEGER,
balancing_type VARCHAR(32),
horizon INTEGER,
hrz_objective_coefficient FLOAT,
total_transmission_target_energy_pos_dir_mwh FLOAT,
transmission_target_pos_dir_min_mwh FLOAT,
fraction_of_transmission_target_pos_dir_min_met FLOAT,
transmission_target_shortage_pos_dir_min_mwh FLOAT,
transmission_target_pos_dir_max_mwh FLOAT,
fraction_of_transmission_target_pos_dir_max_met FLOAT,
transmission_target_overage_pos_dir_max_mwh FLOAT,
total_transmission_target_energy_neg_dir_mwh FLOAT,
transmission_target_neg_dir_min_mwh FLOAT,
fraction_of_transmission_target_neg_dir_min_met FLOAT,
transmission_target_shortage_neg_dir_min_mwh FLOAT,
transmission_target_neg_dir_max_mwh FLOAT,
fraction_of_transmission_target_neg_dir_max_met FLOAT,
transmission_target_overage_neg_dir_min_mwh FLOAT,
PRIMARY KEY (scenario_id, transmission_target_zone,
subproblem_id, stage_id, balancing_type, horizon)
);
Expand Down Expand Up @@ -5160,50 +5168,50 @@ CREATE TABLE results_system_local_capacity
DROP TABLE IF EXISTS results_system_costs;
CREATE TABLE results_system_costs
(
scenario_id INTEGER,
scenario_id INTEGER,
--period INTEGER,
subproblem_id INTEGER,
stage_id INTEGER,
Total_Capacity_Costs Float,
Total_Fixed_Costs FLOAT,
Total_Tx_Capacity_Costs Float,
Total_Tx_Fixed_Costs FLOAT,
Total_PRM_Deliverability_Group_Costs FLOAT,
Total_Variable_OM_Cost Float,
Total_Fuel_Cost Float,
Total_Startup_Cost Float,
Total_Shutdown_Cost Float,
Total_Operational_Violation_Cost FLOAT,
Total_Curtailment_Cost FLOAT,
Total_Hurdle_Cost Float,
Total_Load_Balance_Penalty_Costs Float,
Frequency_Response_Penalty_Costs Float,
Frequency_Response_Partial_Penalty_Costs FLOAT,
LF_Reserves_Down_Penalty_Costs Float,
LF_Reserves_Up_Penalty_Costs Float,
Regulation_Down_Penalty_Costs Float,
Regulation_Up_Penalty_Costs Float,
Spinning_Reserves_Penalty_Costs Float,
Total_PRM_Shortage_Penalty_Costs Float,
Total_Local_Capacity_Shortage_Penalty_Costs Float,
Total_Carbon_Cap_Balance_Penalty_Costs Float,
Total_Carbon_Tax_Cost FLOAT,
Total_Performance_Standard_Balance_Penalty_Costs Float,
Total_Period_Energy_Target_Balance_Penalty_Costs FLOAT,
Total_Horizon_Energy_Target_Balance_Penalty_Costs FLOAT,
Total_Transmission_Target_Balance_Penalty_Costs FLOAT,
Total_Dynamic_ELCC_Tuning_Cost Float,
Total_Import_Carbon_Tuning_Cost Float,
Total_Market_Net_Cost FLOAT,
Total_Export_Penalty_Cost FLOAT,
Total_Horizon_Fuel_Burn_Min_Abs_Penalty_Costs FLOAT,
Total_Horizon_Fuel_Burn_Max_Abs_Penalty_Costs FLOAT,
Total_Horizon_Fuel_Burn_Max_Rel_Penalty_Costs FLOAT,
Total_SOC_Penalty_Cost FLOAT,
Total_SOC_Penalty_Last_Tmp_Cost FLOAT,
Total_Subsidies FLOAT,
Total_Capacity_Transfer_Costs FLOAT,
Total_Carbon_Credit_Revenue FLOAT,
subproblem_id INTEGER,
stage_id INTEGER,
Total_Capacity_Costs Float,
Total_Fixed_Costs FLOAT,
Total_Tx_Capacity_Costs Float,
Total_Tx_Fixed_Costs FLOAT,
Total_PRM_Deliverability_Group_Costs FLOAT,
Total_Variable_OM_Cost Float,
Total_Fuel_Cost Float,
Total_Startup_Cost Float,
Total_Shutdown_Cost Float,
Total_Operational_Violation_Cost FLOAT,
Total_Curtailment_Cost FLOAT,
Total_Hurdle_Cost Float,
Total_Load_Balance_Penalty_Costs Float,
Frequency_Response_Penalty_Costs Float,
Frequency_Response_Partial_Penalty_Costs FLOAT,
LF_Reserves_Down_Penalty_Costs Float,
LF_Reserves_Up_Penalty_Costs Float,
Regulation_Down_Penalty_Costs Float,
Regulation_Up_Penalty_Costs Float,
Spinning_Reserves_Penalty_Costs Float,
Total_PRM_Shortage_Penalty_Costs Float,
Total_Local_Capacity_Shortage_Penalty_Costs Float,
Total_Carbon_Cap_Balance_Penalty_Costs Float,
Total_Carbon_Tax_Cost FLOAT,
Total_Performance_Standard_Balance_Penalty_Costs Float,
Total_Period_Energy_Target_Balance_Penalty_Costs FLOAT,
Total_Horizon_Energy_Target_Balance_Penalty_Costs FLOAT,
Total_Transmission_Target_Balance_Penalty_Costs FLOAT,
Total_Dynamic_ELCC_Tuning_Cost Float,
Total_Import_Carbon_Tuning_Cost Float,
Total_Market_Net_Cost FLOAT,
Total_Export_Penalty_Cost FLOAT,
Total_Horizon_Fuel_Burn_Min_Abs_Penalty_Costs FLOAT,
Total_Horizon_Fuel_Burn_Max_Abs_Penalty_Costs FLOAT,
Total_Horizon_Fuel_Burn_Max_Rel_Penalty_Costs FLOAT,
Total_SOC_Penalty_Cost FLOAT,
Total_SOC_Penalty_Last_Tmp_Cost FLOAT,
Total_Subsidies FLOAT,
Total_Capacity_Transfer_Costs FLOAT,
Total_Carbon_Credit_Revenue FLOAT,
PRIMARY KEY (scenario_id, subproblem_id, stage_id)
);

Expand Down
6 changes: 3 additions & 3 deletions examples/test_tx_targets/inputs/transmission_targets.tab
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
transmission_target_zone balancing_type horizon transmission_target_positive_direction_mwh transmission_target_negative_direction_mwh
TxTargetZone1 period 2020 . 2.0
TxTargetZone2 period 2020 2.0 .
transmission_target_zone balancing_type horizon transmission_target_pos_dir_min_mwh transmission_target_pos_dir_max_mwh transmission_target_neg_dir_min_mwh transmission_target_neg_dir_max_mwh
TxTargetZone1 period 2020 . . 2.0 .
TxTargetZone2 period 2020 2.0 . . .
7 changes: 5 additions & 2 deletions gridpath/geography/transmission_target_zones.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2022 (c) Crown Copyright, GC.
# Modifications Copyright Blue Marble Analytics LLC 2023.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,8 +14,8 @@
# limitations under the License.

"""
Zones where transmission target will be enforced; these can be different from the load zones
and reserve balancing areas.
Zones where transmission target will be enforced; these can be different from
the load zones and reserve balancing areas.
"""

import csv
Expand All @@ -32,6 +33,8 @@ def add_model_components(m, d, scenario_directory, subproblem, stage):

m.TRANSMISSION_TARGET_ZONES = Set()

# Note that these parameters control all target constraints (min, max,
# direction)
m.transmission_target_allow_violation = Param(
m.TRANSMISSION_TARGET_ZONES, within=Boolean, default=0
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2022 (c) Crown Copyright, GC.
# Modifications Copyright Blue Marble Analytics LLC 2023.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,8 +34,10 @@ def add_model_components(m, d, scenario_directory, subproblem, stage):
def total_penalty_costs_rule(mod):
return sum(
(
mod.Transmission_Target_Shortage_Pos_Dir_MWh_Expression[z, bt, hz]
+ mod.Transmission_Target_Shortage_Neg_Dir_MWh_Expression[z, bt, hz]
mod.Transmission_Target_Shortage_Pos_Dir_Min_MWh_Expression[z, bt, hz]
+ mod.Transmission_Target_Overage_Pos_Dir_Max_MWh_Expression[z, bt, hz]
+ mod.Transmission_Target_Shortage_Neg_Dir_Min_MWh_Expression[z, bt, hz]
+ mod.Transmission_Target_Overage_Neg_Dir_Max_MWh_Expression[z, bt, hz]
)
* mod.transmission_target_violation_penalty_per_mwh[z]
* mod.hrz_objective_coefficient[bt, hz]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2022 (c) Crown Copyright, GC.
# Modifications Copyright Blue Marble Analytics LLC 2023.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -95,10 +96,9 @@ def export_results(scenario_directory, subproblem, stage, m, d):
:param d:
:return:
"""

results_columns = [
"total_transmission_target_energy_positive_direction_mwh",
"total_transmission_target_energy_negative_direction_mwh",
"total_transmission_target_energy_pos_dir_mwh",
"total_transmission_target_energy_neg_dir_mwh",
]
data = [
[
Expand Down
57 changes: 40 additions & 17 deletions gridpath/system/policy/transmission_targets/transmission_target.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2022 (c) Crown Copyright, GC.
# Modifications Copyright Blue Marble Analytics LLC 2023.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,7 +14,7 @@
# limitations under the License.

"""
Simplest implementation with a MWh target
Min and max transmission targets by balancing type, horizon, and direction.
"""

import csv
Expand All @@ -40,22 +41,34 @@ def add_model_components(m, d, scenario_directory, subproblem, stage):
dimen=3, within=m.TRANSMISSION_TARGET_ZONES * m.BLN_TYPE_HRZS
)

# Transmission target specified in energy terms for the positive direction of the
# tx line
m.transmission_target_pos_dir_mwh = Param(
# Transmission targets specified in energy terms for the positive
# direction of the tx line
m.transmission_target_pos_dir_min_mwh = Param(
m.TRANSMISSION_TARGET_ZONE_BLN_TYPE_HRZS_WITH_TRANSMISSION_TARGET,
within=NonNegativeReals,
default=0,
)

# Transmission target specified in energy terms for the negative direction of the
# tx line
m.transmission_target_neg_dir_mwh = Param(
m.transmission_target_pos_dir_max_mwh = Param(
m.TRANSMISSION_TARGET_ZONE_BLN_TYPE_HRZS_WITH_TRANSMISSION_TARGET,
within=NonNegativeReals,
default=float("inf"),
)

# Transmission targets specified in energy terms for the negative
# direction of the tx line
m.transmission_target_neg_dir_min_mwh = Param(
m.TRANSMISSION_TARGET_ZONE_BLN_TYPE_HRZS_WITH_TRANSMISSION_TARGET,
within=NonNegativeReals,
default=0,
)

m.transmission_target_neg_dir_max_mwh = Param(
m.TRANSMISSION_TARGET_ZONE_BLN_TYPE_HRZS_WITH_TRANSMISSION_TARGET,
within=NonNegativeReals,
default=float("inf"),
)


def load_model_data(m, d, data_portal, scenario_directory, subproblem, stage):
"""
Expand All @@ -79,8 +92,10 @@ def load_model_data(m, d, data_portal, scenario_directory, subproblem, stage):
),
index=m.TRANSMISSION_TARGET_ZONE_BLN_TYPE_HRZS_WITH_TRANSMISSION_TARGET,
param=(
m.transmission_target_pos_dir_mwh,
m.transmission_target_neg_dir_mwh,
m.transmission_target_pos_dir_min_mwh,
m.transmission_target_pos_dir_max_mwh,
m.transmission_target_neg_dir_min_mwh,
m.transmission_target_neg_dir_max_mwh,
),
)

Expand All @@ -102,8 +117,10 @@ def get_inputs_from_database(scenario_id, subscenarios, subproblem, stage, conn)
transmission_targets = c.execute(
f"""SELECT transmission_target_zone, balancing_type,
inputs_system_transmission_targets.horizon,
transmission_target_positive_direction_mwh,
transmission_target_negative_direction_mwh
transmission_target_pos_dir_min_mwh,
transmission_target_pos_dir_max_mwh,
transmission_target_neg_dir_min_mwh,
transmission_target_neg_dir_max_mwh
FROM inputs_system_transmission_targets
JOIN
(SELECT balancing_type_horizon, horizon
Expand Down Expand Up @@ -179,8 +196,10 @@ def write_model_inputs(
"transmission_target_zone",
"balancing_type",
"horizon",
"transmission_target_positive_direction_mwh",
"transmission_target_negative_direction_mwh",
"transmission_target_pos_dir_min_mwh",
"transmission_target_pos_dir_max_mwh",
"transmission_target_neg_dir_min_mwh",
"transmission_target_neg_dir_max_mwh",
]
)

Expand All @@ -201,16 +220,20 @@ def export_results(scenario_directory, subproblem, stage, m, d):
:return:
"""
results_columns = [
"transmission_target_pos_dir_mwh",
"transmission_target_neg_dir_mwh",
"transmission_target_pos_dir_min_mwh",
"transmission_target_pos_dir_max_mwh",
"transmission_target_neg_dir_min_mwh",
"transmission_target_neg_dir_max_mwh",
]
data = [
[
z,
bt,
hz,
m.transmission_target_pos_dir_mwh[z, bt, hz],
m.transmission_target_neg_dir_mwh[z, bt, hz],
m.transmission_target_pos_dir_min_mwh[z, bt, hz],
m.transmission_target_pos_dir_max_mwh[z, bt, hz],
m.transmission_target_neg_dir_min_mwh[z, bt, hz],
m.transmission_target_neg_dir_max_mwh[z, bt, hz],
]
for (
z,
Expand Down
Loading

0 comments on commit 4152f4b

Please sign in to comment.