Tesla 3 Calculator (for nerds only)

ADK46

Top-Contributor
Joined
Aug 4, 2018
Messages
529
Location
Adirondacks, NY
Tesla Owner
Model 3
Country
Country
#1
Update: You can read below for background information about my development of this tool, but here it is, complete but still subject to tuning and fixes as of September 6, 2018:

http://bikecalculator.com/tesla

=====================
I have some notoriety in the bicycling world through an online calculator and an iPhone app. They predict how fast you can go for your power output, accounting for weight, grade, wind, etc.

I just spent a couple days modifying it for Tesla 3 nerds. Half of that time was digging up relevant parameters, or estimating them when not available. I just reached a point where the thing runs and produces reasonable results.

Reasonable, but not right - that's alway the case for engineering models: all are wrong, some are useful. But it seems to be seriously off in predicting range and watt-hours per mile. I have a lot of faith in the core calculation - it solves the cubic expression for the resistance felt by a rolling object moving through air, using Cd, frontal area, rolling resistance, weight and a conversion efficiency figure. I found good numbers for many but not all parameters. Tires are the most difficult (same goes for bicycles).

It's not accounting for running accessories. It's only counting for motor efficiency, I think - I'm using 95% for lack of anything better (RWD) - but not losses in DC to AC conversion.

My next step is to fudge some things into compliance wth the EPA range data posted by Troy. For example, I'll fudge Cd to account for the difference between having your aero wheel covers on or off. I'll come up with the motor/drivetrain conversion penalty for AWD.

The nerds among you will want to know much more of what's behind this. Some of you may have valuable data and insight - and can code javascript, too. Most will think I have too much time on my hands. More later.

calculatorbeta5-png.13864
 
Last edited:

John

Tech Founder
TOO Supporting Member
Joined
Apr 15, 2016
Messages
1,674
Location
California
Tesla Owner
Model 3
Country
Country
#3
Not sure it worth bothering with the headwind, since no one ever knows what it is on a trip, and you drive different directions during a trip.

Tesla needs to get some energy stats up in that UI...
 

ADK46

