VeraGridEngine.Simulations.ContinuationPowerFlow package

Submodules

VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow module

class VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow.CpfNumericResults[source]

Bases: object

Sbus
Sf
St
V
add(v: ndarray[tuple[Any, ...], dtype[complex128]], sbus: ndarray[tuple[Any, ...], dtype[complex128]], Sf: ndarray[tuple[Any, ...], dtype[complex128]], St: ndarray[tuple[Any, ...], dtype[complex128]], lam: float, losses: ndarray[tuple[Any, ...], dtype[complex128]], loading: ndarray[tuple[Any, ...], dtype[complex128]], normf: float, converged: bool)[source]
Parameters:
  • v

  • sbus

  • Sf

  • St

  • lam

  • losses

  • loading

  • normf

  • converged

Returns:

lmbda
loading
losses
normF
success
VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow.continuation_nr(Ybus, Cf, Ct, Yf, Yt, branch_rates: ndarray[tuple[Any, ...], dtype[float64]], Sbase: float, Sbus_base: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], Sbus_target: ndarray[tuple[Any, ...], dtype[complex128]], V: ndarray[tuple[Any, ...], dtype[complex128]], distributed_slack: bool, bus_installed_power: ndarray[tuple[Any, ...], dtype[float64]], vd: ndarray[tuple[Any, ...], dtype[int64]], pv: ndarray[tuple[Any, ...], dtype[int64]], pq: ndarray[tuple[Any, ...], dtype[int64]], pqv: ndarray[tuple[Any, ...], dtype[int64]], p: ndarray[tuple[Any, ...], dtype[int64]], step: float, approximation_order: CpfParametrization, adapt_step: bool, step_min: float, step_max: float, error_tol: float = 0.001, tol: float = 1e-06, max_it: int = 20, stop_at=CpfStopAt.Nose, control_q=False, qmax_bus: ndarray[tuple[Any, ...], dtype[float64]] | None = None, qmin_bus: ndarray[tuple[Any, ...], dtype[float64]] | None = None, original_bus_types: ndarray[tuple[Any, ...], dtype[int64]] = None, base_overload_number: int = 0, verbose: bool = False, call_back_fx=None) CpfNumericResults[source]

Runs a full AC continuation power flow using a normalized tangent predictor and selected approximation_order scheme. :param Ybus: Admittance matrix :param Cf: Connectivity matrix of the Branches and the β€œfrom” nodes :param Ct: Connectivity matrix of the Branches and the β€œto” nodes :param Yf: Admittance matrix of the β€œfrom” nodes :param Yt: Admittance matrix of the β€œto” nodes :param branch_rates: array of branch rates to check the overload condition :param Sbase: :param Sbus_base: Power array of the base solvable case :param I0: Bus current Injections (MVA at v=1 p.u.) :param Y0: Bus admittance Injections (MVA at v=1 p.u.) :param Sbus_target: Power array of the case to be solved :param V: Voltage array of the base solved case :param distributed_slack: Distribute the slack? :param bus_installed_power: array of installed power per bus :param vd: Array of slack bus indices :param pv: Array of pv bus indices :param pq: Array of pq bus indices :param pqv: Array of p bus indices :param p: Array of p bus indices :param step: Adaptation step :param approximation_order: order of the approximation {Natural, Arc, Pseudo arc} :param adapt_step: use adaptive step size? :param step_min: minimum step size :param step_max: maximum step size :param error_tol: Error tolerance :param tol: Solutions tolerance :param max_it: Maximum iterations :param stop_at: Value of Lambda to stop at. It can be a number or {β€˜NOSE’, β€˜FULL’} :param control_q: Type of reactive power control :param qmax_bus: Array of maximum reactive power per node :param qmin_bus: Array of minimum reactive power per node :param original_bus_types: array of bus types :param base_overload_number: number of overloads in the base situation (used when stop_at=CpfStopAt.ExtraOverloads) :param verbose: Display additional intermediate information? :param call_back_fx: Function to call on every iteration passing the lambda parameter :return: CpfNumericResults instance

Ported from MATPOWER

Copyright (c) 1996-2015 by Power System Engineering Research Center (PSERC) by Ray Zimmerman, PSERC Cornell, Shrirang Abhyankar, Argonne National Laboratory, and Alexander Flueck, IIT

$Id: runcpf.m 2644 2015-03-11 19:34:22Z ray $

MATPOWER is covered by the 3-clause BSD License (see LICENSE file for details). See http://www.pserc.cornell.edu/matpower/ for more info.

VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow.corrector(Ybus, S0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], V0: ndarray[tuple[Any, ...], dtype[complex128]], idx_dtheta: ndarray[tuple[Any, ...], dtype[int64]], idx_dVm: ndarray[tuple[Any, ...], dtype[int64]], idx_dP: ndarray[tuple[Any, ...], dtype[int64]], idx_dQ: ndarray[tuple[Any, ...], dtype[int64]], lam0, Sxfr, Vprv, lamprv, z, step, parametrization, tol, max_it, verbose, mu_0=1.0, acceleration_parameter=0.5)[source]

Solves the corrector step of a continuation power flow using a full Newton method with selected parametrization scheme.

solves for bus voltages and lambda given the full system admittance matrix (for all buses), the complex bus power injection vector (for all buses), the initial vector of complex bus voltages, and column vectors with the lists of bus indices for the swing bus, PV buses, and PQ buses, respectively. The bus voltage vector contains the set point for generator (including ref bus) buses, and the reference angle of the swing bus, as well as an initial guess for remaining magnitudes and angles.

Uses default options if this parameter is not given. Returns the final complex voltages, a flag which indicates whether it converged or not, the number of iterations performed, and the final lambda.

Parameters:
  • Ybus – Admittance matrix (CSC sparse)

  • S0 – Bus power Injections (MVA)

  • I0 – Bus current Injections (MVA at v=1 p.u.)

  • Y0 – Bus admittance Injections (MVA at v=1 p.u.)

  • V0 – Bus initial voltages

  • idx_dtheta – vector of indices of PV|PQ|PQV|P buses

  • idx_dVm – vector of indices of PQ|P buses

  • idx_dP – vector of indices of PV|PQ|PQV|P buses

  • idx_dQ – vector of indices of PQ|PQV buses

  • lam0 – initial value of lambda (loading parameter)

  • Sxfr – [delP+j*delQ] transfer/loading vector for all buses

  • Vprv – final complex V corrector solution from previous continuation step

  • lamprv – final lambda corrector solution from previous continuation step

  • z – normalized predictor for all buses

  • step – continuation step size

  • parametrization

  • tol – Tolerance (p.u.)

  • max_it – max iterations

  • verbose – print information?

  • mu_0

  • acceleration_parameter

Returns:

Voltage, converged, iterations, lambda, power error, calculated power

VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow.cpf_p(parametrization: CpfParametrization, step: float, z: ndarray[tuple[Any, ...], dtype[float64]], V: ndarray[tuple[Any, ...], dtype[complex128]], lam: ndarray[tuple[Any, ...], dtype[float64]], V_prev: ndarray[tuple[Any, ...], dtype[complex128]], lamprv: ndarray[tuple[Any, ...], dtype[float64]], idx_dtheta: ndarray[tuple[Any, ...], dtype[int64]], idx_dVm: ndarray[tuple[Any, ...], dtype[int64]])[source]

Computes the value of the Current Parametrization Function :param parametrization: Value of option (1: Natural, 2:Arc-length, 3: pseudo arc-length) :param step: continuation step size :param z: normalized tangent prediction vector from previous step :param V: complex bus voltage vector at current solution :param lam: scalar lambda value at current solution :param V_prev: complex bus voltage vector at previous solution :param lamprv: scalar lambda value at previous solution :param idx_dtheta: vector of indices of PV|PQ|PQV|P buses :param idx_dVm: vector of indices of PQ|P buses :return: value of the parametrization function at the current point

VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow.cpf_p_jac(parametrization: CpfParametrization, z, V, lam, Vprv, lamprv, idx_dtheta: ndarray[tuple[Any, ...], dtype[int64]], idx_dVm: ndarray[tuple[Any, ...], dtype[int64]])[source]

Computes partial derivatives of Current Parametrization Function (CPF). :param parametrization: :param z: normalized tangent prediction vector from previous step :param V: complex bus voltage vector at current solution :param lam: scalar lambda value at current solution :param Vprv: complex bus voltage vector at previous solution :param lamprv: scalar lambda value at previous solution :param idx_dtheta: vector of indices of PV|PQ|PQV|P buses :param idx_dVm: vector of indices of PQ|P buses :return: partial of parametrization function w.r.t. voltages

partial of parametrization function w.r.t. lambda

VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow.predictor(V, lam, Ybus, Sxfr, idx_dtheta: ndarray[tuple[Any, ...], dtype[int64]], idx_dVm: ndarray[tuple[Any, ...], dtype[int64]], idx_dP: ndarray[tuple[Any, ...], dtype[int64]], idx_dQ: ndarray[tuple[Any, ...], dtype[int64]], step: float, z, Vprv, lamprv, parametrization: CpfParametrization)[source]

