Hi,
I can see two options,
1) Precompute a p_delta for each bus, which is the sum of generator output and bus load. Then post KCL for each bus of the form,
for i in buses
@constraint(p_delta[i] == sum{ p[(i,j)] for (i,j) in bus_edges[i] })
end
2) Break up your p values into demands and generation, then you can post,
for i in buses
@constraint(p_gen[i] - p_load[i] == sum{ p[(i,j)] for (i,j) in bus_edges[i] })
end
Depending on your use case, you might also consider using PowerModels.jl
It supports both AC and DC power flow computations.
Cheers,
-Carleton