User:Duplode/Car model physics (old)

From Stunts Wiki

This article intends to discuss in depth the parameters affecting how a car behaves in Stunts and, in particular, expand on the descriptions done at Car parameters. The first section consists in an analysis of how performance-related CAR*.RES parameters quantitatively affect in-game behaviour, executed through the definition of a consistent measurement unit system. Such an unit system proves to be an useful framework for accurate, realistic tuning, and allows to assess how accurate the original Stunts cars were modeled by the developers. Further sections of the article deal with other, less directly assessable parameters such as grip as well as special effects, the most notable of them being Power Gear. As a final observation, the largely experiment-based nature of the topic means this article will be a work-in-progress for quite a while.

Model fundamentals and the Stunts unit system

Mass

The first parameter to be tackled on this analysis is car mass. Such choice is justified for two reasons; namely for there is no sense to discuss torques and accelerations without information on what they're acting, and also that, unlike most other parameters, there is no in-game clue (such as speedometer readings or time intervals) about how Stunts mass correlates with real-life values. Thus, an arbitrary choice is called for starting up the model. The following table lists the mass of some Stunts cars in-game and in reality. The quoted values come from the database of a a cool program, CarTest 4.5, which provides reasonable estimates for car weight including driver and some fuel.

Car Stunts mass (28h) Real mass estimate
Acura NSX 31 3170lb
Lamborghini Countach 33 3450lb
Ferrari GTO 27 2720lb
Porsche Carrera 4 32 3460lb
Corvette ZR1 35 3625lb

The race cars (Indy and IMSA) were excluded from this comparison due to the lack of reliable data, while Audi, Lancia and LM002 aren't here for they in-game mass is strongly underestimated (far above the average error margin on the table above) in comparison to the other cars. Anyway, from the table it is apparent there is reasonably good consistence on the 28h mass values, and that an unit byte increase equals roughly 100lb, or 45.36kg. A more accurate statistic (using data for NSX, Countach, GTO and ZR1) gives us 103.0lb (46.72kg) for the unit increase. Let us call that value the Stunts mass unit, and abbreviate it as msu from now on. As you could see, this definition is arbitrary in the sense it is not based on in-game data. Thus, adopting a different standard here wouldn't compromise the model as long as all other units are multiplied properly in compensation.

Engine speed

Engine revolution variations have long been described as working on steps of 125rpm for each byte in the torque curve and 250rpm for each unit increase in gross adjustment parameter bytes. However, all rpm parameters have a functional fine tuning byte, which as usual adjusts values in 1/256 fractions of the gross adjustment byte step. Thus, it makes more sense to regard units so that fine adjustment bytes have units of 1rpm and gross adjustment ones of 256rpm. Torque curve steps, however, are indeed 125rpm wide. Although both tachometers and torque curves of the original cars tend to be quite inaccurate, the fact that gear ratio workings seem to agree with this scheme (see discussion below) is strong positive evidence for those units. Engine revs on this article will be quoted directly in rpms.

Transmission

Here is where things start to get more interesting conceptually. A real car has three main factors that influence how much wheel torque and wheel speed will be delivered by the engine at a certain engine speed:

  • The gearbox gear ratio - using a larger output gear (ratio) will lower the output rotational speed but will increase torque in the same proportion.
  • The final drive ratio - that is, the ratio of the gears linking the transmission to the traction axle.
  • Tire radius also plays a part: although it can't affect torque or rotational speed delivered by the transmission, using a larger tire will increase linear speed at the border of the tire, and thus overalll car speed. The necessary drawback is in the larger inertia moment (analogous to mass just like torque is to force), which cuts down acceleration.

Weighing all those factors, we get equations relating engine speed, output acceleration and (linear) speed - disregarding skidding or wheelspin of course, and already accounting for any mechanical losses on transmission:

car speed = engine speed * wheel radius / (gear ratio * final drive ratio)
car acceleration = (engine output torque * gear ratio * final drive ratio / wheel radius) / car mass

Both ratios and wheel radius appear together in corresponding positions at both equation, and so it is for all Stunts-relevant equations. That explains why we have a single (and not three) gear ratio parameters in Stunts, which will be named "overalll gear ratio" from now on and can be defined as:

overalll gear ratio = gear ratio * final drive ratio / wheel radius

And thus, we have:

car speed = engine speed / overalll gear ratio
car acceleration = engine output torque * overalll gear ratio / car mass

As simple as it gets, and it gets even better upon realizing the overalll gear ratio byte value is actually just engine speed in rpm divided by car speed in mph at any point on the torque curve, a fact easily proved by crashing a car at maximum revs in any gear and performing the calculation. That confirms the assumptions about the size of rpm step per byte in the torque curve are correct.

