Skip to content

Commit

Permalink
Carbon credits loose ends (#1045)
Browse files Browse the repository at this point in the history
* Don't require participating in credits

* lint

* fix test objective function value

* fix wrong suscenario id bug
  • Loading branch information
anamileva authored Oct 26, 2023
1 parent ab66a0e commit 60112b4
Show file tree
Hide file tree
Showing 45 changed files with 475 additions and 159 deletions.
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
@@ -0,0 +1,9 @@
features
transmission
lf_reserves_up
lf_reserves_down
regulation_up
regulation_down
carbon_cap
performance_standard
carbon_credits
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
carbon_cap_zone period carbon_cap_target
Zone1 2020 300.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
carbon_cap_zone allow_violation violation_penalty_per_emission
Zone1 0 0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
carbon_credits_zone
Carbon_Credits_Zone1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fuel period month fuel_price_per_mmbtu
Coal 2020 1 4.0
Coal 2020 2 4.0
Gas 2020 1 5.0
Gas 2020 2 5.0
Negative_Carbon_Fuel 2020 1 6.0
Negative_Carbon_Fuel 2020 2 6.0
Uranium 2020 1 2.0
Uranium 2020 2 2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fuel co2_intensity_tons_per_mmbtu fuel_group
Coal 0.09552 Solid
Gas 0.05306 Gas
Negative_Carbon_Fuel -0.1 Gas
Uranium 0.0 Other
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
project period load_point_fraction average_heat_rate_mmbtu_per_mwh
Coal 0 0.4 1250.0
Coal 0 1.0 506.0
Gas_CCGT 0 0.5 506.0
Gas_CCGT 0 1.0 256.0
Gas_CCGT_z2 0 0.5 506.0
Gas_CCGT_z2 0 1.0 256.0
Gas_CT 0 0.4 208.33333
Gas_CT 0 1.0 88.13333
Nuclear 0 1.0 1666.67
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
horizon balancing_type_horizon timepoint
202001 day 20200101
202001 day 20200102
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
horizon balancing_type_horizon boundary
202001 day circular
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ba timepoint requirement
Zone1 20200101 1.0
Zone1 20200102 2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ba timepoint requirement
Zone1 20200101 1.0
Zone1 20200102 2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
balancing_area allow_violation violation_penalty_per_mw reserve_to_energy_adjustment
Zone1 1 999999999.0 .
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
balancing_area allow_violation violation_penalty_per_mw reserve_to_energy_adjustment
Zone1 1 999999999.0 .
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LOAD_ZONES timepoint load_mw
Zone1 20200101 10.0
Zone1 20200102 20.0
Zone2 20200101 10.0
Zone2 20200102 10.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
load_zone allow_overgeneration overgeneration_penalty_per_mw allow_unserved_energy unserved_energy_penalty_per_mwh unserved_energy_limit_mwh max_unserved_load_penalty_per_mw max_unserved_load_limit_mw export_penalty_cost_per_mwh
Zone1 1 99999999.0 1 99999999.0 . 0.0 . 0.0
Zone2 1 99999999.0 1 99999999.0 . 0.0 . 0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project vintage operational_lifetime_yrs fixed_cost_per_mw_yr financial_lifetime_yrs annualized_real_cost_per_mw_yr
Solar 2020 30.0 0.0 30.0 100.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project period min_new_build_power max_new_build_power min_capacity_power max_capacity_power min_new_build_energy max_new_build_energy min_capacity_energy max_capacity_energy
Solar 2020 . . 0.0 2.0 . . . .
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
performance_standard_zone period performance_standard_tco2_per_mwh
PS_Zone1 2020 0.1
PS_Zone2 2020 0.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
performance_standard_zone allow_violation violation_penalty_per_emission
PS_Zone1 0 0.0
PS_Zone2 0 0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
performance_standard_zone carbon_credits_zone
PS_Zone1 Carbon_Credits_Zone1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
period discount_factor period_start_year period_end_year hours_in_period_timepoints
2020 1.0 2020.0 2021.0 8760.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project carbon_cap_zone
Gas_CCGT Zone1
Gas_CT Zone1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project period intensity_threshold_emissions_toCO2_per_MWh absolute_threshold_emissions_toCO2
Coal 2020 . 2000000.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project fuel min_fraction_in_fuel_blend max_fraction_in_fuel_blend
Coal Coal . .
Gas_CCGT Gas 0.0 1.0
Gas_CCGT Negative_Carbon_Fuel 0.0 1.0
Gas_CCGT_z2 Gas . .
Gas_CT Gas . .
Nuclear Uranium . .
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
project capacity_type availability_type operational_type balancing_type_project technology load_zone variable_om_cost_per_mwh min_stable_level_fraction unit_size_mw startup_cost_per_mw shutdown_cost_per_mw startup_fuel_mmbtu_per_mw startup_plus_ramp_up_rate shutdown_plus_ramp_down_rate ramp_up_when_on_rate ramp_down_when_on_rate ramp_up_violation_penalty ramp_down_violation_penalty min_up_time_hours min_up_time_violation_penalty min_down_time_hours min_down_time_violation_penalty allow_startup_shutdown_power storage_efficiency charging_efficiency discharging_efficiency charging_capacity_multiplier discharging_capacity_multiplier minimum_duration_hours maximum_duration_hours aux_consumption_frac_capacity aux_consumption_frac_power last_commitment_stage curtailment_cost_per_pwh powerunithour_per_fuelunit soc_penalty_cost_per_energyunit soc_last_tmp_penalty_cost_per_energyunit partial_availability_threshold nonfuel_carbon_emissions_per_mwh lf_reserves_up_ba lf_reserves_up_derate lf_reserves_down_ba lf_reserves_down_derate regulation_up_ba regulation_up_derate regulation_down_ba regulation_down_derate lf_reserves_up_ramp_rate lf_reserves_down_ramp_rate regulation_up_ramp_rate regulation_down_ramp_rate performance_standard_zone carbon_credits_zone
Coal gen_spec exogenous gen_commit_cap day Coal Zone1 1.0 0.4 6.0 1.0 0.0 . . . . . . . . . . . . . . . . . . . . . 2 . . . . . . . . . . Zone1 . Zone1 . . . . . . Carbon_Credits_Zone1
Gas_CCGT gen_spec exogenous gen_commit_cap day Gas Zone1 2.0 0.4 6.0 1.0 2.0 . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . Zone1 . Zone1 . Zone1 . Zone1 . . . . . PS_Zone1 .
Gas_CCGT_z2 gen_spec exogenous gen_commit_cap day Gas Zone2 2.0 0.4 6.0 1.0 2.0 . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . .
Gas_CT gen_spec exogenous gen_commit_cap day Gas Zone1 2.0 0.4 6.0 0.0 1.0 . . . . . . . . . . . . . . . . . . . . . 3 . . . . . . . . . . . . . . . . . . PS_Zone2 .
Nuclear gen_spec exogenous gen_must_run day Nuclear Zone1 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Solar gen_new_lin exogenous gen_var day Solar Zone1 0.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Wind gen_spec exogenous gen_var day Wind Zone1 0.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
balancing_area allow_violation violation_penalty_per_mw reserve_to_energy_adjustment
Zone1 1 999999999.0 .
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ba timepoint requirement
Zone1 20200101 1.0
Zone1 20200102 2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
balancing_area allow_violation violation_penalty_per_mw reserve_to_energy_adjustment
Zone1 1 999999999.0 .
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ba timepoint requirement
Zone1 20200101 1.0
Zone1 20200102 2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project period specified_capacity_mw hyb_gen_specified_capacity_mw hyb_stor_specified_capacity_mw specified_capacity_mwh fuel_production_capacity_fuelunitperhour fuel_release_capacity_fuelunitperhour fuel_storage_capacity_fuelunit fixed_cost_per_mw_yr hyb_gen_fixed_cost_per_mw_yr hyb_stor_fixed_cost_per_mw_yr fixed_cost_per_mwh_yr fuel_production_capacity_fixed_cost_per_fuelunitperhour_yr fuel_release_capacity_fixed_cost_per_fuelunitperhour_yr fuel_storage_capacity_fixed_cost_per_fuelunit_yr
Coal 2020 6.0 0.0
Gas_CCGT 2020 6.0 0.0
Gas_CCGT_z2 2020 12.0 0.0
Gas_CT 2020 6.0 0.0
Nuclear 2020 6.0 0.0
Wind 2020 2.0 0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
transmission_line period specified_tx_min_mw specified_tx_max_mw fixed_cost_per_mw_yr
Tx1 2020 -10.0 10.0 .
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
timepoint period timepoint_weight number_of_hours_in_timepoint previous_stage_timepoint_map month
20200101 2020 4380.0 1 . 1
20200102 2020 4380.0 1 . 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
transmission_line tx_capacity_type tx_availability_type tx_operational_type load_zone_from load_zone_to tx_simple_loss_factor reactance_ohms
Tx1 tx_spec exogenous tx_simple Zone1 Zone2 . .
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project timepoint cap_factor
Solar 20200101 0.05
Solar 20200102 1.0
Wind 20200101 0.9
Wind 20200102 0.5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-3592014778836.29
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
##### SUMMARY RESULTS FOR SCENARIO *test_performance_standard_carbon_credits_w_cap_no_credits_mapping* #####

### CAPACITY RESULTS ###

--> New Generation Capacity <--
New Capacity (MW)
load_zone technology period
Zone1 Solar 2020 2.00

### OPERATIONAL RESULTS ###

--> Energy Production <--
Annual Energy (MWh) % Total Power
load_zone period technology
Zone1 2020 Coal 18,688.00 14.05
Gas 40,296.00 30.30
Nuclear 52,560.00 39.52
Solar 9,198.00 6.92
Wind 12,264.00 9.22
Zone2 2020 Gas 85,118.00 100.00
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
optimal
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
scenario_id,105
scenario_name,test_performance_standard_carbon_credits_w_cap_no_credits_mapping
of_transmission,1
of_transmission_hurdle_rates,
of_simultaneous_flow_limits,
of_lf_reserves_up,1
of_lf_reserves_down,1
of_regulation_up,1
of_regulation_down,1
of_frequency_response,
of_spinning_reserves,
of_period_energy_target,
of_horizon_energy_target,
of_period_transmission_target,
of_carbon_cap,1
of_track_carbon_imports,
of_carbon_tax,
of_performance_standard,1
of_carbon_credits,1
of_fuel_burn_limit,
of_subsidies,
of_prm,
of_capacity_transfers,
of_deliverability,
of_elcc_surface,
of_local_capacity,
of_markets,
of_tuning,
temporal_scenario_id,1
load_zone_scenario_id,2
lf_reserves_up_ba_scenario_id,1
lf_reserves_down_ba_scenario_id,1
regulation_up_ba_scenario_id,1
regulation_down_ba_scenario_id,1
frequency_response_ba_scenario_id,NULL
spinning_reserves_ba_scenario_id,NULL
energy_target_zone_scenario_id,NULL
transmission_target_zone_scenario_id,NULL
carbon_cap_zone_scenario_id,1
carbon_tax_zone_scenario_id,NULL
performance_standard_zone_scenario_id,1
carbon_credits_zone_scenario_id,1
carbon_cap_zones_carbon_credits_zones_scenario_id,NULL
performance_standard_zones_carbon_credits_zones_scenario_id,1
carbon_tax_zones_carbon_credits_zones_scenario_id,NULL
carbon_credits_price_scenario_id,NULL
fuel_burn_limit_ba_scenario_id,NULL
prm_zone_scenario_id,NULL
local_capacity_zone_scenario_id,NULL
market_scenario_id,NULL
project_portfolio_scenario_id,15
project_operational_chars_scenario_id,16
project_availability_scenario_id,1
fuel_scenario_id,1
project_load_zone_scenario_id,1
project_lf_reserves_up_ba_scenario_id,5
project_lf_reserves_down_ba_scenario_id,5
project_regulation_up_ba_scenario_id,5
project_regulation_down_ba_scenario_id,5
project_frequency_response_ba_scenario_id,NULL
project_spinning_reserves_ba_scenario_id,NULL
project_energy_target_zone_scenario_id,NULL
tx_line_transmission_target_zone_scenario_id,NULL
project_carbon_cap_zone_scenario_id,2
project_carbon_tax_zone_scenario_id,NULL
project_carbon_tax_allowance_scenario_id,NULL
project_performance_standard_zone_scenario_id,1
project_carbon_credits_zone_scenario_id,1
project_carbon_credits_scenario_id,1
project_fuel_burn_limit_ba_scenario_id,NULL
project_prm_zone_scenario_id,NULL
prm_capacity_transfer_scenario_id,NULL
prm_capacity_transfer_params_scenario_id,NULL
transmission_prm_zone_scenario_id,NULL
project_elcc_chars_scenario_id,NULL
prm_deliverability_cost_scenario_id,NULL
prm_deliverability_existing_scenario_id,NULL
prm_deliverability_potential_scenario_id,NULL
project_prm_deliverability_multipliers_scenario_id,NULL
project_local_capacity_zone_scenario_id,NULL
project_local_capacity_chars_scenario_id,NULL
load_zone_market_scenario_id,NULL
project_specified_capacity_scenario_id,3
project_specified_fixed_cost_scenario_id,1
fuel_price_scenario_id,1
project_new_cost_scenario_id,1
project_new_potential_scenario_id,2
project_new_binary_build_size_scenario_id,NULL
project_capacity_group_requirement_scenario_id,NULL
project_relative_capacity_requirement_scenario_id,NULL
project_capacity_group_scenario_id,NULL
transmission_portfolio_scenario_id,1
transmission_load_zone_scenario_id,1
transmission_specified_capacity_scenario_id,1
transmission_new_cost_scenario_id,NULL
transmission_availability_scenario_id,1
transmission_operational_chars_scenario_id,1
transmission_hurdle_rate_scenario_id,NULL
transmission_new_potential_scenario_id,NULL
transmission_flow_scenario_id,NULL
transmission_capacity_group_requirement_scenario_id,NULL
transmission_capacity_group_scenario_id,NULL
transmission_carbon_cap_zone_scenario_id,NULL
transmission_simultaneous_flow_limit_scenario_id,NULL
transmission_simultaneous_flow_limit_line_group_scenario_id,NULL
load_scenario_id,1
lf_reserves_up_scenario_id,1
lf_reserves_down_scenario_id,1
regulation_up_scenario_id,1
regulation_down_scenario_id,1
frequency_response_scenario_id,NULL
spinning_reserves_scenario_id,NULL
period_energy_target_scenario_id,NULL
horizon_energy_target_scenario_id,NULL
period_transmission_target_scenario_id,NULL
carbon_cap_target_scenario_id,1
carbon_tax_scenario_id,NULL
performance_standard_scenario_id,1
fuel_burn_limit_scenario_id,NULL
subsidy_scenario_id,NULL
prm_requirement_scenario_id,NULL
local_capacity_requirement_scenario_id,NULL
elcc_surface_scenario_id,NULL
market_price_scenario_id,NULL
market_volume_scenario_id,NULL
tuning_scenario_id,NULL
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
metric,unit
power,MW
energy,MWh
fuel_energy,MMBtu
cost,USD
carbon_emissions,tonnes CO2
time_for_cost,yr.
heat_rate,MMBtu/MWh
fuel_emission_intensity,tonnes CO2/MMBtu
fuel_price,USD/MMBtu
variable_om_cost,USD/MWh
fixed_om_cost,USD/MW-yr.
fixed_om_cost_energy,USD/MW-yr.
capacity_cost,USD/MW-yr.
energy_capacity_cost,USD/MWh-yr.
26 changes: 15 additions & 11 deletions gridpath/system/policy/carbon_cap/purchase_credits.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_inputs_from_database(scenario_id, subscenarios, subproblem, stage, conn)
AND carbon_credits_zone in (
SELECT carbon_credits_zone
FROM inputs_geography_carbon_credits_zones
WHERE carbon_credits_zone_scenario_id = {subscenarios.CARBON_CAP_ZONE_SCENARIO_ID}
WHERE carbon_credits_zone_scenario_id = {subscenarios.CARBON_CREDITS_ZONE_SCENARIO_ID}
)
;
"""
Expand All @@ -110,7 +110,8 @@ def write_model_inputs(
"inputs",
"carbon_cap_zones_carbon_credits_zone_mapping.tab",
)
df.to_csv(fpath, index=False, sep="\t")
if not df.empty:
df.to_csv(fpath, index=False, sep="\t")


def load_model_data(m, d, data_portal, scenario_directory, subproblem, stage):
Expand All @@ -124,17 +125,20 @@ def load_model_data(m, d, data_portal, scenario_directory, subproblem, stage):
:param stage:
:return:
"""
data_portal.load(
filename=os.path.join(
scenario_directory,
str(subproblem),
str(stage),
"inputs",
"carbon_cap_zones_carbon_credits_zone_mapping.tab",
),
set=m.CARBON_CAP_ZONES_CARBON_CREDITS_ZONES,
map_file = os.path.join(
scenario_directory,
str(subproblem),
str(stage),
"inputs",
"carbon_cap_zones_carbon_credits_zone_mapping.tab",
)

if os.path.exists(map_file):
data_portal.load(
filename=map_file,
set=m.CARBON_CAP_ZONES_CARBON_CREDITS_ZONES,
)


def export_results(scenario_directory, subproblem, stage, m, d):
"""
Expand Down
Loading

0 comments on commit 60112b4

Please sign in to comment.