# Systems of gears (Car simulation)

This topic is 775 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Sorry for making my first (I think?) thread a question.

I've been working on a 2D car physics simulation as a hobby project, and old threads on these boards have been a great help.

I've got the tire modelling working great, as well as the car body and handling phsyics.

Up until now, I've had the tires represented as a regular 2d entity (handled with positional verlet), which is extended to include direction and rotation. The rotation is integrated using positional verlet as well (where forces are accumulated and the "position" is the amount of rotation). The front tires rotate naturally when they are pushed along the road by the rear tires.

I've been testing the system by just having the accelerator apply a force to the rear tires' rotation, which works very nicely, but I'd now like to add engine, clutch and gearbox modelling.

I've modelled an engine and flywheel, and the RPMs and throttle response look very convincing when it's not attached to anything, but getting the force from the engine to the road is confusing me, and it seems to be the point where most discussions on this topic reverse to kludgery.

For example, many people advocate getting the engine speed from the car's longitudinal velocity, and then calculating the engine torque via a lookup table, but in a dead sideways slide, that would cause the engine to bog down into antistall even if you had your foot flat on the throttle. It would also make it impossible to get wheelspin with many engine configurations.

Another issue with deriving engine speed from heading velocity is what happens when the engine is declutched?  And how do you handle damage and wear at an arbitrary point in the driveline without explicitly hardcoding every kind of damage response?

Ideally, I would like to model each component in the driveline separately, but I'm having trouble understanding the way force goes from the engine to the tire and then the resistance make its way back to the engine.

For example, 30%(ish) of the engine's rotation is lost in the transmission due ot efficiency issues, yes? So does that mean that 30% of the resistance coming back from the wheel is also lost?

This has ended up being a very meandering thread, but I guess my main questions are:

-Can anyone point me at resources for realistically modelling the drive line?

or, failing that

-Can anyone explain to me the math I should be learning to simulate a system of gears including mass, friction and inefficiency?

and alse

-Can anyone speak to their own experiences on driveline simulation? I'd love to hear anyone's thoughts.

##### Share on other sites

1. -Can anyone point me at resources for realistically modelling the drive line? or, failing that

2. -Can anyone explain to me the math I should be learning to simulate a system of gears including mass, friction and inefficiency? and alse -

3. Can anyone speak to their own experiences on driveline simulation? I'd love to hear anyone's thoughts.

there are two possible approaches:

1. learn how cars work, and learn physics, and do it right. there are many sources out there on how cars work. Physics by Tippler is the industry standard for university physics texts. I learned cars on my own, and spent my time in physics lecture deriving the formulas to simulate stuff like con rod force on the crank journal. Hint: the secret is the delta N before and after combustion in the PV=NRT gas law from chemistry. for perfect combustion of oxygen and octane, delta n is 32/27 or 32/24, something like that. ie 27 octane and oxygen molecules in, 34 CO2 and H2O molecules out. from this you get a P for F=PA on the piston.

2. something less than correct. IE fake it, kludge it etc.  as you already know, there are TONs of resources on how to fake it.

If you want to make a real mayonaisse, you're going to have to break a few eggs. or in other words if you want a decent simulation you'll have to do some work.

Bottom line, if you don't know how to build a real racecar, how can you hope to simulate one? and FYI, i have a 1971 malibu convertible with a tall deck 454 big block, 30 over pistons, 1/4 inch stoke crank, long rods, 10.28 :1 compression ratio. 489 Cubic inches (IE 8.0 liters)  offenhauser individual runner intake, twin holley 1150's. 688 horsepower on pump gas with no turbo, no nitrous, no blower, no nothing! so yeah i know how to build racecars, and yeah i took all the physics required in college. PS i also have a 71 GMC stepside pickup with a small bock version of the same engine rated at 511 horsepower, a 1999 Z28 camaro, and 1986 porsche 944. can you tell i'm a hot rodder? <g>.

##### Share on other sites

1. -Can anyone point me at resources for realistically modelling the drive line? or, failing that

2. -Can anyone explain to me the math I should be learning to simulate a system of gears including mass, friction and inefficiency? and alse -

3. Can anyone speak to their own experiences on driveline simulation? I'd love to hear anyone's thoughts.