Now the only missing info here is how much an unit increase on the gear ratio bytes amount in terms of real-world units, information that will be necessary later on. The unit increase will be termed gsu just like msu was used for the mass unit. Since overall gear ratio equals engine speed in rpm divided by car speed in mph, it follows that the unit is just rpm per mph, which converted to metric (SI) units gives 1gsu = 0.2343 rad/m.

Torque and force

Now the goal is to find what is the internal Stunts unit for the torque curve (christened from now on tsu for Stunts torque unit), so that it can be related to real-world data. Torque is simply the angular analogous of force - just like a force imparts a body with a certain acceleration depending on its mass, a torque imparts angular acceleration (that is, in our case makes the engine rev higher) depending on the body's inertia moment (mass analogue that depends on both mass and shape of the object). This close relation allows to prove, using basic dynamics as well as the info gathered at the previous section, that:

force = engine torque * overall gear ratio

As force is mass times acceleration and constant acceleration (generated by a constant force) equals velocity difference divided by time elapsed, a practical way of obtaining actual values for in-game torque is to build a car with a flat torque curve, no aero drag (see below) and a small gear ratio, then blast through a long straight from a standstill, obtain acceleration from top speed and time interval and finally substitute in the proper equations from force and torque. Performing such a test with a car having mass of 25msu, gear ratio of 25gsu and a flat torque curve at 50tsu (all bytes equal to 50) results in a final speed of 148mph after 48.8s. After some annoying unit conversions, the following maths lead to a value of 5.406Nm for the tsu. Using different units, that equals 0.5512kgfm or 3.987lbft (which is close to 4lbft for most purposes, and is indeed a very nice result ;-) ).

As a final addition, defining a force unit can be useful on occasion if we don't want to mess up with torques to find acceleration. As force = engine torque * overall gear ratio, it is convenient to say one fsu would be one tsu times one gsu. Using both definitions, we get that 1fsu = 1.267N. That is, in order to find the force propelling the car, just multiply the value of the torque byte for any particular rpm by the gear ratio byte, and then multiply by 1.267N.

Aerodynamical drag

Air resistance is the main opposing force acting on an accelerating car at relatively high speeds, and thus is an effect of critical importance. Indeed, for a Stunts car speeding through the track, it is reasonable to consider drag as the only significant resistance acting on the car. How the 5Eh/5Fh drag parameter correlates with car behaviour is the last missing piece of information needed to predict from parameters and model from external data straight line car performance with reasonable accuracy.

Aerodynamical drag is most often modeled as a force proportional to the square of car velocity. The simplest way of stating that would be:

drag force = drag constant * (car speed)^2

The drag constant includes a number of terms mostly related to the car shape (check Physics of Racing for details). While analyzing how this speed-dependent force would affect car acceleration in order to estimate the constant value would be very troublesome, an easier approach makes use of a very important effect of drag: it plays a major role in defining the straight line top speed. Admitting the car is only affected by engine propulsion and drag, top speed will be reached when those forces cancel each other, that is:

engine force = drag constant * (car speed)^2 			=>
torque * overall gear ratio = drag constant * (car speed)^2 	=>
(car speed)^2 = torque * overall gear ratio / drag constant 	=>
car speed = square root{torque * overall gear ratio / drag constant}

If our considerations are correct, top speed at a flat straightline should increase proportionally to the square root of engine torque, and decrease in inverse proportion to the drag constant, which in turn can hopefully be identified with the 5Eh/5Fh parameter. Thankfully, that is exactly what happens. Using the accumulated knowledge from previous definitions, a dsu unit for the drag unit, associated with unit increase of 5Eh, can be stipulated. A car with a perfectly flat torque curve at 40tsu, drag constant of 15dsu and running at a ratio of 36gsu reaches a top speed of 224mph. Substituting those values, as well as tsu and gsu definitions, on the equation above leads to the conclusion that 1dsu = 0.01213kg/m .

Stunts vs. real cars

So far, so good - we already have the keys to translate a number of CAR*.RES parameters in terms of real physics units. However, in order to do actual modeling from real-world data, we must be sure that the values we calculate indeed have the consistence we expect. The best way to do that is, arguably, contrasting the data on original cars modeled in Stunts with their real counterparts - even if the Stunts models are no standard for accuracy, they apppear to match the real cars reasonably well. As before, the main source of information here will be the CarTest 4.5 database.

