Skip to content

Commit

Permalink
Reformulate gen_var optype (#1144)
Browse files Browse the repository at this point in the history
This is in prep for allowing negative power. There are small changes 
to a few objective functions, but the summary results show only minor 
differences in actual results.
  • Loading branch information
anamileva authored Aug 23, 2024
1 parent 94291b2 commit f2898b0
Show file tree
Hide file tree
Showing 15 changed files with 8,496 additions and 8,492 deletions.
16,872 changes: 8,436 additions & 8,436 deletions db/csvs_test_examples/project/project_availability/weather/Gas-1-ra_toolkit.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
-26966855745108.06
-26966855745105.86
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ Zone1 2020 Coal 0.00 0.00
### HORIZON ENERGY TARGET RESULTS ###
delivered_energy_target_energy_mwh curtailed_energy_target_energy_mwh energy_target_mwh dual energy_target_marginal_cost_per_mwh percent_curtailed
energy_target_zone balancing_type horizon
RPSZone1 year 2020 250,000.00 17,991.12 250,000.00 999,999,990.00 99,999,999.00 6.71
RPSZone1 year 2020 250,000.00 17,991.11 250,000.00 999,999,990.00 99,999,999.00 6.71
2030 250,000.00 175,152.00 250,000.00 999,999,990.00 99,999,999.00 41.20
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-101086984772721.28
-101086984772719.08
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ energy_target_zone balancing_type horizon
RPSZone1 halfyear 20201 172,280.00 52,720.00 125,000.00 -0.00 -0.00 23.43
20202 125,000.00 0.00 125,000.00 1,000,004,600.00 100,000,460.00 0.00
20301 125,000.00 101,008.00 125,000.00 999,999,990.00 99,999,999.00 44.69
20302 125,560.00 -0.00 125,000.00 -0.00 -0.00 -0.00
20302 125,560.00 0.00 125,000.00 -0.00 -0.00 0.00
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-26966855745108.06
-26966855745105.86
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ Zone1 2020 Coal 0.00 0.00
### PERIOD ENERGY TARGET RESULTS ###
delivered_energy_target_energy_mwh curtailed_energy_target_energy_mwh energy_target_mwh percent_curtailed dual energy_target_marginal_cost_per_mwh
energy_target_zone period
RPSZone1 2020 250,000.00 17,991.12 250,000.00 6.71 999,999,990.00 99,999,999.00
RPSZone1 2020 250,000.00 17,991.11 250,000.00 6.71 999,999,990.00 99,999,999.00
2030 250,000.00 175,152.00 250,000.00 41.20 999,999,990.00 99,999,999.00
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-26966855745108.06
-26966855745105.86
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ Zone1 2020 Coal 0.00 0.00
### PERIOD ENERGY TARGET RESULTS ###
delivered_energy_target_energy_mwh curtailed_energy_target_energy_mwh energy_target_mwh percent_curtailed dual energy_target_marginal_cost_per_mwh
energy_target_zone period
RPSZone1 2020 250,000.00 17,991.12 250,000.00 6.71 999,999,990.00 99,999,999.00
RPSZone1 2020 250,000.00 17,991.11 250,000.00 6.71 999,999,990.00 99,999,999.00
2030 250,000.00 175,152.00 250,000.00 41.20 999,999,990.00 99,999,999.00
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-26966830249904.63
-26966830249911.2
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ Zone1 2020 Coal 0.00 0.00
### PERIOD ENERGY TARGET RESULTS ###
delivered_energy_target_energy_mwh curtailed_energy_target_energy_mwh energy_target_mwh percent_curtailed dual energy_target_marginal_cost_per_mwh
energy_target_zone period
RPSZone1 2020 250,000.00 -0.00 250,000.00 -0.00 1,000,001,400.00 100,000,140.00
RPSZone1 2020 250,000.00 0.00 250,000.00 0.00 1,000,001,400.00 100,000,140.00
2030 250,000.00 175,152.00 250,000.00 41.20 999,999,990.00 99,999,999.00
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-16980455713578.63
-16980455713585.2
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ Zone1 2020 Coal 0.00 0.00
### PERIOD ENERGY TARGET RESULTS ###
delivered_energy_target_energy_mwh curtailed_energy_target_energy_mwh energy_target_mwh percent_curtailed dual energy_target_marginal_cost_per_mwh
energy_target_zone period
RPSZone1 2020 250,000.00 17,991.12 250,000.00 6.71 999,999,990.00 99,999,999.00
RPSZone1 2020 250,000.00 17,991.11 250,000.00 6.71 999,999,990.00 99,999,999.00
2030 250,000.00 175,152.00 250,000.00 41.20 999,999,990.00 99,999,999.00
80 changes: 42 additions & 38 deletions gridpath/project/operations/operational_types/gen_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@
"""


import csv
import os.path
from pyomo.environ import (
Param,
Set,
Var,
Constraint,
Reals,
NonNegativeReals,
Expression,
value,
Reals,
)
import warnings

Expand Down Expand Up @@ -120,6 +118,14 @@ def add_model_components(
| Power provision in MW from this project in each timepoint in which the |
| project is operational (capacity exists and the project is available). |
+-------------------------------------------------------------------------+
| | :code:`GenVar_Scheduled_Curtailment_MW` |
| | *Defined over*: :code:`GEN_VAR_OPR_TMPS` |
| | *Within*: :code:`NonNegativeReals` |
| |
| Curtailed power in MW from this project in each timepoint in which the |
| project is operational (capacity exists and the project is available). |
| This will be the available power minus what was actually provided. |
+-------------------------------------------------------------------------+
|
Expand All @@ -136,11 +142,6 @@ def add_model_components(
| |
| Sub-hourly energy delivered (in MW) from providing upward reserves. |
+-------------------------------------------------------------------------+
| | :code:`GenVar_Scheduled_Curtailment_MW` |
| | *Defined over*: :code:`GEN_VAR_OPR_TMPS` |
| |
| The available power minus what was actually provided (in MW). |
+-------------------------------------------------------------------------+
| | :code:`GenVar_Total_Curtailment_MW` |
| | *Defined over*: :code:`GEN_VAR_OPR_TMPS` |
| |
Expand All @@ -160,13 +161,19 @@ def add_model_components(
| | :code:`GenVar_Max_Power_Constraint` |
| | *Defined over*: :code:`GEN_VAR_OPR_TMPS` |
| |
| Limits the power plus upward reserves in each timepoint based on the |
| Limits the power plus scheduled curtailment in each timepoint to equal |
| the available power. |
| :code:`gen_var_cap_factor` and the available capacity. |
+-------------------------------------------------------------------------+
| | :code:`GenVar_Min_Power_Constraint` |
| | :code:`GenVar_Max_Upward_Reserves_Constraint` |
| | *Defined over*: :code:`GEN_VAR_OPR_TMPS` |
| |
| Upward reserves cannot exceed curtailment. |
+-------------------------------------------------------------------------+
| | :code:`GenVar_Max_Downward_Reserves_Constraint` |
| | *Defined over*: :code:`GEN_VAR_OPR_TMPS` |
| |
| Power provision minus downward reserves should exceed zero. |
| Downward reserves cannot exceed power provision. |
+-------------------------------------------------------------------------+
"""
Expand Down Expand Up @@ -197,6 +204,7 @@ def add_model_components(
###########################################################################

m.GenVar_Provide_Power_MW = Var(m.GEN_VAR_OPR_TMPS, within=NonNegativeReals)
m.GenVar_Scheduled_Curtailment_MW = Var(m.GEN_VAR_OPR_TMPS, within=NonNegativeReals)

# Expressions
###########################################################################
Expand Down Expand Up @@ -251,10 +259,6 @@ def subhourly_delivered_energy_expression_rule(mod, g, tmp):
m.GEN_VAR_OPR_TMPS, rule=subhourly_delivered_energy_expression_rule
)

m.GenVar_Scheduled_Curtailment_MW = Expression(
m.GEN_VAR_OPR_TMPS, rule=scheduled_curtailment_expression_rule
)

m.GenVar_Total_Curtailment_MW = Expression(
m.GEN_VAR_OPR_TMPS, rule=total_curtailment_expression_rule
)
Expand All @@ -264,29 +268,19 @@ def subhourly_delivered_energy_expression_rule(mod, g, tmp):

m.GenVar_Max_Power_Constraint = Constraint(m.GEN_VAR_OPR_TMPS, rule=max_power_rule)

m.GenVar_Min_Power_Constraint = Constraint(m.GEN_VAR_OPR_TMPS, rule=min_power_rule)
m.GenVar_Max_Upward_Reserves_Constraint = Constraint(
m.GEN_VAR_OPR_TMPS, rule=max_upward_reserves_rule
)

m.GenVar_Max_Downward_Reserves_Constraint = Constraint(
m.GEN_VAR_OPR_TMPS, rule=max_downward_reserves_rule
)


# Expression Methods
###############################################################################


def scheduled_curtailment_expression_rule(mod, g, tmp):
"""
**Expression Name**: GenVar_Scheduled_Curtailment_MW
**Defined Over**: GEN_VAR_OPR_TMPS
Scheduled curtailment is the available power minus what was actually
provided.
"""
return (
mod.Capacity_MW[g, mod.period[tmp]]
* mod.Availability_Derate[g, tmp]
* mod.gen_var_cap_factor[g, tmp]
- mod.GenVar_Provide_Power_MW[g, tmp]
)


def total_curtailment_expression_rule(mod, g, tmp):
"""
**Expression Name**: GenVar_Total_Curtailment_MW
Expand All @@ -308,8 +302,7 @@ def total_curtailment_expression_rule(mod, g, tmp):
"""

return (
mod.Capacity_MW[g, mod.period[tmp]] * mod.gen_var_cap_factor[g, tmp]
- mod.GenVar_Provide_Power_MW[g, tmp]
mod.GenVar_Scheduled_Curtailment_MW[g, tmp]
+ mod.GenVar_Subhourly_Curtailment_MW[g, tmp]
- mod.GenVar_Subhourly_Energy_Delivered_MW[g, tmp]
)
Expand All @@ -328,19 +321,30 @@ def max_power_rule(mod, g, tmp):
is equal to the available capacity multiplied by the capacity factor.
"""
return (
mod.GenVar_Provide_Power_MW[g, tmp] + mod.GenVar_Upwards_Reserves_MW[g, tmp]
<= mod.Capacity_MW[g, mod.period[tmp]]
mod.GenVar_Provide_Power_MW[g, tmp]
+ mod.GenVar_Scheduled_Curtailment_MW[g, tmp]
== mod.Capacity_MW[g, mod.period[tmp]]
* mod.Availability_Derate[g, tmp]
* mod.gen_var_cap_factor[g, tmp]
)


def min_power_rule(mod, g, tmp):
def max_upward_reserves_rule(mod, g, tmp):
"""
Upward reserves can't exceed curtailment
"""
return (
mod.GenVar_Upwards_Reserves_MW[g, tmp]
<= mod.GenVar_Scheduled_Curtailment_MW[g, tmp]
)


def max_downward_reserves_rule(mod, g, tmp):
"""
**Constraint Name**: GenVar_Min_Power_Constraint
**Enforced Over**: GEN_VAR_OPR_TMPS
Power provision minus downward services cannot be less than zero.
Downward reserves can't exceed power provision.
"""
return (
mod.GenVar_Provide_Power_MW[g, tmp] - mod.GenVar_Downwards_Reserves_MW[g, tmp]
Expand Down
12 changes: 6 additions & 6 deletions tests/test_data/test_scenario_objective_function_values.csv
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ test_aux_cons,-3664910801437.807,-3664910801437.807,,
2periods_new_build_cumulative_and_vintage_min_max,-110384972580597.61,-110384972580597.61,,
2periods_new_build_cumulative_min_max,-27166044526940.195,-27166044526940.195,,
2periods_new_build_fin_lifetime,-10022366566.861605,-10022366566.861605,,
2periods_new_build_horizon_energy_target,-26966855745108.062,-26966855745108.062,,
2periods_new_build_horizon_energy_target_halfyear,-101086984772721.28,-101086984772721.28,,
2periods_new_build_horizon_energy_target,-26966855745105.855,-26966855745105.855,,
2periods_new_build_horizon_energy_target_halfyear,-101086984772719.08,-101086984772719.08,,
2periods_new_build_local_capacity,-10087189895.812916,-10087189895.812916,,
2periods_new_build_rps,-26966855745108.062,-26966855745108.062,,
2periods_new_build_rps_percent_target,-26966855745108.062,-26966855745108.062,,
2periods_new_build_rps,-26966855745105.855,-26966855745105.855,,
2periods_new_build_rps_percent_target,-26966855745105.855,-26966855745105.855,,
2periods_new_build_rps_variable_reserves,-4980266823.194146,-4980266823.194146,,
2periods_new_build_rps_variable_reserves_subhourly_adj,-4980266823.194146,-4980266823.194146,,
2periods_new_build_rps_w_rps_eligible_storage,-26966830249904.633,-26966830249904.633,,
2periods_new_build_rps_w_rps_ineligible_storage,-16980455713578.633,-16980455713578.633,,
2periods_new_build_rps_w_rps_eligible_storage,-26966830249911.2,-26966830249911.2,,
2periods_new_build_rps_w_rps_ineligible_storage,-16980455713585.201,-16980455713585.201,,
2periods_new_build_simple_prm,-10153045900.191605,-10153045900.191605,,
2periods_new_build_simple_prm_2loadzones,-613211671721885.6,-613211671721885.6,,
2periods_new_build_simple_prm_2loadzones_newtx_w_transfers,-17323444870.08402,-17323444870.08402,,
Expand Down

0 comments on commit f2898b0

Please sign in to comment.