In the case of grid-connected microgrid, I want to set up a force charging for battery, i.e. charging is forced when battery SOC is lower than force_charge_SOC. Could someone tell me if it is possible to do this with solph? and how pls?
Hi @vlle, I donāt use solph. But for an entire horizon problem, perhaps just add the following condition to the mix ā on the assumption that two periods are required for the recharge and that discharging is banned (although that constraint is not shown) while recharging (perhaps this is an electric vehicle):
if SOC_t < force_charge_SOC,āthen battery_t+1,2 = āF_t+1,2
where:
t : the prevailing period t battery_t : battery outflow at period t (negative values represents inflows) SOC_t : battery state of charge at period t force_charge_SOC : a constant defining the minimum state of charge (say something like 20%) t+1,2 : indicates the future two periods (assuming two periods are required for charging)
If discharge and recharge can occur simultaneously, you will also need to cater for that situation with variables for both battery_in_t and battery_out_t. And unless F can additionally supply that prevailing load too, the underlying logic will need to be more sophisticated to adaptively cater for battery charging that necessarily exceeds more than two periods.
If āforced chargingā is just required to get the SOC above that level, you will end up having a minimal SOC. This can be easily added using min_storage_level. If you want something that forces the battery to charge (above some minimum rate) to a defined higher SOC (e.g. from 20% to 80 % with at least 2 kW), thatās not implemented. However, I guess that the optimization would often try stay above that level to avoid the penalty (almost no flexibility afterwards).
(@robbie.morrison: In the background, solph creates a set of linear equations and a solver then seeks the minimum costs within that. Conditions and classical control strategies are not easily implemented.)
To formulate a āforced chargeā, there needs to be a constraint added to the energy system that is not formulated by solph. You can do that, as solph gives access to the underlying pyomo code, if you need it. Iād suggest the following three equations:
SOC > minimum_SOC * (1 - start_recharge), where start_recharge is a binary variable. So, SOC needs to be above the minimum, or start_recharge needs to be one. The variable start_recharge is then also linked to the battery charging Flow with
charging_flow > minimum_flow * recharge (recharge is another binary) and
recharge[t1..tn] >= start_recharge[t0], with t1..tn representing every time step that the forced recharging should happen.