Computes a prediction (approximation) to the next solution of the continuation power flow using a normalized tangent predictor. :param V: complex bus voltage vector at current solution :param lam: scalar lambda value at current solution :param Ybus: complex bus admittance matrix :param Sxfr: complex vector of scheduled transfers (difference between bus Injections in base and target cases) :param idx_dtheta: vector of indices of PV|PQ|PQV|P buses :param idx_dVm: vector of indices of PQ|P buses :param idx_dP: vector of indices of PV|PQ|PQV|P buses :param idx_dQ: vector of indices of PQ|PQV buses :param step: continuation step length :param z: normalized tangent prediction vector from previous step :param Vprv: complex bus voltage vector at previous solution :param lamprv: scalar lambda value at previous solution :param parametrization: Value of cpf parametrization option. :return: V0 : predicted complex bus voltage vector

LAM0 : predicted lambda continuation parameter Z : the normalized tangent prediction vector

VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow_driver module

class VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow_driver.ContinuationPowerFlowDriver(grid: MultiCircuit, options: ContinuationPowerFlowOptions, inputs: ContinuationPowerFlowInput, pf_options: PowerFlowOptions, opf_results: OptimalPowerFlowResults | None = None, t: int | None = None)[source]

Bases: DriverTemplate

get_steps()[source]

List of steps

inputs
name = 'Continuation Power Flow'
opf_results
options
pf_options
progress_callback(lmbda: float) None[source]

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

run()[source]

run the voltage collapse simulation @return:

run_at(t_idx: int | None = None) ContinuationPowerFlowResults[source]

run the voltage collapse simulation @return: ContinuationPowerFlowResults

t_idx
tpe = 'Voltage collapse'

VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow_input module

class VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow_input.ContinuationPowerFlowInput(Sbase: ndarray[tuple[Any, ...], dtype[complex128]], Vbase: ndarray[tuple[Any, ...], dtype[complex128]], Starget: ndarray[tuple[Any, ...], dtype[complex128]], base_overload_number=0)[source]

Bases: object

VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow_options module

class VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow_options.ContinuationPowerFlowOptions[source]

Bases: OptionsTemplate

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:step, prop:approximation_order, prop:adapt_step, prop:step_min, prop:step_max, prop:step_tol, prop:solution_tol, prop:max_it, prop:stop_at, prop:verbose)
CLASS_PROPERTY_LIST: Tuple[GCProp, ...] = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes, prop:step, prop:approximation_order, prop:adapt_step, prop:step_min, prop:step_max, prop:step_tol, prop:solution_tol, prop:max_it, prop:stop_at, prop:verbose)
CLASS_REGISTERED_PROPERTIES: Dict[str, GCProp] = {'action': prop:action, 'adapt_step': prop:adapt_step, 'approximation_order': prop:approximation_order, 'code': prop:code, 'comment': prop:comment, 'diff_changes': prop:diff_changes, 'idtag': prop:idtag, 'max_it': prop:max_it, 'name': prop:name, 'rdfid': prop:rdfid, 'solution_tol': prop:solution_tol, 'step': prop:step, 'step_max': prop:step_max, 'step_min': prop:step_min, 'step_tol': prop:step_tol, 'stop_at': prop:stop_at, 'verbose': prop:verbose}
LOCAL_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:step, prop:approximation_order, prop:adapt_step, prop:step_min, prop:step_max, prop:step_tol, prop:solution_tol, prop:max_it, prop:stop_at, prop:verbose)
action: ActionType
comment: str
device_type: DeviceType
diff_changes
selected_to_merge

VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow_results module

class VeraGridEngine.Simulations.ContinuationPowerFlow.continuation_power_flow_results.ContinuationPowerFlowResults[source]

Bases: ResultsTemplate

CLASS_DATA_VARIABLES = {'Sbus': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'Sf': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'St': <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>, 'converged': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'error': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'lambdas': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'loading': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'losses': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'voltages': <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>)
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>)
Sbus: CxMat
Sf: CxMat
St: CxMat
apply_from_island(results: CpfNumericResults, bus_original_idx, branch_original_idx)[source]

Apply the results of an island to this ContinuationPowerFlowResults instance :param results: CpfNumericResults instance of the island :param bus_original_idx: indices of the buses in the complete grid :param branch_original_idx: indices of the Branches in the complete grid

branch_names: StrVec
bus_names: StrVec
bus_types: IntVec
converged: BoolVec
error: Vec
lambdas: Vec
loading: Mat
losses: CxMat
mdl(result_type: ResultTypes) ResultsTable[source]

Plot the results :param result_type: :return:

voltages: CxMat

Module contents