Skip to content

Commit

Permalink
Check if there are passive branche in sub_network during post_processing
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaraBuettner committed Mar 12, 2024
1 parent 863d289 commit 179655a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pypsa/optimization/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,16 @@ def v_ang_for_(sub):
buses_i = sub.buses_o
if len(buses_i) == 1:
return pd.DataFrame(0, index=sns, columns=buses_i)
sub.calculate_B_H(skip_pre=True)
if not sub.branches().empty:
sub.calculate_B_H(skip_pre=True)
Z = pd.DataFrame(np.linalg.pinv((sub.B).todense()), buses_i, buses_i)
Z -= Z[sub.slack_bus]
return n.buses_t.p.reindex(columns=buses_i) @ Z

# TODO: if multi investment optimization, the network topology is not the necessarily the same,
# i.e. one has to iterate over the periods in order to get the correct angles.
# Determine_network_topology is not necessarily called (only if KVL was assigned)
if "obj" in n.sub_networks:
if ("obj" in n.sub_networks) and not (n.lines.empty):
n.buses_t.v_ang = pd.concat(
[v_ang_for_(sub) for sub in n.sub_networks.obj], axis=1
).reindex(columns=n.buses.index, fill_value=0.0)
Expand Down

0 comments on commit 179655a

Please sign in to comment.