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- 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_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ο