VeraGridEngine.Simulations.PowerFlow.NumericalMethods packageο
Submodulesο
VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions moduleο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.active_power_mismatch(slip: float, u: complex, Rs: float, Xs: float, Xm: float, Rr: float, Xr: float, P: float, Sr: float) float[source]ο
- Parameters:
slip
u
Rs
Xs
Xm
Rr
Xr
P
Sr
- Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.asynchronous_gen_q(u: complex, Rs: float, Xs: float, Xm: float, Rr: float, Xr: float, P: float, Sr: float) float[source]ο
- Parameters:
u
Rs
Xs
Xm
Rr
Xr
P
Sr
- Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.compute_current(Ybus: csc_matrix, V: ndarray[tuple[Any, ...], dtype[complex128]]) ndarray[tuple[Any, ...], dtype[complex128]][source]ο
Compute the current from the admittance matrix and the voltage :param Ybus: Admittance matrix :param V: Voltage vector :return: Calculated current injections
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.compute_fx(Scalc: ndarray[tuple[Any, ...], dtype[complex128]], Sbus: ndarray[tuple[Any, ...], dtype[complex128]], idx_dP: ndarray[tuple[Any, ...], dtype[int64]], idx_dQ: ndarray[tuple[Any, ...], dtype[int64]]) ndarray[tuple[Any, ...], dtype[float64]][source]ο
Compute the NR-like error function f = [βP(pqpv), βQ(pq)] :param Scalc: Calculated power injections :param Sbus: Specified power injections :param idx_dP: Array of node indices updated with dP (pvpq) :param idx_dQ: Array of node indices updated with dQ (pq) :return: error
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.compute_fx_error(fx: ndarray[tuple[Any, ...], dtype[float64]]) float[source]ο
Compute the infinite norm of fx this is the same as max(abs(fx)) :param fx: vector :return: infinite norm
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.compute_power(Ybus: csc_matrix, V: ndarray[tuple[Any, ...], dtype[complex128]]) ndarray[tuple[Any, ...], dtype[complex128]][source]ο
Compute the power from the admittance matrix and the voltage :param Ybus: Admittance matrix :param V: Voltage vector :return: Calculated power injections
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.compute_zip_current(S0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], Vm: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[complex128]][source]ο
Compute the equivalent current injection :param S0: Base power (P + jQ) :param I0: Base current (Ir + jIi) :param Y0: Base admittance (G + jB) :param Vm: voltage module, for the 3ph power flow the complete voltage phasor is used (Vm + Va) :return: complex current injection
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.compute_zip_power(S0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], Vm: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[complex128]][source]ο
Compute the equivalent power injection :param S0: Base power (P + jQ) :param I0: Base current (Ir + jIi) :param Y0: Base admittance (G + jB) :param Vm: voltage module, for the 3ph power flow the complete voltage phasor is used (Vm + Va) :return: complex power injection
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.expand(n, arr: ndarray[tuple[Any, ...], dtype[float64]], idx: ndarray[tuple[Any, ...], dtype[int64]], default: float) ndarray[tuple[Any, ...], dtype[float64]][source]ο
Expand array :param n: number of elements :param arr: short array :param idx: indices in the longer array :param default: default value for the longer array :return: longer array
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.expand_magnitudes(magnitude: ndarray[tuple[Any, ...], dtype[complex128]], lookup: ndarray[tuple[Any, ...], dtype[int64]])[source]ο
- Parameters:
magnitude
lookup
- Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.floating_star_currents(Va, Vb, Vc, Istar_a, Istar_b, Istar_c, Vn0) Tuple[complex, complex, complex, complex][source]ο
Given the phase voltages and currents of a floating star connected current load, this function calculates the phase currents (Ia, Ib, Ic) and the neutral voltage (Vn), such that they meet the condition that the current flowing through the neutral point is equal to zero, since the neutral point of the star is floating -> In = Ia + Ib + Ic = 0 :param Va: Phase A load voltage :param Vb: Phase B load voltage :param Vc: Phase C load voltage :param Istar_a: Phase A load current :param Istar_b: Phase B load current :param Istar_c: Phase C load current :param Vn0: Last-iteration neutral point voltage or
just the center of the phase voltages (Va,Vb,Vc) at the first iteration
- Returns:
Ia, Ib, Ic, Vn
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.floating_star_powers(Ua, Ub, Uc, Sa, Sb, Sc) Tuple[complex, complex, complex, complex][source]ο
Given the phase voltages and complex powers of a floating star connected power load, this function calculates the phase currents (Ia, Ib, Ic) and the neutral voltage (Un), such that they meet the condition that the current flowing through the neutral point is equal to zero, since the neutral point of the star is floating -> In = Ia + Ib + Ic = 0 :param Ua: Phase A load voltage :param Ub: Phase B load voltage :param Uc: Phase C load voltage :param Sa: Phase A load complex power :param Sb: Phase B load complex power :param Sc: Phase C load complex power :return: Ia, Ib, Ic, Un
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.fortescue_012_to_abc(z0: complex, z1: complex, z2: complex) ndarray[tuple[Any, ...], dtype[complex128]][source]ο
Convert 012 to abc :param z0: zero-sequence impedance :param z1: positive-sequence impedance :param z2: negative-sequence impedance :return: abc impedance matrix
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.get_If(k: ndarray[tuple[Any, ...], dtype[int64]], V: ndarray[tuple[Any, ...], dtype[complex128]], yff: ndarray[tuple[Any, ...], dtype[complex128]], yft: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]])[source]ο
- Parameters:
k
V
yff
yft
F
T
- Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.get_It(k: ndarray[tuple[Any, ...], dtype[int64]], V: ndarray[tuple[Any, ...], dtype[complex128]], ytf: ndarray[tuple[Any, ...], dtype[complex128]], ytt: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]])[source]ο
- Parameters:
k
V
ytf
ytt
F
T
- Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.get_Sf(k: ndarray[tuple[Any, ...], dtype[int64]], Vm: ndarray[tuple[Any, ...], dtype[float64]], V: ndarray[tuple[Any, ...], dtype[complex128]], yff: ndarray[tuple[Any, ...], dtype[complex128]], yft: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]])[source]ο
- Parameters:
k
Vm
V
yff
yft
F
T
- Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.get_St(k: ndarray[tuple[Any, ...], dtype[int64]], Vm: ndarray[tuple[Any, ...], dtype[float64]], V: ndarray[tuple[Any, ...], dtype[complex128]], ytf: ndarray[tuple[Any, ...], dtype[complex128]], ytt: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]])[source]ο
- Parameters:
k
Vm
V
ytf
ytt
F
T
- Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.polar_to_rect(Vm: ndarray[tuple[Any, ...], dtype[float64]], Va: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[complex128]][source]ο
Convert polar to rectangular coordinates :param Vm: Module :param Va: Angle in radians :return: Polar vector
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.power_flow_post_process_linear(Sbus: ndarray[tuple[Any, ...], dtype[complex128]], V: ndarray[tuple[Any, ...], dtype[complex128]], active: ndarray[tuple[Any, ...], dtype[int64]], X: ndarray[tuple[Any, ...], dtype[float64]], tap_module: ndarray[tuple[Any, ...], dtype[float64]], tap_angle: ndarray[tuple[Any, ...], dtype[float64]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], branch_rates: ndarray[tuple[Any, ...], dtype[float64]], Sbase: float)[source]ο
- Parameters:
Sbus
V
active
X
tap_module
tap_angle
F
T
branch_rates
Sbase
- Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.power_flow_post_process_nonlinear(Sbus: ndarray[tuple[Any, ...], dtype[complex128]], V: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], pv: ndarray[tuple[Any, ...], dtype[int64]], vd: ndarray[tuple[Any, ...], dtype[int64]], Ybus: csc_matrix, Yf: csc_matrix, Yt: csc_matrix, Yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]], branch_rates: ndarray[tuple[Any, ...], dtype[float64]], Sbase: float)[source]ο
- Parameters:
Sbus
V
F
T
pv
vd
Ybus
Yf
Yt
Yshunt_bus
branch_rates
Sbase
- Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.power_flow_post_process_nonlinear_3ph(Sbus: ndarray[tuple[Any, ...], dtype[complex128]], V: ndarray[tuple[Any, ...], dtype[complex128]], Vn_floating: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], pv: ndarray[tuple[Any, ...], dtype[int64]], vd: ndarray[tuple[Any, ...], dtype[int64]], Ybus: csc_matrix, Yf: csc_matrix, Yt: csc_matrix, Yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]], branch_rates: ndarray[tuple[Any, ...], dtype[float64]], Sbase: float, bus_lookup: ndarray[tuple[Any, ...], dtype[int64]], branch_lookup: ndarray[tuple[Any, ...], dtype[int64]])[source]ο
- Parameters:
Sbus
V
Vn_floating
F
T
pv
vd
Ybus
Yf
Yt
Yshunt_bus
branch_rates
Sbase
bus_lookup
branch_lookup
- Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.solve_slip(f, a, b, tol, max_iter, u, Rs, Xs, Xm, Rr, Xr, P, Sr)[source]ο
- Parameters:
f
a
b
tol
max_iter
u
Rs
Xs
Xm
Rr
Xr
P
Sr
- Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.split_bus_quantity(Qbus: ndarray[tuple[Any, ...], dtype[float64]], gen_bus_idx: ndarray[tuple[Any, ...], dtype[int64]], Qmin_gen: ndarray[tuple[Any, ...], dtype[float64]], Qmax_gen: ndarray[tuple[Any, ...], dtype[float64]], gen_status: ndarray[tuple[Any, ...], dtype[bool]], control_mode_int_gen: ndarray[tuple[Any, ...], dtype[int64]], Q0_gen: ndarray[tuple[Any, ...], dtype[float64]], Vset_gen: ndarray[tuple[Any, ...], dtype[float64]], k_droop_gen: ndarray[tuple[Any, ...], dtype[float64]], dead_band_gen: ndarray[tuple[Any, ...], dtype[float64]], batt_bus_idx: ndarray[tuple[Any, ...], dtype[int64]], Qmin_batt: ndarray[tuple[Any, ...], dtype[float64]], Qmax_batt: ndarray[tuple[Any, ...], dtype[float64]], batt_status: ndarray[tuple[Any, ...], dtype[bool]], control_mode_int_batt: ndarray[tuple[Any, ...], dtype[int64]], Q0_batt: ndarray[tuple[Any, ...], dtype[float64]], v_ctrl_val_gen: int, qv_droop_val_gen: int, Vm: ndarray[tuple[Any, ...], dtype[float64]], atol: float = 1e-12) Tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]ο
Split a per-bus reactive power quantity among online generators and batteries.
The function separates generator-like elements into two families:
Generators.
Batteries.
Both families are treated as reactive power providers connected to buses. The bus-level reactive power
Qbusis split among all online controlling elements at each bus, regardless of whether the element is a generator or a battery.Online non-controlling generators and online non-controlling batteries are assigned their initial reactive power set point
Q0. Their contribution is subtracted from the bus reactive power before the controlling elements share the remaining value.For each bus
i, the fixed non-controlling contribution is:
The reactive power left for controlling elements is:

The aggregate controlling limits include both generators and batteries:


The normalized sharing factor at each bus is:

after clipping
Qctrl_ito the aggregate controlling capability.Final assignments are:
Offline generators receive zero.
Offline batteries receive zero.
Online non-controlling generators receive
Q0_gen.Online non-controlling batteries receive
Q0_batt.Online controlling generators share the residual bus Q using their own
Qmin_genandQmax_gen.Online controlling batteries share the residual bus Q using their own
Qmin_battandQmax_batt.
This function assumes that generators and batteries use the same reactive power sign convention as
Qbus.This function assumes that all arrays have compatible sizes and that
gen_bus_idxandbatt_bus_idxcontain valid zero-based bus indices. Input validation should be done by the caller or by a Python wrapper outside this Numba function.- Parameters:
Qbus (Vec) β Total reactive generator-like power requested at each bus.
gen_bus_idx (IntVec) β Bus index of each generator.
Qmin_gen (Vec) β Minimum reactive power limit of each generator.
Qmax_gen (Vec) β Maximum reactive power limit of each generator.
gen_status (BoolVec) β Generator status vector.
Truemeans online.control_mode_int_gen (BoolVec) β Generator control flag.
Truemeans the generator participates in reactive power sharing.Q0_gen (Vec) β Initial or fixed reactive power set point of each generator.
Vset_gen (Vec) β Voltage set point of each generator.
k_droop_gen (Vec) β QV droop constant of each generator.
dead_band_gen (Vec) β QV droop dead band of each generator.
batt_bus_idx (IntVec) β Bus index of each battery.
Qmin_batt (Vec) β Minimum reactive power limit of each battery.
Qmax_batt (Vec) β Maximum reactive power limit of each battery.
batt_status (BoolVec) β Battery status vector.
Truemeans online.control_mode_int_batt (BoolVec) β Battery control flag.
Truemeans the battery participates in reactive power sharing.Q0_batt (Vec) β Initial or fixed reactive power set point of each battery.
v_ctrl_val_gen
qv_droop_val_gen
Vm (Vec) β Converged voltage magnitude per bus.
atol (float) β Tolerance used to detect zero aggregate reactive range.
- Returns:
Reactive power assigned to generators and batteries.
- Return type:
Tuple[Vec, Vec]
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.split_reactive_power_between_generators_and_batteries(Qbus: ndarray[tuple[Any, ...], dtype[float64]], Qfixed_bus: ndarray[tuple[Any, ...], dtype[float64]], gen_bus_idx: ndarray[tuple[Any, ...], dtype[int64]], Qmin_gen: ndarray[tuple[Any, ...], dtype[float64]], Qmax_gen: ndarray[tuple[Any, ...], dtype[float64]], gen_status: ndarray[tuple[Any, ...], dtype[bool]], control_mode_int_gen: ndarray[tuple[Any, ...], dtype[int64]], Q0_gen: ndarray[tuple[Any, ...], dtype[float64]], Vset_gen: ndarray[tuple[Any, ...], dtype[float64]], k_droop_gen: ndarray[tuple[Any, ...], dtype[float64]], dead_band_gen: ndarray[tuple[Any, ...], dtype[float64]], batt_bus_idx: ndarray[tuple[Any, ...], dtype[int64]], Qmin_batt: ndarray[tuple[Any, ...], dtype[float64]], Qmax_batt: ndarray[tuple[Any, ...], dtype[float64]], batt_status: ndarray[tuple[Any, ...], dtype[bool]], control_mode_int_batt: ndarray[tuple[Any, ...], dtype[int64]], Q0_batt: ndarray[tuple[Any, ...], dtype[float64]], v_ctrl_val_gen: int, qv_droop_val_gen: int, Vm: ndarray[tuple[Any, ...], dtype[float64]], atol: float = 1e-12) Tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]ο
Split solved bus reactive power between generator-like controlling devices.
This routine is the reactive-power post-processing counterpart of the generator/battery bus split. Unlike the generic quantity split, it starts from an already compiled fixed bus contribution
Qfixed_busthat includes load-like injections, fixed current/admittance terms, and non-controlling generator-like set points captured by the numerical circuit compilation.The controlling residual at each bus is therefore:

