Fuel consumption of trains at max speed

Post all other topics which do not belong to any other category.
mknejp
Fast Inserter
Fast Inserter
Posts: 154
Joined: Wed Apr 27, 2016 8:29 pm
Contact:

Fuel consumption of trains at max speed

Post by mknejp »

A bit of background: I made the Electric Vehicles mod that converts energy stored in batteries of a vehicle (car/tank/locomotive) to fuel its internal buffer.
The electric locomotive my mod adds has a 1MW max power, compared to the diesel locomotive's output of 600kW. Both have the same top speed. So in theory this should make the electric train better because it is capable of reaching max speed sooner and once cruising at top speed the consumption should be the same.

But strangely it was pointed out to me by zebediah49 that the electric locomotive is actually terribly wasteful.

I did some experimenting and found out that in fact the locomotive is running at *full power* when going at max speed. This is totally counter intuitive and is the equivalent of driving your car at full throttle with the brakes on. I totally did not expect this as I was assuming it would only consume as much as is needed to maintain max speed.

Correct me if I'm wrong but I assume the current tick update is:
1. slow down the train according to friction
2. for each (front|back)_mover take out as much energy out of the buffer as possible limited by the max_power property
3. calculate the gained acceleration
4. set speed to min(speed + acceleration, max_speed) where I assume max_speed is the minimum of all carriages

So my question here is: should this be changed? I know the game is all about polluting the planet, but burning through your fuel at full rate even though you're applying the brakes to not go over a speed limit seems a bit over-the-top.

If you do consider this a problem then I suggest changing the process:
0. for each (front|back)_mover determine the fraction of the total power it contributes (can be done once when the train configuration changes)
1. slow down the train according to friction
2. determine the energy necessary to reach max_speed in relation to the combined power output
3. for each (front|back)_mover take out as much energy as is required distributed according to the weights from step 0
4. calculate the actual acceleration
5. set speed to min(speed + acceleration, max_speed)

This should ensure that
1. the train is consuming only as much power as is actually needed without burning through its fuel at max rate all the time
2. fuel consumption is distributed among all participating locomotives according to their power output so their fuel should drain in a balanced fashion

It also means that it changes the fuel consumption balance of existing trains since those going at max speed most of the time now consume less fuel. If necessary this could be re-balanced by decreasing the diesel locomotive's burner efficiency (which is at 100% right now) and adjusting fuel slots so the available energy stays the same when fully fueled.

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

Re: Fuel consumption of trains at max speed

Post by Optera »