there are two possible approaches:

1. learn how cars work, and learn physics, and do it right. there are many sources out there on how cars work. Physics by Tippler is the industry standard for university physics texts. I learned cars on my own, and spent my time in physics lecture deriving the formulas to simulate stuff like con rod force on the crank journal. Hint: the secret is the delta N before and after combustion in the PV=NRT gas law from chemistry. for perfect combustion of oxygen and octane, delta n is 32/27 or 32/24, something like that. ie 27 octane and oxygen molecules in, 34 CO2 and H2O molecules out. from this you get a P for F=PA on the piston.

2. something less than correct. IE fake it, kludge it etc.  as you already know, there are TONs of resources on how to fake it.

If you want to make a real mayonaisse, you're going to have to break a few eggs. or in other words if you want a decent simulation you'll have to do some work.

Bottom line, if you don't know how to build a real racecar, how can you hope to simulate one? and FYI, i have a 1971 malibu convertible with a tall deck 454 big block, 30 over pistons, 1/4 inch stoke crank, long rods, 10.28 :1 compression ratio. 489 Cubic inches (IE 8.0 liters)  offenhauser individual runner intake, twin holley 1150's. 688 horsepower on pump gas with no turbo, no nitrous, no blower, no nothing! so yeah i know how to build racecars, and yeah i took all the physics required in college. PS i also have a 71 GMC stepside pickup with a small bock version of the same engine rated at 511 horsepower, a 1999 Z28 camaro, and 1986 porsche 944. can you tell i'm a hot rodder? <g>.

The reason I'm doing this project, at least in part, is to learn more of the specifics of the car's physics. I started with the tires, which I'm now fairly comfortable with, and next I'm moving up to the drivetrain. At this stage, I'm not focusing on the specifics of the engine beyond gas in -> torque on the flywheel out. My goal is to learn how to get the flywheel torque though the clutch, through the gearbox, through the diff and onto the road, and then to get the resultant resistance back through the entire system and into the flywheel.

##### Share on other sites
My goal is to learn how to get the flywheel torque though the clutch, through the gearbox, through the diff and onto the road, and then to get the resultant resistance back through the entire system and into the flywheel.

i would think that at each stage you would calculate the resistance  and apply it there.

the front-solve then back-solve approach seems common when faking it, but makes no sense to me based on my one year of jr high school physics, one year of high school physics, three semesters of college physics, one semester of college physics lab, and 37 years as a hot rodder.

off the top of my head...

induction system will determine volumetric efficiency at any given rpm. which determines how many molecules you have and thus how much pressure on the piston after combustion. the force is actually not constant, but varies as the charge burns and the piston moves. F=PA gives you the force on the piston based on cyl pressure, and the force along the rod is F cos(theta) where theta is the angle from the vertical of the rod at that moment. this gives you F at the crank journal, times stoke = torque! <g> so right there you have your torque at the flywheel. now you add a clutch or torque converter, which will add some amount of resistance, based on parasitic driveline drag, and the weight of the vehicle and speed too, as i recall. in the end you end up with some net torque at the drive axle, times tire rad = shear force on the road. F=MA, and away you go!

I've heard good things about "swept volume" methods for modeling engine output. desktop dyno and other high quality engine design software uses it.

chevrolet makes a book called the chevy power manual. Its  available at your local chevy dealer's parts counter. the last chaper is "vehicle dynamics" and is very useful for car simulations.  lots of good theory and formulas in there.

Edited by Norman Barrows

##### Share on other sites

Hi,

I remember this was the most mysterious part in my sim. I couldn't find any usefull info on the topic, not even here, only foggy and misleading docs everywhere, like it had been the most difficult problem of life, or something. It was very frustrating.

I also remember trying what you did, just spinning the rear wheels (fake it) and managed to achieve quite believable result.

And finally I god enlighted by myself :)

I strpiped down the problem to a simple acceleration test in 2d (side view) having only one wheel. It was much easier to follow what the heck is going on.

First forget about the differentials, they make your problem even more difficult to get it right. Do a fixed axle for first.

So, in a nutshell;

You have to differentiate two major cases, when the clutch is locked and when it's "slipping".

