Skip to content

Commit

Permalink
Feature/2030fleet (#17)
Browse files Browse the repository at this point in the history
* update data processing for improved accuracy

* update thermal generation data format and add new entries

* Refactor generator retirement logic and update wind generator count in 2030 scenario

* Update notebook to replace deprecated frame.append method with pandas.concat

* test runs for 2030

* Update notebooks to replace deprecated frame.append method with pandas.concat and improve data processing

* Add 2030 baseline OPF simulation script and adjust generation cost penalties

* Update OPF scripts to reflect new case names and authors for 2030 scenarios

* Remove 2018 baseline OPF simulation script

* Update grid profile year parameter to 2030 in OPF daily scripts

* Refactor simulation parameters and error handling in OPF scripts for 2030 scenarios

* add separate post code for scenarios

* Update execution counts in load profiles notebook for consistency

* correct errors in gen params creation

* examples for running different scenarios in notebooks
  • Loading branch information
boyuan276 authored Dec 4, 2024
1 parent e90a609 commit f1ede33
Show file tree
Hide file tree
Showing 28 changed files with 13,544 additions and 5,020 deletions.
463 changes: 236 additions & 227 deletions data/grid/thermal_gen_2_county.csv

Large diffs are not rendered by default.

176 changes: 0 additions & 176 deletions examples/01_opf_2018Baseline_daily.py

This file was deleted.

80 changes: 56 additions & 24 deletions examples/01_opf_2018NewParams_daily.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""
Run multi-period OPF with 2018 data.
1. Baseline case:
No CPNY and CHPE HVDC lines.
No ESRs.
No future solar and offshore wind.
No residential building electrification.
Case name: 2018NewParams
Authors:
- Bo Yuan (Cornell University)
"""
# %% Packages

Expand All @@ -28,8 +27,8 @@
sim_name = f'2018NewParams_ext{ext_cost_factor}_fo{fo_cost_factor}_daily'

# Simulation time settings
valid_days = 30
lookahead_days = 1
valid_days = 14
lookahead_days = 2

valid_hours = 24 * valid_days
lookahead_hours = 24 * lookahead_days
Expand Down Expand Up @@ -96,8 +95,8 @@
# Decrease FO2, KER and FO6 generation costs
change_index = grid_prop["gen_fuel"]["GEN_FUEL"].isin(
[
# "CT_FO2",
# "CT_KER",
"CT_FO2",
"CT_KER",
"ST_FO6"
]).to_numpy()

Expand All @@ -123,8 +122,8 @@
'UsePTDF': True,
'solver': 'gurobi',
'PenaltyForLoadShed': 10_000,
# 'PenaltyForBranchMwViolation': 10_000,
# 'PenaltyForInterfaceMWViolation': 10_000
'PenaltyForBranchMwViolation': 5_000,
'PenaltyForInterfaceMWViolation': 5_000,
}

solver_options = {
Expand All @@ -142,8 +141,12 @@
hour_since_last_startup = None
hour_since_last_shutdown = None

# Restart from the middle
last_cycle_idx = 0
# last_cycle_idx = 1

# Loop through all days
for d in tqdm(range(len(timestamp_list)), desc='Running OPF'):
for d in tqdm(range(last_cycle_idx, len(timestamp_list)), desc='Running OPF'):
t = time.time()

# Set clycle start and end datetime
Expand All @@ -154,18 +157,47 @@
else:
cycle_end_time = sim_end_time

nygrid_results = ng_run.run_nygrid_sim(grid_prop=grid_prop,
grid_profile=grid_profile,
start_datetime=cycle_start_time,
end_datetime=cycle_end_time,
options=options,
solver_options=solver_options,
gen_init=last_gen,
gen_init_cmt=last_gen_cmt,
soc_init=last_soc,
gen_last_startup_hour=hour_since_last_startup,
gen_last_shutdown_hour=hour_since_last_shutdown,
verbose=verbose)
if cycle_end_time > sim_end_time:
cycle_end_time = sim_end_time

try:
nygrid_results = ng_run.run_nygrid_sim(grid_prop=grid_prop,
grid_profile=grid_profile,
start_datetime=cycle_start_time,
end_datetime=cycle_end_time,
options=options,
solver_options=solver_options,
gen_init=last_gen,
gen_init_cmt=last_gen_cmt,
soc_init=last_soc,
gen_last_startup_hour=hour_since_last_startup,
gen_last_shutdown_hour=hour_since_last_shutdown,
verbose=verbose)
except RuntimeError as e:
logging.error(f'Error running OPF for {cycle_start_time}.')
logging.error(e)

# Try solving without initial conditions
last_gen = np.zeros(grid_prop['gen_prop'].shape[0] +
grid_prop['esr_prop'].shape[0] +
grid_prop['dcline_prop'].shape[0]*2)
last_gen_cmt = np.zeros(sum(grid_prop['gen_prop']['CMT_KEY'] == 1))
last_soc = None
hour_since_last_startup = None
hour_since_last_shutdown = None

nygrid_results = ng_run.run_nygrid_sim(grid_prop=grid_prop,
grid_profile=grid_profile,
start_datetime=cycle_start_time,
end_datetime=cycle_end_time,
options=options,
solver_options=solver_options,
gen_init=last_gen,
gen_init_cmt=last_gen_cmt,
soc_init=last_soc,
gen_last_startup_hour=hour_since_last_startup,
gen_last_shutdown_hour=hour_since_last_shutdown,
verbose=verbose)

# Save simulation nygrid_results to pickle
filename = f'nygrid_sim_{sim_name}_{cycle_start_time.strftime("%Y%m%d")}_{valid_days}_{lookahead_days}.pkl'
Expand Down
3 changes: 3 additions & 0 deletions examples/01_opf_2018NewParams_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@
else:
cycle_end_time = sim_end_time

if cycle_end_time > sim_end_time:
cycle_end_time = sim_end_time

nygrid_results = ng_run.run_nygrid_sim(grid_prop=grid_prop,
grid_profile=grid_profile,
start_datetime=cycle_start_time,
Expand Down
Loading

0 comments on commit f1ede33

Please sign in to comment.