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

class VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.PfBasicFormulation3Ph(V0: ndarray[tuple[Any, ...], dtype[complex128]], S0: 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]
Parameters:

autodiff – If True, use autodiff to compute the Jacobian

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

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

Compute the function residual :param x: Solution vector :return: f

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

# Scalc = V Β· (Y x V - I)^* # Sbus = S0 + I0*Vm + Y0*Vm^2 :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

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]
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]]) None[source]

Convert X to decision variables :param x: solution vector

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

Compute the Jacobian matrix of func at x using finite differences. df/dx = (f(x+h) - f(x)) / h

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_3ph.compute_current_loads(bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_lookup: ndarray[tuple[Any, ...], dtype[int64]], V: ndarray[tuple[Any, ...], dtype[complex128]], Istar: ndarray[tuple[Any, ...], dtype[complex128]], Idelta: ndarray[tuple[Any, ...], dtype[complex128]], Ifloating: ndarray[tuple[Any, ...], dtype[complex128]]) Tuple[ndarray[tuple[Any, ...], dtype[complex128]], ndarray[tuple[Any, ...], dtype[complex128]], ndarray[tuple[Any, ...], dtype[complex128]]][source]
Parameters:
  • bus_idx

  • bus_lookup

  • V

  • Istar

  • Idelta

  • Ifloating

Returns:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.compute_generators(bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_lookup: ndarray[tuple[Any, ...], dtype[int64]], V: ndarray[tuple[Any, ...], dtype[complex128]], P: ndarray[tuple[Any, ...], dtype[float64]], Q: ndarray[tuple[Any, ...], dtype[float64]], control_mode_int: ndarray[tuple[Any, ...], dtype[int64]]) ndarray[tuple[Any, ...], dtype[complex128]][source]
Parameters:
  • bus_idx

  • bus_lookup

  • V

  • P

  • Q

  • control_mode_int

Returns:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.compute_power_loads(bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_lookup: ndarray[tuple[Any, ...], dtype[int64]], V: ndarray[tuple[Any, ...], dtype[complex128]], Sstar: ndarray[tuple[Any, ...], dtype[complex128]], Sfloating: ndarray[tuple[Any, ...], dtype[complex128]], Sdelta: ndarray[tuple[Any, ...], dtype[complex128]]) Tuple[ndarray[tuple[Any, ...], dtype[complex128]], ndarray[tuple[Any, ...], dtype[complex128]], ndarray[tuple[Any, ...], dtype[complex128]]][source]
Parameters:
  • bus_idx

  • bus_lookup

  • V

  • Sstar

  • Sfloating

  • Sdelta

Returns:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.compute_ybus(nc: NumericalCircuit) Tuple[csc_matrix, csc_matrix, csc_matrix, ndarray[tuple[Any, ...], dtype[complex128]], ndarray[tuple[Any, ...], dtype[bool]], ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]]][source]

Compute admittances and masks

The mask is a boolean vector that indicates which bus phases are active

The bus_idx_lookup will relate the original bus indices with the sliced bus indices This is useful for managing the sliced bus indices in the power flow problem. For instance:

original_pq_buses = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] mask = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]

And the lookup becomes: bus_idx_lookup = [0, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1]

And then it will be simple to get the sliced bus indices that we finally need: sliced_pq_buses = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Parameters:

nc – NumericalCircuit

Returns:

Ybus, Yf, Yt, Yshunt_bus, mask, bus_idx_lookup

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.compute_ybus_generator(nc: NumericalCircuit) Tuple[csc_matrix][source]

Compute the Ybus matrix for a generator in a 3-phase system with neutral. It is used only during the short-circuit analysis, not in power flow simulations. :param nc: NumericalCircuit :return: Ybus

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.expand3ph(x: ndarray) ndarray[source]

Expands a numpy array to 3-pase copying the same values :param x: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.expandVoltage3ph(V0: ndarray[tuple[Any, ...], dtype[complex128]]) ndarray[tuple[Any, ...], dtype[complex128]][source]

Expands a numpy array to 3-pase copying the same values :param V0: array of bus voltages in positive sequence :return: Array of three-phase voltages in 3-phase ABC

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.expand_indices_3ph(x: ndarray) ndarray[source]

Expands a numpy array to 3-pase copying the same values :param x: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.expand_magnitudes(magnitude: ndarray[tuple[Any, ...], dtype[complex128]], lookup: ndarray[tuple[Any, ...], dtype[int64]]) ndarray[tuple[Any, ...], dtype[complex128]][source]

Expands the masked magnitude using the lookup saving zeros where the lookup is -1, which means that this bus did not exist, and it was previously eliminated. :param magnitude: The magnitude to expand, for instance, the voltage vector at each bus :param lookup: The vector which contains the information about the existing and eliminated buses :return: magnitude_expanded

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.expand_matrix(magnitude: ndarray, lookup: ndarray[tuple[Any, ...], dtype[int64]]) ndarray[tuple[Any, ...], dtype[complex128]][source]

Expands a matrix by adding zero rows and columns based on the lookup indices. If a lookup value is negative, the corresponding row and column in the matrix will be replaced by zeros.

Parameters:
  • magnitude – 2D numpy array (matrix to expand)

  • lookup – List of indices for lookup

Returns:

Expanded matrix with zeros in the rows and columns where lookup values are negative

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.expand_slice_indices_3ph(x: ndarray, bus_lookup: ndarray[tuple[Any, ...], dtype[int64]]) ndarray[source]

Expands and slices a numpy array to 3-phase copying the same values :param x: :param bus_lookup: :return:

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.lookup_from_mask(mask: ndarray[tuple[Any, ...], dtype[bool]]) ndarray[tuple[Any, ...], dtype[int64]][source]

This function builds the lookup vector based on the information provided by the mask vector. The mask is a boolean vector with True for existing buses and False for non-existing buses. The lookup vector will save a -1 for non-existing buses and will order the existing buses from 0 to n. :param mask: Boolean vector with True for existing buses and False for non-existing buses. :return: lookup

VeraGridEngine.Simulations.PowerFlow.Formulations.pf_basic_formulation_3ph.slice_indices(pq: ndarray[tuple[Any, ...], dtype[int64]], bus_lookup: ndarray[tuple[Any, ...], dtype[int64]]) ndarray[tuple[Any, ...], dtype[int64]][source]

Slice the indices based on the bus_lookup :param pq: original bus indices :param bus_lookup: mapping between original and sliced bus indices :return:

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]], 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

  • 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