VeraGridEngine.Simulations.ContingencyAnalysis packageο
Subpackagesο
- VeraGridEngine.Simulations.ContingencyAnalysis.Methods package
- Submodules
- VeraGridEngine.Simulations.ContingencyAnalysis.Methods.helm_contingencies module
- VeraGridEngine.Simulations.ContingencyAnalysis.Methods.helm_contingency_analysis module
- VeraGridEngine.Simulations.ContingencyAnalysis.Methods.linear_contingency_analysis module
- VeraGridEngine.Simulations.ContingencyAnalysis.Methods.nonlinear_contingency_analysis module
- VeraGridEngine.Simulations.ContingencyAnalysis.Methods.optimal_linear_contingency_analysis module
- VeraGridEngine.Simulations.ContingencyAnalysis.Methods.srap module
- Module contents
Submodulesο
VeraGridEngine.Simulations.ContingencyAnalysis.contingencies_report moduleο
- class VeraGridEngine.Simulations.ContingencyAnalysis.contingencies_report.ContingencyResultsReport[source]ο
Bases:
objectContingency results report table
- add(time_index: int, t_prob: float, mon_idx: int, con_group_idx: int, area_from: str, area_to: str, base_name: str, contingency_name: str, base_rating: float, contingency_rating: float, srap_rating: float, base_flow: complex, post_contingency_flow: complex, post_srap_flow: complex, base_loading: float, post_contingency_loading: float, post_srap_loading: float, msg_ov: str, msg_srap: str, srap_power: float, solved_by_srap: bool = False)[source]ο
Add report data :param time_index: :param mon_idx: :param con_group_idx: :param t_prob: :param area_from: :param area_to: :param base_name: :param contingency_name: :param base_rating: :param contingency_rating: :param srap_rating: :param base_flow: :param post_contingency_flow: :param post_srap_flow: :param base_loading: :param post_contingency_loading: :param post_srap_loading: :param msg_ov: :param msg_srap: :param srap_power: :param solved_by_srap: :return:
- add_entry(entry: ContingencyTableEntry)[source]ο
Add contingencies entry :param entry: ContingencyTableEntry
- analyze(t: None | int, t_prob: float, mon_idx: ndarray[tuple[Any, ...], dtype[int64]], nc: NumericalCircuit, base_flow: ndarray[tuple[Any, ...], dtype[float64]], base_loading: ndarray[tuple[Any, ...], dtype[float64]], contingency_flows: ndarray[tuple[Any, ...], dtype[float64]], contingency_loadings: ndarray[tuple[Any, ...], dtype[float64]], contingency_group_idx: int, contingency_group: ContingencyGroup, using_srap: bool = False, srap_ratings: ndarray[tuple[Any, ...], dtype[float64]] | None = None, srap_max_power: float = 1400.0, srap_deadband: float = 0.0, contingency_deadband: float = 0.0, srap_revert_to_nominal_rating: bool = False, multi_contingency: LinearMultiContingency | None = None, PTDF: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]] = None, available_power: ndarray[tuple[Any, ...], dtype[float64]] = None, srap_used_power: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]] = None, F: ndarray[tuple[Any, ...], dtype[int64]] | None = None, T: ndarray[tuple[Any, ...], dtype[int64]] | None = None, bus_area_indices: ndarray[tuple[Any, ...], dtype[int64]] | None = None, area_names: ndarray[tuple[Any, ...], dtype[float64]] = None, top_n: int = 5, detailed_massive_report: bool = True)[source]ο
Analyze contingency results and add them to the report :param t: time index :param t_prob: probability of the time :param mon_idx: array of monitored branch indices :param nc: NumericalCircuit :param base_flow: base flows array :param base_loading: base loading array :param contingency_flows: flows array after the contingency :param contingency_loadings: loading array after the contingency in the base of the normal rate :param contingency_group_idx: contingency group index :param contingency_group: ContingencyGroup :param using_srap: Inspect contingency using the SRAP conditions :param srap_ratings: Array of protection ratings of the branches to use with SRAP :param srap_max_power: Max amount of power to lower using SRAP conditions :param srap_deadband: (in %) :param contingency_deadband: :param srap_revert_to_nominal_rating: :param multi_contingency: list of buses for SRAP conditions :param PTDF: PTDF for SRAP conditions :param available_power: Array of power available for SRAP :param srap_used_power: (branch, nbus) matrix to stre SRAP usage :param F: Array of From branch indices :param T: Array of To branch indices :param bus_area_indices: Array of area indices per bus :param area_names: Array of area names :param top_n: maximum number of nodes affecting the oveload :param detailed_massive_report: Generate massive report
- get_data(time_array: DatetimeIndex | None = None, time_format='%Y/%m/%d %H:%M.%S') ndarray[tuple[Any, ...], dtype[str_]][source]ο
Get data as list of lists of strings :return: List[List[str]]
- get_df(time_array: DatetimeIndex | None, time_format='%Y/%m/%d %H:%M.%S') DataFrame[source]ο
Get data as pandas DataFrame :return: DataFrame
- get_summary_table(time_array: DatetimeIndex | None, time_format='%Y/%m/%d %H:%M.%S') DataFrame[source]ο
- Parameters:
time_array
time_format
- Returns:
- merge(other: ContingencyResultsReport)[source]ο
Add another ContingencyResultsReport in-place :param other: ContingencyResultsReport instance
- class VeraGridEngine.Simulations.ContingencyAnalysis.contingencies_report.ContingencyTableEntry(time_index: int, t_prob: float, mon_idx: int, con_group_idx: int, area_from: str, area_to: str, base_name: str, contingency_name: str, base_rating: float, contingency_rating: float, srap_rating: float, base_flow: complex, post_contingency_flow: complex, post_srap_flow: complex, base_loading: float, post_contingency_loading: float, post_srap_loading: float, msg_ov: str, msg_srap: str, srap_power: float, solved_by_srap: bool = False)[source]ο
Bases:
objectEntry of a contingency report
- to_array(time_array: DatetimeIndex | None, time_format='%Y/%m/%d %H:%M.%S') ndarray[tuple[Any, ...], dtype[str_]][source]ο
Get array of string values :return: StrVec
- VeraGridEngine.Simulations.ContingencyAnalysis.contingencies_report.get_ptdf_comp(mon_br_idx: int, branch_indices: ndarray[tuple[Any, ...], dtype[int64]], mlodf_factors: csc_matrix, PTDF: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]])[source]ο
Get the compensated PTDF values for a single monitored branch :param mon_br_idx: :param branch_indices: :param mlodf_factors: :param PTDF: :return:
- VeraGridEngine.Simulations.ContingencyAnalysis.contingencies_report.get_ptdf_comp_numba(data: ndarray[tuple[Any, ...], dtype[float64]], indices: ndarray[tuple[Any, ...], dtype[int64]], indptr: ndarray[tuple[Any, ...], dtype[int64]], PTDF: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], m: int, bd_indices: ndarray[tuple[Any, ...], dtype[int64]])[source]ο
This computes the compensatd PTDF for a single branch PTDFc = MLODF[m, Ξ²Ξ΄] x PTDF[Ξ²Ξ΄, :] + PTDF[m, :] :param data: MLODF[:, Ξ²Ξ΄].data :param indices: MLODF[:, Ξ²Ξ΄].indices :param indptr: MLODF[:, Ξ²Ξ΄].indptr :param PTDF: Full PTDF matrix :param m: intex of the monitored branch :param bd_indices: indices of the failed branches :return:
VeraGridEngine.Simulations.ContingencyAnalysis.contingency_analysis_driver moduleο
- class VeraGridEngine.Simulations.ContingencyAnalysis.contingency_analysis_driver.ContingencyAnalysisDriver(grid: MultiCircuit, options: ContingencyAnalysisOptions | None, linear_multiple_contingencies: LinearMultiContingencies | None = None, opf_results: OptimalPowerFlowResults | None = None, engine: EngineType = VeraGrid)[source]ο
Bases:
DriverTemplateContingency analysis driver
- linear_multiple_contingencies: LinearMultiContingenciesο
- name = 'Contingency Analysis'ο
- opf_results: OptimalPowerFlowResults | Noneο
- optionsο
- run_at(t_idx: int = None, t_prob: float = 1.0) ContingencyAnalysisResults[source]ο
Run the contingency at a time point :param t_idx: index for any time series index, None for the snapshot :param t_prob: probability of te time :return: ContingencyAnalysisResults
- tpe = 'Contingency analysis'ο
VeraGridEngine.Simulations.ContingencyAnalysis.contingency_analysis_options moduleο
- class VeraGridEngine.Simulations.ContingencyAnalysis.contingency_analysis_options.ContingencyAnalysisOptions(pf_options: PowerFlowOptions | None = None, lin_options: LinearAnalysisOptions | None = None, use_srap: bool = False, srap_max_power: float = 1400.0, srap_top_n: int = 5, srap_deadband: float = 10, srap_rever_to_nominal_rating: bool = False, detailed_massive_report: bool = False, contingency_deadband: float = 0.0, contingency_method=Power flow, contingency_groups: List[ContingencyGroup] | None = None)[source]ο
Bases:
OptionsTemplateContingency analysis options
- CLASS_NON_EDITABLE_PROPERTIES: Tuple[str, ...] = ('idtag', 'diff_changes')ο
- CLASS_PROPERTIES_WITH_PROFILE: Dict[str, str] = {}ο
- CLASS_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes, prop:use_provided_flows, prop:Pf, prop:contingency_method, prop:pf_options, prop:lin_options, prop:use_srap, prop:srap_max_power, prop:srap_top_n, prop:srap_deadband, prop:srap_rever_to_nominal_rating, prop:detailed_massive_report, prop:contingency_deadband, prop:contingency_groups)ο
- CLASS_PROPERTY_LIST: Tuple[GCProp, ...] = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes, prop:use_provided_flows, prop:Pf, prop:contingency_method, prop:pf_options, prop:lin_options, prop:use_srap, prop:srap_max_power, prop:srap_top_n, prop:srap_deadband, prop:srap_rever_to_nominal_rating, prop:detailed_massive_report, prop:contingency_deadband, prop:contingency_groups)ο
- CLASS_REGISTERED_PROPERTIES: Dict[str, GCProp] = {'Pf': prop:Pf, 'action': prop:action, 'code': prop:code, 'comment': prop:comment, 'contingency_deadband': prop:contingency_deadband, 'contingency_groups': prop:contingency_groups, 'contingency_method': prop:contingency_method, 'detailed_massive_report': prop:detailed_massive_report, 'diff_changes': prop:diff_changes, 'idtag': prop:idtag, 'lin_options': prop:lin_options, 'name': prop:name, 'pf_options': prop:pf_options, 'rdfid': prop:rdfid, 'srap_deadband': prop:srap_deadband, 'srap_max_power': prop:srap_max_power, 'srap_rever_to_nominal_rating': prop:srap_rever_to_nominal_rating, 'srap_top_n': prop:srap_top_n, 'use_provided_flows': prop:use_provided_flows, 'use_srap': prop:use_srap}ο
- LOCAL_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:use_provided_flows, prop:Pf, prop:contingency_method, prop:pf_options, prop:lin_options, prop:use_srap, prop:srap_max_power, prop:srap_top_n, prop:srap_deadband, prop:srap_rever_to_nominal_rating, prop:detailed_massive_report, prop:contingency_deadband, prop:contingency_groups)ο
- action: ActionTypeο
- comment: strο
- device_type: DeviceTypeο
- diff_changesο
- selected_to_mergeο
VeraGridEngine.Simulations.ContingencyAnalysis.contingency_analysis_results moduleο
- class VeraGridEngine.Simulations.ContingencyAnalysis.contingency_analysis_results.ContingencyAnalysisResults(ncon: int, nbus: int, nbr: int, bus_names: ndarray[tuple[Any, ...], dtype[str_]], branch_names: ndarray[tuple[Any, ...], dtype[str_]], bus_types: ndarray[tuple[Any, ...], dtype[int64]], con_names: ndarray[tuple[Any, ...], dtype[str_]])[source]ο
Bases:
ResultsTemplateContingency analysis results
- CLASS_DATA_VARIABLES = {'Sbus': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'Sf': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'Sf_base': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'branch_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'bus_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'bus_types': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'con_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'loading': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'report': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'srap_used_power': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'voltage': <VeraGridEngine.Simulations.results_template.ResultsProperty object>}ο
- CLASS_RESULTS_DECLARATIONS = (<VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>)ο
- LOCAL_RESULTS_DECLARATIONS = (<VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>)ο
- Sbus: CxMatο
- Sf: CxMatο
- Sf_base: CxVecο
- apply_new_rates(nc: NumericalCircuit)[source]ο
Apply new rates :param nc: NumericalCircuit
- branch_namesο
- bus_namesο
- bus_typesο
- con_namesο
- loading: CxMatο
- mdl(result_type: ResultTypes)[source]ο
Plot the results :param result_type: :return:
- report: ContingencyResultsReportο
- srap_used_powerο
- voltage: CxMatο
VeraGridEngine.Simulations.ContingencyAnalysis.contingency_analysis_ts_driver moduleο
- class VeraGridEngine.Simulations.ContingencyAnalysis.contingency_analysis_ts_driver.ContingencyAnalysisTimeSeriesDriver(grid: MultiCircuit, options: ContingencyAnalysisOptions, time_indices: ndarray[tuple[Any, ...], dtype[int64]] | None = None, clustering_results: ClusteringResults | None = None, opf_time_series_results=None, engine: EngineType = VeraGrid)[source]ο
Bases:
TimeSeriesDriverTemplateContingency Analysis Time Series
- branch_names: StrVecο
- name = 'Contingency analysis time series'ο
- opf_time_series_resultsο
- run_contingency_scan() ContingencyAnalysisTimeSeriesResults[source]ο
Run a contngency analysis in series :return: returns the results
- run_gslv() ContingencyAnalysisTimeSeriesResults[source]ο
Run with Newton Power Analytics :return:
- run_linear_contingency_analysis() ContingencyAnalysisTimeSeriesResults[source]ο
Run a contingency analysis in series :return: returns the results
- run_newton_pa() ContingencyAnalysisTimeSeriesResults[source]ο
Run with Newton Power Analytics :return:
- run_nonlinear_contingency_analysis() ContingencyAnalysisTimeSeriesResults[source]ο
Run a contingency analysis in series :return: returns the results
- tpe = 'Contingency analysis time series'ο
VeraGridEngine.Simulations.ContingencyAnalysis.contingency_analysis_ts_results moduleο
- class VeraGridEngine.Simulations.ContingencyAnalysis.contingency_analysis_ts_results.ContingencyAnalysisTimeSeriesResults(n: int, nbr: int, time_array: DatetimeIndex, original_time_array: DatetimeIndex, bus_names: ndarray[tuple[Any, ...], dtype[str_]], branch_names: ndarray[tuple[Any, ...], dtype[str_]], bus_types: ndarray[tuple[Any, ...], dtype[int64]], con_names: ndarray[tuple[Any, ...], dtype[str_]], clustering_results: ClusteringResults | None)[source]ο
Bases:
ResultsTemplateContingency analysis time series results
- CLASS_DATA_VARIABLES = {'S': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'Sf_base': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'branch_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'bus_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'bus_types': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'con_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'max_flows': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'max_loading': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'mean_overload': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'report': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'srap_used_power': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'std_dev_overload': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'sum_overload': <VeraGridEngine.Simulations.results_template.ResultsProperty object>}ο
- CLASS_RESULTS_DECLARATIONS = (<VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>)ο
- LOCAL_RESULTS_DECLARATIONS = (<VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>)ο
- S: Matο
- Sf_base: CxMatο
- apply_new_time_series_rates(nc: NumericalCircuit)[source]ο
Apply new rates :param nc: :return:
- branch_names: StrVecο
- bus_names: StrVecο
- bus_types: IntVecο
Tabla de sobrecargas mΓ‘ximas (tiempo, rama) Tabla de desviaciΓ³n tΓpica (tiempo, rama) Tabla de frecuencia de sobrecarga (tiempo, rama) Tabla de Γndices de la mΓ‘xima sobrecarga (tiempo, rama) Tabla de suma de sobrecarga (tiempo, rama)
- con_names: StrVecο
- max_flows: Matο
- max_loading: Matο
- mdl(result_type: ResultTypes)[source]ο
Plot the results :param result_type: :return:
- mean_overload: Matο
- property nbranch: intο
Number of branches
- property nbus: intο
Number of buses
- property ncon: intο
Number of contingencies
- ntο
- original_time_arrayο
- overload_count: Matο
- report: ContingencyResultsReportο
- srap_used_powerο
- std_dev_overload: Matο
- sum_overload: Matο
VeraGridEngine.Simulations.ContingencyAnalysis.contingency_plan moduleο
- VeraGridEngine.Simulations.ContingencyAnalysis.contingency_plan.add_generator_contingencies(generators: List[Generator], pmin: float, pmax: float, contingency_perc: float, filter_injections_by_power: bool)[source]ο
Create generator contingencies :param generators: Generator list :param pmin: Min power to filter :param pmax: Max power to filter :param contingency_perc: Percentage of power to trigger :param filter_injections_by_power: boolean :return:
- VeraGridEngine.Simulations.ContingencyAnalysis.contingency_plan.add_n1_contingencies(branches: List[Line | DcLine | Transformer2W | HvdcLine | VSC | UPFC | Winding | Switch | SeriesReactance], vmin: float, vmax: float, filter_branches_by_voltage: bool, branch_types: List[DeviceType])[source]ο
generate N-1 contingencies on branches :param branches: :param vmin: :param vmax: :param filter_branches_by_voltage: :param branch_types: :return:
- VeraGridEngine.Simulations.ContingencyAnalysis.contingency_plan.add_n2_contingencies(branches, vmin, vmax, filter_branches_by_voltage, branch_types)[source]ο
Generate N-2 contingencies for branches :param branches: :param vmin: :param vmax: :param filter_branches_by_voltage: :param branch_types: :return:
- VeraGridEngine.Simulations.ContingencyAnalysis.contingency_plan.enumerate_states_n_k(m: int, k: int = 1)[source]ο
Enumerates the states to produce the so called N-k failures :param m: number of Branches :param k: failure level :return: binary array (number of states, m)
- VeraGridEngine.Simulations.ContingencyAnalysis.contingency_plan.generate_automatic_contingency_plan(grid: MultiCircuit, k: int, consider_branches: bool, filter_branches_by_voltage: bool = False, vmin: float = 0, vmax: float = 1000, branch_types: List[DeviceType] | None = None, consider_injections: bool = False, filter_injections_by_power: bool = False, contingency_perc=100.0, pmin=0, pmax=10000, injection_types: List[DeviceType] | None = None) Tuple[List[Contingency], List[ContingencyGroup]][source]ο
- Parameters:
grid β MultiCircuit instance
k β index (1 for N-1, 2 for N-2, other values of k will fail)
consider_branches β consider branches?
filter_branches_by_voltage
vmin
vmax
branch_types β List of allowed branch types
consider_injections β Consider injections?
filter_injections_by_power
contingency_perc
pmin
pmax
injection_types β List of allowed injection types
- Returns: