def diagnostic(net, report_style='detailed', warnings_only=False, return_result_dict=True, overload_scaling_factor=0.001, min_r_ohm=0.001, min_x_ohm=0.001, min_r_pu=1e-05, min_x_pu=1e-05, nom_voltage_tolerance=0.3, numba_tolerance=1e-05): """ Tool for diagnosis of pandapower networks. Identifies possible reasons for non converging loadflows. INPUT: **net** (pandapowerNet) : pandapower network OPTIONAL: - **report_style** (string, 'detailed') : style of the report, that gets ouput in the console 'detailled': full report with high level of additional descriptions 'compact' : more compact report, containing essential information only 'None' : no report - **warnings_only** (boolean, False): Filters logging output for warnings True: logging output for errors only False: logging output for all checks, regardless if errors were found or not - **return_result_dict** (boolean, True): returns a dictionary containing all check results True: returns dict with all check results False: no result dict - **overload_scaling_factor** (float, 0.001): downscaling factor for loads and generation \ for overload check - **lines_min_length_km** (float, 0): minimum length_km allowed for lines - **lines_min_z_ohm** (float, 0): minimum z_ohm allowed for lines - **nom_voltage_tolerance** (float, 0.3): highest allowed relative deviation between nominal \ voltages and bus voltages OUTPUT: - **diag_results** (dict): dict that contains the indices of all elements where errors were found Format: {'check_name': check_results} EXAMPLE: <<< pandapower.diagnostic(net, report_style='compact', warnings_only=True) """ diag_functions = ["missing_bus_indices(net)", "disconnected_elements(net)", "different_voltage_levels_connected(net)", "impedance_values_close_to_zero(net, min_r_ohm, min_x_ohm, min_r_pu, min_x_pu)", "nominal_voltages_dont_match(net, nom_voltage_tolerance)", "invalid_values(net)", "overload(net, overload_scaling_factor)", "wrong_switch_configuration(net)", "multiple_voltage_controlling_elements_per_bus(net)", "no_ext_grid(net)", "wrong_reference_system(net)", "deviation_from_std_type(net)", "numba_comparison(net, numba_tolerance)", "parallel_switches(net)"] diag_results = {} diag_errors = {} for diag_function in diag_functions: try: diag_result = eval(diag_function) if not diag_result == None: diag_results[diag_function.split("(")[0]] = diag_result except Exception as e: diag_errors[diag_function.split("(")[0]] = e diag_params = { "overload_scaling_factor": overload_scaling_factor, "min_r_ohm": min_r_ohm, "min_x_ohm": min_x_ohm, "min_r_pu": min_r_pu, "min_x_pu": min_x_pu, "nom_voltage_tolerance": nom_voltage_tolerance, "numba_tolerance": numba_tolerance } if report_style == 'detailed': diagnostic_report(net, diag_results, diag_errors, diag_params, compact_report=False, warnings_only=warnings_only) elif report_style == 'compact': diagnostic_report(net, diag_results, diag_errors, diag_params, compact_report=True, warnings_only=warnings_only) if return_result_dict: return diag_results
def diagnostic(net, report_style='detailed', warnings_only=False, return_result_dict=True, overload_scaling_factor=0.001, lines_min_length_km=0, lines_min_z_ohm=0, nom_voltage_tolerance=0.3): """ Tool for diagnosis of pandapower networks. Identifies possible reasons for non converging loadflows. INPUT: **net** (PandapowerNet) : pandapower network OPTIONAL: - **report_style** (string, 'detailed') : style of the report, that gets ouput in the console 'detailled': full report with high level of additional descriptions 'compact' : more compact report, containing essential information only 'None' : no report - **warnings_only** (boolean, False): Filters logging output for warnings True: logging output for errors only False: logging output for all checks, regardless if errors were found or not - **return_result_dict** (boolean, True): returns a dictionary containing all check results True: returns dict with all check results False: no result dict - **overload_scaling_factor** (float, 0.001): downscaling factor for loads and generation \ for overload check - **lines_min_length_km** (float, 0): minimum length_km allowed for lines - **lines_min_z_ohm** (float, 0): minimum z_ohm allowed for lines - **nom_voltage_tolerance** (float, 0.3): highest allowed relative deviation between nominal \ voltages and bus voltages RETURN: - **diag_results** (dict): dict that contains the indeces of all elements where errors were found Format: {'check_name': check_results} EXAMPLE: <<< pandapower.diagnostic(net, report_style='compact', warnings_only=True) """ diag_results = {} if disconnected_elements(net): diag_results["disconnected_elements"] = disconnected_elements(net) if different_voltage_levels_connected(net): diag_results["different_voltage_levels_connected"] = \ different_voltage_levels_connected(net) if lines_with_impedance_close_to_zero(net, lines_min_length_km, lines_min_z_ohm): diag_results["lines_with_impedance_close_to_zero"] = \ lines_with_impedance_close_to_zero(net, lines_min_length_km, lines_min_z_ohm) if nominal_voltages_dont_match(net, nom_voltage_tolerance): diag_results["nominal_voltages_dont_match"] = \ nominal_voltages_dont_match(net, nom_voltage_tolerance) if invalid_values(net): diag_results["invalid_values"] = invalid_values(net) if overload(net, overload_scaling_factor): diag_results["overload"] = overload(net, overload_scaling_factor) if wrong_switch_configuration(net): diag_results[ "wrong_switch_configuration"] = wrong_switch_configuration(net) if multiple_voltage_controlling_elements_per_bus(net): diag_results["multiple_voltage_controlling_elements_per_bus"] = \ multiple_voltage_controlling_elements_per_bus(net) if no_ext_grid(net): diag_results["no_ext_grid"] = no_ext_grid(net) if wrong_reference_system(net): diag_results["wrong_reference_system"] = wrong_reference_system(net) diag_params = { "overload_scaling_factor": overload_scaling_factor, "lines_min_length_km": lines_min_length_km, "lines_min_z_ohm": lines_min_z_ohm, "nom_voltage_tolerance": nom_voltage_tolerance } if warnings_only: logger.setLevel(logging.WARNING) else: logger.setLevel(logging.INFO) logger.propagate = False if report_style == 'detailed': diagnostic_report(net, diag_results, diag_params, compact_report=False) elif report_style == 'compact': diagnostic_report(net, diag_results, diag_params, compact_report=True) if return_result_dict: return diag_results