The International Simutrans Forum

 

Author Topic: Braking rates and differential equations  (Read 321 times)

0 Members and 1 Guest are viewing this topic.

Offline lambo

  • *
  • Posts: 1
    • tìm người giữ em bé tại tphcm
  • Languages: EN
Braking rates and differential equations
« on: April 14, 2019, 09:55:58 AM »
I am hoping to implement a realistic approximation of braking distance calculation in the next version of Experimental (brake performance is highly relevant to the maximum speed of rail vehicles and the capacity of railways), but my limited mathematical ability does not stretch to writing C++ code to solve differential equations of the sort required to calculate braking distances (see here for an explanation of those equations). What I need is a formula for converting speed, weight, brake force and rolling/air resistance into a braking distance. I should be grateful for any suggestions or pointers as to how to go about this task; integrating this into the Simutrans code should then be fairly straightforward.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18593
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Braking rates and differential equations
« Reply #1 on: April 14, 2019, 11:04:59 AM »
Thank you for your interest in working on the code. I am also not proficient in advanced mathematics: the existing code relating to physics was written by Bernd Gabriel, who has not been active in development recently.

One particular (and somewhat challenging) thing to bear in mind when dealing with code relating to the physics is that it is not possible to use the standard floating point types because these are not consistent between different platforms (Linux, Windows, etc.), so will cause clients to lose synchronisation from the servers in network games if client and server are running different operating systems. To get around this, Bernd wrote a floating point class for the physics code (float32e8_t), which works effectively to prevent loss of synchronisation, but which is much slower than the normal floating point standard types.

Incidentally, do you have a particular reason to believe that the current modelling of braking is inaccurate? It was intended, at least, to be accurate when it was written for precisely the reasons that you give (viz. that braking performance is important to the speed of rail vehicles and thus the capacity of railways).

Offline ACarlotti

  • *
  • Posts: 444
Re: Braking rates and differential equations
« Reply #2 on: April 14, 2019, 01:56:08 PM »
Like James, I am unsure what issue you are hoping to solve with a 'realistic approximation of braking distance calculation'. The only issue I'm currently aware of is that braking distance calculations could be inaccurate if there is a change of gradient just before the stopping point - are you referring to this? If not, then what precisely are you referring to?

You mention that your "limited mathematical ability does not stretch to writing C++ code to solve differential equations of the sort required to calculate braking distances". I suspect that it might be more effective with someone who understands the maths better to write the code themselves, rather than them trying to explain the maths to another person who would then be more likely to write code that is inefficient or incorrect (and perhaps subtlely so). I could, however, be wrong about this.

Anyway, thanks for mentioning that you think there is an issue - if you explain more clearly what you think the issue is, then hopefully we can sort it out together (or perhaps istead find a good reason why it can't practicably be solved).



Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9460
  • Languages: De,EN,JP
Re: Braking rates and differential equations
« Reply #3 on: April 15, 2019, 06:58:49 AM »
Before solving differential equation for a game like Simutrans, one should rather use polynomal fit functions, which work well with integers. That may also speed up the current acceleration code more (or had that issue ever been solved).

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18593
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Braking rates and differential equations
« Reply #4 on: April 15, 2019, 09:32:27 AM »
Before solving differential equation for a game like Simutrans, one should rather use polynomal fit functions, which work well with integers. That may also speed up the current acceleration code more (or had that issue ever been solved).

The issue has not been solved - we still use the integer based floating point class, which is notably slower than built-in floating point types.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18593
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Braking rates and differential equations
« Reply #5 on: April 15, 2019, 03:27:05 PM »
Incidentally, Lambo - do not be discouraged from making contributions. Anyone willing to contribute to the coding is always very welcome. You have chosen a particularly challenging area to start with and one that it is not immediately apparent that there is anything wrong with as it stands; although, if you have data to the contrary, please do let us know.

There are plenty of other things on which your work would be much appreciated if you were so minded.