Top-Contributor
Joined
Aug 4, 2018
Messages
529
Location
Adirondacks, NY
Tesla Owner
Model 3
Country
Country
#4
Wait. Can I get the biking app?
bikecalculator dot com for the web version (like the one we'll have for the M3). The iPhone app is easy to find, but it's gotten long in the tooth. A much better version is in the works.

Not sure it worth bothering with the headwind, since no one ever knows what it is on a trip, and you drive different directions during a trip.

Tesla needs to get some energy stats up in that UI...
Quite right about the difficulties of knowing and accounting for actual wind. But the educational aspect of the model is served. In fact, the first thing I did with it myself was to explore the effects of a headwind. On a bike, it has a huge effect, but not so much in the car. Much lower Cd, and higher relative speeds.

I'll get it up and working (as a beta version) on the web somewhere later today, with a long explanation. I'm inclined to make it open source. Leaks of official Tesla engineering figures will be welcome!
 

ADK46

Top-Contributor
Joined
Aug 4, 2018
Messages
529
Location
Adirondacks, NY
Tesla Owner
Model 3
Country
Country
#5
OK, here is an INCOMPLETE beta version of the calculator. Mind the instructions! Wheel type and RWD/AWD ARE NOT YET modeled, pay no attention to them. The energy predictions are low, for reasons I think we can address.

The model is limited to steady-state conditions. It is not practical to do anything else. There's an interesting case where you add up two segments, one up and one down a grade (an out-and-back up a hill). Compare it to a case where you go the same total distance on the flat. Do something similar with a headwind/tailwind combinaton. Learn to say "non-linear" with a smug expression.

http://bikecalculator.com/tesla

Pardon the ads - removing them upset the formatting, but I'll get rid of them eventually.
 

tivoboy

Top-Contributor
Joined
Mar 24, 2017
Messages
600
Location
Palo Alto, CA
Country
Country
#6
Not sure it worth bothering with the headwind, since no one ever knows what it is on a trip, and you drive different directions during a trip.

Tesla needs to get some energy stats up in that UI...
I always thought that headwind could actually be incorporated into an onboard calculator (or offboard on a phone) by taking hyper local weather data into context and using some 70-80% of that based on direction of travel and wind direction. It certainly seems like it might be possible, but with a CD of .20 something it probably isn't going to make much of a difference unless its pretty high wind and pretty head on (or tail on ;-)
 

tivoboy

Top-Contributor
Joined
Mar 24, 2017
Messages
600
Location
Palo Alto, CA
Country
Country
#7
hmm, I just checked it out and the end results don't really seem to line up with most reported reality or even the EPA numbers (even the actual EPA numbers).

Just inputting say 65 mph, 300 lb load, flat conditions, modest temp, etc, it spits out 393 miles range. Seems really high, and the predicted kw/m rating of 188 seems VERY low. I know I drive faster than that, and get closer to 225-230 at 72'ish with some overall elevation changes, equating to about zero.
 

ADK46

Top-Contributor
Joined
Aug 4, 2018
Messages
529
Location
Adirondacks, NY
Tesla Owner
Model 3
Country
Country
#8
I always thought that headwind could actually be incorporated into an onboard calculator (or offboard on a phone) by taking hyper local weather data into context and using some 70-80% of that based on direction of travel and wind direction. It certainly seems like it might be possible, but with a CD of .20 something it probably isn't going to make much of a difference unless its pretty high wind and pretty head on (or tail on ;-)
There is (or was) a bicycle power meter that used modeling rather than an actual torque meter on the drivetrain, using speed and an inclinometer, plus an anemometer. I had reason to suspect the model was based on my bikecalculator.com site.

hmm, I just checked it out and the end results don't really seem to line up with most reported reality or even the EPA numbers (even the actual EPA numbers).

Just inputting say 65 mph, 300 lb load, flat conditions, modest temp, etc, it spits out 393 miles range. Seems really high, and the predicted kw/m rating of 188 seems VERY low. I know I drive faster than that, and get closer to 225-230 at 72'ish with some overall elevation changes, equating to about zero.
Just inputting say 65 mph, 300 lb load, flat conditions, modest temp, etc, it spits out 393 miles range. Seems really high, and the predicted kw/m rating of 188 seems VERY low. I know I drive faster than that, and get closer to 225-230 at 72'ish with some overall elevation changes, equating to about zero.[/QUOTE]

Hah! You didn't read the description, which discusses this error. Are you sure you're a nerd? ;)

The model is yet incomplete and has not been "calibrated" to available efficiency data. It omits a number of things, like system power, DC to AC conversion efficiency, HVAC, battery temperature management, etc. I have some thinking to do for those. Fudge factors have not yet been applied to match its predictions to range data for the various models.

188 wh/mile seems fairly close to the right number before accounting for these things. I could display the power needed at the wheels (that's as accurate as the Cd, frontal area, and rolling resistance), power eaten up by losses here and there, and let the remainder (to EPA data) be HVAC, etc.

Stand by.
 

tivoboy

Top-Contributor
Joined
Mar 24, 2017
Messages
600
Location
Palo Alto, CA
Country
Country
#9
Hah! You didn't read the description, which discusses this error. Are you sure you're a nerd? ;).
well, in all honesty I did read the instructions but missed the part where it said, don't expect the numbers to be near accurate. I think rather than saying "the numbers represented are low" one might say, "efficiency data reported is currently not near accurate and off by ~ca 20-25%".

but, back to the science and math question. Is it just not incorporated yet into your model, or is the actual efficiency calculation algorithm that the model 3/s/x uses not available? Based on all the great online calculators out there, like evtriplanner and abetterrouteplanner it would seem those algos have been modeled by now.
 

ADK46

Top-Contributor
Joined
Aug 4, 2018
Messages
529
Location
Adirondacks, NY
Tesla Owner
Model 3
Country
Country
#10
Aerodynamic problems are difficult, especially for someone on a bicycle with an uncertain Cd and frontal area, which is my mindset. Being off by 25% on the power side of the equation isn't horrible in that context - the speed prediction will seem pretty good since it depends largely on the cube root of power. I need to change that mindset here, where we have a good Cd value (if we trust Tesla) and frontal area (I should recheck my measurement), and the focus is predicting energy use.

