Forcing a battery to a certain charge at a certain time

Hey all,
I am currently struggeling to get a battery to behave in the way I want. To break it down, I want the charge to be at least 90% at a certain part of the day.
This is my battery:

storage = solph.components.GenericStorage(
    nominal_storage_capacity=battery_cap,  # capacity = 100 kWh
    inputs={bel: solph.flows.Flow()},
    outputs={bel: solph.flows.Flow()},

As you can see, I am using a timeseries for min_storage and max_storage. To begin, I want the battery fully charged at 6:00 am, so I am using the following timeseries:

2015-01-01 00:00:00,0.25,1
2015-01-01 01:00:00,0.25,1
2015-01-01 02:00:00,0.25,1
2015-01-01 03:00:00,0.25,1
2015-01-01 04:00:00,0.25,1
2015-01-01 05:00:00,0.25,1
2015-01-01 06:00:00,1,1

Other components in the system can charge/discharge the battery, if they need energy or produce more than needed. This works fine, as long as I don’t specify the charging power of the battery. If limit the flows like this:

    inputs={car: solph.flows.Flow(nominal_value=charging_power)},
    outputs={car: solph.flows.Flow(nominal_value=charging_power)},

the model is no longer solvable. The reason for this seems to be, that by limiting the flows the battery cannot be charged fast enough in the step from 5:00 am to 6:00 am.

My question is: Is there a way for the model to “know” a few timesteps ahead, that it needs to begin charging, in order to be full at 6:00 am?

I’m thankful for any help.
Kind regards,

Hi @MariusD,

This whole issue with having to think in two different dimensions (power and energy) with two different time-indexes (time intervals and points in time) can be quite confusing and occupying mental power that could be needed for other stuff. Unluckily, I do not really see a way around this. If you feel we should have more (didactical) examples, please tell.

The model always has perfect foresight during the optimisation, so your charging_power seems to be too low to even compensate the loss_rate=0.1. You have given a capacity of 100 kWh, so you need to compensate for 10 kWh/h, which means that charging_power needs to be at least 10/0.9 (maybe round it to at least 12).