I do have a network with buses, lines, generators, generators max_pu and min_pu profiles, loads, loads-p_set and snapshots. Network data is uploaded via import_from_csv. There is a slack bus in the bus.csv file. The network carries AC (no transformers). The network.lopf() seems to work and the power balance is completed for all the buses. The LOPF deals with unit commitment (dispatch) and not optimal capacity expansion. The optimal solution is obtained in less than 30 seconds. The code for network.lopf() is written below. Current installed version of Pypsa is 0.23.

try:
    network.lopf(network.snapshots)
except Exception as e:
    print("An error occurred during optimization: " + str(e))

Adding a store unit for unit comitmment in order to balance the excess of PV solar power makes the network to run the OP forever. Any combination of hours, etc. never gets results...

I did try an isolated store and load in a new bus (random "bus1") and two links for charging and discharging (after the part of the code in which I import the network data using the import_from_csv). This also takes forever ( no results). Please see below the code in order to add the bus, the load, the store and the links:


# Add a store to the network
network.add("Bus", "bus1",
            v_nom=380,
            carrier='AC',
            control='Slack',
            )
# Add a store to the network
network.add("Store", "store1",
            bus="bus1",
            e_nom=100,
            e_initial=50,
            e_min_pu=0,
            e_max_pu=1,
            marginal_cost=1,
            )

# Add two links to the network, representing the charging and discharging of the storage unit
network.add("Link", "charging_link",
            bus0="bus1",
            bus1="bus1",
            p_nom=100,
            efficiency=0.9)

network.add("Link", "discharging_link",
            bus0="bus1",
            bus1="bus1",
            p_nom=100,
            efficiency=0.9)

# Add a load to the network
network.add("Load", "load1",
            bus="bus1",
            p_set=1)

Adding reporting options in the network.lopf as

# Setting solver options as a dictionary for GLPK
solver_options = {"msg_lev": "GLP_MSG_ALL"}


try:
    network.lopf(network.snapshots,solver_options=solver_options)
except Exception as e:
    print("An error occurred during optimization: " + str(e))

also seems to create other type of 'weird' problems (not finding a line name which is obviously in the csv file).

Any tips/clues on how to configure an energy store/two links in order to perform the network LOPF? When doing so, the optimization problems never returns a solution when it should be done in less than one minute (given the fact that the rest of the network is optimized in 30 seconds). Any configuration for the store unit so it can be executed with random value then later fitted with real values for the existing network? Thank you so much in advance ;)

1

There are 1 answers

0
euronion On

I think you have a flaw in setting up your network: The Store be connected to a dedicated bus, as the charging_link and discharging_link must not have the same Bus as bus0 and bus1.

Try this:


# Add a store to the network
network.add("Bus", "bus1",
            v_nom=380,
            carrier='AC',
            control='Slack',
            )


# Add a load to the network
network.add("Load", "load1",
            bus="bus1",
            p_set=1)

# Dedicated bus for store and it's links to connect to
network.add("Bus", "bus1_store")

# Add a store to the network
network.add("Store", "store1",
            bus="bus1_store",
            e_nom=100,
            e_initial=50,
            e_min_pu=0,
            e_max_pu=1,
            marginal_cost=1,
            )

# Add two links to the network, representing the charging and discharging of the storage unit
network.add("Link", "charging_link",
            bus0="bus1",
            bus1="bus1_store",
            p_nom=100,
            efficiency=0.9)

network.add("Link", "discharging_link",
            bus0="bus1_store",
            bus1="bus1",
            p_nom=100,
            efficiency=0.9)