Calculate train acceleration including drag

Suggestions that have been added to the game.

Moderator: ickputzdirwech

Post Reply
Peppow
Burner Inserter
Burner Inserter
Posts: 6
Joined: Thu Jun 01, 2017 6:14 pm
Contact:

Calculate train acceleration including drag

Post by Peppow »

TL;DR
As of now, trains accelerate linearly to their maximum speed. This should be converging depending on drag, mass and power of the train.
What ?
Train acceleration (and vehicles in general) should include drag. Since drag increases squared to speed, trains converge to a certain speed. This means there is no need for a hard limit on maximum speed anymore. A higher train to wagon ratio should therefore increase maximum speed.
It should behave like this:
Drag calculates by frontal area plus increasing cw-value the longer the train is: So...

Acceleration = "acceleration depending on power and mass" - ("Constant for balancing" * "frontal area" + "Constant for balancing 2" * "Length of train") * "Current speed"^2
Why ?
Makes the game more realistic as hard limits on speed seem weird to me. Encourages players to experiment with train composition and optimize ratios of trains to wagon for specific uses. Eg fast long range transports or small inner base trains.


Edit: This also means that breaking at high speeds is supported by drag, so breaking from 200km/h to 100 is a lot faster than from 100 to 0.
Additionaly, a wind noise getting louder with speed would fit really nicely to make the player realize why the train isn't accelerating any further near max speed.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Calculate train acceleration including drag

Post by eradicator »

"I'm no physicist but..." i think they already do. Just build an L-CCCCCCCCCCCCCCC train and watch while it never reaches maximum speed. You could also try setting the maximum speed of locomotives to 10^6, as long as you don't change anything else (i.e. engine power) they will probably reach about the same maximum speed as now.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Calculate train acceleration including drag

Post by Optera »

Trains acceleration already includes drag. At some point air_resistance becomes more pronounced than weight resulting in a nice curve.

If I read the code right this should be the train acceleration logic turned into one formula:
speed[t] = (speed[t-1] - min( speed[t-1]; friction/weight) + power/weight/1000) * (1 - air_resistance/(weight/1000) )

air_resistance is taken from the front carriage
all other variables are summed for whole train

@eradicator
Your example of an L-15C train only demonstrates weight reducing max speed.
Your second example of setting max_speed to higher values is the correct test to find out drag induced speed limits.

Post Reply

Return to “Implemented Suggestions”