Detailed comparisons of gear ratios and torque curve shapes won't be presented here in order to avoid excessive cluttering of the discussion. It can be said, however, that gear ratios are surprisingly accurate for most cars, at least to the extent we can evaluate them - that is, quotients between different ratios for the same car, as opposed to absolute values, which analysis wouldn't make sense anyway since final drive ratios or tire radius are not in the model. The same can not be said of torque curve shapes, however. Probably the most striking example is LM002: the real car used Countach engines (see Wikipedia on that subject), yet the torque curves for the LM002 and Countach are completely different. Also, maximum rpm, torque and power peak positions normally do not coincide with the real car data, the difference often being in the order of 1000rpm or more. Alongside with the rather wild discrepancies in mass seen for Audi, Lancia and LM002, that suggests quite a bit of improvisation by the guys at DSI during the modeling process... Anyway, some further insight on that matter can be gained by comparing masses, maximum torques and overalll drag coefficients for a few cars. Data will be presented in real units, with corresponding values in Stunts internal units (which as discussed before simply represent byte values for the appropriate parameters) enclosed in brackets. Drag constants were calculated from info available on CarTest as well, but since for some cars frontal section area was missing there is some degree of guessing in them (somewhat less than ~10% in worst cases, hopefully).

Car Real mass (lb, msu) Stunts mass Real max torque (lbft, tsu) Stunts max torque Real drag const. (kg/m, dsu) Stunts drag const.
Acura NSX 3170 (30.8) 3193 (31) 210 (52.7) 183 (46) 0.333 (27.4) 0.328 (27)
Lamborghini Countach 3450 (33.5) 3399 (33) 368 (92.3) 259 (65) 0.467 (38.5) 0.303 (25)
Ferrari GTO 2720 (26.4) 2781 (27) 366 (91.8) 239 (62) 0.354 (29.2) 0.243 (20)
Porsche Carrera 4 3460 (33.6) 3296 (32) 228 (57.2) 183 (46) 0.335 (27.6) 0.303 (25)
Corvette ZR1 3625 (35.2) 3605 (35) 370 (92.8) 287 (72) 0.356 (29.3) 0.400 (33)

Some interesting analysis can be done on the figures presented above. First of all, we see that at least one car, the NSX, both mass and drag are accurate. In fact, even the torque peak (5300rpm on the real car) is correctly positioned! However, even on this very favourable case peak torque is some 13% below the expected value, the understimation getting quite large for other cars (reaching 32.5% for the GTO). However, not all is lost. For all cars but the ZR1, the understimation of torque seems to go hand in hand to a strong understimation of aerodynamical drag (reaching near-comical proportions for Countach and GTO), as if the developers, while balancing higher gear acceleration versus top speed, tried to compensate one thing with the other... Corvette seems to fail the trend, as its aerodynamics are actually worst than it should. However, the ZR1 torque curve looks very strange even for Stunts standards, as if the low-rpm half got artificially raised for some kind of correction, so it wouldn't be very surprising if the scale was more wrong than usual anyway. But there's still the 13% discrepancy for the NSX... that can be justified, however. The simple model we discussed up to now does not include a number of smaller effects which drain power from the engine output, such as rolling resistance (tire friction against the ground) and energy losses at transmission system. The most consistent way of accounting for these in the limited framework of Stunts car model is scaling down the torque curve, and 13% wouldn't be too bad of an estimate for such a correction.

The bottom line: The unit system adopted works pretty well, and it allows to rationalize for some shortcomings of the original car models of Stunts. If one wishes to convert real values to Stunts, however, scaling down torque curves for about 15%-20% will probably be necessary.

Additional parameters and effects

Braking

Brakes in Stunts are a rather straightforward matter. Bytes 2Ah/2Bh define a linear scale of acceleration opposing to the car's movement that determines effectiveness of brakes. With 2Ah = 0 and 2Bh = 1 a car without aero drag will go from 169mph to a full stop in 8.45s. That corresponds to an deceleration of 8.94m/(s^2), or 0.911g (1g = gravity acceleration at sea level); naturally, increments to 2Bh correspond to 1/256 of that amount. The use of acceleration instead of force here is not an oversight: however naïve it may feel, Stunts does not account for mass for braking! Aerodynamic drag will also slow down a car whenever the accelerator is not pushed (at least while the car is planted to the ground), that's why one gets the impression that brakes are more effective at higher speeds. Finally, a curious point is that if both brakes and aero drag are set to zero a car running on straight road will not slow down no matter what you do, due to the complete lack of opposing forces...

Cornering grip

Doing accurate estimates for cornering grip is rather more difficult than for other parameters, since there are variables that are a bit hard to control, the most important of them being test driver precision... The simplest method of measurement is to pick a flat, tarmac large corner and try to find the highest constant speed at which it is possible to complete the corner following the centerline (approximate radius of 93.1m) without sliding/skidding. For CAh = 0 and CBh = 1, that speed is approximately 74mph. That information allows one to find maximum centripetal acceleration available, which is a good enough reflection of maximum grip for our purposes. The equation for centripetal acceleration is:

centripetal acceleration = (cornering speed)^2 / corner radius

