def setup_runtimes(self, options, stats_manager: StatsManager): _round = self._round runtime_path = os.path.join(options.output_directory, 'runtimes.csv') runtime_file = open(runtime_path, 'w', newline='') ops_runtime_columns = { "Date": lambda ops: str(ops.timestamp.date()), "Hour": lambda ops: ops.timestamp.hour, "Minute": lambda ops: ops.timestamp.minute, "Type": lambda ops: "SCED", "Solve Time": lambda ops: _round(ops.sced_runtime) } ops_runtime_writer = CsvReporter.from_dict(runtime_file, ops_runtime_columns) stats_manager.register_for_sced_stats(ops_runtime_writer.write_record) if options.sced_frequency_minutes != 60: hr_runtime_columns = { "Date": lambda hourly: str(hourly.date), "Hour": lambda hourly: hourly.hour, "Minute": lambda hourly: 0, "Type": lambda hourly: "Hourly Average", "Solve Time": lambda hourly: _round(hourly.average_sced_runtime) } hr_runtime_writer = CsvReporter.from_dict(runtime_file, hr_runtime_columns, write_headers=False) stats_manager.register_for_hourly_stats( hr_runtime_writer.write_record) stats_manager.register_for_overall_stats( lambda overall: runtime_file.close())
def setup_hourly_summary(self, options, stats_manager: StatsManager): _round = self._round hourly_path = os.path.join(options.output_directory, 'hourly_summary.csv') hourly_file = open(hourly_path, 'w', newline='') hourly_columns = { 'Date': lambda hourly: str(hourly.date), 'Hour': lambda hourly: hourly.hour, 'TotalCosts': lambda hourly: _round(hourly.total_costs), 'FixedCosts': lambda hourly: _round(hourly.fixed_costs), 'VariableCosts': lambda hourly: _round(hourly.variable_costs), 'LoadShedding': lambda hourly: _round(hourly.load_shedding), 'OverGeneration': lambda hourly: _round(hourly.over_generation), 'ReserveShortfall': lambda hourly: _round(hourly.reserve_shortfall), 'RenewablesUsed': lambda hourly: _round(hourly.renewables_used), 'RenewablesCurtailment': lambda hourly: _round(hourly.renewables_curtailment), 'Demand': lambda hourly: _round(hourly.total_demand), 'Price': lambda hourly: _round(hourly.price) } hourly_writer = CsvReporter.from_dict(hourly_file, hourly_columns) stats_manager.register_for_hourly_stats(hourly_writer.write_record) stats_manager.register_for_overall_stats( lambda overall: hourly_file.close())
def setup_hourly_gen_summary(self, options, stats_manager: StatsManager): hourly_gen_path = os.path.join(options.output_directory, 'hourly_gen_summary.csv') hourly_gen_file = open(hourly_gen_path, 'w', newline='') hourly_gen_columns = { 'Date': lambda hourly: str(hourly.date), 'Hour': lambda hourly: hourly.hour, 'Load shedding': lambda hourly: hourly.load_shedding, 'Reserve shortfall': lambda hourly: hourly.reserve_shortfall, 'Available reserves': lambda hourly: hourly.available_reserve, 'Over generation': lambda hourly: hourly.over_generation, 'Reserve Price DA': lambda hourly: hourly.planning_reserve_price if options.compute_market_settlements else None, 'Reserve Price RT': lambda hourly: hourly.reserve_RT_price } hourly_gen_writer = CsvReporter.from_dict(hourly_gen_file, hourly_gen_columns) stats_manager.register_for_hourly_stats(hourly_gen_writer.write_record) stats_manager.register_for_overall_stats( lambda overall: hourly_gen_file.close())
def write_overall_stats(overall: OverallStats): overall_path = os.path.join(options.output_directory, 'overall_simulation_output.csv') overall_file = open(overall_path, 'w', newline='') overall_cols = { 'Total demand': lambda overall: _round(overall.cumulative_demand), 'Total fixed costs': lambda overall: _round(overall.total_overall_fixed_costs), 'Total generation costs': lambda overall: _round(overall.total_overall_generation_costs), 'Total costs': lambda overall: _round(overall.total_overall_costs), 'Total load shedding': lambda overall: _round(overall.total_overall_load_shedding), 'Total over generation': lambda overall: _round(overall.total_overall_over_generation), 'Total reserve shortfall': lambda overall: _round(overall.total_overall_reserve_shortfall ), 'Total renewables curtailment': lambda overall: _round(overall. total_overall_renewables_curtailment), 'Total on/offs': lambda overall: overall.total_on_offs, 'Total sum on/off ramps': lambda overall: _round(overall.total_sum_on_off_ramps), 'Total sum nominal ramps': lambda overall: _round(overall.total_sum_nominal_ramps), 'Maximum observed demand': lambda overall: _round(overall.max_hourly_demand), 'Overall renewables penetration rate': lambda overall: _round(overall. overall_renewables_penetration_rate), 'Cumulative average price': lambda overall: _round(overall.cumulative_average_price) } if options.compute_market_settlements: overall_cols.update({ 'Total energy payments': lambda overall: _round(overall.total_energy_payments), 'Total reserve payments': lambda overall: _round(overall.total_reserve_payments), 'Total uplift payments': lambda overall: _round(overall.total_uplift_payments), 'Total payments': lambda overall: _round(overall.total_payments), 'Cumulative average payments': lambda overall: _round(overall.cumulative_average_payments) }) overall_reporter = CsvReporter.from_dict(overall_file, overall_cols) overall_reporter.write_record(overall) overall_file.close()
def setup_runtimes(self, options, stats_manager: StatsManager): runtime_path = os.path.join(options.output_directory, 'runtimes.csv') runtime_file = open(runtime_path, 'w', newline='') runtime_columns = { "Date": lambda hourly: str(hourly.date), "Hour": lambda hourly: hourly.hour + 1, "Type": lambda hourly: "SCED", "Solve Time": lambda hourly: hourly.sced_runtime } runtime_writer = CsvReporter.from_dict(runtime_file, runtime_columns) stats_manager.register_for_hourly_stats(runtime_writer.write_record) stats_manager.register_for_overall_stats( lambda overall: runtime_file.close())
def setup_daily_summary(self, options, stats_manager: StatsManager): daily_path = os.path.join(options.output_directory, 'daily_summary.csv') daily_file = open(daily_path, 'w', newline='') daily_columns = { 'Date': lambda daily: str(daily.date), 'Demand': lambda daily: daily.this_date_demand, 'Renewables available': lambda daily: daily.this_date_renewables_available, 'Renewables used': lambda daily: daily.this_date_renewables_used, 'Renewables penetration rate': lambda daily: daily. this_date_renewables_penetration_rate, ############ TODO: Implement ############## 'Average price': lambda daily: daily.this_date_average_price, 'Fixed costs': lambda daily: daily.this_date_fixed_costs, 'Generation costs': lambda daily: daily.this_date_variable_costs, 'Load shedding': lambda daily: daily.this_date_load_shedding, 'Over generation': lambda daily: daily.this_date_over_generation, 'Reserve shortfall': lambda daily: daily.this_date_reserve_shortfall, 'Renewables curtailment': lambda daily: daily.this_date_renewables_curtailment, 'Number on/offs': lambda daily: daily.this_date_on_offs, 'Sum on/off ramps': lambda daily: daily.this_date_sum_on_off_ramps, 'Sum nominal ramps': lambda daily: daily.this_date_sum_nominal_ramps } if options.compute_market_settlements: daily_columns.update({ 'Renewables energy payments': lambda daily: daily.this_date_renewable_energy_payments, 'Renewables uplift payments': lambda daily: daily.this_date_renewable_uplift, 'Thermal energy payments': lambda daily: daily.this_date_thermal_energy_payments, 'Thermal uplift payments': lambda daily: daily.this_date_thermal_uplift, 'Total energy payments': lambda daily: daily.this_date_energy_payments, 'Total uplift payments': lambda daily: daily.this_date_uplift_payments, 'Total reserve payments': lambda daily: daily.this_date_reserve_payments, 'Total payments': lambda daily: daily.this_date_total_payments, 'Average payments': lambda daily: daily.this_date_average_payments, }) daily_writer = CsvReporter.from_dict(daily_file, daily_columns) stats_manager.register_for_daily_stats(daily_writer.write_record) stats_manager.register_for_overall_stats( lambda overall: daily_file.close())
def setup_hourly_gen_summary(self, options, stats_manager: StatsManager): _round = self._round hourly_gen_path = os.path.join(options.output_directory, 'hourly_gen_summary.csv') hourly_gen_file = open(hourly_gen_path, 'w', newline='') hourly_gen_columns = { 'Date': lambda hourly: str(hourly.date), 'Hour': lambda hourly: hourly.hour, 'Load shedding': lambda hourly: _round(hourly.load_shedding), 'Reserve shortfall': lambda hourly: _round(hourly.total_reserve_shortfall), 'Available headroom': lambda hourly: _round(hourly.total_thermal_headroom), 'Over generation': lambda hourly: _round(hourly.over_generation) } hourly_gen_writer = CsvReporter.from_dict(hourly_gen_file, hourly_gen_columns) stats_manager.register_for_hourly_stats(hourly_gen_writer.write_record) stats_manager.register_for_overall_stats( lambda overall: hourly_gen_file.close())