Can the demand be optimized in oemof solph.Sink?

I have hit a step in the energy modelling learning curve. In Oemof I can use solph.Sink as a demand with either data from time series or a fixed value for each timestep (see below). But I can’t find out how to create demand which is free to be optimized by the model across all timesteps with only a fixed total as a constraint. Have tried summed_min (see below), but in only results in infeasibility.

efuel_bunker = solph.Sink(
label="efuel_bunker",
inputs={bef: solph.Flow(fix=data['demand_from_csv'], nominal_value=1)},
)

efuel_bunker = solph.Sink(
label="efuel_bunker",
inputs={bef: solph.Flow(fix=99100, nominal_value=1)},
)

efuel_bunker = solph.Sink(
label="efuel_bunker",
inputs={bef: solph.Flow(summed_min=870494400, nominal_value=1)},
)

I guess, you want to put an upper limit to the sink. Otherwise you will get infinite flows if using that sink can create revenue. So, consider putting a summed_max. If you really want to have a fixed total, setting summed_max and summed_min to the same value should guarantee that no matter what the costs are.

1 Like

In your case the nominal_value can be interpreted as an installed capacity of the demand. If the nominal_value is one, you can put one unit to the sink in each time step. So you would need at least
870494400 time steps to fulfil the minimum demand. If you switch the number it would work but you could satisfy the demand in one time step (theoretically).

efuel_bunker = solph.Sink(
label="efuel_bunker",
inputs={bef: solph.Flow(summed_min=1, nominal_value=870494400)},
)

You can use numbers in between like nominal_value=290164800 and summed_min=3 but keep in mind that the absolute bound is: summed_max * nominal_value

Check the results using:

[...]
model = solph.Model(energysystem)
model.solve(solver="cbc")
results = solph.processing.results(model)
demand_flow_key = [k for k in results.keys() if k[1] == efuel_bunker][0]
print(results[demand_flow_key]["sequences"]["flow"].sum())
2 Likes

It works now, after I switched the values of summed_min and nominal_value.
The components supplying the demand are optimized, so if lowest cost is to satisfy the demand in one step, so be it. :slight_smile:

Thanks!