where
Qdroop_iis the contribution of droop-controlled generators evaluated at the solved voltage magnitude.Online voltage-controlled generators and batteries share that residual subject to their aggregate limits. Online non-controlling generators and batteries keep their compiled set points. Offline devices receive zero.
- Parameters:
Qbus β Solved nodal reactive power injection.
Qfixed_bus β Fixed compiled reactive contribution per bus.
gen_bus_idx β Generator bus index.
Qmin_gen β Generator minimum reactive power.
Qmax_gen β Generator maximum reactive power.
gen_status β Generator active status.
control_mode_int_gen β Generator control mode codes.
Q0_gen β Generator fixed reactive set point.
Vset_gen β Generator voltage set points.
k_droop_gen β Generator droop coefficients.
dead_band_gen β Generator droop dead bands.
batt_bus_idx β Battery bus index.
Qmin_batt β Battery minimum reactive power.
Qmax_batt β Battery maximum reactive power.
batt_status β Battery active status.
control_mode_int_batt β Battery control mode codes.
Q0_batt β Battery fixed reactive set point.
v_ctrl_val_gen β Integer code for voltage control.
qv_droop_val_gen β Integer code for QV droop control.
Vm β Solved bus voltage magnitudes.
atol β Numerical zero tolerance.
- Returns:
Tuple with generator and battery reactive power vectors.
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.split_slack_bus_quantity_between_generators_and_batteries(Qbus: ndarray[tuple[Any, ...], dtype[float64]], Qfixed_bus: ndarray[tuple[Any, ...], dtype[float64]], slack_bus_mask: ndarray[tuple[Any, ...], dtype[bool]], gen_bus_idx: ndarray[tuple[Any, ...], dtype[int64]], Qmin_gen: ndarray[tuple[Any, ...], dtype[float64]], Qmax_gen: ndarray[tuple[Any, ...], dtype[float64]], gen_status: ndarray[tuple[Any, ...], dtype[bool]], Q0_gen: ndarray[tuple[Any, ...], dtype[float64]], batt_bus_idx: ndarray[tuple[Any, ...], dtype[int64]], Qmin_batt: ndarray[tuple[Any, ...], dtype[float64]], Qmax_batt: ndarray[tuple[Any, ...], dtype[float64]], batt_status: ndarray[tuple[Any, ...], dtype[bool]], Q0_batt: ndarray[tuple[Any, ...], dtype[float64]], atol: float = 1e-12) Tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]ο
Split one solved bus quantity among online generator-like devices at slack buses.
This helper is used after the main power-flow post-processing to reconstruct the per-device values that belong to slack buses. The solved bus quantities are already correct, but the slack balancing residual can remain attached only to the bus result instead of being reassigned to the connected online generators and batteries.
The split is performed independently at every slack bus. Devices connected to non-slack buses preserve their input values
Q0_genandQ0_batt. Online devices connected to slack buses share the residual bus quantity after subtracting the fixed bus contributionQfixed_bus. Offline devices receive zero.- Parameters:
Qbus β Solved per-bus quantity to reconstruct.
Qfixed_bus β Fixed per-bus contribution that does not belong to the participating slack devices.
slack_bus_mask β Boolean mask marking the slack buses.
gen_bus_idx β Generator bus index.
Qmin_gen β Generator lower bound for the reconstructed quantity.
Qmax_gen β Generator upper bound for the reconstructed quantity.
gen_status β Generator active status.
Q0_gen β Generator baseline values kept at non-slack buses.
batt_bus_idx β Battery bus index.
Qmin_batt β Battery lower bound for the reconstructed quantity.
Qmax_batt β Battery upper bound for the reconstructed quantity.
batt_status β Battery active status.
Q0_batt β Battery baseline values kept at non-slack buses.
atol β Numerical zero tolerance.
- Returns:
Tuple with generator and battery reconstructed values.
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.voltage_pdc_droop(ut: complex, u_setpoint_min: float, u_setpoint_max: float, u_setpoint: float, Pdc_setpoint: float, S_r: float, droop: float, P_min: float, P_max: float, S_base: float) float[source]ο
Find the actual DC power output for converters controlled with a voltage droop.
Implements Pdc = Pdc* - Pdroop * (Vdc* - Vdc)
- Parameters:
ut β Actual voltage value at the terminal [pu]
u_setpoint_min β Minimum voltage setpoint [pu]
u_setpoint_max β Maximum voltage setpoint [pu]
u_setpoint β Specified voltage setpoint [pu]
Pdc_setpoint β Specified dispatch DC power [MW]
S_r β Rated apparent power [MVA]
droop β Voltage droop value [%]
P_min β Minimum DC power the converter can inject/absorb [MW]
P_max β Maximum DC power the converter can inject/absorb [MW]
S_base β Base power of the network [MVA]
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.common_functions.voltage_q_droop(ut: complex, u_setpoint_min: float, u_setpoint_max: float, u_setpoint: float, Q_setpoint: float, S_r: float, droop: float, Q_min: float, Q_max: float, S_base: float)[source]ο
Find the actual reactive power output for generators controlled with a voltage droop. :param ut: Actual voltage value at the terminal [pu] :param u_setpoint_min: Minimum voltage setpoint [pu] :param u_setpoint_max: Maximum voltage setpoint [pu] :param u_setpoint: Specified voltage setpoint [pu] :param Q_setpoint: Specified dispatch reactive power [MVAr] :param S_r: Rated apparent power [MVA] :param droop: Voltage droop value [%] :param Q_min: Minimum reactive power the converter can inject/absorb [MVAr] :param Q_max: Maximum reactive power the converter can inject/absorb [MVAr] :param S_base: Base power of the network [MVA]
VeraGridEngine.Simulations.PowerFlow.NumericalMethods.converter_fault_controls moduleο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.converter_fault_controls.current_limit_logic(Iqcmd, vdlq, vdlp, is_blocked)[source]ο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.converter_fault_controls.genstat(ur, ui, iq_ref, id_ref, Sn, is_blocked)[source]ο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.converter_fault_controls.reec_d(u, Vpf, Qpf, Ppf)[source]ο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.converter_fault_controls.regc_c(Iqcmd, Ipcmd)[source]ο
VeraGridEngine.Simulations.PowerFlow.NumericalMethods.converter_fault_controls_no_ifs moduleο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.converter_fault_controls_no_ifs.genstat(ur, ui, iq_ref, id_ref, Sn)[source]ο
- Parameters:
ur
ui
iq_ref
id_ref
Sn
- Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.converter_fault_controls_no_ifs.reec_d(u, Vpf, Paux, Qext, Pref)[source]ο
- Parameters:
u
Vpf
Paux
Qext
Pref
- Returns:
VeraGridEngine.Simulations.PowerFlow.NumericalMethods.discrete_controls moduleο
- class VeraGridEngine.Simulations.PowerFlow.NumericalMethods.discrete_controls.DiscreteShuntControlState(nc: NumericalCircuit)[source]ο
Bases:
objectPython-side state holder for discrete shunt controls.
The packed arrays owned by this class are consumed by the Numba kernel so the formulations only need to keep a lightweight wrapper object.
- apply(Vm: ndarray[tuple[Any, ...], dtype[float64]], adm: AdmittanceMatrices | AdmittanceMatricesFast, yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]] | None = None) bool[source]ο
Apply one discrete shunt control step.
- Parameters:
Vm β Voltage magnitude vector.
adm β Admittance container updated in place.
yshunt_bus β Optional external shunt-bus vector that must remain synchronized with
adm.Yshunt_bus.
- Returns:
Trueif any discrete shunt changed state,Falseotherwise.
- class VeraGridEngine.Simulations.PowerFlow.NumericalMethods.discrete_controls.QvDroopControlState(S0: ndarray[tuple[Any, ...], dtype[complex128]], nc: NumericalCircuit)[source]ο
Bases:
objectPython-side state holder for generator QV droop controls.
The arrays are allocated once and the numerical update remains delegated to the Numba kernel.
- apply(S0: ndarray[tuple[Any, ...], dtype[complex128]], Vm: ndarray[tuple[Any, ...], dtype[float64]]) bool[source]ο
Apply one QV droop control step.
- Parameters:
S0 β Specified bus power updated in place.
Vm β Voltage magnitude vector.
- Returns:
Trueif any droop generator changed,Falseotherwise.
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.discrete_controls.compute_slack_distribution(Scalc: ndarray[tuple[Any, ...], dtype[complex128]], vd: ndarray[tuple[Any, ...], dtype[int64]], bus_installed_power: ndarray[tuple[Any, ...], dtype[float64]]) Tuple[bool, ndarray[tuple[Any, ...], dtype[float64]]][source]ο
Slack distribution logic :param Scalc: Computed power array :param vd: slack indices :param bus_installed_power: Amount of installed power :return: is slack division possible?
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.discrete_controls.control_discrete_shunts(Vm: ndarray[tuple[Any, ...], dtype[float64]], shunt_discrete_ctrl_idx: ndarray[tuple[Any, ...], dtype[int64]], shunt_discrete_bus_idx: ndarray[tuple[Any, ...], dtype[int64]], shunt_discrete_vmax: ndarray[tuple[Any, ...], dtype[float64]], shunt_discrete_vmin: ndarray[tuple[Any, ...], dtype[float64]], shunt_step: ndarray[tuple[Any, ...], dtype[int64]], shunt_g_steps: ndarray, shunt_b_steps: ndarray, shunt_n_steps: ndarray[tuple[Any, ...], dtype[int64]], sbase: float)[source]ο
Control discrete shunts within the numerical method. The sparse Ybus diagonal update is returned to the caller and applied outside numba. :param Vm: Voltage module array. :param shunt_discrete_ctrl_idx: Array of controlled shunt indices in the full shunt arrays. :param shunt_discrete_bus_idx: Array of bus indices for the controlled shunts. :param shunt_discrete_vmax: Array of upper voltage bounds for the controlled shunts. :param shunt_discrete_vmin: Array of lower voltage bounds for the controlled shunts. :param shunt_step: Array of current shunt steps in the full shunt arrays (changed inside). :param shunt_g_steps: Packed cumulative G steps for the controlled shunts. :param shunt_b_steps: Packed cumulative B steps for the controlled shunts. :param shunt_n_steps: Number of valid steps for each controlled shunt. :param sbase: Base power. :return: changed bus indices, Ybus diagonal increments, number of changed shunts.
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.discrete_controls.control_q_direct(V, Vm, Vset, Q, Qmax, Qmin, types, original_types, verbose=False)[source]ο
Change the buses type in order to control the generators reactive power. :param V: Array of complex voltages :param Vm: Array of voltage modules (for speed) :param Vset: array of voltage Set points :param Q: Array of reactive power values per bus :param Qmax: Array of Qmax per bus :param Qmin: Array of Qmin per bus :param types: Array of bus types :param original_types: Array of original bus types :param verbose: More info? :return:
Vnew (list): New voltage values
Qnew (list): New reactive power values
types_new (list): Modified types array
any_control_issue (bool): Was there any control issue?
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.discrete_controls.control_q_for_generalized_method(Scalc: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], pv: ndarray[tuple[Any, ...], dtype[int64]], i_u_vm: ndarray[tuple[Any, ...], dtype[int64]], i_k_q: ndarray[tuple[Any, ...], dtype[int64]], Qmin: ndarray[tuple[Any, ...], dtype[float64]], Qmax: ndarray[tuple[Any, ...], dtype[float64]])[source]ο
Control of reactive power within the numerical method Assume we only want to change regular PV buses to PQ buses (as in the conventional method) :param Scalc: Calculated power array (changed inside) :param S0: Specified power array (changed inside) :param pv: array of pv bus indices (changed inside) :param i_u_vm: array of buses with unknown Vm (changed inside) :param i_k_q: array of buses with known Q (changed inside) :param Qmin: Array of lower bus reactive power limits per bus in p.u. :param Qmax: Array of upper bus reactive power limits per bus in p.u. :return: list of changed buses, i_u_vm, i_k_q
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.discrete_controls.control_q_inside_method(Scalc: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], pv: ndarray[tuple[Any, ...], dtype[int64]], pq: ndarray[tuple[Any, ...], dtype[int64]], pqv: ndarray[tuple[Any, ...], dtype[int64]], p: ndarray[tuple[Any, ...], dtype[int64]], Qmin: ndarray[tuple[Any, ...], dtype[float64]], Qmax: ndarray[tuple[Any, ...], dtype[float64]])[source]ο
Control of reactive power within the numerical method :param Scalc: Calculated power array (changed inside) :param S0: Specified power array (changed inside) :param pv: array of pv bus indices (changed inside) :param pq: array of pq bus indices (changed inside) :param pqv: array of pqv bus indices (changed inside) :param p: array of p bus indices (changed inside) :param Qmin: Array of lower reactive power limits per bus in p.u. :param Qmax: Array of upper reactive power limits per bus in p.u. :return: any change?, Scalc, Sbus, pv, pq, pqv, p
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.discrete_controls.get_q_increment(V1, V2, k)[source]ο
Logistic function to get the Q increment gain using the difference between the current voltage (V1) and the target voltage (V2).
The gain varies between 0 (at V1 = V2) and inf (at V2 - V1 = inf).
The default steepness factor k was set through trial an error. Other values may be specified as a PowerFlowOptions.
Arguments:
V1 (float): Current voltage
V2 (float): Target voltage
k (float, 30): Steepness factor
Returns:
Q increment gain
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.discrete_controls.update_qv_droop_generators(S0: ndarray[tuple[Any, ...], dtype[complex128]], Q0: ndarray[tuple[Any, ...], dtype[float64]], generator_q: ndarray[tuple[Any, ...], dtype[float64]], qv_droop_bus_idx: ndarray[tuple[Any, ...], dtype[int64]], qv_droop_gen_idx: ndarray[tuple[Any, ...], dtype[int64]], generator_bus_idx: ndarray[tuple[Any, ...], dtype[int64]], generator_k_droop: ndarray[tuple[Any, ...], dtype[float64]], generator_dead_band: ndarray[tuple[Any, ...], dtype[float64]], generator_v: ndarray[tuple[Any, ...], dtype[float64]], generator_qmin: ndarray[tuple[Any, ...], dtype[float64]], generator_qmax: ndarray[tuple[Any, ...], dtype[float64]], Vm: ndarray[tuple[Any, ...], dtype[float64]]) bool[source]ο
Update generators with QV droop control within the numerical method. :param S0: Specified power array (changed inside). :param Q0: Initial specified reactive power per bus. :param generator_q: Reactive power per generator (changed inside). :param qv_droop_bus_idx: Buses hosting QV droop generators. :param qv_droop_gen_idx: Generator indices with QV droop control. :param generator_bus_idx: Generator-to-bus map. :param generator_k_droop: Generator droop gain. :param generator_dead_band: Generator dead-band. :param generator_v: Generator voltage set point. :param generator_qmax: Generator reactive power upper limit (p.u.). :param generator_qmin: Generator reactive power lower limit (p.u.). :param Vm: Voltage module array. :return: Was there any change?
VeraGridEngine.Simulations.PowerFlow.NumericalMethods.fast_decoupled moduleο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.fast_decoupled.FDPF(nc: NumericalCircuit, Vbus: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], Ybus: csc_matrix, Yf: csc_matrix, Yt: csc_matrix, Yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]], B1: csc_matrix, B2: csc_matrix, pv_: ndarray[tuple[Any, ...], dtype[int64]], pq_: ndarray[tuple[Any, ...], dtype[int64]], pqv_: ndarray[tuple[Any, ...], dtype[int64]], p_: ndarray[tuple[Any, ...], dtype[int64]], vd_: ndarray[tuple[Any, ...], dtype[int64]], Qmin: ndarray[tuple[Any, ...], dtype[float64]], Qmax: ndarray[tuple[Any, ...], dtype[float64]], bus_installed_power: ndarray[tuple[Any, ...], dtype[float64]], tol: float = 1e-09, max_it: float = 100, control_q: bool = False, distribute_slack: bool = False) NumericPowerFlowResults[source]ο
Fast decoupled power flow :param nc: NumericalCircuit instance :param Vbus: array of initial voltages :param S0: array of power Injections :param I0: array of current Injections :param Y0: array of admittance Injections :param Ybus: Admittance matrix :param Yf: Admittance from matrix :param Yt: Admittance to matrix :param Yshunt_bus: Array of shunts to add to the diagonal (from shunt devices) :param B1: Bβ matrix for the fast decoupled algorithm :param B2: Bββ matrix for the fast decoupled algorithm :param pv_: Array with the indices of the PV buses :param pq_: Array with the indices of the PQ buses :param pqv_: Array with the indices of the PQV buses :param p_: Array with the indices of the P buses :param vd_: Array with the indices of the VD buses :param Qmin: Minimum voltage :param Qmax: Maximum voltage :param tol: Tolerance :param bus_installed_power: Array of installed power per bus :param max_it: maximum number of iterations :param control_q: Control Q method :param distribute_slack: Distribute Slack method :return: NumericPowerFlowResults instance
VeraGridEngine.Simulations.PowerFlow.NumericalMethods.gauss_power_flow moduleο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.gauss_power_flow.gausspf(nc: NumericalCircuit, Ybus: csc_matrix, Yf: csc_matrix, Yt: csc_matrix, Yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], V0: ndarray[tuple[Any, ...], dtype[complex128]], pv: ndarray[tuple[Any, ...], dtype[int64]], pq: ndarray[tuple[Any, ...], dtype[int64]], p: ndarray[tuple[Any, ...], dtype[int64]], pqv: ndarray[tuple[Any, ...], dtype[int64]], vd: ndarray[tuple[Any, ...], dtype[int64]], bus_installed_power: ndarray[tuple[Any, ...], dtype[float64]], Qmin: ndarray[tuple[Any, ...], dtype[float64]], Qmax: ndarray[tuple[Any, ...], dtype[float64]], tol=0.001, max_it=50, control_q=False, distribute_slack=False, verbose=False, logger: Logger = None) NumericPowerFlowResults[source]ο
Gauss-Seidel Power flow :param nc: NumericalCircuit :param Ybus: Admittance matrix :param Yf: Admittance from matrix :param Yt: Admittance to matrix :param Yshunt_bus: Vector of admittance due to devices :param S0: Power Injections array :param I0: Current Injections array :param Y0: Admittance Injections array :param V0: Voltage seed solution array :param pv: array of pv-node indices :param pq: array of pq-node indices :param p: array of p-node indices :param pqv: array of pqv-node indices :param vd: array of vd-node indices :param bus_installed_power: array of bus installed power :param Qmin: Minimum Q limits per bus :param Qmax: Maximum Q limits per bus :param tol: Tolerance :param max_it: Maximum number of iterations :param control_q: Control Q limits? :param distribute_slack: Distribute Slack? :param verbose: Verbose? :param logger: Logger to store the debug information :return: NumericPowerFlowResults instance
VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow moduleο
- class VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow.HelmPreparation[source]ο
Bases:
object
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow.conv1(A, B, c)[source]ο
Performs the convolution of A* and B :param A: Coefficients matrix 1 (orders, buses) :param B: Coefficients matrix 2 (orders, buses) :param c: order of the coefficients :return: Array with the convolution for the buses given by βindicesβ
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow.conv1_old(A, B, c, indices)[source]ο
Performs the convolution of A* and B :param A: Coefficients matrix 1 (orders, buses) :param B: Coefficients matrix 2 (orders, buses) :param c: order of the coefficients :param indices: bus indices array :return: Array with the convolution for the buses given by βindicesβ
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow.conv2(A, B, c, indices)[source]ο
Performs the convolution of A and B :param A: Coefficients matrix 1 (orders, buses) :param B: Coefficients matrix 2 (orders, buses) :param c: order of the coefficients :param indices: bus indices array :return: Array with the convolution for the buses given by βindicesβ
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow.conv3(A, B, c, indices)[source]ο
Performs the convolution of A and B* :param A: Coefficients matrix 1 (orders, buses) :param B: Coefficients matrix 2 (orders, buses) :param c: order of the coefficients :param indices: bus indices array :return: Array with the convolution for the buses given by βindicesβ
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow.epsilon(Sn, n, E)[source]ο
- Fast recursive Wynnβs epsilon algorithm from:
NONLINEAR SEQUENCE TRANSFORMATIONS FOR THE ACCELERATION OF CONVERGENCE AND THE SUMMATION OF DIVERGENT SERIES
by Ernst Joachim Weniger
- Args:
Sn: sum of coefficients n: order E: Coefficients structure copy that is modified in this algorithm
Returns:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow.helm_coefficients_dY(dY, sys_mat_factorization, Uini, Xini, Yslack, Ysh, Ybus, vec_P, vec_Q, S0, vec_W, V0, Vslack, pq, pv, pqpv, npqpv, nbus, sl, pqpv_original, pq_original, tolerance=1e-06, max_coeff=10)[source]ο
Holomorphic Embedding LoadFlow Method as formulated by Josep Fanals Batllori in 2020 This function just returns the coefficients for further usage in other routines
- Based on the paper: Novel AC Distribution Factor for Efficient Outage Analysis
Rui Yao, Senior Member, IEEE, and Feng Qiu, Senior Member, IEEE
- Parameters:
dY
sys_mat_factorization β factorized HELM system matrix
Uini
Xini
Yslack
Ysh
Ybus
vec_P
vec_Q
S0 β vector of specified power
vec_W
V0 β vector of specified voltages
Vslack
pq β reduced scheme list of pq nodes
pv β reduced scheme list of pv nodes
pqpv β reduced scheme list of pq|pv nodes
npqpv β number of pq and pv nodes
nbus β number of nodes
pqpv β sorted list of pq and pv nodes
:param pq:list of pq nodes :param sl: list of slack nodes :param pqpv_original: sorted list of pq and pv nodes in the original order, considering slack :param pq_original: list of pq nodes in the original order, considering slack :param tolerance: target error (or tolerance) :param max_coeff: maximum number of coefficients :return: U, V, iter_, norm_f
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow.helm_coefficients_josep(Ybus: csc_matrix, Yseries: csc_matrix, V0: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], Ysh0: ndarray[tuple[Any, ...], dtype[complex128]], pq: ndarray[tuple[Any, ...], dtype[int64]], pv: ndarray[tuple[Any, ...], dtype[int64]], sl: ndarray[tuple[Any, ...], dtype[int64]], no_slack: ndarray[tuple[Any, ...], dtype[int64]], tolerance=1e-06, max_coeff=30, verbose=False, stop_if_too_bad=False, logger: Logger = None)[source]ο
Holomorphic Embedding LoadFlow Method as formulated by Josep Fanals Batllori in 2020 This function just returns the coefficients for further usage in other routines :param Ybus: Admittance matrix :param Yseries: Admittance matrix of the series elements :param V0: vector of specified voltages :param S0: vector of specified power :param Ysh0: vector of shunt admittances (including the shunts of the Branches) :param pq: list of pq nodes :param pv: list of pv nodes :param sl: list of slack nodes :param no_slack: sorted list of pq and pv nodes :param tolerance: target error (or tolerance) :param max_coeff: maximum number of coefficients :param verbose: print intermediate information :param stop_if_too_bad: stop when things go wrong :param logger: Logger object to store the debug info :return: U, X, Q, V, iterations
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow.helm_josep(nc: NumericalCircuit, Ybus: csc_matrix, Yf: csc_matrix, Yt: csc_matrix, Yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]], Yseries: csc_matrix, V0: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], Ysh0: ndarray[tuple[Any, ...], dtype[complex128]], pq: ndarray[tuple[Any, ...], dtype[int64]], pv: ndarray[tuple[Any, ...], dtype[int64]], vd: ndarray[tuple[Any, ...], dtype[int64]], no_slack: ndarray[tuple[Any, ...], dtype[int64]], tolerance: float = 1e-06, max_coefficients: int = 30, use_pade: bool = True, verbose: int = 0, logger: Logger = None) NumericPowerFlowResults[source]ο
Holomorphic Embedding LoadFlow Method as formulated by Josep Fanals Batllori in 2020 :param nc: NumericalCircuit :param Ybus: Complete admittance matrix :param Yf: admittance from matrix :param Yt: admittance to matrix :param Yseries: Admittance matrix of the series elements :param V0: vector of specified voltages :param S0: vector of specified power :param Ysh0: vector of shunt admittances (including the shunt βlegsβ of the pi Branches) :param pq: list of pq nodes :param pv: list of pv nodes :param vd: list of slack nodes :param no_slack: sorted list of pq and pv nodes :param tolerance: target error (or tolerance) :param max_coefficients: maximum number of coefficients :param use_pade: Use the PadΓ¨ approximation? otherwise, a simple summation is done :param verbose: print intermediate information :param logger: Logger object to store the debug info :return: V, converged, norm_f, Scalc, iter_, elapsed
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow.helm_preparation_dY(Yseries, V0, S0, Ysh0, pq, pv, sl, pqpv, verbose: int = 0, logger: Logger = None) HelmPreparation[source]ο
This function returns the constant objects to run many HELM simulations
- Based on the paper: Novel AC Distribution Factor for Efficient Outage Analysis
Rui Yao, Senior Member, IEEE, and Feng Qiu, Senior Member, IEEE
- Parameters:
Yseries β Admittance matrix of the series elements
V0 β vector of specified voltages
S0 β vector of specified power
Ysh0 β vector of shunt admittances (including the shunts of the Branches)
pq β list of pq nodes
pv β list of pv nodes
sl β list of slack nodes
pqpv β sorted list of pq and pv nodes
verbose β print intermediate information
logger β Logger object to store the debug info
- Returns:
U, X, Q, V, iterations
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow.pade4all(order, coeff_mat, s=1.0)[source]ο
Computes the βorderβ PadΓ¨ approximant of the coefficients at the approximation point s
- Arguments:
coeff_mat: coefficient matrix (order, buses) order: order of the series s: point of approximation (at 1 you get the voltage)
- Returns:
Padè approximation at s for all the series
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.helm_power_flow.sigma_function(coeff_matU, coeff_matX, order, V_slack)[source]ο
- Parameters:
coeff_matU β array with voltage coefficients
coeff_matX β array with inverse conjugated voltage coefficients
order β should be prof - 1
V_slack β slack bus voltage vector. Must contain only 1 slack bus
- Returns:
sigma complex value
VeraGridEngine.Simulations.PowerFlow.NumericalMethods.iwamoto_newton_raphson moduleο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.iwamoto_newton_raphson.IwamotoNR(nc: NumericalCircuit, Ybus: csc_matrix, Yf: csc_matrix, Yt: csc_matrix, Yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], V0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], pv_: ndarray[tuple[Any, ...], dtype[int64]], pq_: ndarray[tuple[Any, ...], dtype[int64]], pqv_: ndarray[tuple[Any, ...], dtype[int64]], p_: ndarray[tuple[Any, ...], dtype[int64]], vd_: ndarray[tuple[Any, ...], dtype[int64]], Qmin: ndarray[tuple[Any, ...], dtype[float64]], Qmax: ndarray[tuple[Any, ...], dtype[float64]], tol: float, max_it: int = 15, control_q: bool = False, robust: bool = False, logger: Logger = None) NumericPowerFlowResults[source]ο
Solves the power flow using a full Newtonβs method with the Iwamoto optimal step factor. :param nc: NumericalCircuit instance :param Ybus: Admittance matrix :param Yf: Admittance from matrix :param Yt: Admittance to matrix :param S0: Array of nodal power Injections :param V0: Array of nodal voltages (initial solution) :param I0: Array of nodal current Injections :param Y0: Array of nodal admittance Injections :param pv_: Array with the indices of the PV buses :param pq_: Array with the indices of the PQ buses :param pqv_: Array with the indices of the PQV buses :param p_: Array with the indices of the P buses :param vd_: Array with the indices of the slack buses :param Qmin: Array of nodal minimum reactive power injections :param Qmax: Array of nodal maximum reactive power injections :param tol: Tolerance :param max_it: Maximum number of iterations :param control_q: Control reactive power? :param robust: use of the Iwamoto optimal step factor?. :param logger: Logger :return: Voltage solution, converged?, error, calculated power Injections
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.iwamoto_newton_raphson.mu(Ybus: csc_matrix, J: CSC, incS: ndarray[tuple[Any, ...], dtype[float64]], dV: ndarray[tuple[Any, ...], dtype[complex128]], dx: ndarray[tuple[Any, ...], dtype[float64]], block1_idx: ndarray[tuple[Any, ...], dtype[int64]], block2_idx: ndarray[tuple[Any, ...], dtype[int64]], block3_idx: ndarray[tuple[Any, ...], dtype[int64]])[source]ο
Calculate the Iwamoto acceleration parameter as described in: βA Load Flow Calculation Method for Ill-Conditioned Power Systemsβ by Iwamoto, S. and Tamura, Y.β :param Ybus: Admittance matrix :param J: Jacobian matrix :param incS: mismatch vector :param dV: voltage increment (in complex form) :param dx: solution vector as calculated dx = solve(J, incS) :param block1_idx: pv, pq, p, pqv :param block2_idx: pq, p :param block3_idx: pq, pqv :return: the Iwamotoβs optimal multiplier for ill conditioned systems
VeraGridEngine.Simulations.PowerFlow.NumericalMethods.levenberg_marquadt_fx moduleο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.levenberg_marquadt_fx.levenberg_marquardt_fx(problem: PfFormulationTemplate, tol: float = 1e-06, max_iter: int = 10, verbose: int = 0, logger: Logger = <VeraGridEngine.basic_structures.Logger object>) NumericPowerFlowResults[source]ο
Levenberg-Marquardt to solve:
min: error(f(x)) s.t.
f(x) = 0
From METHODS FOR NON-LINEAR LEAST SQUARES PROBLEMS by K. Madsen, H.B. Nielsen, O. Tingleff
- Parameters:
problem β PfFormulationTemplate
tol β Error tolerance
max_iter β Maximum number of iterations
verbose β Display console information
logger β Logger instance
- Returns:
ConvexMethodResult
VeraGridEngine.Simulations.PowerFlow.NumericalMethods.linearized_power_flow moduleο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.linearized_power_flow.acdc_lin_pf(nc: NumericalCircuit, Bbus: csc_matrix, Bf: csc_matrix, Gbus: csc_matrix, Gf: csc_matrix, ac: ndarray[tuple[Any, ...], dtype[int64]], dc: ndarray[tuple[Any, ...], dtype[int64]], vd: ndarray[tuple[Any, ...], dtype[int64]], pv: ndarray[tuple[Any, ...], dtype[int64]], S0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], V0: ndarray[tuple[Any, ...], dtype[complex128]], tau: ndarray[tuple[Any, ...], dtype[float64]]) NumericPowerFlowResults[source]ο
Solves a linear-ACDC power flow. :param nc: :param Bbus: :param Bf: :param Gbus: :param Gf: :param ac: :param dc: :param vd: :param pv: :param S0: :param I0: :param Y0: :param V0: :param tau: :return:
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.linearized_power_flow.lacpf(nc: NumericalCircuit, Ybus: csc_matrix, Yf: csc_matrix, Yt: csc_matrix, Ys: csc_matrix, Yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]], S0: ndarray[tuple[Any, ...], dtype[complex128]], V0: ndarray[tuple[Any, ...], dtype[complex128]], pq: ndarray[tuple[Any, ...], dtype[int64]], pv: ndarray[tuple[Any, ...], dtype[int64]], vd: ndarray[tuple[Any, ...], dtype[int64]], logger: Logger) NumericPowerFlowResults[source]ο
Linearized AC Load Flow
form the article:
- Linearized AC Load Flow Applied to Analysis in Electric Power Systems
by: P. Rossoni, W. M da Rosa and E. A. Belati
- Parameters:
nc β NumericalCircuit instance
Ybus β Admittance matrix
Yf β Admittance from matrix
Yt β Admittance to matrix
Ys β Admittance matrix of the series elements
Yshunt_bus β Admittance vector of the series elements per bus
S0 β Power Injections vector of all the nodes
V0 β Set voltages of all the nodes (used for the slack and PV nodes)
pq β list of indices of the pq nodes
pv β list of indices of the pv nodes
vd β Array with the indices of the slack buses
logger β Logger
- Returns:
NumericPowerFlowResults
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.linearized_power_flow.linear_pf(nc: NumericalCircuit, Ybus: csc_matrix, Bpqpv: csc_matrix, Bref: csc_matrix, Bf: csc_matrix, S0: ndarray[tuple[Any, ...], dtype[complex128]], I0: ndarray[tuple[Any, ...], dtype[complex128]], Y0: ndarray[tuple[Any, ...], dtype[complex128]], V0: ndarray[tuple[Any, ...], dtype[complex128]], tau: ndarray[tuple[Any, ...], dtype[float64]], vd: ndarray[tuple[Any, ...], dtype[int64]], no_slack: ndarray[tuple[Any, ...], dtype[int64]], pq: ndarray[tuple[Any, ...], dtype[int64]], pv: ndarray[tuple[Any, ...], dtype[int64]]) NumericPowerFlowResults[source]ο
Solves a linear-DC power flow. :param nc: NumericalCircuit instance :param Ybus: Normal circuit admittance matrix :param Bpqpv: Susceptance matrix reduced :param Bref: Susceptance matrix sliced for the slack node :param Bf: Susceptance matrix of the Branches to nodes (used to include the phase shifters) :param S0: Complex power Injections at all the nodes :param I0: Complex current Injections at all the nodes :param Y0: Complex admittance Injections at all the nodes :param V0: Array of complex seed voltage (it contains the ref voltages) :param tau: Array of branch angles :param vd: array of the indices of the slack nodes :param no_slack: array of the indices of the non-slack nodes :param pq: array of the indices of the pq nodes :param pv: array of the indices of the pv nodes :return: NumericPowerFlowResults instance
VeraGridEngine.Simulations.PowerFlow.NumericalMethods.newton_raphson_fx moduleο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.newton_raphson_fx.newton_raphson_fx(problem: PfFormulationTemplate, tol: float = 1e-06, max_iter: int = 10, trust: float = 1.0, verbose: int = 0, logger: Logger = <VeraGridEngine.basic_structures.Logger object>) NumericPowerFlowResults[source]ο
Newton-Raphson with Line search to solve:
min: error(g(x)) s.t.
g(x) = 0
- Parameters:
problem β PfFormulationTemplate
tol β Error tolerance
max_iter β Maximum number of iterations
trust β trust amount in the derivative length correctness
verbose β Display console information
logger β Logger instance
- Returns:
ConvexMethodResult
VeraGridEngine.Simulations.PowerFlow.NumericalMethods.powell_fx moduleο
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.powell_fx.compute_beta(a: ndarray[tuple[Any, ...], dtype[float64]], b: ndarray[tuple[Any, ...], dtype[float64]], delta: float)[source]ο
compute the beta parameter :param a: alpha + hsd :param b: hgn :param delta: trust region :return: beta value
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.powell_fx.compute_hdl(hgn: ndarray[tuple[Any, ...], dtype[float64]], hsd: ndarray[tuple[Any, ...], dtype[float64]], g: ndarray[tuple[Any, ...], dtype[float64]], alpha: float, delta: float, f_error: float) Tuple[ndarray[tuple[Any, ...], dtype[float64]], float][source]ο
Compute the Hdl vector :param hgn: Hgn vector :param hsd: Hsd vector :param g: g vector :param alpha: alpha parameter :param delta: delta parameter (trust region size) :param f_error: error of the function top optimize :return: Hdl Vector, L(0) - L(hdl)
- VeraGridEngine.Simulations.PowerFlow.NumericalMethods.powell_fx.powell_fx(problem: PfFormulationTemplate, tol: float = 1e-06, max_iter: int = 10, trust: float = 1.0, verbose: int = 0, logger: Logger = <VeraGridEngine.basic_structures.Logger object>) NumericPowerFlowResults[source]ο
Powellβs Dog leg algorithm to solve:
min: error(f(x)) s.t.
f(x) = 0
From METHODS FOR NON-LINEAR LEAST SQUARES PROBLEMS by K. Madsen, H.B. Nielsen, O. Tingleff
- Parameters:
problem β PfFormulationTemplate
tol β Error tolerance
max_iter β Maximum number of iterations
trust β trust amount in the derivative length correctness
verbose β Display console information
logger β Logger instance
- Returns:
ConvexMethodResult