The question to ask here is a deceptively simple one: what is the capacity of a rail network? Trying to find information on this topic is difficult, since most theorycrafting works on belts and bots, and the underlying formulas for trains aren't easy to track down.
Step 0: How to tackle the question
Trains are complex, and so the answer to how much can you move by rail is going to have to have a complex answer. It's going to need to be answered in several parts. Breaking it down into pieces, we need to start by looking at what the absolute maximum throughput of a rail is, in terms of all trains infinitely remaining at the same speed on a track. Then, we can look at the impact of getting trains to and from their max speed. At that point, we can observe the impact of stations on throughput. Finally, we can integrate the impact of more complex train networks and switching on capacity. But before we can quantify anything, we need to understand first how trains work.In terms of formulas, trains have more formulas that you need to know than any other logistic system. There are distinct formulas for acceleration, deceleration, and braking distance that are critical to analysis, not to mention the basic calculations for computing things like maximum speed, energy consumption, train loading, etc. Here are the formulas I have:
- Acceleration: speed at next tick = (speed - min(speed, friction / weight) + power / weight) * (1 - air_resistance / weight) {up to max_speed}
- Braking distance (in tiles): max( ½ * weight * speed / (braking + friction), 1.1) * speed + 2
- speed: Speed in tiles/tick. Max speed of a nuclear fuel train (298.1km/h) is 1.38. Note that the speed in the GUI is shown as km/h, divide by 216 to get tiles/tick.
- friction: Sum of all friction_force values on the locomotives and wagons on the train. This is 0.5 each for locomotive and wagon.
- weight: Sum of all weight values on the locomotives and wagons on the train. This is 2000 for locomotives and 1000 for wagons.
- power: I'm not entirely sure where this value comes from, but this is where I believe the fuel acceleration modifiers kick in, and it's dependent on the number of forward-facing locomotives.
- air_resistance: The air_resistance value of the first thing in the train. 0.075 for locomotives, 0.01 for wagons.
- braking: Sum of all braking_force values on the locomotives and wagons on the train, multiplied by the braking force bonus modifier. This is 10 for locomotives and 3 for wagons, assuming +0% braking force.
Step 1: Assume trains at constant speed on an infinite track…
Imagine you had an infinite flat track with trains going at a constant speed spaced several tiles apart. Now imagine a signal on this track. It will start out green. A train will come along, reserve it and change it to yellow when its braking distance spot passes over the signal. Then the train will pass over the signal, and the signal will change to red. When the train passes through the signal, it will stay red until the train passes the next signal some distance away. Then our signal changes back to green, awaiting the next train. If we shrink the length of the green cycle to an infinitesimally small amount, then it is impossible to squeeze any more trains on the track without slowing them down. Thus the capacity of a track is 1 train / (time_yellow + time_red), and is obviously dependent on train length, braking distance, speed, and signal distance.Let's return to the braking distance formula. If we assume vanilla parameters, we can simplify the equation. One thing that may seem surprising is that braking distance does not depend on train length or train consist details, but rather the ratio of locomotives to wagons: R = # wagons / # locomotive. A 1-4, 2-8, even a 5-20 train all have the exact same braking distance. Another simplification is the max: for max speed trains, the first leg of the max is going to be in the region of 100. Trains really have to be going very slow for the 1.1 to kick in instead. With that in mind, here is a simplified formula (B = braking force modifier, i.e., goes from 1 to 2 in vanilla research):
- braking distance (in tiles) = 1000 * (speed)² * (R + 2) / (2 * B * (3R + 10) + R + 1) + 2
- yellow cycle time (in ticks) = braking distance / speed = 1000 * speed * (R + 2) / (2 * B * (3R + 10) + R + 1) + 2 / speed
A red cycle consists of first the time it takes for the entire train to pass the signal, and then the time for the train to clear the block. The first is (7 * L * R / speed), where L is the number of locomotives, and the second is (signal_distance / speed. Summing up, we get:
- red cycle time = (7 * L * R + signal_distance) / speed
- total time = 1000 * speed * (R + 2) / (2 * B * (3R + 10) + R + 1) + (7 * L * R + signal_distance + 2) / speed
- Throughput (in trains per tick) = 1 / total time
- Throughput per speed = O(1 / speed). Higher max speed means lower throughput. This is actually true to reality, too--higher speed is lower throughput.
- Throughput per braking speed = O(1), O(B) for yellow cycle time only. If you had an infinite braking speed research, the value would reach an asymptote and wouldn't decrease forever. Intuitively, this makes sense: braking speed only decreases the yellow cycle time, so even if you drove it to 0, you'd still have to worry about the red cycle time.
- Throughput per signal distance = O(1), O(D) for red cycle time only. Same thing: drive the signal distance down, and you shrink red cycle time without touching yellow cycle.
- Throughput per locomotive ratio = O(1). Essentially, the makeup of your train doesn't matter in the long run.
- Throughput of total cargo moved = O(k * #cargo wagons / (#cargo wagons + l)), where k and l are some constants. Effectively, there is a maximum capacity you will hit (for 1-to-4 ratios, that maximum capacity is about 11.8 per second), but increasing the number of cargo wagons will get you closer to the asymptote.
When I find more time, I'll come back and discuss the later portions.