OpenTTDDevBlackBook/Simulation/Train Acceleration

From OpenTTD
Jump to: navigation, search
External Links

OpenTTD GitHub
Contributing to OpenTTD - guidelines
OpenTTD Doxygen

General Reference

Coding style
Compiling OpenTTD
Debugging
Add a setting
Add a squirrel function
Understanding the SaveGame handler
Bumping the savegame version
Doing an OpenTTD release

Language and Strings

Format of langfiles
Using OpenTTD strings
List of special strings

Window System

Using the window system
Colour codes that exist in OpenTTD
Adding a text box
Understanding the widget focus system
GUI style guide

Multiplayer

The OpenTTD TCP protocol
The OpenTTD UDP protocol
Debugging desyncs
Server Admin Port development

Ingame Console

The console window
Console commands
Console variables
Using console scripting
Adding functions/commands to the console
Adding variables to the console
Console development history

Content APIs (modding frameworks)

Graphics and similar (NewGRF)
AI framework (NoAI)
GameScript framework (NoGO)

Other Reference

Map array (landscape grid)
Vehicles
Pathfinding
Train acceleration


This page tries to summarize the algorithm used for realistic train acceleration. What follows is a description of the formulas listed at the bottom of this page.


  • acceleration = (force – friction) / 4m
    • where m is the mass of the train
  • force = 2.2 * power / velocity = 2.2 * time * power / distance
  • friction = 4 * (1.3m + 60n + μmv*10-3 + Adv2/10,000 + q)
    • where n is the number of cars
    • and v is the velocity.
  • μ is the coefficient of friction, which is set to 35 for OpenTTD.
  • A is the area of mumble, mumble 120.
  • d = 20+3n
    • This is the drag coefficient, although it does not depend on velocity as one would expect.
  • q = Σ 60simi
    • where si is the slope of car i
    • and mi is the mass of car i.
This is incline of the train as a whole (or the sum of the inclines of each car), where 60simi is the incline of a single car i.
  • The slop of a car is one of the following:
    • 1 if the car is ascending
    • 0 if the car is level
    • -1 if the car is descending



Units used

velocity [v] = mph

power [P] = W

mass [m] = t

Formulas

F = 22P / 10v [N]

n — number of cars

μ = 35 (eq. 1e-3 ?) — coefficient of friction

A = 120 — area (units?)

d = 20+3n — drag coefficient

q = Σ 60simi — incline term, summed over cars

si — slope, -1 (going down), 0, or 1

mi — mass of the car

Fr = 4(13m / 10 + 60n + μmv / 1000 + Adv2/10000 + q) [N]

a = (F - Fr) / (m * 4) [m s-2]

Personal tools