Thank you all for your replies. I think that I have found a possible workable solution to this issue. The possible solution is in two parts, and further work is required in particular in relation to the second part.

**The first part - calibrating for speed**The most fundamental problem is that per km fuel consumption requires a speed to calculate, but that speed can vary enormously from an express passenger train to a slow mineral train. Generally, the higher speed given for calibration, the less units of fuel used per kilometre even if actual power output is the same. Thus, if things were calibrated without taking this into account, players may have perverse incentives to use vehicles designed for higher speeds because they would appear to be more fuel efficient even though, in reality, a lower speed vehicle would be more efficient and suitable for the task in question.

The solution requires understanding how I have calculated power and efficiency for steam locomotives in the pakset (the efficiency calculations are not yet used in the game, but will be when the appropriate features are added; however, the range feature already exists, and if I were to use range, efficiency would be necessary). What I have done is, for a sample of the locomotives that are in Pak128.Britian-Ex, obtained data as to their top speed with a given load, corrected for the effect of any gradient prevailing at the time that the top speed was obtained, and then worked out what level of power would be necessary for that locomotive to haul that load in-game on the flat using the game engine itself (by adjusting the power multiplier percentage), and then set the power to that amount.

I then calculate the efficiency for the locomotive by taking the firegrate area, the calorific value of the coal or coke that the railway that used it was likely to have used, a figure for the amount of fuel burnt per area of firegrate per hour, and combining those in a formula to get a figure for the overall thermal efficiency of the locomotive (i.e. the amount of chemical energy in the coal that translates to mechanical energy available for haulage). This tends to be around 4-7%. The spreadsheet in which I do so is

here. The yellow rows represent locomotives calibrated for power.

Since yesterday, I have added columns for per kilometre fuel consumption, fuel capacity and range, and have been going back through the list using real life coal consumption figures for the locomotives in question and adding these. I have also added a "calibration speed" column next to the top speed column as the average speed to use when calculating per kilometre fuel consumption. (One of the complexities is that fuel consumption calculations require average speeds whereas power calculations require top speeds with a given load; ideally, one would have figures from the same run - the average and the top speed - with the same load both used to calibrate the fuel consumption, but it is not always possible to get matching data). One of the consequences of this exercise is that I have found that I had under-estimated the fuel consumption for many later steam locomotives, and thus over-estimated their efficiency, which I will have to correct (and have been correcting for some of the locomotives for which I have data). The green cells represent instances where I have real world data for fuel consumption.

To get sensible values for locomotives for which I do not have data, I extrapolate from those for which I do by using the firegrate area and likely calorific value of coal consumed, together with an estimate of the efficiency and fuel consumption rates based on similar locomotives for which I do have data, together with things known about the locomotive in question (e.g. that it was heavy on coal or similar).

The trouble comes when attempting to compare fuel consumption per kilometre between locomotives whose power was measured at different average speeds. To illustrate the problem, suppose we have a locomotive which can reach a top speed of 100km/h with load X. If its fuel consumption is 10kg/h, then its per km fuel consumption would be 10 / 100 = 0.1.

However, suppose that the same locomotive, when hauling a load of Y, can reach only 50km/h. The power output and thus hourly fuel consumption is the same, but it is hauling a heavier load at a lower speed. Its fuel consumption per km would therefore be 10 / 50 = 0.2 - twice as much as when hauling the lighter load at a higher speed.

The solution is to use the mathematics of the above illustration in reverse to back-calculate the per km fuel consumption for any given load by reference to a fixed calibrated load:speed ratio. The game engine can calculate the maximum load at any given speed (I think - I am not sure how easy that it is to get this information from the physics engine, which I did not write - the maximum speed at any given load is given in the depot window). So, if we have per km fuel consumption data that has been calibrated with a load producing a maximum speed of N, and the vehicle is in fact operated with a load producing a maximum speed of P, the actual fuel consumption should be the base fuel consumption multiplied by N and divided by P. So:

nF = (oF * N) / P

where nF is the new fuel consumption and oF is the original (calibrated) fuel consumption. Note that the figure of N must be the

*maximum* speed obtainable with the load in question for any given fuel consumption, not the average speed, even though we also need the average speed to calculate the fuel consumption. Note also that, for these purposes, we need to compare the maximum theoretical speed achievable on the basis of the power and load only, ignoring any speed limit inherent in the vehicle.

Thus, what we need to do is to add a parameter in the .dat files that gives a maximum calibration speed for the fuel consumption, which will then be compared with the data above to give a sensible fuel consumption rate. Where no value be specified (or zero explicitly specified), this will need to result in the disabling of this feature and the use of the base figure (oF) at all levels of loading.

**The second part - adjusting for non-maximum power output**The above formula will give sensible figures if we assume that the vehicle in question will be making full use of its power output at all times while in motion. This will be the case when it is accelerating and when it is travelling at the maximum speed allowed by the power and load combination, but will not be the case when decelerating nor when its speed is limited by something other than physics (such as a vehicle or way speed limit).

