VeraGridEngine.Simulations.PowerFlow.Formulations package

Submodules

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_advanced_formulation module

class VeraGridEngine.Simulations.PowerFlow.Formulations.pf_advanced_formulation.PfAdvancedFormulation(V0: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], Qmin: ndarray[tuple[Any, ...], dtype[float64]], Qmax: ndarray[tuple[Any, ...], dtype[float64]], nc: NumericalCircuit, options: PowerFlowOptions, logger: Logger)[source]

Bases: PfFormulationTemplate

Jacobian(autodiff: bool = False) CSC[source]

Get the Jacobian :return:

analyze_branch_controls() List[int][source]

Analyze the control branches and compute the indices :return: k_v_m for later comparison with pqv

check_error(x: ndarray[tuple[Any, ...], dtype[float64]]) Tuple[float, ndarray[tuple[Any, ...], dtype[float64]]][source]

Check error of the solution without affecting the problem :param x: Solution vector :return: error

fx() ndarray[tuple[Any, ...], dtype[float64]][source]
Returns:

fx_diff(x: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[float64]][source]

Fx for autodiff :param x: solutions vector :return: f(x)

get_fx_names() List[str][source]

Names matching fx :return:

get_solution(elapsed: float, iterations: int) NumericPowerFlowResults[source]

Get the problem solution :param elapsed: Elapsed seconds :param iterations: Iteration number :return: NumericPowerFlowResults

get_x_names() List[str][source]

Names matching x :return:

size() int[source]

Size of the jacobian matrix :return:

update(x: ndarray[tuple[Any, ...], dtype[float64]], update_controls: bool = False) Tuple[float, bool, ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]

Update step :param x: Solution vector :param update_controls: :return: error, converged?, x, fx

update_bus_types(pq: ndarray[tuple[Any, ...], dtype[int64]], pv: ndarray[tuple[Any, ...], dtype[int64]], pqv: ndarray[tuple[Any, ...], dtype[int64]], p: ndarray[tuple[Any, ...], dtype[int64]]) None[source]

Update the bus types :param pq: Array of PQ indices :param pv: Array of PV indices :param pqv: Array of PQV indices :param p: Array of P indices

var2x() ndarray[tuple[Any, ...], dtype[float64]][source]

Convert the internal decision variables into the vector :return: Vector

x2var(x: ndarray[tuple[Any, ...], dtype[float64]]) None[source]

Convert X to decision variables :param x: solution vector

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_advanced_formulation.adv_jacobian(nbus: int, nbr: int, idx_dva: ndarray[tuple[Any, ...], dtype[int64]], idx_dvm: ndarray[tuple[Any, ...], dtype[int64]], idx_dm: ndarray[tuple[Any, ...], dtype[int64]], idx_dtau: ndarray[tuple[Any, ...], dtype[int64]], idx_dP: ndarray[tuple[Any, ...], dtype[int64]], idx_dQ: ndarray[tuple[Any, ...], dtype[int64]], idx_dPf: ndarray[tuple[Any, ...], dtype[int64]], idx_dQf: ndarray[tuple[Any, ...], dtype[int64]], idx_dPt: ndarray[tuple[Any, ...], dtype[int64]], idx_dQt: ndarray[tuple[Any, ...], dtype[int64]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], Ys: ndarray[tuple[Any, ...], dtype[complex128]], complex_tap: ndarray[tuple[Any, ...], dtype[complex128]], tap_modules: ndarray[tuple[Any, ...], dtype[float64]], Bc: ndarray[tuple[Any, ...], dtype[float64]], V: ndarray[tuple[Any, ...], dtype[complex128]], Vm: ndarray[tuple[Any, ...], dtype[float64]], Va: ndarray[tuple[Any, ...], dtype[float64]], Ybus_x: ndarray[tuple[Any, ...], dtype[complex128]], Ybus_p: ndarray[tuple[Any, ...], dtype[int64]], Ybus_i: ndarray[tuple[Any, ...], dtype[int64]], yff: ndarray[tuple[Any, ...], dtype[complex128]], yft: ndarray[tuple[Any, ...], dtype[complex128]], ytf: ndarray[tuple[Any, ...], dtype[complex128]], ytt: ndarray[tuple[Any, ...], dtype[complex128]]) CSC[source]

Compute the advanced jacobian :param nbus: :param nbr: :param idx_dva: :param idx_dvm: :param idx_dm: :param idx_dtau: :param idx_dP: :param idx_dQ: :param idx_dQf: :param idx_dPf: :param idx_dPt: :param idx_dQt: :param F: :param T: :param Ys: Series admittance 1 / (R + jX) :param complex_tap: :param tap_modules: :param Bc: Total changing susceptance :param V: :param Vm: :param Va: :param Ybus_x: :param Ybus_p: :param Ybus_i: :param yff: :param yft: :param ytf: :param ytt: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_advanced_formulation.calc_autodiff_jacobian(func: Callable[[ndarray[tuple[Any, ...], dtype[float64]]], ndarray[tuple[Any, ...], dtype[float64]]], x: ndarray[tuple[Any, ...], dtype[float64]], h=1e-08) csc_matrix[source]

Compute the Jacobian matrix of func at x using finite differences.

Parameters:
  • func – function accepting a vector x and args, and returning either a vector or a tuple where the first argument is a vector and the second.

  • x – Point at which to evaluate the Jacobian (numpy array).

  • h – Small step for finite difference.

Returns:

Jacobian matrix as a CSC matrix.

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation module

class VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation.PfBasicFormulation(V0: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], Qmin: ndarray[tuple[Any, ...], dtype[float64]], Qmax: ndarray[tuple[Any, ...], dtype[float64]], nc: NumericalCircuit, options: PowerFlowOptions)[source]

Bases: PfFormulationTemplate

Jacobian() CSC[source]
Returns:

check_error(x: ndarray[tuple[Any, ...], dtype[float64]]) Tuple[float, ndarray[tuple[Any, ...], dtype[float64]]][source]

Check error of the solution without affecting the problem :param x: Solution vector :return: error

fx() ndarray[tuple[Any, ...], dtype[float64]][source]
Returns:

get_fx_names() List[str][source]

Names matching fx :return:

get_solution(elapsed: float, iterations: int) NumericPowerFlowResults[source]

Get the problem solution :param elapsed: Elapsed seconds :param iterations: Iteration number :return: NumericPowerFlowResults

get_x_names() List[str][source]

Names matching x :return:

size() int[source]

Size of the jacobian matrix :return:

update(x: ndarray[tuple[Any, ...], dtype[float64]], update_controls: bool = False) Tuple[float, bool, ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]

Update step :param x: Solution vector :param update_controls: :return: error, converged?, x

update_bus_types(pq: ndarray[tuple[Any, ...], dtype[int64]], pv: ndarray[tuple[Any, ...], dtype[int64]], pqv: ndarray[tuple[Any, ...], dtype[int64]], p: ndarray[tuple[Any, ...], dtype[int64]])[source]
Parameters:
  • pq

  • pv

  • pqv

  • p

Returns:

var2x() ndarray[tuple[Any, ...], dtype[float64]][source]

Convert the internal decision variables into the vector :return: Vector

x2var(x: ndarray[tuple[Any, ...], dtype[float64]])[source]

Convert X to decision variables :param x: solution vector

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph module

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_formulation_template module

class VeraGridEngine.Simulations.PowerFlow.Formulations.pf_formulation_template.PfFormulationTemplate(V0: ndarray[tuple[Any, ...], dtype[complex128]], options: PowerFlowOptions)[source]

Bases: object

Base Power Flow Formulation class

Jacobian() CSC[source]
Returns:

property Va: ndarray[tuple[Any, ...], dtype[float64]]

Voltage angles :return:

property Vm: ndarray[tuple[Any, ...], dtype[float64]]

Voltage modules :return:

check_error(x: ndarray[tuple[Any, ...], dtype[float64]]) Tuple[float, ndarray[tuple[Any, ...], dtype[float64]]][source]

Check error of the solution without affecting the problem :param x: Solution vector :return: error

property converged: bool

Converged? :return:

property error: float

Converged? :return:

property f: ndarray[tuple[Any, ...], dtype[float64]]

Converged? :return:

fx() ndarray[tuple[Any, ...], dtype[float64]][source]
Returns:

get_f_df(f=None) DataFrame[source]

Get the f(x) DataFrame

get_fx_names() List[str][source]

Names matching fx :return:

get_jacobian_df(J=None, autodiff=False) DataFrame[source]

Get the Jacobian DataFrame :return: DataFrame

get_solution(elapsed: float, iterations: int) NumericPowerFlowResults[source]
Returns:

get_x_df(x=None) DataFrame[source]

Get the x DataFrame

get_x_names() List[str][source]

Names matching x :return:

size() int[source]

Size of the jacobian matrix :return:

solve_step() Tuple[ndarray[tuple[Any, ...], dtype[float64]], bool][source]
Returns:

solve_step_from_f(f: ndarray[tuple[Any, ...], dtype[float64]]) Tuple[ndarray[tuple[Any, ...], dtype[float64]], bool][source]
Parameters:

f – Function residual

Returns:

update(x: ndarray[tuple[Any, ...], dtype[float64]], update_controls: bool = False) Tuple[float, bool, ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]

Update the problem :param x: Solution vector :param update_controls: Update controls :return: error, converged, x, f

var2x() ndarray[tuple[Any, ...], dtype[float64]][source]

Convert the internal decision variables into the vector

x2var(x: ndarray[tuple[Any, ...], dtype[float64]])[source]

Convert X to decision variables :param x: solution vector

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles module

class VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles.PfAcDcWithNegativePoles(V0: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], Qmin: ndarray[tuple[Any, ...], dtype[float64]], Qmax: ndarray[tuple[Any, ...], dtype[float64]], nc: NumericalCircuit, options: PowerFlowOptions, logger: Logger)[source]

Bases: PfFormulationTemplate

Jacobian(autodiff: bool = True) CSC[source]

Get the Jacobian :return:

check_error(x: ndarray[tuple[Any, ...], dtype[float64]]) Tuple[float, ndarray[tuple[Any, ...], dtype[float64]]][source]

Check error of the solution without affecting the problem :param x: Solution vector :return: error

compute_f(x: ndarray[tuple[Any, ...], dtype[float64]], update_class_vars: bool = False) ndarray[tuple[Any, ...], dtype[float64]][source]

Compute the residual vector :param x: Solution vector :param update_class_vars: Update the class vars related to the calculation step :return: Residual vector

fx() ndarray[tuple[Any, ...], dtype[float64]][source]

Used when updating the controls :return:

get_fx_names() List[str][source]

Names matching fx :return:

get_solution(elapsed: float, iterations: int) NumericPowerFlowResults[source]

Get the problem solution :param elapsed: Elapsed seconds :param iterations: Iteration number :return: NumericPowerFlowResults

get_x_names() List[str][source]

Names matching x :return:

size() int[source]

Size of the jacobian matrix :return:

update(x: ndarray[tuple[Any, ...], dtype[float64]], update_controls: bool = False) Tuple[float, bool, ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]

