VeraGridEngine.Simulations.Reliability package

Submodules

VeraGridEngine.Simulations.Reliability.blackout_driver module

class VeraGridEngine.Simulations.Reliability.blackout_driver.CascadingDriver(grid: MultiCircuit, options: PowerFlowOptions, triggering_idx=None, max_additional_islands=1, cascade_type_: CascadeType = LHS, n_lhs_samples_=1000)[source]

Bases: DriverTemplate

cancel()[source]

Cancel the simulation :return:

cascade_type
current_step
get_failed_idx()[source]

Return the array of all failed Branches Returns:

array of all failed Branches

get_table()[source]

Get DataFrame of the failed elements :return: DataFrame

max_additional_islands
n_lhs_samples
name = 'Cascading'
options
perform_step_run()[source]

Perform only one step cascading Returns:

Nothing

static remove_elements(circuit: MultiCircuit, loading_vector, idx=None)[source]

Remove Branches based on loading Returns:

Nothing

static remove_probability_based(numerical_circuit: NumericalCircuit, results: StochasticPowerFlowResults, max_val, min_prob)[source]

Remove Branches based on their chance of overload :param numerical_circuit: :param results: :param max_val: :param min_prob: :return: list of indices actually removed

run()[source]

Run the monte carlo simulation @return:

tpe = 'Cascade'
triggering_idx
class VeraGridEngine.Simulations.Reliability.blackout_driver.CascadingReportElement(removed_idx, pf_results, criteria)[source]

Bases: object

criteria
pf_results
removed_idx
class VeraGridEngine.Simulations.Reliability.blackout_driver.CascadingResults(cascade_type: CascadeType)[source]

Bases: object

cascade_type
events
get_failed_idx()[source]

Return the array of all failed Branches Returns:

array of all failed Branches

get_table()[source]

Get DataFrame of the failed elements :return: DataFrame

plot()[source]

VeraGridEngine.Simulations.Reliability.reliability module

VeraGridEngine.Simulations.Reliability.reliability.compose_states(mttf: float, mttr: float, horizon: int, initially_working: bool = True)[source]

Compose random states vector (on -> off -> on -> …) :param mttf: Mean time to failure (h) :param mttr: Mean time to recovery (h) :param horizon: Time horizon (h) :param initially_working: is the component initially working? :return: Vector of states (size horizon) [1: on, 0: off]

VeraGridEngine.Simulations.Reliability.reliability.compute_loss_of_load_because_of_lack_of_generation(gen_pmax: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], load: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], dt: ndarray[tuple[Any, ...], dtype[float64]])[source]

Compute the loss of load because of lack of generation :param gen_pmax: Matrix of available generation (MW) :param load: Matrix of load (MW) :param dt: Time step array (h) :return: loss of load values in MWh

VeraGridEngine.Simulations.Reliability.reliability.find_different_states(mat1: ndarray[tuple[Any, ...], dtype[int64]], mat2: ndarray[tuple[Any, ...], dtype[int64]])[source]

Find different states :param mat1: Matrix 1 of states :param mat2: Matrix 1 of states :return: Array of states

VeraGridEngine.Simulations.Reliability.reliability.find_time_blocks(horizon: int, all_actives: ndarray[tuple[Any, ...], dtype[int64]])[source]

Get the contigous time blocks of failure :param horizon: number of time steps (ntime) :param all_actives: matrix of active states (ntime, n_device) :return:

VeraGridEngine.Simulations.Reliability.reliability.generate_states_matrix(mttf: ndarray[tuple[Any, ...], dtype[float64]], mttr: ndarray[tuple[Any, ...], dtype[float64]], horizon: int, initially_working: bool = True)[source]

Generate random states vector (on -> off -> on -> …) :param mttf: Vector of Mean time to failure (h) :param mttr: Vector of Mean time to recovery (h) :param horizon: Time horizon (h) :param initially_working: is the component initially working? :return: matrix of states (size horizon, size mttf) [1: on, 0: off]

VeraGridEngine.Simulations.Reliability.reliability.reliability_grid_simulation(nc, grid, n_sim: int, branch_mttf: ndarray[tuple[Any, ...], dtype[float64]], branch_mttr: ndarray[tuple[Any, ...], dtype[float64]], dt: ndarray[tuple[Any, ...], dtype[float64]], tol=1e-06)[source]
Parameters:
  • n_sim

  • gen_mttf

  • gen_mttr

  • dt

  • tol

Returns:

VeraGridEngine.Simulations.Reliability.reliability.reliability_simulation(n_sim: int, load_profile: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_profile: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_p_max: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_p_min: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_dispatchable: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_active: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_cost: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_mttf: ndarray[tuple[Any, ...], dtype[float64]], gen_mttr: ndarray[tuple[Any, ...], dtype[float64]], batt_active: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_p_max_charge: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_p_max_discharge: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_energy_max: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_eff_charge: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_eff_discharge: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_cost: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_soc0: ndarray[tuple[Any, ...], dtype[float64]], batt_soc_min: ndarray[tuple[Any, ...], dtype[float64]], dt: ndarray[tuple[Any, ...], dtype[float64]], force_charge_if_low: bool = True, tol=1e-06)[source]
Parameters:
  • n_sim

  • load_profile

  • gen_profile

  • gen_p_max

  • gen_p_min

  • gen_dispatchable

  • gen_active

  • gen_cost

  • gen_mttf

  • gen_mttr

  • batt_active

  • batt_p_max_charge

  • batt_p_max_discharge

  • batt_energy_max

  • batt_eff_charge

  • batt_eff_discharge

  • batt_soc0

  • batt_soc_min

  • batt_cost

  • dt

  • force_charge_if_low

  • tol