1. When locked, the whole stuffs rotates together and can be handled together.
You can indeed derive the rpm from speed, but instead of using linear speed use the wheels angular velocity.
Calculate the torque from the engine, through the gearbox to the wheels and accelerate only the wheel usng (torque_drive + torque_road) / effective_inertia
As you accelerate the wheel calculate the rotation speed of gearbox and engine back from the wheel rotation. Pretty simple.
2. When the clucth is not locked, you have to separate the engine and the rest of the driveline.
Use the engine torque to accelerate the engine only, and do the same as in (1) to the gearbox to wheel acceleration with the difference of using a portion of engine torque. The "portion" is the amount that the clutch can transfer depending on the pedal position.
Here is an extra torque created by the clutch that accelerates and decelerates these two to synchronize their speed.
And the same as above calculate the gearbox rotation speed from wheel speed (the engine is calculated separately)
3. And you are done. The only thing you have to take care of is when to open and close the clutch, and its only a relation between the pedal position and the amount of torque going through it.

I hope it was clear somehow.

You'll need this: http://www.racer.nl/tech/effinertia.htm to calculate the inertia of the whole driveline or just part of it.

Regarding transmission efficiency, I didn't have an idea where to "put" it, so I just left it out. It looked cool without it, though.

My guess would be, it's enough to use the efficiency "loss" once, when the torque is calculated that accelerates the wheel. The reaction is handled at the wheel too, it's "not going back" to the engine that way.

##### Share on other sites

I started to make a car simulator years ago and really studied up on physics and even chemistry trying to figure out how much energy is produced when hydro-carbons like octane  break their bonds. The conclusion I came to is that besides physics and chemistry, it's a calculus problem. Things in the system are dynamic and variable and it seems to me that's really what calculus is for. I don't know calculus, but trying to understand this problem really made me want to learn it. That was also about the time I was reading a text book on cars and decided to pull my front axel apart on my truck. Still, I never did figure all the math out.

The gears themselves are pretty simple. It's figuring out the torque curve of the engine and such that's difficult. I think most engineers get that from a chart rather than calculating it.

I think I may try something a little more simple and straight forward like a steam locomotive this next year. For the most part, that's just let steam into the cylinder until it slides to one end where it reverses it's own steam valves and puts steam on the opposite side of the same piston. But there are far fewer variables and moving parts to contend with.

Oh. One thing I might point out is the entire car/system is connected. The octane in the engine is what applies force to the wheels and the wheels and friction throughout the system are what resist the force of the octane igniting in the cylinder. If you don't believe this pop a clutch without giving it enough gas to overcome the sudden load. Or try coming to a stop without disengaging the clutch. As long as the clutch is attached, the engine can't push against the system without the car moving. The car dies when the engine is faced with a resistance it can't overcome. The only way to keep the engine from dying is to disengage the clutch or move the car.  Automatics have a torque converter to get around this and can idle the engine at a stop in gear.

Edited by BBeck

##### Share on other sites

The conclusion I came to is that besides physics and chemistry, it's a calculus problem. Things in the system are dynamic and variable and it seems to me that's really what calculus is for. I don't know calculus, but trying to understand this problem really made me want to learn it.

Oh my god I could kiss you. Of course it's a calculus problem. Meaning of course you can solve it through relaxation using constraints and integration.

It's so simple! I can't believe it took me this long to realise it.

EDIT: I realise this post looks actually quite sarcastic but I'm completely serious. Your post gave me the eureka moment I needed :)

Edited by ElliottSmith

##### Share on other sites

Can you share your conclusions with the rest of the class? :)

##### Share on other sites

Can you share your conclusions with the rest of the class? :)

Ah, sorry, of course.

Basically I just solved it like a system of ragdoll constraints. A "gear" constrains two rotating objects' rotational velocities to a ratio of each other's velocities.

So if object A is geared to object B at a ratio of 1:2, then every frame the "gear" solver will apply the appropriate forces to make A's rotational velocity equal to 1/2 of B's, and B's rotational velocity to 2/1 of A's.

If you iterate over the solver for each gear in the system a few times, the system relaxes so that each object's rotational velocity is correct.

Correcting the ratio for difference in inertia (for say, the flywheel vs the gearbox) or clutch ratio is just done by adding the appropriate coefficients.

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633662
• Total Posts
3013228
×