Hi there,
i have difficulties to define constraints for a storage element.
I would like to integrate a constraints acoording to which the storage can be wither charged or discharged at each time step.
I would like to use the following function:
SOC (t) <= storage.capacity (t) * (1-storage.inputs(t).fix)
and
SOC (t) >= storage.capacity (t)*storage.outputs(t).fix)
If someone has anytips, i would be really grateful.
BR
Roberta
This is how i tried it, but it is not working:
datetimeindex = pd.date_range('04/08/2019', periods=8760, freq='60min')
esys = solph.EnergySystem(timeindex=datetimeindex)
esys = fill_energysystem(esys, esysd_filename)
# ***** Defining the Storages of the States *****
Electricity_Storage_State_1: GenericStorage = solph.GenericStorage(
label="Electricity Storage State 1",
inputs={esys.entities[4]: solph.Flow(nominal_value=10, variable_costs=0.1)},
outputs={esys.entities[3]: solph.Flow(nominal_value=10, variable_costs=0.1)},
loss_rate=0, nominal_storage_capacity=100000, initial_storage_level=0.5, balanced=True,
inflow_conversion_factor=0.7, outflow_conversion_factor=0.7)
esys.add(Electricity_Storage_State_1)
model = solph.Model(esys)
For t in model.datetimeindex
model.solph.constraints(
expr=solph.Flow(Electricity_Storage_State_1, esys.entities[4])[t] <= storage.nominal_value[t] * (1 - Electricity_Storage_State_1.inputs[esys.entities[4]][t].fix),
label='max_charge_' + str(t)
)
model.solph.constraints(
expr=solph.Flow(Electricity_Storage_State_1, esys.entities[3])[t] >= -Electricity_Storage_State_1.nominal_value[t] * Electricity_Storage_State_1.outputs[esys.entities[3]][t].fix,
label='max_discharge_' + str(t)
)
# Add constraint function to the model for each time step
for t in esys.timeindex:
charge_discharge_constraint(esys, t)```