I am trying to simulate the rotating masses of engine and other drive-train components in code and as I'm not too great in physics and math, I'm struggling a bit.
How to simulate the rotating inertia of an engine (and other similar objects like wheels)? The effect I'm looking for is that the force applied to the car is not only based on the power that the engine can out at specific rotating speed, rpm and throttle position but also the change of speed of transmission components and wheel contact.
Lets say the car is dropped from a height and it's revving in gear at max rpm. There is quite a lot of kinetic energy in the rotating mass of the engine, transmission components and wheels so that when the car hits the ground, it propels the car forward (either just a short jolt or with enough power, spinning the wheels and accelerating).
The same thing is when hitting the limiter in neutral and then changing into gear, the car should spin the wheels.
Since my engine only exists in code and not as a real rotating mass connected to the vehicle and the wheels are also ray-cast and thus imaginary, how do I simulate this kinetic energy accumulation and transfer to the wheels?
I understand the kinetic energy is a function of inertia and angular speed (link1), (link2):
This gives me the energy in Joules which is W*s. I'm not sure how to put this all together
I have included some of my engine code but I'm quite sure I'm not doing it right.
Ogre::Real enginePower = getTorque() * internalAngularSpeed.valueRadians(); // not using kinetic energy in this calculation Ogre::Real work = enginePower * timeStep;
What I'm looking for is, given inertia and rotating mass, how to calculate how quickly the object spins up under given torque, how it slows down with drag and how it transmits it's rotating kinetic energy to connected objects
As an update, this is my current method for solving tire visual angular speed and visually, it seems more-or-less ok, the method I use elsewhere is similar. Is this mathematically-physically correct?
void BasicTireSolver::solveAirborne(Ogre::Real timeStep) { if (requestedBrakeForce > 0.1f) { // braking harder then the tire can take, make it look to slow down and eventually lock up Ogre::Real torque = requestedBrakeForce * tireVisualizer->getTireRadius(); Ogre::Radian angularAcceleration = Ogre::Radian(torque / rotationalInertia); //Ogre::Radian angularSpeedChange = angularAcceleration * timeStep; Ogre::Radian angularSpeedChange = angularAcceleration * timeStep * 0.1f; // smoother, but is it correct?
And I'm still wondering how to handle the kinetic energy of rotating mass so that the car would spin the wheels when changing from neutral to first at high rpm.
Hope you'll find a moment to take a look at this, I'm still not sure I'm doing this right
Hey, I'm back on this subject and still wondering how to correctly simulate system of rotating masses geared together - an engine connected to flywheel, connected to a gearbox, connected to driveshaft, to differential and finally to the wheels. Each part has certain rotating mass and inertia.
As background information, I'm trying to build a realistic ray-cast car.
What I want to simulate is that the power-train does not simply pass the torque generated at the engine to the wheels, but it also takes energy to spin it up and also to slow down, as inertial systems do.
As an extreme example, imagine the car is stopped, in first gear and you spin the engine to high RPM with clutch disengaged and then suddenly come off the throttle (so the engine is not actually producing any torque any more) and instantly engage the clutch, the car would probably spin the wheels momentarily and move the car a bit from just the energy stored in the spinning engine and flywheel.
I found a rather good article on inertia here and have tried making sense of such a system as an example with more or less realistic data of the example described above. This is what I came up with but I'm pretty sure that my physics, math and reasoning are not quite correct. Just to show I have tried to think about this myself
Wheelspin from rotational kinetic energy 1) Engine RPM = 6000 RPM = (2PI / 60) * 6000rpm = 0.14719 * 6000 = 628 rad/s (engine speed - rotational velocity) 2) Engine torque = 0 (no power from engine) 3) Engine inertia = 0.2 kg∙m2 4) Gearbox inertia = 0.1 kg∙m2 5) Drive shaft inertia = 0.05 kg∙m2 6) Differential inertia = 0.1 kg∙m2 7) Wheel inertia = 0.35 kg∙m2 8 ) Car is in first gear with ratio of n = 3.8 9) Using locked diff with ratio of 3.6 10) Total inertia of spinning components = Igearbox + (Iengine/n2) = 0.1 + (0.3 / 3.82) = 0.1 + 0.02 = 0.12 N∙m 11) Total inertia of parts to spin = driveshaft + diff + 2 wheels = 0.05 + 0.1 + (2*0.35) * (3.62) = 9.22 N∙m 12) Kinetic energy of the engine and gearbox = Ek = (inertia * rotational-speed2) / 2 = 0.12 * (628rad/s)2 = 0.12kg∙m2 * 394784rad/s = 47374J= 47kJ 13) Car is coasting slowly, wheels spinning at 10 rad/s 14) The drive shaft is spinning at 10rad/s * 3.6 = 36rad/s 15) Kinetic energy of the wheels is ((0.35* 102) / 2) * 2 = 35J (nearly nothing) 16) Kinetic energy of diff is small too 17) Angular speed after gearbox = 628rad/s / 3.8 = 165,263rad/s 18) Angular speed difference between the gearbox and the driveshaft = 165,26rad/s – 36rad/s = 129,26rad/s 19) The clutch is instantly engaged 20) Simulation timestep = 0.016s (60 FPS) 21) What would be the torque required to equalize the rotational speed difference? 22) Change of speed = 129rad/s, duration = 0.016s, acceleration = speed diff / time = 129rad/s / 0.016s = 8078.75rad/s2 23) Torque required = acceleration * inertia = 8078.75rad/s2 * 9.22 kg∙m2 = 74486 N∙m 24) How much torque can the spinning engine give out? 25) Angular speed after gearbox = 628rad/s / 3.8 = 165,263rad/s 26) Acceleration to stop it in 0.016s = 165rad/s / 0.016s = 10312 rad/s2 27) Torque to stop it = 10312rad/s2 * 0.12 kg∙m2 = 1237.44∙N∙m 28) The torque the spinning engine could give out in this time is smaller then what would be needed to make the wheels spin at the same speed in 0.016s 29) Wheel outer radius = 0.292m 30) Force that could be sent to wheels = torque / radius = 1237.44 / 0.292 = 4237N 31) Let’s say the maximum force the tire could sent to the ground is 1500N 32) Then excessive force is 4237 – (1500N * 2) = 1222N 33) For each tire, this is 1222N / 2 = 611N 34) Excessive torque on both tires = 2737N * 0.292m = 178N∙m 35) Wheel inertia = 0.35 kg∙m2 36) Angular acceleration of wheels = torque / inertia = 178Nm / 0.35kg∙m2 = 62rad/s2 37) Timestep = 0.016s 38) Increase in wheel angular speed = acceleration * timestep = 62rad/s2 * 0.016s = 0.9968rad/s 39) In this frame – 0.99 rad/s * 0.016s = 0.0158rad ~ 0.9 degrees
I have also started work on a base class of RotatingMass that every spinning component of my power-train would eventually extend.
In short, I would like to know how to simulate the system of rotating masses in a car driveline in a way that the effects of inertia and gearing is taken into account.
As an opposite example to spinning the wheels from rotational energy, would be cool if the simulator I'm building could once simulate this