Returns:

VeraGridEngine.Simulations.Reliability.reliability2 module

VeraGridEngine.Simulations.Reliability.reliability2.compute_transition_probabilities(mttf: ndarray[tuple[Any, ...], dtype[float64]], mttr: ndarray[tuple[Any, ...], dtype[float64]], forced_mttf: None | float, forced_mttr: None | float) Tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]

Compute the transition probabilities :param mttf: Vector of mean-time-to-failures :param mttr: Vector of mean-time-to-recoveries :param forced_mttf: forced mttf value (used if not None) :param forced_mttr: forced mttr value (used if not None) :return: Probability of being up, Probability of being down

VeraGridEngine.Simulations.Reliability.reliability2.get_failure_time(mttf)[source]

Get an array of possible failure times :param mttf: mean time to failure

VeraGridEngine.Simulations.Reliability.reliability2.get_reliability_events(horizon, mttf, mttr, tpe: DeviceType)[source]

Get random fail-repair events until a given time horizon in hours

Parameters:
  • horizon – maximum horizon in hours

  • mttf – Mean time to failure (h)

  • mttr – Mean time to repair (h)

  • tpe – device type (DeviceType)

Returns:

list of events, each event tuple has: (time in hours, element index, activation state (True/False))

VeraGridEngine.Simulations.Reliability.reliability2.get_reliability_scenario(nc: NumericalCircuit, horizon=10000)[source]

Get reliability events :param nc: numerical circuit instance :param horizon: time horizon in hours :return: dictionary of events, each event tuple has: (time in hours, DataType, element index, activation state (True/False))

VeraGridEngine.Simulations.Reliability.reliability2.get_repair_time(mttr)[source]

Get an array of possible repair times :param mttr: mean time to recovery

VeraGridEngine.Simulations.Reliability.reliability2.get_transition_probabilities(lbda: ndarray[tuple[Any, ...], dtype[float64]], mu: ndarray[tuple[Any, ...], dtype[float64]]) Tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]

Probability of the component being unavailable See: Power distribution system reliability p.67 :param lbda: failure rate ( 1 / mttf) :param mu: repair rate (1 / mttr) :return: availability probability, unavailability probability

VeraGridEngine.Simulations.Reliability.reliability2.run_events(nc: NumericalCircuit, events_list: list)[source]
Parameters:
  • nc

  • events_list

VeraGridEngine.Simulations.Reliability.reliability_driver module

class VeraGridEngine.Simulations.Reliability.reliability_driver.ReliabilityStudyDriver(grid: MultiCircuit, pf_options: PowerFlowOptions, reliability_mode: ReliabilityMode = Generation Adequacy, time_indices=None, n_sim: int = 1000000)[source]

Bases: DriverTemplate

cancel()[source]

Cancel the simulation

greedy_dispatch_inputs
n_sim
name = 'Reliability analysis'
pf_options
progress_callback(lmbda: float)[source]

Send progress report :param lmbda: lambda value :return: None

reliability_mode
run()[source]

Run reliability

run_adequacy_reliability()[source]

run the voltage collapse simulation @return:

run_grid_reliability() None[source]

run the voltage collapse simulation @return:

time_indices
tpe = 'Reliability'
VeraGridEngine.Simulations.Reliability.reliability_driver.count_device_incidences(active_states: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]]) int[source]

Count device incidence starts in an active-state matrix.

An incidence is counted when one device changes from active to inactive. If one device is already inactive at t=0, that also counts as one incidence. The matrix is organized as (time, device).

Parameters:

active_states – Boolean matrix of shape (time, device)

Returns:

Number of incidences.

VeraGridEngine.Simulations.Reliability.reliability_driver.get_gen_pmax(nt: int, k: int, Snom: float, P_array: ndarray[tuple[Any, ...], dtype[float64]], active_array: ndarray[tuple[Any, ...], dtype[bool]], dispatchable_array: ndarray[tuple[Any, ...], dtype[bool]])[source]

Get a generator array of Pmax given the active and dispatchable conditions :param nt: Number of time steps :param k: Generator index :param Snom: Nominal power :param P_array: Array of P :param active_array: array of active :param dispatchable_array: array of dispatchable :return: Array of possible Pmax

VeraGridEngine.Simulations.Reliability.reliability_iterable module

class VeraGridEngine.Simulations.Reliability.reliability_iterable.ReliabilityIterable(grid: MultiCircuit, forced_mttf: None | float = None, forced_mttr: None | float = None, logger: Logger = <VeraGridEngine.basic_structures.Logger object>)[source]

Bases: object

RealTimeStateEnumeration

VeraGridEngine.Simulations.Reliability.reliability_results module

class VeraGridEngine.Simulations.Reliability.reliability_results.ReliabilityResults(nsim: int)[source]

Bases: ResultsTemplate

CAIDI_evolution
CLASS_DATA_VARIABLES = {'CAIDI_evolution': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'ENS_evolution': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'LOLET_evolution': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'LOLE_evolution': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'LOLFT_evolution': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'LOLF_evolution': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'SAIDI_evolution': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'SAIFI_evolution': <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>)
ENS_evolution
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>)
LOLET_evolution
LOLE_evolution
LOLFT_evolution
LOLF_evolution
SAIDI_evolution
SAIFI_evolution
mdl(result_type: ResultTypes) ResultsTable[source]

Plot the results. :param result_type: ResultTypes :return: ResultsModel

Module contents