Fuel Consumption Function
I wanted to derive a vehicle fuel consumption function for a videogame. I wanted to make it somewhat realistic where the fuel's mass is also taken into account, not just the cargo's. In this post I am documenting the result. I won't go into explaning many details. Sorry if this is too terse for you.
Setup
First of all, we define a couple constants:
- \(0 \leq u \in \mathbb{R}\): Mass of each unit of fuel.
- \(0 < r \in \mathbb{R}\): Fuel consumed per unit of mass and time. We call this the consumption rate.
Our goal is to define two functions:
- \(\lambda(m,s,t)\): Fuel remaining in the tank after carrying the mass \(m\) for the duration \(t\), starting with \(s\) units of fuel in the tank.
- \(\varphi(m,t)\): Fuel required to transport the mass \(m\) for the duration \(t\).
If we had an expression for \(\lambda\), we could get \(\varphi\) from the following equation:
\[\lambda(m, \varphi(m,t), t) = 0\]
Therefore, we will obtain \(\lambda\) first.
Consumption base
We define the constant \(\beta = e^{ru}\) and call it the consumption base. It's the base of an exponential function that will be widely used below.
The total mass function
We define the total mass function \(T\) as the function that returns the total mass of the vehicle at any given time. It's defined by adding the carried mass together with the fuel mass:
\[T(m,s,t) = m + u \lambda(m,s,t)\]
Note that, by the definition of \(\lambda\):
\[T(m,s,0) = m + us.\]
If \(m > 0\) and \(\lambda(m,s,t) \geq 0\), then \(T(m,s,t) > 0\). Neither transporting massless cargo nor having negative amounts of fuel in the tank are scenarios I would like to consider, so I will assume from now on that \(T(m,s,t)\) is always positive.
The partial derivative of \(T\) with respect to \(t\) is as follows:
\[\frac{\partial T}{\partial t} (m,s,t) = u \frac{\partial \lambda}{\partial t} (m,s,t)\]
From which it follows that, if \(u > 0\), then:
\[\frac{\partial \lambda}{\partial t} (m,s,t) = \frac{1}{u} \frac{\partial T}{\partial t} (m,s,t)\]
We will use this fact later.
Obtaining \(\lambda\)
From the definition of \(r\), we know the rate of change of \(\lambda\) over time. This can be expressed as the following differential equation:
\[\frac{\partial \lambda}{\partial t} (m,s,t) = -rT(m,s,t)\]
Solving this differential equation should give us a definition for \(\lambda\). However, as I have already solved this in advanced, I know the solutions are different depending on whether \(u\) is 0 or not. Thus we will consider the case \(u = 0\) separately.
With massless fuel
If we assume \(u = 0\), then \(T(m,s,t) = m\), and the differential equation simplifies to:
\[\frac{\partial \lambda}{\partial t} (m,s,t) = -rm\]
Integrating with respect to \(t\) on both sides yields:
\[\lambda(m,s,t) = -rmt + C(m,s)\]
An expression for \(C(m,s)\) can be obtained from the initial condition:
\[\lambda(m,s,0) = s\]
It immediately follows that \(C(m,s) = s\), giving us the final expression for \(\lambda\):
\[\lambda(m,s,t) = s - rmt\]
With fuel with mass
Let us now assume that \(u > 0\). First we divide the differential equation for \(\lambda\) by \(T(m,s,t)\) (we already justified above \(T(m,s,t) > 0\)):
\[\frac{1}{T(m,s,t)} \frac{\partial \lambda}{\partial t} (m,s,t) = -r\]
Utilizing the expression we derived earlier for \(\frac{\partial \lambda}{\partial t}\) in terms of \(\frac{\partial T}{\partial t}\) we get:
\[\frac{1}{T(m,s,t)} \frac{1}{u} \frac{\partial T}{\partial t} (m,s,t) = -r\]
Now we integrate both sides with respect to \(t\), leaving \(\frac{1}{u}\) out of the integral:
\[\frac{1}{u} \int \frac{1}{T(m,s,t)} \frac{\partial T}{\partial t} (m,s,t) \, dt = \int -r \, dt\]
The left-hand side can be solved using the chain rule. The right-hand side is trivial. This leaves us with:
\[\frac{1}{u} \log(T(m,s,t)) = -rt + C(m,s)\]
Multiplying both sides by \(u\) (and abusing notation with \(C\)):
\[\log(T(m,s,t)) = -rut + C(m,s)\]
Applying the exponential function on both sides (and, again, abusing notation with \(C\)):
\[T(m,s,t) = C(m,s) e^{-rut} = C(m,s) \beta^{-t}\]
Setting \(t = 0\) now gives us that:
\[C(m,s) = T(m,s,0) = m + us\]
We can now have an expression for \(T\):
\[T(m,s,t) = (m + us) \beta^{-t}\]
And using the definition of \(T\), we get the expression for \(\lambda\):
\[\lambda(m,s,t) = \frac{T(m,s,t) - m}{u} = \frac{(m + us) \beta^{-t} - m}{u}\]
Obtaining \(\varphi\)
Now that we have an expression for \(\lambda\), an expression for \(\varphi\) can be obtained by solving the equation:
\[\lambda(m, \varphi(m,t), t) = 0\]
But, since the expression for \(\lambda\) is different depending on whether \(u\) is 0 or not, we have to consider two cases again.
With massless fuel
When \(u = 0\), \(\lambda(m,s,t) = s - rmt\). Therefore, we need to solve:
\[\varphi(m,t) - rmt = 0\]
Thus:
\[\varphi(m,t) = rmt\]
With fuel with mass
When \(u > 0\):
\[\lambda(m,s,t) = \frac{(m + us) \beta^{-t} - m}{u}\]
Therefore, we need to solve:
\[\frac{(m + u \varphi(m,t)) \beta^{-t} - m}{u} = 0\]
Multiplying both sides by \(u\) to get rid of the fraction:
\[(m + u \varphi(m,t)) \beta^{-t} - m = 0\]
Adding \(m\) to both sides and multiplying by \(\beta^t\):
\[m + u \varphi(m,t)= m \beta^t\]
Solving now directly for \(\varphi(m,t)\) gives us:
\[\varphi(m,t) = \frac{m \beta^t - m}{u} = \frac{m}{u}(\beta^t - 1)\]
Properties of \(\varphi\)
The function \(\varphi\) is linear with respect to its first component, meaning:
\[\varphi(ax + by, t) = a \varphi(x,t) + b \varphi (y,t)\]
This follows from the fact that \(\varphi(m,t)\) is \(m\) times an expression that doesn't depend on \(m\).
The function \(\varphi\) also has the following property:
\[\varphi(m, t + a) = \beta^a \varphi(m, t) + \varphi(m, a)\]
Here's the proof:
\[\varphi(m, t + a) = \frac{m}{u}(\beta^{t+a} - 1) = \frac{m}{u}(\beta^t \beta^a - 1)\]
We add and substract \(\beta^a\) and rearrange:
\[\varphi(m, t + a) = \frac{m}{u}(\beta^t \beta^a - 1 + \beta^a - \beta^a) = \frac{m}{u}(\beta^t \beta^a - \beta^a + \beta^a - 1)\]
We take \(\beta^a\) as a common factor:
\[\varphi(m, t + a) = \frac{m}{u}(\beta^a (\beta^t - 1) + (\beta^a - 1))\]
And, finally, we distribute \(\frac{m}{u}\) appropriately, concluding the proof:
\[\varphi(m, t + a) = \beta^a \frac{m}{u}(\beta^t - 1) + \frac{m}{u}(\beta^a - 1) = \beta^a \varphi(m, t) + \varphi(m, a)\]
As a corollary, we get the following result. Given \(k \in \mathbb{N}\):
\[\varphi(m, kt) = \left( \sum_{i = 0}^{k-1} \beta^{it} \right) \varphi(m, t)\]