Substituting our data gives a centripetal acceleration of 11.758m/(s^2), or 1.198g, for CAh = 0 and CBh = 1. The grip scale is nearly linear, but not exactly, as can be proven by setting zero grip and repeating the test. Cornering without skidding is still possible, even if at 7mph... that may hint on the existence of a very minor secondary factor affecting cornering grip. Notice that again there was no mention of mass - the cornering model does not take it into account to as it was supposed, which is somewhat disappointing... Banked corners of course increase centripetal acceleration, thus allowing higher corner speeds. For the same grip discussed just above, a banked turn can be taken on its centerline at 104mph. That is a 40.5% increase on cornering speed, corresponding to a massive 97.5% increase in centripetal acceleration. Such a large growth in relation to the ~1,2g flat corner grip would require, in reality, a banking of about 50 (!) degrees, obviously much more than in-game graphics display. Of course, this discussion is immaterial, since mass does not affect grip in bankings either, while mechanics tell us the very fact cornering is easier on positive-banked turns is due to a reaction force to the car's weight...

Grass slowdown

The slowdown cars suffer when running on grass resembles aero drag, in that both define limit speeds and, therefore, scale up with car speed. A closer inspection on grass slowdown reveals it differs from drag in that the force is proportional to speed, instead of to the square of the speed (proof is given by verifying limit speeds on grass grow linearly with gear ratio). Moreover, the limit speed is proportional to car mass, indicating yet another effect described in terms of accelerations and not forces. A test car set with 40tsu flat torque curve, 100gsu gear ratio and 12msu mass reaches 63.5mph (that is, a digital speedometer oscillates constantly between 63mph and 64mph). The relevant equation would be:

engine force = grass slowdown force 								=>
engine torque * overalll gear ratio = grass deceleration * car mass 				=>	
engine torque * overalll gear ratio = grass deceleration constant * car speed * car mass 	

Substituting the values gives 0.1444(1/s) value for the deceleration constant. A word of caution, though, that this result is not fully proved to be universal, not at least until someone fully dissects CAR*.RES and proves grass slowdown is not regulated by some odd unknown parameter.

Airborne and ramp behaviour

(in progress)

Power Gear and Anti-Power Gear

Power Gear, or simply PG, the most famous and revered oddity of Stunts car model, is a trait of a number of cars, a sort of overdrive mode activated in some specific circumstances. Those circumstances usually involve performing any event that disrupts the balance of forces acting on the car while in the final gear with throttle fully engaged and without hitting the grass. That includes rounding loops, taking jumps, riding ramps or even having minor bumps on banked surfaces. A Power Gear car will then react by shooting suddenly to maximum revs/speed, and will not be slowed down by aero drag or even grass while throttle is held. This general definition, however, does not cover many particularities of Power Gear cars. For instance, Indy and NSX can shoot suddenly to maximum revs on a loop at fourth gear; the speed boost will not, however, be maintained on the grass in that case. Also, Power Gear cars normally can shoot to top speed without bumps or obstacles, simply by reaching a high enough speed on a long enough close banked track. And finally, to complicate matters further, there is a seemingly related effect for some non-Power Gear cars that causes drastic deceleration upon hitting with gas pressed an obstacle that could trigger overdrive in a Power Gear. This effect, dubbed Anti-Power Gear, is very typical of the Countach.

The origins and workings of both Power Gear and Anti-Power Gear are still quite obscure, but it is very roughly known how settings in CAR*.RES can trigger them. It seems particular combinations of car mass and aero drag constant are the main factor in activating both effects, what further reinforces their similar nature. The nature of those specific combinations is confusing, but there are some hints available from investigations done on test cars with varying mass and drag. For instance, Ferrari GTO, one of the Power Gear cars, has 27msu and 20dsu values of mass and drag respectively. Other cars fitted with such a 27/20 combination become PG-able as well. More strikingly, though, is the fact that by varying either mass, drag or both in multiples of 8 will result in PG combinations too: 27/12, 27/28, 35/28, 19/28, etc. The 31/27 NSX leads to another PG series, with combos such as 23/27 and 15/27. Similar behaviour can be seen for Anti-Power Gear: Countach has the combination 33/33; 33/25 is Anti-PG as well. 25/33, on the other hand, is a PG combination. Indy has 15/25 parameters; however it's a very weird observation that all 15/? combos seem to be PG-able. Other exceptions are rather more disheartening: the Audi has 25/33 and no Power Gear (despite it's oddly quirky physics at high speeds). The Skoda Felicia Kompressor cheat car carries 15/27 but has no PG either. Thus, it seems there are more factors involved in determining the occurrence, let alone the specific traits, of Power Gear-like effects. One thing is certain, however: the causes seem so random that any doubters of Kevin Pickell's statement about Power Gear not being a bug will have to give up and trust his word...

See Also

  • Car files, a general overview on file structure of a Stunts car.
  • Car parameters, a general-purprose tuning guide with concise descriptions of relevant CAR*.RES parameters.