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 ;)
I think you have a flaw in setting up your network: The
Store
be connected to a dedicated bus, as thecharging_link
anddischarging_link
must not have the sameBus
asbus0
andbus1
.Try this: