(batch, Ybus)
| 249 | return Ybus |
| 250 | |
| 251 | def deltapq_loss(batch, Ybus): |
| 252 | Vm, Va, P_net, Q_net = 0, 1, 2, 3 |
| 253 | bus = batch.to_homogeneous().x |
| 254 | v = bus[:, Vm] * torch.exp(1j * bus[:, Va]) |
| 255 | i = torch.conj(torch.matmul(Ybus, v)) |
| 256 | s = v * i + bus[:, P_net] + 1j * bus[:, Q_net] |
| 257 | |
| 258 | delta_p = torch.real(s) |
| 259 | delta_q = torch.imag(s) |
| 260 | return delta_p, delta_q |
| 261 | |
| 262 | |
| 263 | # -------------------------- # |
no outgoing calls
no test coverage detected