Update step :param x: Solution vector :param update_controls: :return: error, converged?, x, fx

var2x() ndarray[tuple[Any, ...], dtype[float64]][source]

Convert the internal decision variables into the vector :return: Vector

x2var(x: ndarray[tuple[Any, ...], dtype[float64]]) None[source]

Convert X to decision variables :param x: solution vector

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles.adv_jacobian(nbus: int, nbr: int, nvsc: int, nhvdc: int, F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], Fdcp_vsc: ndarray[tuple[Any, ...], dtype[int64]], Fdcn_vsc: ndarray[tuple[Any, ...], dtype[int64]], T_vsc: ndarray[tuple[Any, ...], dtype[int64]], F_hvdc: ndarray[tuple[Any, ...], dtype[int64]], T_hvdc: ndarray[tuple[Any, ...], dtype[int64]], tap_angles: ndarray[tuple[Any, ...], dtype[float64]], tap_modules: ndarray[tuple[Any, ...], dtype[float64]], V: ndarray[tuple[Any, ...], dtype[complex128]], Vm: ndarray[tuple[Any, ...], dtype[float64]], Va: ndarray[tuple[Any, ...], dtype[float64]], I0: ndarray[tuple[Any, ...], dtype[complex128]], u_cbr_m: ndarray[tuple[Any, ...], dtype[int64]], u_cbr_tau: ndarray[tuple[Any, ...], dtype[int64]], k_cbr_pf: ndarray[tuple[Any, ...], dtype[int64]], k_cbr_pt: ndarray[tuple[Any, ...], dtype[int64]], k_cbr_qf: ndarray[tuple[Any, ...], dtype[int64]], k_cbr_qt: ndarray[tuple[Any, ...], dtype[int64]], u_vsc_pfp: ndarray[tuple[Any, ...], dtype[int64]], u_vsc_pfn: ndarray[tuple[Any, ...], dtype[int64]], u_vsc_pt: ndarray[tuple[Any, ...], dtype[int64]], u_vsc_qt: ndarray[tuple[Any, ...], dtype[int64]], k_vsc_has_dc_n: ndarray[tuple[Any, ...], dtype[int64]], k_vsc_imax: ndarray[tuple[Any, ...], dtype[int64]], alpha1: ndarray[tuple[Any, ...], dtype[float64]], alpha2: ndarray[tuple[Any, ...], dtype[float64]], alpha3: ndarray[tuple[Any, ...], dtype[float64]], hvdc_r: ndarray[tuple[Any, ...], dtype[float64]], hvdc_droop: ndarray[tuple[Any, ...], dtype[float64]], i_u_vm: ndarray[tuple[Any, ...], dtype[int64]], i_u_va: ndarray[tuple[Any, ...], dtype[int64]], i_k_p: ndarray[tuple[Any, ...], dtype[int64]], i_k_q: ndarray[tuple[Any, ...], dtype[int64]], Pfp_vsc: ndarray[tuple[Any, ...], dtype[float64]], Pfn_vsc: ndarray[tuple[Any, ...], dtype[float64]], k_vsc_pfp_droop: ndarray[tuple[Any, ...], dtype[int64]], dpfp_droop_slope: ndarray[tuple[Any, ...], dtype[float64]], k_vsc_vmdc_diff: ndarray[tuple[Any, ...], dtype[int64]], k_vsc_pdc: ndarray[tuple[Any, ...], dtype[int64]], Pt_vsc: ndarray[tuple[Any, ...], dtype[float64]], Qt_vsc: ndarray[tuple[Any, ...], dtype[float64]], Pf_hvdc: ndarray[tuple[Any, ...], dtype[float64]], Ys: ndarray[tuple[Any, ...], dtype[complex128]], Bc: ndarray[tuple[Any, ...], dtype[float64]], yff_cbr: ndarray[tuple[Any, ...], dtype[complex128]], yft_cbr: ndarray[tuple[Any, ...], dtype[complex128]], ytf_cbr: ndarray[tuple[Any, ...], dtype[complex128]], ytt_cbr: ndarray[tuple[Any, ...], dtype[complex128]], Yi: ndarray[tuple[Any, ...], dtype[int64]], Yp: ndarray[tuple[Any, ...], dtype[int64]], Yx: ndarray[tuple[Any, ...], dtype[complex128]]) CSC[source]
Parameters:
  • nbus

  • nbr

  • nvsc

  • nhvdc

  • F

  • T

  • Fdcp_vsc

  • Fdcn_vsc

  • T_vsc

  • F_hvdc

  • T_hvdc

  • tap_angles

  • tap_modules

  • V

  • Vm

  • Va

  • I0 – Current injections vector (for Norton equivalent in short-circuit)

  • u_cbr_m

  • u_cbr_tau

  • k_cbr_pf

  • k_cbr_pt

  • k_cbr_qf

  • k_cbr_qt

  • u_vsc_pfp

  • u_vsc_pfn

  • u_vsc_pt

  • u_vsc_qt

  • alpha1

  • alpha2

  • alpha3

  • hvdc_r

  • hvdc_droop

  • i_u_vm

  • i_u_va

  • i_k_p

  • i_k_q

  • Pfp_vsc

  • Pfn_vsc

  • k_vsc_pfp_droop

  • dpfp_droop_slope

  • k_vsc_vmdc_diff

  • Pt_vsc

  • Qt_vsc

  • Pf_hvdc

  • Ys

  • Bc

  • yff_cbr

  • yft_cbr

  • ytf_cbr

  • ytt_cbr

  • Yi

  • Yp

  • Yx

