Skip to content

Commit

Permalink
add leading_hours options and fixed time logging
Browse files Browse the repository at this point in the history
  • Loading branch information
boyuan276 committed Jan 31, 2024
1 parent 18def23 commit fcc4611
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions examples/ex_opf_wo_renew.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# %% Simulation settings
# NOTE: Change the following settings to run the simulation
sim_name = 'wo_renew'
leading_hours = 12

start_date = datetime(2018, 1, 1, 0, 0, 0)
end_date = datetime(2018, 1, 10, 0, 0, 0)
Expand All @@ -31,8 +32,8 @@
handlers=[logging.FileHandler(f'ex_opf_{sim_name}.log'),
logging.StreamHandler()])

t = time.time()
logging.info('Start running multi-period OPF without renewable generators.')
prog_start = time.time()
logging.info(f'Start running multi-period OPF simulation {sim_name}.')

# %% Set up directories
cwd = os.getcwd()
Expand Down Expand Up @@ -87,10 +88,13 @@

# Loop through all days
for d in range(len(timestamp_list) - 1):
# Run OPF for two days at each iteration
# The first day is valid, the second day is used for creating initial condition for the next iteration

t = time.time()

# Run OPF for one day (24 hours) plus leading hours
# The first day is valid, the leading hours are used to dispatch batteries properly
start_datetime = timestamp_list[d]
end_datetime = start_datetime + timedelta(hours=47)
end_datetime = start_datetime + timedelta(hours=24+leading_hours)

nygrid_results = run_nygrid_one_day(start_datetime, end_datetime, grid_data, grid_data_dir, options, last_gen)

Expand All @@ -106,3 +110,6 @@
elapsed = time.time() - t
logging.info(f'Finished running for {start_datetime.strftime("%Y-%m-%d")}. Elapsed time: {elapsed:.2f} seconds')
logging.info('-' * 80)

tot_elapsed = time.time() - prog_start
logging.info(f"Finished multi-period OPF simulation {sim_name}. Total elapsed time: {tot_elapsed:.2f} seconds")

0 comments on commit fcc4611

Please sign in to comment.