From df06d74125e5a1d99fa3c217c89f48dd15acecc7 Mon Sep 17 00:00:00 2001 From: "gintautas.poderys" Date: Thu, 2 Jan 2025 14:20:13 +0200 Subject: [PATCH 1/2] Updated validator to include more metadata in validation report. --- emf/loadflow_tool/helper.py | 14 +++++++++----- emf/loadflow_tool/model_validator/validator.py | 6 +++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/emf/loadflow_tool/helper.py b/emf/loadflow_tool/helper.py index 8cf0118..299a93a 100644 --- a/emf/loadflow_tool/helper.py +++ b/emf/loadflow_tool/helper.py @@ -507,13 +507,17 @@ def get_model_outages(network: pypowsybl.network): outage_log = [] lines = network.get_lines().reset_index(names=['grid_id']) lines['element_type'] = 'Line' - dls = get_network_elements(network, pypowsybl.network.ElementType.DANGLING_LINE).reset_index(names=['grid_id']) - dls['element_type'] = 'Tieline' + dlines = get_network_elements(network, pypowsybl.network.ElementType.DANGLING_LINE).reset_index(names=['grid_id']) + dlines['element_type'] = 'Tieline' + gens = get_network_elements(network, pypowsybl.network.ElementType.GENERATOR).reset_index(names=['grid_id']) + gens['element_type'] = 'Generator' disconnected_lines = lines[(lines['connected1'] == False) | (lines['connected2'] == False)] - disconnected_dls = dls[dls['connected'] == False] + disconnected_dlines = dlines[dlines['connected'] == False] + disconnected_gens = gens[gens['connected'] == False] - outage_log.extend(disconnected_lines[['grid_id', 'name', 'element_type']].to_dict('records')) - outage_log.extend(disconnected_dls[['grid_id', 'name', 'element_type']].to_dict('records')) + outage_log.extend(disconnected_lines[['grid_id', 'name', 'country', 'element_type']].to_dict('records')) + outage_log.extend(disconnected_dlines[['grid_id', 'name', 'country', 'element_type']].to_dict('records')) + outage_log.extend(disconnected_gens[['grid_id', 'name', 'country', 'element_type']].to_dict('records')) return outage_log diff --git a/emf/loadflow_tool/model_validator/validator.py b/emf/loadflow_tool/model_validator/validator.py index 5d6cd4d..5ac4335 100644 --- a/emf/loadflow_tool/model_validator/validator.py +++ b/emf/loadflow_tool/model_validator/validator.py @@ -117,6 +117,7 @@ def validate_model(opdm_objects, loadflow_parameters=getattr(loadflow_settings, model_data["validation_duration_s"] = round(time.time() - start_time, 3) logger.info(f"Load flow validation status: {model_valid} [duration {model_data['validation_duration_s']}s]") + # Get outages of the model try: model_data['outages'] = get_model_outages(network) except Exception as e: @@ -131,6 +132,7 @@ def validate_model(opdm_objects, loadflow_parameters=getattr(loadflow_settings, model_data['@scenario_timestamp'] = model_metadata['pmd:scenarioDate'] model_data['@time_horizon'] = model_metadata['pmd:timeHorizon'] model_data['@version'] = model_metadata['pmd:versionNumber'] + model_data['tso'] = model_metadata['pmd:TSO'] # Pop out pypowsybl network object model_data.pop('network') @@ -160,7 +162,9 @@ def validate_model(opdm_objects, loadflow_parameters=getattr(loadflow_settings, opdm = OPDM() latest_boundary = opdm.get_latest_boundary() - available_models = opdm.get_latest_models_and_download(time_horizon='1D', scenario_date="2023-08-16T09:30")#, tso="ELERING") + available_models = opdm.get_latest_models_and_download(time_horizon='1D', + scenario_date="2025-01-01T09:30", + tso="AST") validated_models = [] From b73f42272926108fc037f29a6f3b6cce4f33979a Mon Sep 17 00:00:00 2001 From: "gintautas.poderys" Date: Thu, 2 Jan 2025 15:51:09 +0200 Subject: [PATCH 2/2] bugfix for function get_model_outages --- emf/loadflow_tool/helper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emf/loadflow_tool/helper.py b/emf/loadflow_tool/helper.py index 299a93a..28915c4 100644 --- a/emf/loadflow_tool/helper.py +++ b/emf/loadflow_tool/helper.py @@ -516,8 +516,8 @@ def get_model_outages(network: pypowsybl.network): disconnected_dlines = dlines[dlines['connected'] == False] disconnected_gens = gens[gens['connected'] == False] - outage_log.extend(disconnected_lines[['grid_id', 'name', 'country', 'element_type']].to_dict('records')) - outage_log.extend(disconnected_dlines[['grid_id', 'name', 'country', 'element_type']].to_dict('records')) - outage_log.extend(disconnected_gens[['grid_id', 'name', 'country', 'element_type']].to_dict('records')) + outage_log.extend(disconnected_lines[['grid_id', 'name', 'element_type']].to_dict('records')) + outage_log.extend(disconnected_dlines[['grid_id', 'name', 'element_type']].to_dict('records')) + outage_log.extend(disconnected_gens[['grid_id', 'name', 'element_type']].to_dict('records')) return outage_log