0
$\begingroup$

I'm trying to program some kind of car game in unity just for practice. So I want to start off with an engine that behaves normally, so I can then convert the engine's RPM into torque.

Currently, I have capped the engine's max rpm with a variable $maxRpm$.

I have added a second variable $acceleration$ because I don't really know how to have an accurate engine's acceleration (I'm not talking about the car's acceleration here but simply the rate at which the engine's rpm increases).

So to calculate the engine's RPM, at each physics update I take my $rpm$ variable and add to it the input of the gas pedal (between 0.0 and 1.0) times the acceleration times the elapsed time between two updates.

$$rpm = rpm + (gas \times acceleration \times deltaTime)$$

And now I'm wondering how to make the engine's speed decrease when the gas pedal is fully released, I've tried to find formulas concerning engine braking but didn't find anything, anyone as a clue?

$\endgroup$

3 Answers 3

2
$\begingroup$

I don't know whether there are any general formulas concerning engine braking, but you could incorporate drag proportional to the car's velocity:

$$ F =ma= -bv $$

where $b$ is a constant and $v$ the car's velocity. This should reproduce a similar effect to engine braking. The deceleration $a$ is then also proportional to the car's velocity:

$$ a = -\frac{bv}{m} $$

with $m$ the car's mass.


Edit:

Real drag due to aerodynamics is usually taken to be proportional to $v^2$, and also the (frontal) surface area of the car:

$$ F\sim\rho A v^2 $$

where $\rho$ is the density of the medium (in this case: air). I think that the model proportional to $v$ would emulate engine braking slightly better, but you can try both and see which feels more natural.

$\endgroup$
5
  • $\begingroup$ Typical aerodynamic drag is proportional to $v^2$, and rolling resistance is relatively constant. I cannot think of any real effect that is proportional to $v$. $\endgroup$ Commented Aug 17, 2019 at 2:19
  • $\begingroup$ That's true, and I made an edit illustrating your point. But I do think that the $\sim v$ model might be a better approximation to engine braking $\endgroup$ Commented Aug 17, 2019 at 8:07
  • $\begingroup$ Even engine braking is $v^2$ since most engine friction comes from the piston side forces which are proportional to ${\rm rpm}^2$. $\endgroup$ Commented Aug 17, 2019 at 14:13
  • $\begingroup$ How would you calculate the frontal area of the car ? $\endgroup$
    – Matt
    Commented Aug 23, 2019 at 17:57
  • $\begingroup$ I would approximate the frontal surface by a rectangle. If you want it to be more accurate of a representation, you could add more rectangles until you have reached sufficient accuracy. $\endgroup$ Commented Aug 23, 2019 at 19:56
1
$\begingroup$

The engine makes torque based on the rpm and the throttle applied. That torque gets geared through the transmission and differential and finally applied to the tires. Finally, aerodynamic resistance, as well as gravity on a slope needs to be accounted for to get the final acceleration.

At the basic level follow the following steps to estimate the acceleration.

  1. Vehicle speed $v$ to tire rotational speed $\omega_T = \frac{v}{r}$
  2. Tire rotation through the differential with gear ratio $\gamma_D$ and the transmission with gear ratio $\gamma_X$ to get engine speed $\omega_E = \gamma_X \,\gamma_D\, \omega_T$.
  3. Engine torque at that speed $T_E = {\rm torquecurve}(\omega_E)$
  4. Torque at tires through transmission and differential $T_T = \gamma_D \gamma_X T_E$
  5. Acceleration of car on slope $\theta$, with aerodynamic drag parameter $\beta$ $$ a = \frac{T_T}{m r} - \beta v^2 - g \sin \theta$$
  6. Engine power at same instant $P = T_E\, \omega_E$

You can use the known top speed $v_{\rm TOP}$ and the peak power $P_{\rm MAX}$ to find the drag parameter $$\beta = \frac{P_{\rm MAX}}{m v_{\rm TOP}^3}$$

  • You might also want to produce some torque loss on the transmission with $T_T = (1-\lambda) \gamma_D \gamma_X T_E$ where the loss parameter $\lambda=0.15$ is standard for automotive transmissions.

NOTE: That all parameters must be in consistent units, such as Kilograms, Newtons, Meters, Radians and Seconds. So you have to convert rotations from RPM to Radians per Second for example.

Update 1

Based on the comments the OP is asking about specifically the engine behavior. Below is a realistically looking torque curve for a hypothetical engine. There is a family of curves for different throttle positions.

dyno

You might want to simulate something similar to this, or you might want to start simplifying the above in various ways. There is no correct answer in terms of Physics. That is unless you are willing to write fluid and combustion simulation code and model the exact behavior of every part of an engine with the myriad of information needed that you don't have.

$\endgroup$
4
  • $\begingroup$ Thanks for the complete answer, however as I said i'm trying to focus on the engine only for now. $\endgroup$
    – Matt
    Commented Aug 16, 2019 at 20:44
  • $\begingroup$ The most basic ${\rm torquecurve}(\omega)$ function you can create is constant torque $T_E$ up to a max speed value. This will have peak power of $P_{\rm MAX} = T_E \omega_{\rm MAX}$. You can start adding line segments that ramp up to peak torque at low rpm, and drop the torque at higher rpm, or you can go and model actual torque from a dyno chart to get some more realism. $\endgroup$ Commented Aug 17, 2019 at 2:17
  • $\begingroup$ @Matt - see update now. $\endgroup$ Commented Aug 17, 2019 at 20:41
  • $\begingroup$ Thanks a lot, that will surely help me. $\endgroup$
    – Matt
    Commented Aug 23, 2019 at 17:59
0
$\begingroup$

tl;dr: The value you are looking for depends on the clutch design, is constant in power for the most common type of manual clutch and only really affects the gear shifting sound anyways.

Nothing in the physics world is discontinuous, but the engine axle is just a short rod inside the engine, a couple of cams inside the engine and a disc inside the clutch. It doesn't have enough inertia to affect how a car feels when driving. Its angular acceleration is greatest when changing gears, not during braking.

The angular acceleration when shifting gears is then governed the moment of inertia of the engine axle and by the clutch design (more friction = less service life for the clutch). The angular acceleration when revving up is governed by the moment of inertia and the engine torque. The angular acceleration when idling is governed by the moment of inertia and the friction from bearings. When the clutch is fully engaged, the engine axle's rotational inertia becomes insignificant. If your car uses automatic transmission, you can ignore all three of these values.

When the car accelerates, the acceleration is governed by the car mass (plus cargo) and by the engine torque as a function of its current speed (RPM) and the amount of fuel flow (normally you measure maxTorque(RPM) and then fit a curve onto it) and by the transmission ratio.

When the car brakes, most of its deceleration is comes from the friction between the tires and the road (dependent on both the tire and the road surface). Car's ability to break doesn't depend on its speed or the engine power. There's an electronic system that prevents the brakes from applying too much friction between the wheels and the braking mechanism. The same number also applies when the car accelerates.

When the car coasts, its deceleration is determined by air drag (quadratic function of the speed) and its tires' rolling friction (function of road surface and car type). These two forces also help braking and reduce acceleration.

Sources / useful links:
https://en.wikipedia.org/wiki/Drag_equation
https://en.wikipedia.org/wiki/Clutch
https://en.wikipedia.org/wiki/Automatic_transmission
https://www.caranddriver.com/news/a15347872/horsepower-vs-torque-whats-the-difference/ (contains a typical torque and power curve)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.