Weather and power
The same car is slower on a hot, humid day or at a high-altitude track: the air is thinner and the engine makes less power. To compare runs from different days, TorkeKit corrects the times to standard air (25 °C, 990 hPa of dry air, the SAE J1349 standard).
Try it
Section titled “Try it”Move the weather and watch the demo run change. At 31 °C, 70 % humidity and 910 hPa (an afternoon at a track about 900 m up) the air behaves as if you were at almost 1,800 m, and the car loses 14 % of its power: the demo run would drop from 12.826 to 12.196 s in standard air.
In code
Section titled “In code”let weather = Weather(temperatureC: 31, humidity: 70, pressureHpa: 910)
weather.densityAltitude // meters: higher = thinner airweather.airDensity // kg/m³weather.correctionFactor // above 1: the air cost power
let corrected = result.corrected(for: weather)corrected.quarterMile // the 1/4 in standard airval weather = Weather(temperatureC = 31.0, humidity = 70.0, pressureHpa = 910.0)
weather.densityAltitude // meters: higher = thinner airweather.airDensity // kg/m³weather.correctionFactor // above 1: the air cost power
val corrected = result.corrected(weather)corrected.quarterMile // the 1/4 in standard airPressure from the phone’s barometer
Section titled “Pressure from the phone’s barometer”Most mid and high range phones have a barometer, and every iPhone since the 6. PhoneBarometer reads the station pressure right there, at the track:
import TorkeKitSensors
if PhoneBarometer.isAvailable, let hpa = await PhoneBarometer().stationPressureHpa() { let weather = Weather(temperatureC: 31, humidity: 70, pressureHpa: hpa)}val barometer = PhoneBarometer(context)val hpa = if (barometer.isAvailable) barometer.stationPressureHpa() else nullhpa?.let { Weather(temperatureC = 31.0, humidity = 70.0, pressureHpa = it) }Temperature and humidity come from your app (a weather station or the user): phones don’t have those sensors.
Times are corrected with the cube root of power (time × factor^-1/3) and speeds the other way (speed × factor^1/3). The trace stays as measured.
Estimated power
Section titled “Estimated power”With the car’s weight including the driver and the quarter-mile trap speed, Hale’s formula gives a good estimate of flywheel horsepower:
// Trap speed: the most reliablePowerEstimate.fromTrapSpeed(massKg: 1350, quarterMileKmh: result.quarterMileKmh!)
// From the ET: reads low if the car spins at the launchPowerEstimate.fromElapsedTime(massKg: 1350, quarterMile: result.quarterMile!)
// Wheel power along the runlet curve = PowerEstimate.wheelPower(result, massKg: 1350, dragArea: 0.6)let peak = PowerEstimate.peakWheelHp(result, massKg: 1350)// Trap speed: the most reliablePowerEstimate.fromTrapSpeed(massKg = 1350.0, quarterMileKmh = result.quarterMileKmh!!)
// From the ET: reads low if the car spins at the launchPowerEstimate.fromElapsedTime(massKg = 1350.0, quarterMile = result.quarterMile!!)
// Wheel power along the runval curve = PowerEstimate.wheelPower(result, massKg = 1350.0, dragArea = 0.6)val peak = PowerEstimate.peakWheelHp(result, massKg = 1350.0)wheelPower adds what it took to accelerate the car, beat the air and the tires’ rolling resistance. The parameters:
| Parameter | Default | Typical values |
|---|---|---|
dragArea |
0.7 m² | Drag coefficient × frontal area. 0.6 for a sedan, 0.8 for a pickup. |
rollingResistance |
0.015 | 0.012 on drag radials, 0.015 on street tires. |
airDensity |
1.2 kg/m³ | weather.airDensity if you have it. |