You raise an interesting point - how do these trip planners work? I have not used one yet - don't have my car yet! Do they just ask your for wh/mile? Ask what type of car you have, which fixes on a simple "mileage" and battery capacity? Do they ask how fast you'll be going? Do they automatically reduce range in the winter? Do they take the elevation profile into consideration? Et cetera. A full calculation would be very complicated and would annoy the user by asking too many questions.

The core algorithm is solid, but the model is missing constant system load, accessory load, and DC to AC conversion efficiency. The 95% motor and reduction gear efficiency I've assumed for now may be way off - anyone have knowledge here? The accessory load can be quite high, but is uncertain. I'll be working on these things in the coming week.

Thanks for watching. The purpose of presenting this and future beta versions is to solicit comments, suggestions, and help.
 

tivoboy

Top-Contributor
Joined
Mar 24, 2017
Messages
600
Location
Palo Alto, CA
Country
Country
#11
You raise an interesting point - how do these trip planners work? I have not used one yet - don't have my car yet! Do they just ask your for wh/mile? Ask what type of car you have, which fixes on a simple "mileage" and battery capacity? Do they ask how fast you'll be going? Do they automatically reduce range in the winter? Do they take the elevation profile into consideration? Et cetera. A full calculation would be very complicated and would annoy the user by asking too many questions.
Why not just check them out online. They both describe in pretty good detail exactly how they make their calculations

As to your questions. Yes yes and yes. Almost all those factors are taken into account.
 

ADK46

Top-Contributor
Joined
Aug 4, 2018
Messages
529
Location
Adirondacks, NY
Tesla Owner
Model 3
Country
Country
#12
Why not just check them out online. They both describe in pretty good detail exactly how they make their calculations

As to your questions. Yes yes and yes. Almost all those factors are taken into account.
EVTripPlanner is impressive! And done by someone 50 years younger than me. That's an advantage, I guess.

I'll carry on with my more limited and different objectives.
 

ADK46

Top-Contributor
Joined
Aug 4, 2018
Messages
529
Location
Adirondacks, NY
Tesla Owner
Model 3
Country
Country
#13
I've made a lot of progress: http://bikecalculator.com/tesla/

The effects of wheels and tires are not yet implemented.

Note that the purpose of this calculator is to explore the effects of parameters, such as speed and altitude, on power consumption and range. It's more for satisfying your curiosity than anything practical.

Remember, all engineering models are wrong, some are useful.

By the way, my investigations have turned up a few curiosities:

1) Why is the added weight of a second motor 95 kgs in the standard range model, and 121 kgs in the long range model?

2) Examining the "EPA" range figures in Troy's tables reveals that the effects of the second motor and the effects of wheels/tires were not tested for each combination - they are identical, as if applied by separate analysis or testing. For example the ratio of AWD/RWD ranges are 0.929 for both SR and LR models, and for all wheels and tires - you don't get that repeatability even in lab testing. I am struggling to use the range numbers for the wheel/tire effects, since it seems they must be purely aerodynamic effects. They must come from somewhere other than dyno testing - but at what speed? I'll have to assume some speed relevant to user expectations, like 65 mph.
 

Bokonon

Self-identified Teslaholic
Moderator
TOO Supporting Member
Joined
Apr 12, 2017
Messages
3,093
Location
Boston
Tesla Owner
Model 3
Country
Country
#15
The model is complete now, including the effects of wheels and tires. I also fixed a typo that was causing a range prediction error for long range models. I’ll keep tweaking it to make it better conform to experience.
http://bikecalculator.com/tesla/
Love the idea behind this tool, but I can't seem to get it to work for me. No matter what parameters I enter, the results always compute out to NaN, and I get the Javascript error below. (I'm using Chrome, FWIW.)

