Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion edisgo/io/pypsa_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def _get_grid_component_dict(grid_object):
],
"Line": grid_object.lines_df.loc[
:,
["bus0", "bus1", "x", "r", "s_nom", "num_parallel", "length"],
["bus0", "bus1", "x", "r", "b", "s_nom", "num_parallel", "length"],
],
}
return components
Expand Down
30 changes: 30 additions & 0 deletions tests/io/test_pypsa_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,36 @@ def test_to_pypsa(self):
assert len(pypsa_network.buses) == 15
# ToDo: Check further things and parameter options

def test_to_pypsa_line_b_column_consistent_across_modes(self):
# the full-grid path (mode=None) and the per-grid paths (mode="mv" and
# mode="lv") used to select different Line columns from lines_df, with
# the per-grid paths silently dropping "b" (see GitHub issue #654).
# Since "b" is always zero in eDisGo grids today, that regressed
# silently, so set a distinguishing non-zero value here to catch it.
self.edisgo = EDisGo(ding0_grid=pytest.ding0_test_network_path)
self.edisgo.set_time_series_worst_case_analysis()
timeindex = self.edisgo.timeseries.timeindex

mv_grid = self.edisgo.topology.mv_grid
lv_grid = self.edisgo.topology.get_lv_grid(1)
mv_line = mv_grid.lines_df.index[0]
lv_line = lv_grid.lines_df.index[0]
self.edisgo.topology.lines_df.loc[mv_line, "b"] = 1.234e-5
self.edisgo.topology.lines_df.loc[lv_line, "b"] = 5.678e-5

pypsa_network_full = pypsa_io.to_pypsa(self.edisgo, timesteps=timeindex)
pypsa_network_mv = pypsa_io.to_pypsa(
self.edisgo, timesteps=timeindex, mode="mv"
)
pypsa_network_lv = pypsa_io.to_pypsa(
self.edisgo, timesteps=timeindex, mode="lv", lv_grid_id=lv_grid.id
)

assert pypsa_network_full.lines.loc[mv_line, "b"] == 1.234e-5
assert pypsa_network_full.lines.loc[lv_line, "b"] == 5.678e-5
assert pypsa_network_mv.lines.loc[mv_line, "b"] == 1.234e-5
assert pypsa_network_lv.lines.loc[lv_line, "b"] == 5.678e-5

def test_append_lv_components(self):
lv_components = {
"Load": pd.DataFrame(),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_edisgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,8 @@ def test_enhanced_reinforce_grid(self):

results = edisgo_obj.results

assert len(results.grid_expansion_costs) == 454
assert len(results.equipment_changes) == 892
assert len(results.grid_expansion_costs) == 453
assert len(results.equipment_changes) == 835
assert results.v_res.shape == (4, 148)

edisgo_obj = copy.deepcopy(self.edisgo)
Expand Down