Hi everyone,

I'm reviewing a car transmission model for a basic racing game, and I've noticed a slight discrepancy between what I would expect of the macroscopic properties of the model (when changing gear) and the numerical results.

Here is the basic model:

from math import pi import numpy as np class Car: gearRatios = [] maxTorqueArray = [] rpmAtMaxTorque = [] wheelRadius = 0.0 differentialRatio = 0.0 Cd = 0.0 Crr = 0.0 transmissionEfficiency = 0.0 mass = 0 def __init__(self): self.speed = 0.0 self.acceleration = 0.0 self.currentGear = 1 def update(self, dt): throttle = 1.0 # Gear ratios assert self.currentGear > 0 currentGearRatio = self.gearRatios[self.currentGear - 1] effectiveGearRatio = self.differentialRatio * currentGearRatio transmission = effectiveGearRatio * self.transmissionEfficiency wheelCircumference = 2 * pi * self.wheelRadius # Find RPM wheelRPM = (self.speed / wheelCircumference) * 60 engineRPM = wheelRPM * transmission engineRPM = min(max(engineRPM, self.rpmAtMaxTorque[0]), self.rpmAtMaxTorque[-1]) # Find torque at RPM maxTorque = np.interp(engineRPM, self.rpmAtMaxTorque, self.maxTorqueArray) engineTorque = maxTorque * throttle wheelTorque = engineTorque * transmission tractionForce = wheelTorque / self.wheelRadius # Resolve forces dragForce = -self.Cd * self.speed * abs(self.speed) rollingResistanceForce = -self.Cd * 30 * self.speed # Resultant resultantForce = tractionForce + dragForce + rollingResistanceForce self.acceleration = resultantForce / self.mass self.speed += self.acceleration * dt self.currentForce = resultantForce self.currentRPM = engineRPM self.currentSpeed = self.speed self.currentTorque = wheelTorque class BoxsterS2004(Car): gearRatios = [3.82, 2.20, 1.52, 1.22, 1.02, 0.84] maxTorqueArray = [220, 220, 310, 220] rpmAtMaxTorque = [0, 1000, 4500, 6600] wheelRadius = 0.345 differentialRatio = 3.42 Cd = 0.32 transmissionEfficiency = 0.7 mass = 1300 if __name__ == "__main__": car = BoxsterS2004() dt = 1 / 60 while True: car.update(dt)

Now, in it's actual implementation, I'm running the update function in a fixed-step game loop, which allows me to inspect the car state and shift gear at runtime.

Now, the behaviour:

It is to be expected that the force of the car drops according to the speed for the same power.

It is also to be expected that the car cannot reach as high a speed in lower gears.

Yet, for these parameters, the top speed can only be reached in 1st gear, and decelerates according as the gears are shifted higher.

I'm not sure why this happens. It makes sense that the acceleration rate is lesser for higher speeds, because the drag force is proportional to v^2, and the force of the engine falls with higher gears, but my resultant forces are negative for higher gears when they're not for the lower gears. Shifting at any point reduces the max speed achievable.

Evidently, I don't quite understand the model well enough, could anyone point me in the right direction?

To my mind, given that the driving force of the car falls off at