Returns:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles.calcSf(k: ndarray[tuple[Any, ...], dtype[int64]], V: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], R: ndarray[tuple[Any, ...], dtype[float64]], X: ndarray[tuple[Any, ...], dtype[float64]], G: ndarray[tuple[Any, ...], dtype[float64]], B: ndarray[tuple[Any, ...], dtype[float64]], m: ndarray[tuple[Any, ...], dtype[float64]], tau: ndarray[tuple[Any, ...], dtype[float64]], vtap_f: ndarray[tuple[Any, ...], dtype[float64]], vtap_t: ndarray[tuple[Any, ...], dtype[float64]])[source]

Compute Sf for pi branches :param k: :param V: :param F: :param T: :param R: :param X: :param G: :param B: :param m: :param tau: :param vtap_f: :param vtap_t: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles.calcSt(k: ndarray[tuple[Any, ...], dtype[int64]], V: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], R: ndarray[tuple[Any, ...], dtype[float64]], X: ndarray[tuple[Any, ...], dtype[float64]], G: ndarray[tuple[Any, ...], dtype[float64]], B: ndarray[tuple[Any, ...], dtype[float64]], m: ndarray[tuple[Any, ...], dtype[float64]], tau: ndarray[tuple[Any, ...], dtype[float64]], vtap_f: ndarray[tuple[Any, ...], dtype[float64]], vtap_t: ndarray[tuple[Any, ...], dtype[float64]])[source]

Compute St for pi branches :param k: :param V: :param F: :param T: :param R: :param X: :param G: :param B: :param m: :param tau: :param vtap_f: :param vtap_t: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles.calc_autodiff_jacobian(func: Callable[[ndarray[tuple[Any, ...], dtype[float64]]], ndarray[tuple[Any, ...], dtype[float64]]], x: ndarray[tuple[Any, ...], dtype[float64]], h=1e-08) CSC[source]

Compute the Jacobian matrix of func at x using finite differences.

Parameters:
  • func – function accepting a vector x and args, and returning either a vector or a tuple where the first argument is a vector and the second.

  • x – Point at which to evaluate the Jacobian (numpy array).

  • h – Small step for finite difference.

Returns:

Jacobian matrix as a CSC matrix.

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles.calc_flows_active_branch_per_bus(nbus: int, F_hvdc: ndarray[tuple[Any, ...], dtype[int64]], T_hvdc: ndarray[tuple[Any, ...], dtype[int64]], Sf_hvdc: ndarray[tuple[Any, ...], dtype[complex128]], St_hvdc: ndarray[tuple[Any, ...], dtype[complex128]], Fdcp_vsc: ndarray[tuple[Any, ...], dtype[int64]], Fdcn_vsc: ndarray[tuple[Any, ...], dtype[int64]], T_vsc: ndarray[tuple[Any, ...], dtype[int64]], Pfp_vsc: ndarray[tuple[Any, ...], dtype[float64]], Pfn_vsc: ndarray[tuple[Any, ...], dtype[float64]], St_vsc: ndarray[tuple[Any, ...], dtype[complex128]]) ndarray[tuple[Any, ...], dtype[complex128]][source]

Summation of magnitudes per bus (complex) Used to add effects of VSCs and HVDCs to the traditional branches (lines and controllable transformers) :param nbus: :param F_hvdc: :param T_hvdc: :param Sf_hvdc: :param St_hvdc: :param Fdcp_vsc: :param Fdcn_vsc: :param T_vsc: :param Pfp_vsc: :param Pfn_vsc: :param St_vsc: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles.calc_flows_summation_per_bus(nbus: int, F_br: ndarray[tuple[Any, ...], dtype[int64]], T_br: ndarray[tuple[Any, ...], dtype[int64]], Sf_br: ndarray[tuple[Any, ...], dtype[complex128]], St_br: ndarray[tuple[Any, ...], dtype[complex128]], F_hvdc: ndarray[tuple[Any, ...], dtype[int64]], T_hvdc: ndarray[tuple[Any, ...], dtype[int64]], Sf_hvdc: ndarray[tuple[Any, ...], dtype[complex128]], St_hvdc: ndarray[tuple[Any, ...], dtype[complex128]], Fdcp_vsc: ndarray[tuple[Any, ...], dtype[int64]], Fdcn_vsc: ndarray[tuple[Any, ...], dtype[int64]], T_vsc: ndarray[tuple[Any, ...], dtype[int64]], Pfp_vsc: ndarray[tuple[Any, ...], dtype[float64]], Pfn_vsc: ndarray[tuple[Any, ...], dtype[float64]], St_vsc: ndarray[tuple[Any, ...], dtype[complex128]]) ndarray[tuple[Any, ...], dtype[complex128]][source]

Summation of magnitudes per bus (complex) Includes everything: VSCs, HVDCs, and all traditional branches (lines and controllable transformers) :param nbus: :param F_br: :param T_br: :param Sf_br: :param St_br: :param F_hvdc: :param T_hvdc: :param Sf_hvdc: :param St_hvdc: :param Fdcp_vsc: :param Fdcn_vsc: :param T_vsc: :param Pfp_vsc: :param Pfn_vsc: :param St_vsc: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles_sc module

class VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles_sc.PfAcDcWithNegativePolesSc(V0: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], St_vsc_pf: ndarray[tuple[Any, ...], dtype[complex128]], Qmin: ndarray[tuple[Any, ...], dtype[float64]], Qmax: ndarray[tuple[Any, ...], dtype[float64]], nc: NumericalCircuit, options: PowerFlowOptions, logger: Logger)[source]

Bases: PfFormulationTemplate