Code:
tesla3calculator.js:138 Uncaught TypeError: Cannot convert undefined or null to object
    at update (tesla3calculator.js:138)
    at (index):318
It looks like the variable "otherPower" is doing double-duty in the "with" block as both a reference to the "other power" <select> element and the numerical value represented by its current selection. After the "with" block, "otherPower" reverts to being a reference to the <select> element, so this calculation...

Code:
nonMotorDraw = systemPower + hvacPower + otherPower + packConditioningPower;
...works out to up to a value like "1600[object HTMLSelectElement]0". This causes the subsequent power calculations that depend on this value to evaluate to NaN. If I edit the code above and remove otherPower, the calculations finish without issue (apart from the fact that "Other Power" is no longer a factor).

Not sure if this is a bug or if I'm missing something obvious...?

EDIT TO ADD: When I enter parameters from a few of my highway drives today, the consumption calculations are almost an exact match with reality (assuming my guesses for HVAC and system power are correct). Very nice!
 
Last edited:

ADK46

Top-Contributor
Joined
Aug 4, 2018
Messages
529
Location
Adirondacks, NY
Tesla Owner
Model 3
Country
Country
#16
Thank you for this report! I appreciate your deep dive into the code. I've only been testing it with Safari and whatever Apple provides for Javascript. I've made this sort of error before - not sure why I'm not seeing a NaN storm now, but I'll look into it. (For the less nerdy, "NaN" means not a number, often the result of dividing by zero.)

As you compare your actual experience with the calculator results, let me know which guesses seem best for system and HVAC power. The system power must include the display, the various computers, cameras, sensors, the control circuitry in the inverter, coolant and lubrication pumps, who knows.

The predictions should tend to be optimistic versus actual, at least to the extent that there is nearly always some wind in an unfavorable direction. We often don't notice gentle winds until we try to fold up a tarp or light a match, but they can have a significant effect. On the other hand, follow a truck closely, and the predictions might be pessimistic.
 

ADK46

Top-Contributor
Joined
Aug 4, 2018
Messages
529
Location
Adirondacks, NY
Tesla Owner
Model 3
Country
Country
#17
I believe I have it fixed now, though I have not tested it with Chrome. Yup, my sloppiness in variable naming was responsible. I'll go in and make everything more consistent, one of these days. Also found the obscure code responsible for the other error.

Bug reports are needed and greatly appreciated.
 

PNWmisty

Legendary Member
Joined
Aug 19, 2017
Messages
2,539
Location
Anacortes, WA
Country
Country
#18
I believe I have it fixed now, though I have not tested it with Chrome. Yup, my sloppiness in variable naming was responsible. I'll go in and make everything more consistent, one of these days. Also found the obscure code responsible for the other error.

Bug reports are needed and greatly appreciated.
I tried a bunch of variables that I have first-hand experience with and the model seems very good but with a tendency towards overestimating consumption (compared to the Wh/mile reported by the car), even when I turn "System Power" down to 400W and zero out the other power consumption variables (HVAC, battery conditioning, other). I assume this model is trying to replicate steady state driving with no regen braking cycles thrown in? If that is the intent, steady cruising in mild weather on perfectly flat roads at 60 mph can easily return numbers around 170 Wh/mile or even lower (I need to do more testing). However, the range numbers returned by the model seem more realistic than the Wh/mile figures. In other words, without having done carefully recorded tests, collecting the data and doing the math, there seems to be a larger disconnect with the Wh/mile reported by the model vs. the car (while the range figures between the two seem more aligned). I'm not sure how this is possible unless the car is cheating on the Wh/mile! Does the car only report drivetrain consumption?

I do think the tire resistance in the model is maybe too high for the recommended pressure of 42 psi. in the 18" LRR tires. I noticed it is a linear function. I believe at low speeds it slightly higher than a linear function projects. And maybe 400W is a more accurate default value for system power. I say this because, IMHO, the model should not return estimates that would be accurate under conditions of casual driving with speed variations, cross breezes, etc. but should be more perfect case scenario, ie. the theoretical limit if one could hold a perfectly steady speed.

