How can I prevent the system from charging and discharging the battery at the same time? I already tried to set low variable costs for in- and output but that’s not working. Do you have an idea on how to fix that?
for bus in range(elStorage):
es.add(solph.components.GenericStorage(
nominal_storage_capacity=capacity,
label="elStorage"+str(bus),
inputs={bel: Flow(nominal_value=maxPower, variable_costs=0.01)},
outputs={bel: Flow(nominal_value=maxPower, variable_costs=0.01)},
loss_rate=0.001, initial_storage_level=None,
inflow_conversion_factor=chargeEfficiency, outflow_conversion_factor=dischargeEfficiency,))
its just a simple generic storage like this one.
in my model the excess electricity can be fed in the grid to gain profit. vice versa the system can buy electricity from it. These costs are not final of course and no fees are included. I tried setting the costs for buying electricity a bit higher but that had no effect either.
#bought electricity from the grid
es.add(Source(label="shortage_el", outputs={bel: Flow(variable_costs=elPrice["Preis"]+10)}))
#direct marketing for excess electricity
es.add(Sink(label="excess_el", inputs={bel: Flow(variable_costs=-1*elPrice["Preis"])}))
I get a flow situation like this, which doesn’t make a lot of sense:
There is an additional constraint in oemof.solph to prevent to flows from being active at the same time but it will create a mixed-integer problem and in my opinion this is not necessary in 90% of the cases.
Normally this indicates that it is good/necessary for the system to “dump” energy and you have to analyse why. Even though it is not the preferred/wanted it is a possible behaviour.