Error when using storage object with time dependent min/max storage levels

Hey there,
I am running into a problem with the storage object not working with a sequence of values for the min_storage_level and max_storage_level. I have it currently set up like this:

storage = solph.components.GenericStorage(
    nominal_storage_capacity=100,
    label="storage",
    inputs={bel: solph.Flow(nominal_value=22)},
    outputs={
        bel: solph.Flow(nominal_value=22, variable_costs=0)
    },
    min_storage_level=data["min_storage"],
    max_storage_level=data["max_storage"]
)

energysystem.add(storage)

I’m using this data for testing:

timestep,demand_el,min_storage,max_storage,grid_avail
1,20,0.8,1,20
2,20,0.8,1,15
3,20,0.8,1,15
4,10,0,0,15
5,10,0,0,10
6,10,0,0,15

Interestingly, if I set all values for min_storage to zero it seems to work. Otherwise I get an error.

ERROR: evaluating object as numeric value: flow[grid,electricity,0]
        (object: <class 'pyomo.core.base.var._GeneralVarData'>)
    No value for uninitialized NumericValue object flow[grid,electricity,0]

I can provide more code if necessary. I am thankful for advice.

Hi @MariusD,

Seeing this makes me think that the problem might be caused by an insufficiently long time series for the limit of the storage level. please note that demands (power) are defined on time intervals but storage content (energy) on points in time. Thus, you have one more storage level than you have demand values.

(Without a minimum working example, it’s hard to pin down the issue.)

Hi,
thank you for the clarification. I think, that was actually the problem.