Jacobian(autodiff: bool = True) CSC[source]

Get the Jacobian :return:

check_error(x: ndarray[tuple[Any, ...], dtype[float64]]) Tuple[float, ndarray[tuple[Any, ...], dtype[float64]]][source]

Check error of the solution without affecting the problem :param x: Solution vector :return: error

compute_f(x: ndarray[tuple[Any, ...], dtype[float64]], update_class_vars: bool = False) ndarray[tuple[Any, ...], dtype[float64]][source]

Compute the residual vector :param x: Solution vector :param update_class_vars: Update the class vars related to the calculation step :return: Residual vector

fx() ndarray[tuple[Any, ...], dtype[float64]][source]

Used when updating the controls :return:

get_fx_names() List[str][source]

Names matching fx :return:

get_solution(elapsed: float, iterations: int) NumericPowerFlowResults[source]

Get the problem solution :param elapsed: Elapsed seconds :param iterations: Iteration number :return: NumericPowerFlowResults

get_x_names() List[str][source]

Names matching x :return:

size() int[source]

Size of the jacobian matrix :return:

update(x: ndarray[tuple[Any, ...], dtype[float64]], update_controls: bool = False) Tuple[float, bool, ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]

Update step :param x: Solution vector :param update_controls: :return: error, converged?, x, fx

var2x() ndarray[tuple[Any, ...], dtype[float64]][source]

Convert the internal decision variables into the vector :return: Vector

x2var(x: ndarray[tuple[Any, ...], dtype[float64]]) None[source]

Convert X to decision variables :param x: solution vector

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles_sc.adv_jacobian(nbus: int, nbr: int, nvsc: int, nhvdc: int, F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], Fdcp_vsc: ndarray[tuple[Any, ...], dtype[int64]], Fdcn_vsc: ndarray[tuple[Any, ...], dtype[int64]], T_vsc: ndarray[tuple[Any, ...], dtype[int64]], F_hvdc: ndarray[tuple[Any, ...], dtype[int64]], T_hvdc: ndarray[tuple[Any, ...], dtype[int64]], tap_angles: ndarray[tuple[Any, ...], dtype[float64]], tap_modules: ndarray[tuple[Any, ...], dtype[float64]], V: ndarray[tuple[Any, ...], dtype[complex128]], Vm: ndarray[tuple[Any, ...], dtype[float64]], Va: ndarray[tuple[Any, ...], dtype[float64]], I0: ndarray[tuple[Any, ...], dtype[complex128]], u_cbr_m: ndarray[tuple[Any, ...], dtype[int64]], u_cbr_tau: ndarray[tuple[Any, ...], dtype[int64]], k_cbr_pf: ndarray[tuple[Any, ...], dtype[int64]], k_cbr_pt: ndarray[tuple[Any, ...], dtype[int64]], k_cbr_qf: ndarray[tuple[Any, ...], dtype[int64]], k_cbr_qt: ndarray[tuple[Any, ...], dtype[int64]], u_vsc_pfp: ndarray[tuple[Any, ...], dtype[int64]], u_vsc_pfn: ndarray[tuple[Any, ...], dtype[int64]], u_vsc_pt: ndarray[tuple[Any, ...], dtype[int64]], u_vsc_qt: ndarray[tuple[Any, ...], dtype[int64]], k_vsc_has_dc_n: ndarray[tuple[Any, ...], dtype[int64]], k_vsc_imax: ndarray[tuple[Any, ...], dtype[int64]], alpha1: ndarray[tuple[Any, ...], dtype[float64]], alpha2: ndarray[tuple[Any, ...], dtype[float64]], alpha3: ndarray[tuple[Any, ...], dtype[float64]], hvdc_r: ndarray[tuple[Any, ...], dtype[float64]], hvdc_droop: ndarray[tuple[Any, ...], dtype[float64]], i_u_vm: ndarray[tuple[Any, ...], dtype[int64]], i_u_va: ndarray[tuple[Any, ...], dtype[int64]], i_k_p: ndarray[tuple[Any, ...], dtype[int64]], i_k_q: ndarray[tuple[Any, ...], dtype[int64]], Pfp_vsc: ndarray[tuple[Any, ...], dtype[float64]], Pfn_vsc: ndarray[tuple[Any, ...], dtype[float64]], Pt_vsc: ndarray[tuple[Any, ...], dtype[float64]], Qt_vsc: ndarray[tuple[Any, ...], dtype[float64]], Pf_hvdc: ndarray[tuple[Any, ...], dtype[float64]], Ys: ndarray[tuple[Any, ...], dtype[complex128]], Bc: ndarray[tuple[Any, ...], dtype[float64]], yff_cbr: ndarray[tuple[Any, ...], dtype[complex128]], yft_cbr: ndarray[tuple[Any, ...], dtype[complex128]], ytf_cbr: ndarray[tuple[Any, ...], dtype[complex128]], ytt_cbr: ndarray[tuple[Any, ...], dtype[complex128]], Yi: ndarray[tuple[Any, ...], dtype[int64]], Yp: ndarray[tuple[Any, ...], dtype[int64]], Yx: ndarray[tuple[Any, ...], dtype[complex128]]) CSC[source]
Parameters:
  • nbus

  • nbr

  • nvsc

  • nhvdc

  • F

  • T

  • Fdcp_vsc

  • Fdcn_vsc

  • T_vsc

  • F_hvdc

  • T_hvdc

  • tap_angles

  • tap_modules

  • V

  • Vm

  • Va

  • I0 – Current injections vector (for Norton equivalent in short-circuit)

  • u_cbr_m

  • u_cbr_tau

  • k_cbr_pf

  • k_cbr_pt

  • k_cbr_qf

  • k_cbr_qt

  • u_vsc_pfp

  • u_vsc_pfn

  • u_vsc_pt

  • u_vsc_qt

  • alpha1

  • alpha2

  • alpha3

  • hvdc_r

  • hvdc_droop

  • i_u_vm

  • i_u_va

  • i_k_p

  • i_k_q

  • Pfp_vsc

  • Pfn_vsc

  • Pt_vsc

  • Qt_vsc

  • Pf_hvdc

  • Ys

  • Bc

  • yff_cbr

  • yft_cbr

  • ytf_cbr

  • ytt_cbr

  • Yi

  • Yp

  • Yx

