Finite Difference Method
We often want to estimate or compute the amount of something, maybe energy, when energy is continuously being added and taken away.
Imagine we have a building or box where we are adding thermal energy with a heater, but energy is also leaving the box through conduction, convection, and radiation.
Starting Point
A simple model to start with is a loan. Here, the quantity we want to estimate is the balance and the interest is adding to the balance and payments are subtracting from the balance.
The moment we take out a loan, we balance of money we owe is the original loan amount.
One period later, the bank adds the interest to our balance by multiplying the balance owed by the interest rate. At the same time, we make a payment that reduces the balance.
We can create a spreadsheet that computes this. Each row will be a period and we start with the previous balance, add the interest, and subtract the payment to create the new balance. Then we do this for several periods and we can see the balance.
This is happening at discrete intervals, but we can also do this continuously.
Energy or charge in a battery
To show how to use this method in an energy context we’ll use an “ideal battery” that we are charging and discharging.
E(t) = \int_{t_{\textrm{start}}}^{t}\frac{dE}{dt}dt + E(t_{\textrm{start}})
E(t) = \int_{t_{\textrm{start}}}^{t} (P_{\textrm{charge}} - P_{\textrm{discharge}}) dt + E(t_{\textrm{start}})
To do this numerically, we can do this in small steps:
E_{n+1} = E_{n} + P_{\textrm{charge}, n} \cdot \Delta t - P_{\textrm{discharge}, n} \cdot \Delta t
Both Pdt and P\Delta t are small rectangles of energy that we are adding to get the energy.
Temperature of a simple building or box
Under construction