pypowsybl
pypowsybl copied to clipboard
Deliver i and v values on DC loadflows
Describe the current behavior
When running DC loadflows, powsybl currently returns NaN for net.get_branches()["i1"]
and net.get_buses()["v_mag"]
Describe the expected behavior
While it's correct that the DC loadflows don't return q values, v
and i
values are actually defined in the DC loadflow framework. v
is defined to be just v_nominal
and hence I
can be computed through i = p / (sqrt(3) * v_nominal)
.
It would be nice if these values are returned, both for the normal loadflows and for the security analysis, as it makes comparing with current limits easier. Especially the i
value is important there but logically the v_mag value could also be returned.
Describe the motivation
No response
Extra Information
A simple implementation in python could look like this
injections = pd.merge(
left=net.get_injections(),
right=net.get_voltage_levels()["nominal_v"],
left_on="voltage_level_id",
right_index=True,
)
injections["i"] = (
injections["p"] / (injections["nominal_v"] * math.sqrt(3) * 1e-3)
).abs()
del injections["nominal_v"]
and
branches = pd.merge(
left=net.get_branches(),
right=net.get_voltage_levels()["nominal_v"].rename("nominal_v_1"),
left_on="voltage_level1_id",
right_index=True,
)
branches = pd.merge(
left=branches,
right=net.get_voltage_levels()["nominal_v"].rename("nominal_v_2"),
left_on="voltage_level2_id",
right_index=True,
)
branches["i1"] = (
branches["p1"] / (branches["nominal_v_1"] * math.sqrt(3) * 1e-3)
).abs()
branches["i2"] = (
branches["p2"] / (branches["nominal_v_2"] * math.sqrt(3) * 1e-3)
).abs()
del branches["nominal_v_1"]
del branches["nominal_v_2"]