~~The case of deceleration is a difficult one, as, if we use start to stop timings to calculate our average speed for the purpose of fuel consumption data, that implicitly includes deceleration, and we must not therefore take deceleration out of account. Ideally, therefore, we would not use start to stop average speeds, but use the highest speed attained during the run as our calibration speed, but these data are not always available. Using the highest speed attained during the run makes sense so long as this is indeed the maximum speed limited by physics. Quite what to do when only averages are available is difficult to consider at this stage.~~**Edit**: On reflection, deceleration is not as much of an issue as it first appears: because vehicles travel more slowly when accelerating than they do when at their maximum speed, the per kilometre fuel consumption, calibrated by the maximum speed, is excessively generous to the player. However, if the same fuel consumption be maintained during deceleration, this should be evened out effectively. Thus, there is no need for any adjustment in relation to deceleration: during deceleration, the fuel consumption should be the same as it was immediately before deceleration, whatever that might be, based on the formula to be described below.

In any event, if we assume that we have available data for the maximum physics limited speed at a given load from which we have calculated a power output, and we use that speed as our calibration speed, then we can detect whether the vehicle is either at that maximum speed or accelerating and, in those cases, consume the full amount of fuel per km calculated by the formula outlined in stage 1. However, where the vehicle is maintaining a speed less than the maximum speed that it is physically capable of reaching with its current load, one can then apply a proportionate reduction in fuel consumption.

The simplest formula would be simply to take the current speed as a proportion of the maximum physical speed and apply that proportion to the fuel consumption so that, if a vehicle is not accelerating nor decelerating and travelling at 50% of its maximum physical speed, its fuel consumption would be 50% of what the stage 1 formula gives us.

However, we know from

this source that that is not how efficiency works, for steam locomotives at least; below a certain percentage of load, efficiency reduces considerably, so we cannot simply apply this as a linear proportion.

Interpreting the graphs in that paper (see the lower graph on page 15 in particular) is not easy. We see a U shaped curve for coal consumption as against horsepower output - at the maximum possible power output, efficiency is low because the engine is being "forced", emitting large quantities of unburnt fuel out of the chimney. At very low power outputs, efficiency is low because there is a lower limit to how much coal per unit of time can be burnt on a firegrate of any given size so as to keep the fire going enough to produce any steam at all.

If we use the system described in part I, we simplify reality somewhat by ignoring the possibility of "forcing" a steam locomotive, except for steam locomotives that were so underpowered that they were effectively always forced, in which case, we assume constant forcing. In any event, we assume for these purposes maximum efficiency at maximum power. What we need to extract from that graph is what level of power, in proportion to the approximately maximum power output within the maximum efficiency range, is the minimum level of power before efficiency starts to decline drastically. We can see on the graph that the maximum efficiency range is between approximately 4 and 8 drawbar horsepower per hour (ignore the non-metric units: it does not matter what the units are for this purpose, as we only need a proportion). Higher than 8 and lower than 4 efficiency declines drastically. This suggests that - very approximately - efficiency starts to decline below 50% of maximum (efficient) power output.

Quite how to model this is another matter. The simplest solution would be to impose a minimum limit of 50% on per km fuel consumption (that is, 50% of the figure produced as a result of stage 1). This might be somewhat harsh on players who run things at lower speeds.

Another possibility would be to have a hard limit, but allow this to be set per vehicle in the .dat files - I imagine that electric traction, for example, will scale much better in efficiency at lower power outputs than steam or internal combustion engine traction, whose fires/engines have to be burning/turning over all the time.

Another possibility would be some sort of formula to model a falloff in efficiency, either standardised for all vehicles, differing per type (steam, electric, etc.) or set by a few data points in the .dat files. However, what that formula/those formulae should be and how to calibrate it I currently do not know.

I should note that we currently have something very similar (albeit much more crude) for circling aircraft: their per km cost is halved during the time that they are circling to take account of the fact that they will be using less fuel. This mechanism would be replaced by this if implemented.

At this stage, I am provisionally inclined to go for the cut-off specified in the .dat file with a default of 50% unless anyone has any good ideas for formulae.

**Some general issues**One complexity in all this is aircraft. Aircraft data generally show fuel burnt per hour and their maximum cruise speed, but their actual maximum speeds are almost never given and may not be obtainable without damaging the airframe and therefore destroying the aircraft.

Thus, it may be necessary to apply the stage 2 formula even if the stage 1 formula is disabled, as it might have to be for aircraft. Alternatively, one might possibly use a system whereby the fuel consumption calibrated by reference to a proportion of the maximum load rather than the maximum speed, but quite how this would work at this stage I am not sure.

Likewise, I am not sure how one might find suitable data for use for road or water vehicles for this, and this will require consideration.

There is also the issue of range. Currently, range is calculated statically: vehicles simply have a single range specified in their .dat files and that applies at all times. However, where range is based on fuel consumption (as it is for almost all vehicles aside from horse powered vehicles), this presents a problem, as range becomes potentially variable depending on load. In reality, this is of importance for aircraft in particular. However, I am not sure at this stage how best to deal with this: a dynamic range system is potentially difficult to implement and difficult to communicate to players. Any thoughts on this subject would be appreciated.