Rated Range calculation ≠ Actual Range calculation!
The range of the vehicle, typically displayed in miles or kilometers, is a function of many parameters in the vehicle to provide the most accurate assessment of range remaining. We do this to prevent the customer from running out of charge prematurely. The voltage of the pack is directly correlated to the State of Charge (SOC) of the vehicle. This is indicated by the bar in the UI. However the capacity of the pack changes over time which means 100% SOC will always be 100% but the range can change based on the battery capacity. The capacity is tracked by the HVBMS in a value called Calculated Amp-hour Capacity (CAC).
Starting from left to right, we can see the first important number that comes into the equation is CAC. This number can viewed in logs and Garage and is constantly changing from HVBMS calculations to update the value to reflect energy capabilities in the pack. Note that this value is the Ah capacity for a single brick. All bricks have their capacities calculated and the minimum brick is used for the range calculation as is the brick that will at the end limit the pack capacity. As seen earlier, the parallel count of cells (brick) defines the pack energy storage capacity and the series count its power output.
Now to get the full capacity of the entire battery the value will need to be multiplied. Multiplied by the average brick voltage will give the kWh value. *Note that this full pack energy does take into account temperature in a small amount; therefore a really cold pack will have slightly less full pack energy.
The full pack energy is then just multiplied by the SOC of the pack. Therefore 50% SOC means .5 (or half) of the full pack energy.
The energy is then divided by a fixed Watt-hour per mile (whpm) value that is hard-coded into the pack based on the rated range setting and vehicle configuration. This is the average efficiency found during the EPA drive cycle testing (or EU/APAC equivalent standard). The final number will appear in units of distance and this is what is displayed on the MCU.
As shown above, the capacity of the pack has a direct correlation to the final range displayed to the customer. CAC is calculated by the HVBMS by monitoring voltage change as well as current leaving and entering the pack.
Quelle: Interne technische Dokumentation von Tesla