Returns:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles_sc.calcSf(k: ndarray[tuple[Any, ...], dtype[int64]], V: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], R: ndarray[tuple[Any, ...], dtype[float64]], X: ndarray[tuple[Any, ...], dtype[float64]], G: ndarray[tuple[Any, ...], dtype[float64]], B: ndarray[tuple[Any, ...], dtype[float64]], m: ndarray[tuple[Any, ...], dtype[float64]], tau: ndarray[tuple[Any, ...], dtype[float64]], vtap_f: ndarray[tuple[Any, ...], dtype[float64]], vtap_t: ndarray[tuple[Any, ...], dtype[float64]])[source]

Compute Sf for pi branches :param k: :param V: :param F: :param T: :param R: :param X: :param G: :param B: :param m: :param tau: :param vtap_f: :param vtap_t: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles_sc.calcSt(k: ndarray[tuple[Any, ...], dtype[int64]], V: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], R: ndarray[tuple[Any, ...], dtype[float64]], X: ndarray[tuple[Any, ...], dtype[float64]], G: ndarray[tuple[Any, ...], dtype[float64]], B: ndarray[tuple[Any, ...], dtype[float64]], m: ndarray[tuple[Any, ...], dtype[float64]], tau: ndarray[tuple[Any, ...], dtype[float64]], vtap_f: ndarray[tuple[Any, ...], dtype[float64]], vtap_t: ndarray[tuple[Any, ...], dtype[float64]])[source]

Compute St for pi branches :param k: :param V: :param F: :param T: :param R: :param X: :param G: :param B: :param m: :param tau: :param vtap_f: :param vtap_t: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles_sc.calc_autodiff_jacobian(func: Callable[[ndarray[tuple[Any, ...], dtype[float64]]], ndarray[tuple[Any, ...], dtype[float64]]], x: ndarray[tuple[Any, ...], dtype[float64]], h=1e-08) CSC[source]

Compute the Jacobian matrix of func at x using finite differences.

Parameters:
  • func – function accepting a vector x and args, and returning either a vector or a tuple where the first argument is a vector and the second.

  • x – Point at which to evaluate the Jacobian (numpy array).

  • h – Small step for finite difference.

Returns:

Jacobian matrix as a CSC matrix.

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles_sc.calc_flows_active_branch_per_bus(nbus: int, F_hvdc: ndarray[tuple[Any, ...], dtype[int64]], T_hvdc: ndarray[tuple[Any, ...], dtype[int64]], Sf_hvdc: ndarray[tuple[Any, ...], dtype[complex128]], St_hvdc: ndarray[tuple[Any, ...], dtype[complex128]], Fdcp_vsc: ndarray[tuple[Any, ...], dtype[int64]], Fdcn_vsc: ndarray[tuple[Any, ...], dtype[int64]], T_vsc: ndarray[tuple[Any, ...], dtype[int64]], Pfp_vsc: ndarray[tuple[Any, ...], dtype[float64]], Pfn_vsc: ndarray[tuple[Any, ...], dtype[float64]], St_vsc: ndarray[tuple[Any, ...], dtype[complex128]]) ndarray[tuple[Any, ...], dtype[complex128]][source]

Summation of magnitudes per bus (complex) Used to add effects of VSCs and HVDCs to the traditional branches (lines and controllable transformers) :param nbus: :param F_hvdc: :param T_hvdc: :param Sf_hvdc: :param St_hvdc: :param Fdcp_vsc: :param Fdcn_vsc: :param T_vsc: :param Pfp_vsc: :param Pfn_vsc: :param St_vsc: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_full_acdc_with_negative_poles_sc.calc_flows_summation_per_bus(nbus: int, F_br: ndarray[tuple[Any, ...], dtype[int64]], T_br: ndarray[tuple[Any, ...], dtype[int64]], Sf_br: ndarray[tuple[Any, ...], dtype[complex128]], St_br: ndarray[tuple[Any, ...], dtype[complex128]], F_hvdc: ndarray[tuple[Any, ...], dtype[int64]], T_hvdc: ndarray[tuple[Any, ...], dtype[int64]], Sf_hvdc: ndarray[tuple[Any, ...], dtype[complex128]], St_hvdc: ndarray[tuple[Any, ...], dtype[complex128]], Fdcp_vsc: ndarray[tuple[Any, ...], dtype[int64]], Fdcn_vsc: ndarray[tuple[Any, ...], dtype[int64]], T_vsc: ndarray[tuple[Any, ...], dtype[int64]], Pfp_vsc: ndarray[tuple[Any, ...], dtype[float64]], Pfn_vsc: ndarray[tuple[Any, ...], dtype[float64]], St_vsc: ndarray[tuple[Any, ...], dtype[complex128]]) ndarray[tuple[Any, ...], dtype[complex128]][source]

