Physics patches
Moderator: OpenTTD Developers
Physics patches
When I looked into the code, I discovered that the function that handles "realistic" acceleration for trains is a little bit dirty piece of code (i.e. it is unclear what is happening). And it's not really realistic after all (i.e. as far as I can discover, the equations are wrong). In the near future, I will write a new piece of code for realistic (physically realistic this time) acceleration, and maybe some other things as well.
I have already a little patch which allows you to view vehicle statistics in SI units. If you turn on the patch (in the patch configuration window, tab "interface"), velocities will be displayed in m/s and powers in kW. Weights will still be displayed in tonnes (t), not kilograms (kg).
[edit]
The physics patch can be downloaded from here:
Physics patch - version 22 jan 2006 - r3411
Physics patch - version 25 jan 2006 - r3426
Physics patch - version 31 jan 2006 - r3493
Physics patches - versions 07 feb 2006 - r3575 (Versions: Train physics; Road vehicle physics; Merged version.)
Physics patches - versions 12 feb 2006 - r3596 (Versions: Road vehicle physics; Merged version.)
Physics patches - version 15 feb 2006 - r3606
Physics patch - version 26 feb 2006 - r3676
Physics patch - version 08 mar 2006 - r3798
Physics patch - version 22 mar 2006 - r4031 (+ Dutch translation)
Physics patch - version 01 apr 2006 - r4229 (+ Dutch translation)
Physics patch - version 14 apr 2006 - r4415
Physics patch - version 17 apr 2006 - r4458
Physics patch - version 23 apr 2006 - r4552
Physics patch - version 10 may 2006 - r4810 (+ Version with vehicle speed cheat)
Physics patch - version 21 may 2006 - r4942 (+ Version with vehicle speed cheat)
Physics patch - version 08 jun 2006 - r5177
Physics patch - versions 19 jun 2006 - r5317 (trunk) and r5317-MiniIN
Physics patch - versions 30 jul 2006 - r5656 (trunk) and r5656-MiniIN
(MiniIN version 5656 merged to branch MiniIN at revision r5657)
Physics patch - versions 30 jul 2006 - r5698 (trunk) and r5698-MiniIN
(MiniIN version 5698 merged to branch MiniIN at revision r5718)
Physics patch - version 07 aug 2006 - r5806-MiniIN (no trunk version this time)
Physics patch - version 08 aug 2006 - r5810-MiniIN
Physics patch - version 05-sep-2006 - r6394-MiniIN
Physics patch - version 09-sep-2006 - r6434 (trunk) and r6434-MiniIN
Physics patch - version 20-oct-2006 - r6859 (trunk)
Physics patch - version 12-nov-2006 - r7134 (trunk) and r7134-MiniIN
(newer versions not listed here; just search for it at the end of this topic)
[/edit]
[edit]
Background information on my patches can be found on my website.
[/edit]
I have already a little patch which allows you to view vehicle statistics in SI units. If you turn on the patch (in the patch configuration window, tab "interface"), velocities will be displayed in m/s and powers in kW. Weights will still be displayed in tonnes (t), not kilograms (kg).
[edit]
The physics patch can be downloaded from here:
Physics patch - version 22 jan 2006 - r3411
Physics patch - version 25 jan 2006 - r3426
Physics patch - version 31 jan 2006 - r3493
Physics patches - versions 07 feb 2006 - r3575 (Versions: Train physics; Road vehicle physics; Merged version.)
Physics patches - versions 12 feb 2006 - r3596 (Versions: Road vehicle physics; Merged version.)
Physics patches - version 15 feb 2006 - r3606
Physics patch - version 26 feb 2006 - r3676
Physics patch - version 08 mar 2006 - r3798
Physics patch - version 22 mar 2006 - r4031 (+ Dutch translation)
Physics patch - version 01 apr 2006 - r4229 (+ Dutch translation)
Physics patch - version 14 apr 2006 - r4415
Physics patch - version 17 apr 2006 - r4458
Physics patch - version 23 apr 2006 - r4552
Physics patch - version 10 may 2006 - r4810 (+ Version with vehicle speed cheat)
Physics patch - version 21 may 2006 - r4942 (+ Version with vehicle speed cheat)
Physics patch - version 08 jun 2006 - r5177
Physics patch - versions 19 jun 2006 - r5317 (trunk) and r5317-MiniIN
Physics patch - versions 30 jul 2006 - r5656 (trunk) and r5656-MiniIN
(MiniIN version 5656 merged to branch MiniIN at revision r5657)
Physics patch - versions 30 jul 2006 - r5698 (trunk) and r5698-MiniIN
(MiniIN version 5698 merged to branch MiniIN at revision r5718)
Physics patch - version 07 aug 2006 - r5806-MiniIN (no trunk version this time)
Physics patch - version 08 aug 2006 - r5810-MiniIN
Physics patch - version 05-sep-2006 - r6394-MiniIN
Physics patch - version 09-sep-2006 - r6434 (trunk) and r6434-MiniIN
Physics patch - version 20-oct-2006 - r6859 (trunk)
Physics patch - version 12-nov-2006 - r7134 (trunk) and r7134-MiniIN
(newer versions not listed here; just search for it at the end of this topic)
[/edit]
[edit]
Background information on my patches can be found on my website.
[/edit]
Last edited by hertogjan on 07 May 2007 15:40, edited 24 times in total.
I think it's a bit poor that a train can ride over a small hill faster than it can detour around it. Those little S-bends are a disaster to speed when horizontal, but not when vertical!csuke wrote:also i dont think it should replace the current improved acceleration, as that works well, whether its actually realistic or not
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
I'm not quite sure how OTTD does the "realistic" train acceleration. It's probably loosely based on my patch code, although OTTD doesn't have tractive effort yet, IIRC.
I've written down the formulas I used in the page here, which is probably as close as you can get to realism within (O)TTD's limited model of train engines. There are also various fudge factors involved due to TTD's lack of consistent time and length scales.
In any case, it models the engine force as a constant-force curve below a certain speed (with the force being equal to the maximum tractive effort possible), and a constant-power curve (or equivalently, constant-engine-torque) above that speed. The critical speed here is given by v = P/TE_max.
I've written down the formulas I used in the page here, which is probably as close as you can get to realism within (O)TTD's limited model of train engines. There are also various fudge factors involved due to TTD's lack of consistent time and length scales.
In any case, it models the engine force as a constant-force curve below a certain speed (with the force being equal to the maximum tractive effort possible), and a constant-power curve (or equivalently, constant-engine-torque) above that speed. The critical speed here is given by v = P/TE_max.
He knows that, and this is why he wrote "still" and "not kilograms (kg)Moriarty wrote:Tonne isn't an actual SI unit, but kg is.I have already a little patch which allows you to view vehicle statistics in SI units. If you turn on the patch .... Weights will still be displayed in tonnes (t), not kilograms (kg).
Right now, I have made a new piece of code which handles acceleration quite well. Entering typical values of the friction coefficients (more details later) let's the trains move as I wanted (after fiddling around with some "magic" constants): Trains with low loads accelerate quite fast. Trains which are overloaded do not even reach their maximum speeds.
Nice to see what air resistance does to high speed movement: The Chimaera MagLev engine does not even come close to its maximum speed (reaches 130 m/s out of 178 m/s), while it is powerful enough to even accelerate uphill. (On my test track, that is).
I have made a little change to the train window, so that it shows not only speed, but also several forces, which helps to tweak the values of the coefficients, and the acceleration itself.
I am not finished yet: I will also change curve handling (to be mass-dependent), and acceleration at station platforms.
More tomorrow.
P.S. Indeed, metric tonne is a derived SI unit, but it is easy to use with SI units because it's a power of 10 related to the standard SI unit kg. You can imagine working in meters, tonnes, seconds. Other derived units will then be different (for instance, forces will be in kN and power in kW). Most people work with mks (meter-kilogram-second) and some with cgs (centimeter-gram-second). But they're all correct according to SI.
If you take care of all units, your calculations will not go wrong.
Nice to see what air resistance does to high speed movement: The Chimaera MagLev engine does not even come close to its maximum speed (reaches 130 m/s out of 178 m/s), while it is powerful enough to even accelerate uphill. (On my test track, that is).
I have made a little change to the train window, so that it shows not only speed, but also several forces, which helps to tweak the values of the coefficients, and the acceleration itself.
I am not finished yet: I will also change curve handling (to be mass-dependent), and acceleration at station platforms.
More tomorrow.
P.S. Indeed, metric tonne is a derived SI unit, but it is easy to use with SI units because it's a power of 10 related to the standard SI unit kg. You can imagine working in meters, tonnes, seconds. Other derived units will then be different (for instance, forces will be in kN and power in kW). Most people work with mks (meter-kilogram-second) and some with cgs (centimeter-gram-second). But they're all correct according to SI.
If you take care of all units, your calculations will not go wrong.
I'd be interested in seeing the formulas/code you came up with 
As far as monorail/maglev go, however, you should probably use a different acceleration model. If the maglev is in any way similar to the German Transrapid, it would use a linear motor with constant force all the way to the top speed. While this makes little sense in respect to TTD's concept of power (because in this model, power would be proportional to speed), it's more realistic that way. This is also how TTD's own acceleration model works, by the way. Of course, there is also no limit on maximum TE, although practically it'll be equal to the force delivered by the maglev track.
Even for the Japanese maglev, on which the TTD ones are based visually, propulsion is with a linear motor, although at lower speeds you also have additional friction until the speed is high enough to lift the vehicle off the track by electrodynamic repulsion.
Either way, monorail/maglev need a different acceleration model, because they don't use friction-based propulsion.

