Battery Sizing Exercise
We are tasked with purchasing a battery for a house to complement its existing has solar PV system. In this exercise we will focus on choosing the correct battery capacity so as to provide the best return to the owners. Factors which will influence this decision include the network tariffs, the household consumption profile and the PV generation profile.
Installation
An installation of python and additional third party libraries are required:
- python
- pulp (modelling interface)
- either glpk (linear programming solver)
- or clp (linear programming solver)
Instructions
Once the above libraries are installed, download the following script and data files:
The battery.py script will be used to simulate and optimise the battery performance in this residential setting. The student will make minor changes to the script, and then record the impact of these changes.
In order to properly assess the financial impact of different batteries, we need to decide on how the battery will be controlled. The controller could be a simple reactive one or we could do more sophisticated model predictive control. For this exercise, in order to keep things simple, we assume that the battery controller has access to perfect knowledge about what will happen in the house. The controller knows exactly how much power the house will consume, and how much PV will be generated for the next 7 days. The controller then has to work out an optimal battery charge/discharge schedule.
For a given battery, the battery.py script calculates the optimal battery operation and returns the total cost for the household. For the purposes of this exercise we assume that the 7 days of data are sufficient to make a decision on the battery capacity. The data is discretised into 5 minute time steps.
E1: Cost Savings
Run the script (on command line or through IDE):
$ python battery.py
Some results will be printed and a graph will pop up that displays the power profile of the house over 7 days without any solar and without any battery.
a) What is the cost to the house and what units are these in?
Change the PV system size to 2kW:
pv_size = 2.0 # nominal PV power (kW)
Rerun the script and record the cost, notice how the total power in the house now goes negative which indicates that power is being pushed back out to the network.
b) How much does the home owner save on their electricity bill each week by owning a 2kW PV system (ignoring the cost of the PV system)?
Now include a 7kWh battery (Tesla Powerwall) in the system:
Emax = 7.0 # battery capacity (kWh)
Observe the changes in battery charge and how the household total power profile has changed. The cost takes into consideration the purchase price of the battery (with larger batteries being more expensive), averaged out over the lifetime of the battery.
c) Is it financially viable for the house to purchase this battery?
Play around with the battery size to try and get a feel for how this affects the costs to the household.
d) What is the maximum sized battery that the house could buy before it gets more expensive than solar with no battery?
e) Approximately, what is the battery size that minimises the costs of the household?
E2: Optimal battery sizing
In the previous section we manually explored different battery sizes to search for the optimal one. Instead let's find the optimal battery size by turning the battery capacity into a variable and putting it into our optimal control problem:
#Emax = 7 # battery capacity (kWh)
Emax = LpVariable('Emax', 0, None) # battery capacity (kWh)
Now the solver will find the optimal combination of control strategy and battery size.