I was under the impression trains simply go full throttle all the time until their weight (which isn't currently calculated properly) prevents them from accelerating any more.
If we added speed limits, your proposal would totally make sense.

mknejp
Fast Inserter
Fast Inserter
Posts: 154
Joined: Wed Apr 27, 2016 8:29 pm
Contact:

Re: Fuel consumption of trains at max speed

Post by mknejp »

Optera wrote:I was under the impression trains simply go full throttle all the time until their weight (which isn't currently calculated properly) prevents them from accelerating any more.
If we added speed limits, your proposal would totally make sense.
There is a speed limit. Diesel locomotives are limited to 1.2 tiles/tick, cargo wagons to 1.5 tiles/tick. That's why the current behavior makes no sense.

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

Re: Fuel consumption of trains at max speed

Post by Optera »

mknejp wrote:
Optera wrote:I was under the impression trains simply go full throttle all the time until their weight (which isn't currently calculated properly) prevents them from accelerating any more.
If we added speed limits, your proposal would totally make sense.
There is a speed limit. Diesel locomotives are limited to 1.2 tiles/tick, cargo wagons to 1.5 tiles/tick. That's why the current behavior makes no sense.
Speed limit may be something different for you. For me it's the maximum safe speed at which something can operate.
Factorio trains seem to run at "unsafe" maximum possible speed. viewtopic.php?f=18&t=8145#p64914

mknejp
Fast Inserter
Fast Inserter
Posts: 154
Joined: Wed Apr 27, 2016 8:29 pm
Contact:

Re: Fuel consumption of trains at max speed

Post by mknejp »

Optera wrote:
mknejp wrote:
Optera wrote:I was under the impression trains simply go full throttle all the time until their weight (which isn't currently calculated properly) prevents them from accelerating any more.
If we added speed limits, your proposal would totally make sense.
There is a speed limit. Diesel locomotives are limited to 1.2 tiles/tick, cargo wagons to 1.5 tiles/tick. That's why the current behavior makes no sense.
Speed limit may be something different for you. For me it's the maximum safe speed at which something can operate.
Factorio trains seem to run at "unsafe" maximum possible speed. viewtopic.php?f=18&t=8145#p64914
That *is* the max speed. 1.2 tiles/tick * 60 ticks/s * 3.6 = 259.2 km/h assuming 1 tile = 1 meter. It is not a simulated equilibrium but an arbitrary value specified in the entity's data files. So since this is a set limit for each carriage that the game won't allow to be crossed it makes no sense for the train to consume full power when it is not allowed to accelerate beyond that point.

Ratzap
Filter Inserter
Filter Inserter
Posts: 371
Joined: Sun Aug 16, 2015 11:15 pm
Contact:

Re: Fuel consumption of trains at max speed

Post by Ratzap »

Good work Mknejp, I love how people making mods or fiddling about find things in the Factorio simulation like this.

You're right of course, it makes sense to use fuel as required not just always take away max per tick. Well spotted.

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

Re: Fuel consumption of trains at max speed

Post by Optera »

mknejp wrote:
Optera wrote:
mknejp wrote:
Optera wrote:I was under the impression trains simply go full throttle all the time until their weight (which isn't currently calculated properly) prevents them from accelerating any more.
If we added speed limits, your proposal would totally make sense.
There is a speed limit. Diesel locomotives are limited to 1.2 tiles/tick, cargo wagons to 1.5 tiles/tick. That's why the current behavior makes no sense.
Speed limit may be something different for you. For me it's the maximum safe speed at which something can operate.
Factorio trains seem to run at "unsafe" maximum possible speed. viewtopic.php?f=18&t=8145#p64914
That *is* the max speed. 1.2 tiles/tick * 60 ticks/s * 3.6 = 259.2 km/h assuming 1 tile = 1 meter. It is not a simulated equilibrium but an arbitrary value specified in the entity's data files. So since this is a set limit for each carriage that the game won't allow to be crossed it makes no sense for the train to consume full power when it is not allowed to accelerate beyond that point.
The way I see it those 259.2km/h are the max speed they are capable of. It makes perfect sense for an engine to use 100% power when pushed to it's limit.
Again, if they where to introduce speed limits your idea of engines throttling back and using less power makes perfect sense.
Let's assume a speed limit of 230km/h with oversimplified throttle mechanic.
up to 1-2 we'd have engines running at 88,7%
1-2.5 would run at 96%
1-3 and above would run at 100% never reaching the speed limit

mknejp
Fast Inserter
Fast Inserter
Posts: 154
Joined: Wed Apr 27, 2016 8:29 pm
Contact:

Re: Fuel consumption of trains at max speed

Post by mknejp »

Optera wrote:The way I see it those 259.2km/h are the max speed they are capable of. It makes perfect sense for an engine to use 100% power when pushed to it's limit.
Again, if they where to introduce speed limits your idea of engines throttling back and using less power makes perfect sense.
Let's assume a speed limit of 230km/h with oversimplified throttle mechanic.
up to 1-2 we'd have engines running at 88,7%
1-2.5 would run at 96%
1-3 and above would run at 100% never reaching the speed limit
Don't you see that those values *are* speed limits? It's even called "max_speed" in the data files. The locomotives aren't "pushed to their limit". They have a set value at which they stop accelerating, even if you make the locomotive ten times as powerful. If you increase the value in the data file they go faster. Even though the data files contain values for friction and air resistance for each type of carriage the game still sets a hard limit for the train regardless of power, friction or drag. It is a speed limit for all intents and purposes. I simply argue that when a locomotive has reached its max speed it should only consume as much power as is necessary to maintain said speed.

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

Re: Fuel consumption of trains at max speed

Post by Optera »

mknejp wrote:
Optera wrote:The way I see it those 259.2km/h are the max speed they are capable of. It makes perfect sense for an engine to use 100% power when pushed to it's limit.
Again, if they where to introduce speed limits your idea of engines throttling back and using less power makes perfect sense.
Let's assume a speed limit of 230km/h with oversimplified throttle mechanic.
up to 1-2 we'd have engines running at 88,7%
1-2.5 would run at 96%
1-3 and above would run at 100% never reaching the speed limit
Don't you see that those values *are* speed limits? It's even called "max_speed" in the data files. The locomotives aren't "pushed to their limit". They have a set value at which they stop accelerating, even if you make the locomotive ten times as powerful. If you increase the value in the data file they go faster. Even though the data files contain values for friction and air resistance for each type of carriage the game still sets a hard limit for the train regardless of power, friction or drag. It is a speed limit for all intents and purposes. I simply argue that when a locomotive has reached its max speed it should only consume as much power as is necessary to maintain said speed.
You are right, max_speed is redundant and seems arbitrary compared to the values of weight, power, power efficiency, friction, drag. 600kw feels way underpowered for a locomotive reaching 260km/h, making max_speed less of a speed limit and more of a speed boost. Did you do the math as to what speed locomotives with these values should reach?
I'm way too tired to get into that math right now.

mknejp
Fast Inserter
Fast Inserter
Posts: 154
Joined: Wed Apr 27, 2016 8:29 pm
Contact:

Re: Fuel consumption of trains at max speed

Post by mknejp »

Optera wrote:You are right, max_speed is redundant and seems arbitrary compared to the values of weight, power, power efficiency, friction, drag. 600kw feels way underpowered for a locomotive reaching 260km/h, making max_speed less of a speed limit and more of a speed boost. Did you do the math as to what speed locomotives with these values should reach?
I'm way too tired to get into that math right now.
In order to do any math I'd first have to know what the values actually mean and what quantity they're supposed to have. I have no idea what the "weight" unit is as a locomotive with a mass of 2000kg isn't heavier than a pickup truck but 2000t is almost as heavy as an entire real world (empty) train. From the comments in the data file I assume that air resistance is actually applied linearly instead of quadratically but who knows what approximations the game uses. Those values may not have any relation to real world physics but simply "feel right". But honestly I don't mind the physics the way they are. All I'm wondering is whether the trains really need to consume full power when cruising at max speed.

zebediah49
Fast Inserter
Fast Inserter
Posts: 119
Joined: Fri Jun 17, 2016 8:17 pm
Contact:

Re: Fuel consumption of trains at max speed

Post by zebediah49 »

I'm glad to see this getting some attention. I originally noticed this a few versions back, but didn't really care because it was a pretty minor cost with heavily loaded steam-locomotives. Anyway, I'm down for a bit of reverse engineering here for you all, so let's go.

First off, a bit of empirical testing. Take a single unloaded train; changes its 'max_power' stat, hop in it and run it in a circle until it hits max speed.

400kW -- 176.9
300kW -- 129.1
200kW -- 81.3
100kW -- 33.5

You're welcome to plot that yourself, or you can take my word for it being a dead-straight line. y [speed, kph] = 0.478 (x [power, kWh] - 29.9 kW). You'll note it's in x-intercept form rather than y-intercept, because that's more useful, and tells us the work-function of a train. It's 30 kW. (This was then confirmed with an electric train with 3 solar panels not appreciably moving, while one with 4 solar panels could happily cruise at about 5kph.)

The linear nature of this plot, combined with the comment in the train entity description ( "this is a percentage of current speed that will be subtracted" ) indicates to me that the devs didn't implement energy consumption physics correctly. Specifically, the [ v *= (1-loss) ] method of friction produces a linear friction term of the [ F = -gamma v ] form. Multiply through both sides by v, and we get a [ P = -gamma v^2 ]... which doesn't agree with our empirical data.

Conclusion: Factorio trains are rocket powered.

Slightly more seriously and usefully, the observed data can be explained by a [ F = k P ] model, in which power directly converts into force -- or in the time-discretized form, energy directly converts into impulse.

Great, let's get real numbers out of this. Taking the conversion factor 1.2 (tiles/tick) = 259.2 km/h, we can rewrite our constants as v [speed, tiles/tick] = 0.133 ( P - 0.5 ), where power is now in kJoules/tick. Let's see what we can make of this. First, we should attribute the air resistance of '0.0075' to our slope. At maximum speed, our power input (minus the flat tax) goes into returning 0.75% of that maximum speed. delta v = 0.000975 E. 1 MJ buys you 1 tile/tick... that seems way too close to be luck. What about Friction Force? Well, if 500 J produces a speed increase of 0.5 mtile/tick.. I guess Friction Force is in mtile/tick?

Last (and hopefully least, because I'm getting tired of restarting the game), we have weight. Doubling weight has approximately no effect on speed (400kW still goes a little over 175 kph); it only affects acceleration.

Last, to come full circle, let's use what we've learned to do a little extrapolation. To travel the max speed of 1.2 tile/tick, we should need (1.2/0.113+0.5) = 9.52 kJ/tick = 570 kW.

No wonder this was such a minimal problem for the 600 kW train.

E: I propose that an ambitious person who is not me should construct the Factorio equivalent of a quarter-mile racetrack to test the effects of weight. Make like a 100-tile loop with a combinator contraption to act as a stopwatch and give lap times (preferably a set of them, so you know how long each lap took to get enough datapoints to fit a curve).

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

Re: Fuel consumption of trains at max speed

Post by Optera »

Impressive math, it proves how off factorios numbers are.
Factorio diesel locomotives have an unrealistic low weight of 2t. Their power of 600kW is somewhat in line with real world switcher typically reaching around 50-80km/h.

The lightest diesel switching engine I know is the Köf III
power 177kW
weight 22t
speed 45km/h

The closest match to Factorio's locomotives I can think of would be the V100
power 730kW - 1100kW
weight 64t
speed 80 or 100km/h

In contrast, the currently fastest off-the-shelf electric locomotive Siemens ES64U4
power 6000kW/6400kW
weight 78t
top speed 357km/h (world record 2006 for single locomotive)
normal speed limit 230km/h

So Factorio has locomotives that are 10 times lighter than the smallest switcher, have the power of a light cargo locomotive and match normal speeds of world record holders. Not to mention no diesel-hydraulic or diesel-electric locomotive has an efficiency of 100%.

Seeing how unrealistic these engines are, for me any discussion of a more realistically modeled fuel consumption is pointless. There simply are no parameters to base somewhat realistic fuel consumption on.

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Fuel consumption of trains at max speed

Post by Adil »

zebediah49 wrote: First off, a bit of empirical testing. Take a single unloaded train; changes its 'max_power' stat, hop in it and run it in a circle until it hits max speed.
Nice math, however I believe that trains decelerate a little when they turn, so this might be a little off.
edit: nevermind, in 0.14 trains traverse turns at the same speed and acceleration as straight sections.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Fuel consumption of trains at max speed

Post by Nexela »

Optera wrote:Impressive math, it proves how off factorios numbers are.
Factorio diesel locomotives have an unrealistic low weight of 2t. Their power of 600kW is somewhat in line with real world switcher typically reaching around 50-80km/h.

The lightest diesel switching engine I know is the Köf III
power 177kW
weight 22t
speed 45km/h
But if they make it any heavier how will it fit in our pocket?

User avatar
Deadly-Bagel
Smart Inserter
Smart Inserter
Posts: 1498
Joined: Wed Jul 13, 2016 10:12 am
Contact:

Re: Fuel consumption of trains at max speed

Post by Deadly-Bagel »

Here's a problem for you to scratch your heads at, what about the weight of the raw materials going into it?

Raw materials are 280 iron plate and 15 copper. With a combined weight of 2T, each plate has a weight of just under 6.8kg. Not unreasonable. I am also reasonably happy to assume that given the obvious level of scientific advancement of the engineer, he knows of some way to make metals ludicrously strong. Main problem with realism there of course is he can carry thousands of them but that's a different discussion.

However, say you want to make a train 15T - each iron plate now weighs over 50kg. So if you want to make weight somewhat realistic you've got to follow it down the chain and it'll end up totally screwing with game balance.

As for energy consumption, I'm not averse to trains using more energy. As it is coal is only really used for plastic wood is in abundance - the more trains you add the more you expand and the more wood you end up with, there will eventually be a point you run out but it's well past the average factory size. Also given the abundance of wood and coal, I've never had any reason whatsoever to make solid fuel other than to build the rocket.
Money might be the root of all evil, but ignorance is the heart.

saturn7
Long Handed Inserter
Long Handed Inserter
Posts: 89
Joined: Wed Apr 27, 2016 6:14 pm
Contact:

Re: Fuel consumption of trains at max speed

Post by saturn7 »

Don't forget that Factorio has quantum compression (that's why you can put wagons into wagons, and make a train carry 1000 refineries), and that's also the reason the player can carry so much. Given that tech, it makes sense that a Factorio locomotive is lighter and more efficient than any real world counterpart, and that any content the wagons have loaded weighs nothing.

Though that's a bit offtopic here. I'd definitely like the fuel consumption at max speed adapted to the power needed to keep the train at that speed.

skillabstinenz
Inserter
Inserter
Posts: 43
Joined: Thu Aug 18, 2016 12:13 am
Contact:

Re: Fuel consumption of trains at max speed

Post by skillabstinenz »

REALISM!!!!!111
If you want realism take some iron plates, go to some third world country and have fun building your factory.

Is always running at 600kw/s realistic? No! But it‘s easier to calculate! So -1 realism.
Do you want trains to slow down in curves?! No! So -1 realism.
Do you want to build two rail networks, one for empty and one for full trains?! No! So -1 realism.
Do you want to run slower the fuller you inventory is (high there big inventory mods)?! No! So -1 realism.
Do you want to unable to store trains, oil refineries etc. in your inventory/chests?! No! So -1 realism.
Do I need to go on?!

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2633
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Fuel consumption of trains at max speed

Post by steinio »

saturn7 wrote:Don't forget that Factorio has quantum compression (that's why you can put wagons into wagons, and make a train carry 1000 refineries), and that's also the reason the player can carry so much. Given that tech, it makes sense that a Factorio locomotive is lighter and more efficient than any real world counterpart, and that any content the wagons have loaded weighs nothing.

Though that's a bit offtopic here. I'd definitely like the fuel consumption at max speed adapted to the power needed to keep the train at that speed.
Time lord technology.
Image

Transport Belt Repair Man

View unread Posts

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

Re: Fuel consumption of trains at max speed

Post by Optera »

skillabstinenz wrote:REALISM!!!!!111
If you want realism take some iron plates, go to some third world country and have fun building your factory.

Is always running at 600kw/s realistic? No! But it‘s easier to calculate! So -1 realism.
I'd love to have realistic energy consumption.
Do you want trains to slow down in curves?! No! So -1 realism.
Sure I do
Do you want to build two rail networks, one for empty and one for full trains?! No! So -1 realism.
If we get bridges and tunnels it'd be fun to do that.
Do you want to run slower the fuller you inventory is (high there big inventory mods)?! No! So -1 realism.
Do you want to unable to store trains, oil refineries etc. in your inventory/chests?! No! So -1 realism.
The base mechanics would have to change a lot. Players or bots carrying several whole refineries around needs a lot of -realism.
Do I need to go on?!
Sure, let's continue this. :D

Hannu
Filter Inserter
Filter Inserter
Posts: 850
Joined: Thu Apr 28, 2016 6:27 am
Contact:

Re: Fuel consumption of trains at max speed

Post by Hannu »

skillabstinenz wrote:Is always running at 600kw/s realistic? No! But it‘s easier to calculate! So -1 realism.
It is just stupid but in any case energy consumption of trains is completely negligible so it is not the worst issue in Factorio. Much more realistic model would be very easy to program and would not consume any more CPU than current model.
Do you want trains to slow down in curves?! No! So -1 realism.
Certainly. It looks very stupid when the train run 250 km/s through the curve which would be impossible to drive through even at walk speed. I would like to have wider curve radii. Not realistic but tight curve intended for trainyards could have radius of 30 units and speed limit of 50 km/h. Wider curves (60 m, 100 m, 200 m) with higher speeds would be used for lines. It would be much more interesting to travel through the railworld by a train, if the basics of train traffic would be somewhat realistic.

There could also be tiers of tracks. First tier would have wooden ties and have low axle load and speed limitations but give tighter curves. Higher tier high capacity track would have large radius and speed and would allow more slots in cargo wagons.

It would also give an interesting risk management element in the game if player could exceed speed and load limits at the cost of accident probability. Accident would destroy the train and its contents.
Do you want to build two rail networks, one for empty and one for full trains?! No! So -1 realism.
I do not understand. There are not separate rails for full and empty trains in real rail networks.
Do you want to run slower the fuller you inventory is (high there big inventory mods)?! No! So -1 realism.
Certainly yes. That would be part of immersion even probably have not large straightforward effect to the game. But it would follow from sane train model in any case.
Do you want to unable to store trains, oil refineries etc. in your inventory/chests?!
No, It is the unrealistic element which have to be in the game for practical reasons. But it would not exclude consistent behavior of trains.

In my opinion Factorio could give larger role for a train logistics. It would fit perfectly in theme of the logistics game. There could be automated schedules, locomotive circulations, switching works etc. Instead of having fixed length trains you could change trains when needed. I understand that it is not realistic to expect it from the basic game, but it would be for example paid DLC extension sometimes after official publication.

Post Reply

Return to “General discussion”