Summation of magnitudes per bus (complex) Includes everything: VSCs, HVDCs, and all traditional branches (lines and controllable transformers) :param nbus: :param F_br: :param T_br: :param Sf_br: :param St_br: :param F_hvdc: :param T_hvdc: :param Sf_hvdc: :param St_hvdc: :param Fdcp_vsc: :param Fdcn_vsc: :param T_vsc: :param Pfp_vsc: :param Pfn_vsc: :param St_vsc: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_generalized_formulation module

class VeraGridEngine.Simulations.PowerFlow.Formulations.pf_generalized_formulation.PfGeneralizedFormulation(V0: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], Qmin: ndarray[tuple[Any, ...], dtype[float64]], Qmax: ndarray[tuple[Any, ...], dtype[float64]], nc: NumericalCircuit, options: PowerFlowOptions, logger: Logger)[source]

Bases: PfFormulationTemplate

Jacobian(autodiff: bool = False) CSC[source]

Get the Jacobian :return:

check_error(x: ndarray[tuple[Any, ...], dtype[float64]]) Tuple[float, ndarray[tuple[Any, ...], dtype[float64]]][source]

Check error of the solution without affecting the problem :param x: Solution vector :return: error

compute_f(x: ndarray[tuple[Any, ...], dtype[float64]], update_class_vars: bool = False) ndarray[tuple[Any, ...], dtype[float64]][source]

Compute the residual vector :param x: Solution vector :param update_class_vars: Update the class vars related to the calculation step :return: Residual vector

fx() ndarray[tuple[Any, ...], dtype[float64]][source]

Used when updating the controls :return:

get_fx_names() List[str][source]

Names matching fx :return:

get_solution(elapsed: float, iterations: int) NumericPowerFlowResults[source]

Get the problem solution :param elapsed: Elapsed seconds :param iterations: Iteration number :return: NumericPowerFlowResults

get_x_names() List[str][source]

Names matching x :return:

size() int[source]

Size of the jacobian matrix :return:

update(x: ndarray[tuple[Any, ...], dtype[float64]], update_controls: bool = False) Tuple[float, bool, ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]

Update step :param x: Solution vector :param update_controls: :return: error, converged?, x, fx

var2x() ndarray[tuple[Any, ...], dtype[float64]][source]

Convert the internal decision variables into the vector :return: Vector

x2var(x: ndarray[tuple[Any, ...], dtype[float64]]) None[source]

Convert X to decision variables :param x: solution vector

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_generalized_formulation.adv_jacobian(nbus: int, nbr: int, nvsc: int, nhvdc: int, F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], F_vsc: ndarray[tuple[Any, ...], dtype[int64]], T_vsc: ndarray[tuple[Any, ...], dtype[int64]], F_hvdc: ndarray[tuple[Any, ...], dtype[int64]], T_hvdc: ndarray[tuple[Any, ...], dtype[int64]], tap_angles: ndarray[tuple[Any, ...], dtype[float64]], tap_modules: ndarray[tuple[Any, ...], dtype[float64]], V: ndarray[tuple[Any, ...], dtype[complex128]], Vm: ndarray[tuple[Any, ...], dtype[float64]], Va: ndarray[tuple[Any, ...], dtype[float64]], u_cbr_m: ndarray[tuple[Any, ...], dtype[int64]], u_cbr_tau: ndarray[tuple[Any, ...], dtype[int64]], k_cbr_pf: ndarray[tuple[Any, ...], dtype[int64]], k_cbr_pt: ndarray[tuple[Any, ...], dtype[int64]], k_cbr_qf: ndarray[tuple[Any, ...], dtype[int64]], k_cbr_qt: ndarray[tuple[Any, ...], dtype[int64]], u_vsc_pf: ndarray[tuple[Any, ...], dtype[int64]], u_vsc_pt: ndarray[tuple[Any, ...], dtype[int64]], u_vsc_qt: ndarray[tuple[Any, ...], dtype[int64]], alpha1: ndarray[tuple[Any, ...], dtype[float64]], alpha2: ndarray[tuple[Any, ...], dtype[float64]], alpha3: ndarray[tuple[Any, ...], dtype[float64]], hvdc_r: ndarray[tuple[Any, ...], dtype[float64]], hvdc_droop: ndarray[tuple[Any, ...], dtype[float64]], i_u_vm: ndarray[tuple[Any, ...], dtype[int64]], i_u_va: ndarray[tuple[Any, ...], dtype[int64]], i_k_p: ndarray[tuple[Any, ...], dtype[int64]], i_k_q: ndarray[tuple[Any, ...], dtype[int64]], Pfp_vsc: ndarray[tuple[Any, ...], dtype[float64]], Pt_vsc: ndarray[tuple[Any, ...], dtype[float64]], Qt_vsc: ndarray[tuple[Any, ...], dtype[float64]], Pf_hvdc: ndarray[tuple[Any, ...], dtype[float64]], Ys: ndarray[tuple[Any, ...], dtype[complex128]], Bc: ndarray[tuple[Any, ...], dtype[float64]], yff_cbr: ndarray[tuple[Any, ...], dtype[complex128]], yft_cbr: ndarray[tuple[Any, ...], dtype[complex128]], ytf_cbr: ndarray[tuple[Any, ...], dtype[complex128]], ytt_cbr: ndarray[tuple[Any, ...], dtype[complex128]], Yi: ndarray[tuple[Any, ...], dtype[int64]], Yp: ndarray[tuple[Any, ...], dtype[int64]], Yx: ndarray[tuple[Any, ...], dtype[complex128]]) CSC[source]
Parameters:
  • nbus

  • nbr

  • nvsc

  • nhvdc

  • F

  • T

  • F_vsc

  • T_vsc

  • F_hvdc

  • T_hvdc

  • tap_angles

  • tap_modules

  • V

  • Vm

  • Va

  • u_cbr_m

  • u_cbr_tau

  • k_cbr_pf

  • k_cbr_pt

  • k_cbr_qf

  • k_cbr_qt

  • u_vsc_pf

  • u_vsc_pt

  • u_vsc_qt

  • alpha1

  • alpha2

  • alpha3

  • hvdc_r

  • hvdc_droop

  • i_u_vm

  • i_u_va

  • i_k_p

  • i_k_q

  • Pfp_vsc

  • Pt_vsc

  • Qt_vsc

  • Pf_hvdc

  • Ys

  • Bc

  • yff_cbr

  • yft_cbr

  • ytf_cbr

  • ytt_cbr

  • Yi

  • Yp

  • Yx

