def test_slack_in_generic_constraints_with_all_features(): inputs_database = 'test_files/historical_all.db' con = sqlite3.connect('test_files/historical_all.db') historical_inputs = loaders.HistoricalInputs( market_management_system_database_connection=con, nemde_xml_cache_folder='test_files/historical_xml_files') for interval in get_test_intervals(): print(interval) historical_inputs.load_interval(interval) market = historical_market_builder.SpotMarket( inputs_database=inputs_database, inputs=historical_inputs, interval=interval) market.add_unit_bids_to_market() market.add_interconnectors_to_market() market.add_generic_constraints_fcas_requirements() market.set_unit_fcas_constraints() market.set_unit_limit_constraints() market.set_ramp_rate_limits() market.set_unit_dispatch_to_historical_values(wiggle_room=0.003) market.set_interconnector_flow_to_historical_values() market.dispatch(calc_prices=False) assert market.is_generic_constraint_slack_correct() assert market.is_fcas_constraint_slack_correct() assert market.is_regional_demand_meet()
def test_fcas_trapezium_scaled_availability(): inputs_database = 'test_files/historical_all.db' con = sqlite3.connect('test_files/historical_all.db') historical_inputs = loaders.HistoricalInputs( market_management_system_database_connection=con, nemde_xml_cache_folder='test_files/historical_xml_files') for interval in get_test_intervals(): print(interval) historical_inputs.load_interval(interval) market = historical_market_builder.SpotMarket( inputs_database=inputs_database, inputs=historical_inputs, interval=interval) market.add_unit_bids_to_market() market.set_unit_fcas_constraints() market.set_unit_limit_constraints() market.set_unit_dispatch_to_historical_values(wiggle_room=0.0001) market.dispatch(calc_prices=False) avails = market.do_fcas_availabilities_match_historical() # I think NEMDE might be getting avail calcs wrong when units are opperating on the slopes, and the slopes # are vertical. They should be ignore 0 slope cofficients, maybe this is not happing because of floating # point comparison. if interval == '2019/01/29 18:10:00': avails = avails[~(avails['unit'] == 'PPCCGT')] if interval == '2019/01/07 19:35:00': avails = avails[~(avails['unit'] == 'PPCCGT')] assert avails['error'].abs().max() < 1.1
def test_if_ramp_rates_calculated_correctly(): inputs_database = 'test_files/historical.db' con = sqlite3.connect(inputs_database) historical_inputs = loaders.HistoricalInputs( market_management_system_database_connection=con, nemde_xml_cache_folder='test_files/historical_xml_files') for interval in get_test_intervals(): print(interval) market = historical_market_builder.SpotMarket( inputs_database=inputs_database, inputs=historical_inputs, interval=interval) market.add_unit_bids_to_market() market.set_ramp_rate_limits() market.set_unit_dispatch_to_historical_values() market.dispatch() assert market.measured_violation_equals_historical_violation( historical_name='ramp_rate', nempy_constraints=['ramp_up', 'ramp_down']) with open('interval_with_violations.pickle', 'rb') as f: interval_with_violations = pickle.load(f) for interval, types in interval_with_violations.items(): if 'ramp_rate' in types: print(interval) market = historical_market_builder.SpotMarket( inputs_database=inputs_database, inputs=historical_inputs, interval=interval) market.add_unit_bids_to_market() market.set_ramp_rate_limits() market.set_unit_dispatch_to_historical_values() market.dispatch() assert market.measured_violation_equals_historical_violation( historical_name='ramp_rate', nempy_constraints=['ramp_up', 'ramp_down'])
def test_all_units_and_service_dispatch_historically_present_in_market(): inputs_database = 'test_files/historical_all.db' con = sqlite3.connect('test_files/historical_all.db') historical_inputs = loaders.HistoricalInputs( market_management_system_database_connection=con, nemde_xml_cache_folder='test_files/historical_xml_files') for interval in get_test_intervals(): historical_inputs.load_interval(interval) market = historical_market_builder.SpotMarket( inputs_database=inputs_database, inputs=historical_inputs, interval=interval) market.add_unit_bids_to_market() assert market.all_dispatch_units_and_service_have_decision_variables()
def test_capacity_constraints(): inputs_database = 'test_files/historical_all.db' con = sqlite3.connect(inputs_database) historical_inputs = loaders.HistoricalInputs( market_management_system_database_connection=con, nemde_xml_cache_folder='test_files/historical_xml_files') for interval in get_test_intervals(): print(interval) market = historical_market_builder.SpotMarket( inputs_database=inputs_database, inputs=historical_inputs, interval=interval) market.add_unit_bids_to_market() market.set_unit_limit_constraints() market.set_unit_dispatch_to_historical_values() market.dispatch() assert market.measured_violation_equals_historical_violation( 'unit_capacity', nempy_constraints=['unit_bid_capacity'])
def test_slack_in_generic_constraints_use_fcas_requirements_interface(): inputs_database = 'test_files/historical_all.db' con = sqlite3.connect('test_files/historical_all.db') historical_inputs = loaders.HistoricalInputs( market_management_system_database_connection=con, nemde_xml_cache_folder='test_files/historical_xml_files') for interval in get_test_intervals(): print(interval) historical_inputs.load_interval(interval) market = historical_market_builder.SpotMarket( inputs_database=inputs_database, inputs=historical_inputs, interval=interval) market.add_unit_bids_to_market() market.add_interconnectors_to_market() market.add_generic_constraints_fcas_requirements() market.set_unit_dispatch_to_historical_values(wiggle_room=0.0001) market.set_interconnector_flow_to_historical_values(wiggle_room=0.001) market.dispatch(calc_prices=False) market.market.get_elastic_constraints_violation_degree('generic') assert market.all_constraints_presenet() assert market.is_generic_constraint_slack_correct() assert market.is_fcas_constraint_slack_correct()