Module ml4opf.functional.soc

SOCOPF Functional interface

Functions

def balance_residual_bus(pd_bus: torch.Tensor,
qd_bus: torch.Tensor,
pg_bus: torch.Tensor,
qg_bus: torch.Tensor,
w: torch.Tensor,
pf_bus: torch.Tensor,
pt_bus: torch.Tensor,
qf_bus: torch.Tensor,
qt_bus: torch.Tensor,
gs_bus: torch.Tensor,
bs_bus: torch.Tensor) ‑> tuple[torch.Tensor, torch.Tensor]

Compute power balance residual.

\text{p_viol} = \text{pg_bus} - \text{pd_bus} - \text{pt_bus} - \text{pf_bus} - \text{gs_bus} \times \text{vm}^2 \text{q_viol} = \text{qg_bus} - \text{qd_bus} - \text{qt_bus} - \text{qf_bus} + \text{bs_bus} \times \text{vm}^2

Args

pd_bus : Tensor
Active power demand at each bus. (batch, n_bus)
qd_bus : Tensor
Reactive power demand at each bus. (batch, n_bus)
pg_bus : Tensor
Active power generation at each bus. (batch, n_bus)
qg_bus : Tensor
Reactive power generation at each bus. (batch, n_bus)
w : Tensor
Voltage magnitude squared at each bus. (batch, n_bus)
pf_bus : Tensor
Active power flow from each bus. (batch, n_bus)
pt_bus : Tensor
Active power flow to each bus. (batch, n_bus)
qf_bus : Tensor
Reactive power flow from each bus. (batch, n_bus)
qt_bus : Tensor
Reactive power flow to each bus. (batch, n_bus)
gs_bus : Tensor
Shunt conductance at each bus. (batch, n_bus)
bs_bus : Tensor
Shunt susceptance at each bus. (batch, n_bus)

Returns

tuple[Tensor]
Active and reactive power balance violation \text{p_viol}, \text{q_viol} each of shape (batch, n_bus).
def flows_from_voltage(w: torch.Tensor,
wr: torch.Tensor,
wi: torch.Tensor,
fbus: torch.Tensor,
tbus: torch.Tensor,
gff: torch.Tensor,
gft: torch.Tensor,
gtf: torch.Tensor,
gtt: torch.Tensor,
bff: torch.Tensor,
bft: torch.Tensor,
btf: torch.Tensor,
btt: torch.Tensor) ‑> tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]

Compute power flows from w, wr, wi, and branch info.

def jabr_residual(w: torch.Tensor,
wr: torch.Tensor,
wi: torch.Tensor,
fbus: torch.Tensor,
tbus: torch.Tensor)

Compute the Jabr constraint residual.

def voltage_phasor_bounds(E: int,
vmin: torch.Tensor,
vmax: torch.Tensor,
dvamin: torch.Tensor,
dvamax: torch.Tensor,
bus_fr: torch.Tensor,
bus_to: torch.Tensor) ‑> tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]

Compute the voltage phasor bounds.

Args

E : int
Number of branches.
vmin : Tensor
Minimum voltage magnitude at each bus. (n_bus)
vmax : Tensor
Maximum voltage magnitude at each bus. (n_bus)
dvamin : Tensor
Minimum voltage angle difference across each branch. (E)
dvamax : Tensor
Maximum voltage angle difference across each branch. (E)
bus_fr : Tensor
From bus of each branch. (E)
bus_to : Tensor
To bus of each branch. (E)

Returns

tuple[Tensor]
Minimum and maximum real and imaginary parts of the voltage phasor at each branch. \text{wr_min}, \text{wr_max}, \text{wi_min}, \text{wi_max} each of shape (E).