Skip to content

Commit

Permalink
io, pf: Change order of components read in; better slack reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
nworbmot committed Nov 30, 2016
1 parent ff91ae2 commit bc7584a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pypsa/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ def import_from_csv_folder(network, csv_folder_name, encoding=None):
if "weightings" in df.columns:
network.snapshot_weightings = df["weightings"].reindex(network.snapshots)

#now read in other components
for cls in pypsa.components.component_types - {pypsa.components.SubNetwork}:
#now read in other components; make sure buses and carriers come first
for cls in sorted(pypsa.components.component_types - {pypsa.components.SubNetwork},key=lambda cls:cls.__name__):

list_name = cls.list_name

Expand Down
6 changes: 3 additions & 3 deletions pypsa/pf.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,18 +414,18 @@ def find_slack_bus(sub_network):
if len(slacks) == 0:
sub_network.slack_generator = gens.index[0]
sub_network.network.generators.loc[sub_network.slack_generator,"control"] = "Slack"
logger.debug("No slack generator found, using %s as the slack generator", sub_network.slack_generator)
logger.debug("No slack generator found in sub-network {}, using {} as the slack generator".format(sub_network.name, sub_network.slack_generator))

elif len(slacks) == 1:
sub_network.slack_generator = slacks[0]
else:
sub_network.slack_generator = slacks[0]
sub_network.network.generators.loc[slacks[1:],"control"] = "PV"
logger.debug("More than one slack generator found, taking %s to be the slack generator", sub_network.slack_generator)
logger.debug("More than one slack generator found in sub-network {}, using {} as the slack generator".format(sub_network.name, sub_network.slack_generator))

sub_network.slack_bus = gens.bus[sub_network.slack_generator]

logger.info("Slack bus is %s" % sub_network.slack_bus)
logger.info("Slack bus for sub-network {} is {}".format(sub_network.name, sub_network.slack_bus))


def find_bus_controls(sub_network):
Expand Down

0 comments on commit bc7584a

Please sign in to comment.