What would add a lot more value to this model would be the incorporation of a motor efficiency curve at different rpm's/loads. I know we don't have access to that but even curves based on likely generic motor efficiency curves would be a big plus.

I enjoyed messing with it and will return when I've had time to collect more data and compare. Currently, it's all from memory and seat of the pants observations.
 

ADK46

Top-Contributor
Joined
Aug 4, 2018
Messages
529
Location
Adirondacks, NY
Tesla Owner
Model 3
Country
Country
#19
Thank you for your many thoughtful remarks. You clearly have a solid understanding of the issues. To others reading along, I'll make some elaborations:

Yes, the model is strictly for steady state conditions. It is definitely not a trip planner sort of thing, and does nothing to include the non-steady aspects of real trips, which will usually increase energy use.

It would take extraordinary luck to match closely any single data point from actual driving. There is a huge potential for error from winds, which the model cannot handle unless directly ahead or behind, and for which a steady speed is virtually impossible to know. We'd need a statistical treatment to calibrate the model scientifically. What will happen instead is people will learn to treat it as a tool to explore differences, not so much for its absolute predictions. That's how engineers use models.

(It's always been impossible to calibrate BikeCalculator, for similar reasons. People find it useful anyway, adding their own corrections if they believe they know better.)

The Wh/mile and range are directly related, just as mpg (US metric) and liters/100km (Europe) are related. It does require a figure for battery capacity, which is a less certain thing than the number of gallons a tank can hold. Perhaps we'll learn something about this.

The non-linearity problems! Difficult, whether deviations that render rolling resistance coefficients inaccurate, or part-load efficiency fall off in the inverter(s) and motor(s). But I think perhaps these are not big issues if we restrict the use of the model to highway speeds, the only steady state condition we're probably interested in. Other driving conditions are hopelessly variable. But maybe we'll learn something as we go. It wouldn't be difficult to add some dependence of efficiency on load; at this point, I think it would feel like false precision.

The system's power requirements are a very interesting part of the problem. There's not a big difference between 400 and 600 watts, but how much has Tesla reduced it? There could be some very clever engineering involved, like using the drivetrain unit coolant flows to condition the battery. That may be a structural error in the model - there are no electric heaters used, but there is an intentional inefficiency introduced to the inverter(s).

We'll keep working on it.
 

PNWmisty

Legendary Member
Joined
Aug 19, 2017
Messages
2,539
Location
Anacortes, WA
Country
Country
#20
The non-linearity problems! Difficult, whether deviations that render rolling resistance coefficients inaccurate, or part-load efficiency fall off in the inverter(s) and motor(s). But I think perhaps these are not big issues if we restrict the use of the model to highway speeds, the only steady state condition we're probably interested in. Other driving conditions are hopelessly variable.
Actually, I think the tool is hugely interesting in its ability to show how changing HVAC or "System Power" loads changes the speed at which maximum miles/kWh occurs (which, depending upon specific conditions is in the general vicinity of 22-45 mph). When I have the time and inclination, I love to cruise little used scenic rural roads in an enjoyable and relaxing manner for many hours on a single charge. You might be surprised how this can change the nature of your automobile touring for the better.

Having a good idea how the most efficient speed changes with different temperatures and the corresponding increase in HVAC and battery conditioning loads can be useful for covering more miles with less worry. Sometimes there is the option to get on the Superhighway and blaze along at 70 mph, hitting a Supercharger along the way or taking a shorter rural route, without any fast charging potential, to arrive at the same destination. In the rural West, I often prefer the shorter (but longer timewise) route and it is always the more efficient route because it's shorter and the speeds are slower. It's possible to cross any of the Western states, E-W or N-S, multiple times without ever getting on so much as (even) a rural State Hwy. Many of these roads are not even depicted on a great big paper road map of the State such as those published by Rand McNally and the like. And this is but one example of how your tool could be used to gain greater understanding of what's going on under the hood.

I do notice it seems to be limited to 40 kW power to the wheels? The LR Model 3 is rated by Tesla at around 270 hp or so.