Train Physics Realism

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 432
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Train Physics Realism

Post by protocol_1903 »

TL;DR
Train acceleration, speed, and top speed are not functions of properties, but more just set numbers.
What?
AFAIK, train speeds are just a basic calculation of the weight of the full train, the air resistance based on the first entity, and the fuel value. My suggestion is that actual physics calculations are used, allowing for more realistic top speeds and acceleration. Train speed is currently a function of air resistance (a set number), weight (a set number), and acceleration (a set number). I recommend that it is a function of air resistance (a function of speed), weight, acceleration, and rolling friction. Air resistance is currently a number, instead of a function of speed. It also doesn't take into account the mass of the train (inertia). Therefore, the top speed of a train is not based on the balancing of acceleration and the counteracting forces, air resistance and friction. This could also interact with new gravity properties of SA, where on higher gravity planets trains are slower. Also, higher air pressures would mean more air resistance for trains, also making them slower.
Why?
I believe that the main plus for this change would be I think this would integrate very well with the improvements and additions introduced by SA. This would also give the opporotunity (with some modded integration) for train wagons to have variable weights based on the held items/fluids. Further implementation would allow for friction reduction research, as well as better aerodynamics for locomotives or special aerodynamic railcars for the front of locomotives. There could also be modules/equipment inserted into trains for other improvements.
Cons?
There is always a computational cost when adding features. The per-update speed calculation would be slightly inflated, due to the inclusion of rolling friction and the added calculation for air resistance. Air resistance would need to be a per-update calculation, but rolling friction could be either depending on implementation. Acceleration, trian weight, friction coefficient, and some air resistance values could be calculated when the train leaves a station, therefore only updating once per route. I've detailed below some of the required calculations.
Calculations
  • Acceleration: Constant, based on fuel used. Certain locomotives could have specific fuel efficiency.
    NOTE: Could be a function of speed where higher speeds are more fuel efficient. Would need to be updated regularly.
  • Weight: Constant (based on train weight) or variable (based on train weight and contents)
    NOTE: Would need to be recalculated per-update if locomotive fuel is considered to add to weight
  • Friction: A function of mass. The following formula details the natural calculation of this force.
    image_2023-10-18_110413295.png
    image_2023-10-18_110413295.png (2.08 KiB) Viewed 1320 times
    C sub rr is the rolling resistance coefficient. This would be a small value between 0 and 1. For reference, rolling resistance for railroad wheels on steel tracks is between 0.0003 and 0.0020. This would need to be guessed, estimated, or playtested.
    N is the normal force, which can be calculated by the following equation.
    image_2023-10-18_110516764.png
    image_2023-10-18_110516764.png (1.27 KiB) Viewed 1320 times
    This would calculate the normal force based on the mass, gravitational constant, and the angle of attack. In most cases, cosine(theta) would return 1 due to running on a flat surface, but otherwise could be implemented if elevated track transitions were taken into account.
  • Air resistance: A function of speed. The following formula details the natural calculation of this force.
    image_2023-10-18_105237261.png
    image_2023-10-18_105237261.png (3.97 KiB) Viewed 1320 times
    Rho is the density of the fluid/gas, which in this case would be the density of the atmosphere on the planet/body. This would need a special calculation/variable unless you want to include the chemical makeup and mass ratio of the surrounding atmosphere. For reference, the density of air at sea level and 15C is 1.225 kg m/s^2.
    v is the velocity relative to the gas, which in this case would just be the speed of the train.
    C sub D is the drag coefficient. This is a value that changes based on the 3 dimensional shape of the object. In this case, only the first entity would need to be referenced. The more streamlined the object, the smaller the value. A good bulk of guessing will happen here. For reference, a sphere has a drag coefficient of 0.47 while a cube has a coefficient of 1.05, and a steamlined body has a coefficient of 0.04.
    A is the surface area of the object perpendicular to the direction of travel. In this case, it would be the surface area of the front of the first entity.
  • Velocity/Speed: A function of all forces. The change in velocity, deltaV, would be the sum of all forces (air resistance, acceleration/braking, and friction) times the time, which for 60 UPS would be 1/60th of a second. That value would then be added to the current speed of the train.
Py and PyBlock developer, wielder of LUA in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
Illiander42
Filter Inserter
Filter Inserter
Posts: 546
Joined: Mon Feb 05, 2018 10:01 am
Contact:

Re: Train Physics Realism

Post by Illiander42 »

I think Factorio currently does Accelleration and air resistence.

Overloaded Trains adds wieght.

I think friction is a constant currently?
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2766
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Train Physics Realism

Post by FuryoftheStars »

I'm pretty sure power, air resistance, weight, and friction are all moddable values on a per entity (loco, wagons, etc, but not rails) basis. Burner efficiency can also be used to some nice effects in here, too.

I have an unreleased personal mod I had been working on at one point to make trains feel truly realistic. :)
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 432
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: Train Physics Realism

Post by protocol_1903 »

I have an unreleased personal mod I had been working on at one point to make trains feel truly realistic.
Would you be willing to share said mod? I would love to develop it, if not just take a look under the hood.
Py and PyBlock developer, wielder of LUA in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
Post Reply

Return to “Ideas and Suggestions”