Returns:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_generalized_formulation.calcSf(k: ndarray[tuple[Any, ...], dtype[int64]], V: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], R: ndarray[tuple[Any, ...], dtype[float64]], X: ndarray[tuple[Any, ...], dtype[float64]], G: ndarray[tuple[Any, ...], dtype[float64]], B: ndarray[tuple[Any, ...], dtype[float64]], m: ndarray[tuple[Any, ...], dtype[float64]], tau: ndarray[tuple[Any, ...], dtype[float64]], vtap_f: ndarray[tuple[Any, ...], dtype[float64]], vtap_t: ndarray[tuple[Any, ...], dtype[float64]])[source]

Compute Sf for pi branches :param k: :param V: :param F: :param T: :param R: :param X: :param G: :param B: :param m: :param tau: :param vtap_f: :param vtap_t: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_generalized_formulation.calcSt(k: ndarray[tuple[Any, ...], dtype[int64]], V: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], R: ndarray[tuple[Any, ...], dtype[float64]], X: ndarray[tuple[Any, ...], dtype[float64]], G: ndarray[tuple[Any, ...], dtype[float64]], B: ndarray[tuple[Any, ...], dtype[float64]], m: ndarray[tuple[Any, ...], dtype[float64]], tau: ndarray[tuple[Any, ...], dtype[float64]], vtap_f: ndarray[tuple[Any, ...], dtype[float64]], vtap_t: ndarray[tuple[Any, ...], dtype[float64]])[source]

Compute St for pi branches :param k: :param V: :param F: :param T: :param R: :param X: :param G: :param B: :param m: :param tau: :param vtap_f: :param vtap_t: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_generalized_formulation.calc_autodiff_jacobian(func: Callable[[ndarray[tuple[Any, ...], dtype[float64]]], ndarray[tuple[Any, ...], dtype[float64]]], x: ndarray[tuple[Any, ...], dtype[float64]], h=1e-08) CSC[source]

Compute the Jacobian matrix of func at x using finite differences.

Parameters:
  • func – function accepting a vector x and args, and returning either a vector or a tuple where the first argument is a vector and the second.

  • x – Point at which to evaluate the Jacobian (numpy array).

  • h – Small step for finite difference.

Returns:

Jacobian matrix as a CSC matrix.

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_generalized_formulation.calc_flows_active_branch_per_bus(nbus: int, F_hvdc: ndarray[tuple[Any, ...], dtype[int64]], T_hvdc: ndarray[tuple[Any, ...], dtype[int64]], Sf_hvdc: ndarray[tuple[Any, ...], dtype[complex128]], St_hvdc: ndarray[tuple[Any, ...], dtype[complex128]], F_vsc: ndarray[tuple[Any, ...], dtype[int64]], T_vsc: ndarray[tuple[Any, ...], dtype[int64]], Pfp_vsc: ndarray[tuple[Any, ...], dtype[float64]], St_vsc: ndarray[tuple[Any, ...], dtype[complex128]]) ndarray[tuple[Any, ...], dtype[complex128]][source]

Summation of magnitudes per bus (complex) Used to add effects of VSCs and HVDCs to the traditional branches (lines and controllable transformers) :param nbus: :param F_hvdc: :param T_hvdc: :param Sf_hvdc: :param St_hvdc: :param F_vsc: :param T_vsc: :param Pfp_vsc: :param St_vsc: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_generalized_formulation.calc_flows_summation_per_bus(nbus: int, F_br: ndarray[tuple[Any, ...], dtype[int64]], T_br: ndarray[tuple[Any, ...], dtype[int64]], Sf_br: ndarray[tuple[Any, ...], dtype[complex128]], St_br: ndarray[tuple[Any, ...], dtype[complex128]], F_hvdc: ndarray[tuple[Any, ...], dtype[int64]], T_hvdc: ndarray[tuple[Any, ...], dtype[int64]], Sf_hvdc: ndarray[tuple[Any, ...], dtype[complex128]], St_hvdc: ndarray[tuple[Any, ...], dtype[complex128]], F_vsc: ndarray[tuple[Any, ...], dtype[int64]], T_vsc: ndarray[tuple[Any, ...], dtype[int64]], Pfp_vsc: ndarray[tuple[Any, ...], dtype[float64]], St_vsc: ndarray[tuple[Any, ...], dtype[complex128]]) ndarray[tuple[Any, ...], dtype[complex128]][source]

Summation of magnitudes per bus (complex) Includes everything: VSCs, HVDCs, and all traditional branches (lines and controllable transformers) :param nbus: :param F_br: :param T_br: :param Sf_br: :param St_br: :param F_hvdc: :param T_hvdc: :param Sf_hvdc: :param St_hvdc: :param F_vsc: :param T_vsc: :param Pfp_vsc: :param St_vsc: :return:

Module contents