As far as monorail/maglev go, however, you should probably use a different acceleration model. If the maglev is in any way similar to the German Transrapid, it would use a linear motor with constant force all the way to the top speed. While this makes little sense in respect to TTD's concept of power (because in this model, power would be proportional to speed), it's more realistic that way. This is also how TTD's own acceleration model works, by the way. Of course, there is also no limit on maximum TE, although practically it'll be equal to the force delivered by the maglev track.
Even for the Japanese maglev, on which the TTD ones are based visually, propulsion is with a linear motor, although at lower speeds you also have additional friction until the speed is high enough to lift the vehicle off the track by electrodynamic repulsion.
Either way, monorail/maglev need a different acceleration model, because they don't use friction-based propulsion.
Monorails are actually just trains but only with one rail, maglevs use magnetic force to lift them a few centimeters above the track to reduce friction (maglev stands for magnetic levitation), they also use the same magnetic force to pull them forward. But if I remember it correctly maglevs accelerate exponential until the friction is to high (maglevs can accelerate up to 8000km/h in a vacuum).Patchman wrote:Either way, monorail/maglev need a different acceleration model, because they don't use friction-based propulsion.
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)

OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone

OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone







I'll be posting the formulas tomorrow (and maybe also a debugging version of the code, who knows...).
What I've done is getting all magic coefficients out of the function, so it will be clear what is going on.
Preceding to the function, I define a bunch of constants and coefficients. Those have different values for different track types (rail, monorail, maglev). Five of these sets of constants control the friction of the trains (maybe in the future, this could be a property of a locomotive rather than of a rail type), being:
-Static (constant) friction, which is constant for all masses and speeds.
-Rolling friction, which proportional to mass, but not dependent on speed.
-Internal friction, which is proportional to speed.
-Air drag, which is quadratic in speed. There are two different constants: for the first car and for the other cars.
Two more control the maximum speed in curves, which will be approximately proportional to the square root of the mass of the vehicles in the curve. So it may happen that an empty train, where the locomotives are heavier than the carriages, may already speed up while the locomotives have passed the curve but the carriages are still in it (get it?
).
Finally, for each track type there is a velocity threshold below which an engine will not be fully powered. Also, this number functions as a minimum speed on hills, to prevent underpowered trains from being totally stuck on a hill.
Also, the steepness of the hills can be set (currently, I use a gradient of 50 parts per 1000).
I have done several test with some settings, and currently the results are good. With these setting, you will have to be more careful with the choice of your engines. Especially, for classic railroad, it might be needed to hook up more engines to pull heavier trains. For MagLev, you may need more engines for higher speeds and to accelerate faster.
I am still busy on the curve handling, and on braking (i.e. decelerating) more smoothly.
What I've done is getting all magic coefficients out of the function, so it will be clear what is going on.
Preceding to the function, I define a bunch of constants and coefficients. Those have different values for different track types (rail, monorail, maglev). Five of these sets of constants control the friction of the trains (maybe in the future, this could be a property of a locomotive rather than of a rail type), being:
-Static (constant) friction, which is constant for all masses and speeds.
-Rolling friction, which proportional to mass, but not dependent on speed.
-Internal friction, which is proportional to speed.
-Air drag, which is quadratic in speed. There are two different constants: for the first car and for the other cars.
Two more control the maximum speed in curves, which will be approximately proportional to the square root of the mass of the vehicles in the curve. So it may happen that an empty train, where the locomotives are heavier than the carriages, may already speed up while the locomotives have passed the curve but the carriages are still in it (get it?

Finally, for each track type there is a velocity threshold below which an engine will not be fully powered. Also, this number functions as a minimum speed on hills, to prevent underpowered trains from being totally stuck on a hill.
Also, the steepness of the hills can be set (currently, I use a gradient of 50 parts per 1000).
I have done several test with some settings, and currently the results are good. With these setting, you will have to be more careful with the choice of your engines. Especially, for classic railroad, it might be needed to hook up more engines to pull heavier trains. For MagLev, you may need more engines for higher speeds and to accelerate faster.
I am still busy on the curve handling, and on braking (i.e. decelerating) more smoothly.
do you have some sources ?KING wrote:some place on a test track they made a maglev (with a straight track) that was supersonic. I can`t remember why. I think it was to beat the fastest ever train record or something
I tought that maglev record was 581 km/h in 2003 (and 515 km/h for TGV in 1990)
fast, but still far from supersonic...
A maglev could get to 1500 km/h with ease but they decided to limit it to 500 km/h for commercial use (saw it on NGC today).Gedemon wrote:do you have some sources ?KING wrote:some place on a test track they made a maglev (with a straight track) that was supersonic. I can`t remember why. I think it was to beat the fastest ever train record or something
I tought that maglev record was 581 km/h in 2003 (and 515 km/h for TGV in 1990)
fast, but still far from supersonic...
There was also a documentary about a trans atlantic tunnel where they wanted maglevs to run trough in a vacuum so they could theoretically be as fast as light because they don't have friction.
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)

OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone

OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone







viral marketing is bad : http://www.transatlantys.com/
so they can do 1500km/h "with ease" but never tried ?
why ?
so they can do 1500km/h "with ease" but never tried ?

why ?
Presumably because there's no track long enough yet. 1500kmh is 25km per minute. Considering maglev tracks aren't more than a few tens of kilometers long I doubt there's enough room to accelerate up to that speed, measure it and then decelerate before running out of track.
Brignell’s law of consensus: At times of high scientific controversy, the consensus is always wrong.
I guess they have tried, but because of commercialism it is limited to about 500km/h just like the trains in the 1800s were limited to 160mph because people thought you would die then.Gedemon wrote:viral marketing is bad : http://www.transatlantys.com/
so they can do 1500km/h "with ease" but never tried ?![]()
why ?
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)

OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone

OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone







Who is online
Users browsing this forum: No registered users and 4 guests