A Physics Mistake, and a Lesson in Checking the Code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pschlik
    Senior Member



    • Jun 2011
    • 289
    • Missouri
    • MSOR

    #1

    A Physics Mistake, and a Lesson in Checking the Code

    I have a bit of story time for everyone, and a warning not to make a mistake that even payware devs weren't immune from:
    Today I spent a bit more time than I should have trying to debug why the main reservior in my locomotives felt so small and the compressor seemed so weak despite me setting the correct volume and correct main res charging rate. So, I went to the Open Rails github repository to search the source code for answers. All the code related to adding and subtracting air from the main res made perfect sense, nothing seemed to indicate that air would be lost in some way, so it had to be something else draining air out of my main res. This led me down the path of investigating how Open Rails decides the volume of the main reservior.

    Then it hit me. Open Rails looks for the token "AirBrakesMainResVolume" to determine the main res volume. That's it. There's no alternative, that token is the only thing that says how big the main res is. And I wasn't using that.

    I had been programming main res volume as "ORTSAirBrakeMainResVolume" for years, and it's straight up wrong. Doing that just gets ignored and results in the main res being set to the default, pathetically tiny, 0.3 cubic meter size. And if you work like me and assume that is accurate, then you start to make lots of mistakes elsewhere when trying to make things more accurate, inadvertently taking steps that cover up the fact that you gave yourself a stupidly small main res. (In this case, the brake pipe recharge rate was set much lower than realistic in order to not overwhelm the tiny main res.)

    But why? How had I been working for years with something that doesn't do what I thought? Well...mostly because other people use ORTSAirBrakeMainResVolume and I assumed that was correct. I started my physics set on the base of Gerry Storey's common.inc set, and Gerry used the wrong code. TrainSimulations has been using the wrong code ever since they started using Open Rails physics (even their newest trains still make this mistake, resulting in the default main res size). Of course, anyone basing reskins off of either of these physics sets will also get it wrong.

    Why would they get it wrong? That I do not know. The manual makes mention of the vacuum brakes token "ORTSVacuumBrakesMainResVolume", which might lead someone to assume similar syntax applies for air brakes, but the manual has not a single reference to ORTSAirBrakeMainResVolume (meanwhile, it does reference the correct AirBrakesMainResVolume once in an example .eng file). Searching the internet for "ORTSAirBrakeMainResVolume" gives 3 results from this forum and Elvas tower, which reveals it seems that someone might have mentioned it offhand as an idea for a token to add, but it wasn't actually added. Perhaps other users saw that post and mistakenly assumed the post was talking of a real token rather than a hypothetical one? Doesn't really matter, somehow something small and unofficial was enough 'evidence' for the community to converge on a completely fictional token for years without checking if it actually worked.


    In short-it pays to do your own research for Open Rails and real life. If you aren't sure how something works or why it's working the way it does, then go down that rabbit hole. Search the manual, search the source code, don't just trust what other people wrote down without evidence. Getting that deeper understanding requires going deeper, and in this case, you can come out on top with a better product than what you made before.

    Also, to those who made this mistake, I can't exactly expect anyone to fix something from 5 years ago (that's where modding comes in) but perhaps the dev team can be convinced to add ORTSAirBrakeMainResVolume to the parser to retroactively fix all this content. In any case, hopefully this story helps everyone make their future projects better than their past projects.
    Last edited by pschlik; 05-21-2023, 12:56.

    Contributing to ORTS since 2023
    Find me on GitHub @SteelFill

    Like what I do? Join my Patreon to help me do more!
  • R. Steele
    3500 Post Veteran

    • Feb 2013
    • 3928
    • known universe
    • ORTS

    #2
    Nice Catch ( so far - but I would like a member of the OR Dev Team to confirm ) In point of fact, I also cannot find it in the manual and in the GitHub list ( and other sources I've searched ) as being an official token. Also, Joe Realmuto does not mention this specific token in his "Guideline For Setting Open Rails Braking Parameters" pdf. ...so WHOOPS on my part! I did find some posts and discussions at ET that appeared to be stating that the parameter was being used...going back to 2014 or so.

    Using this token does not necessarily mean you will get incorrect braking behavior in the sim.

    It will depend on how the user has setup their files.

    If the user is employing an OpenRails subfolder with include files within the MSTS parent equipment folder...which has the MSTS token "AirBrakesMainResVolume" then OR should use that, even though the "ORTSAirBrakeMainResVolume" is in the include files. In that specific case behavior will depend upon the values used in the MSTS file.

    Perhaps the development team will add the "ORTSAirBrakeMainResVolume" to the code, in any case, glad it was caught and now I've got another chore to do --- removing it from all the files ( thank goodness for Search & Replace ) and then making sure the proper values are being used in the MSTS parameter.

    Note to pschlik: Did you post this at Elvas to make sure the developers see it, and others.
    Last edited by R. Steele; 05-21-2023, 14:55.
    Cheers, Gerry
    "A mind is like a parachute. It doesn't work if it is not open." Frank Zappa
    It's my railroad and I'll do what I want! Historically accurate attitude of US Railroad Barons.
    Forever, ridin' drag in railroad knowledge.
    Audi, Vide, Tace, Si Vis Vivere In Pace​

    https://www.trainsim.com/forums/filedata/fetch?filedataid=79656&type=medium​ https://www.trainsim.com/forums/filedata/fetch?filedataid=79654&type=small

    Comment

    • pschlik
      Senior Member



      • Jun 2011
      • 289
      • Missouri
      • MSOR

      #3
      Originally posted by R. Steele
      If the user is employing an OpenRails subfolder with include files within the MSTS parent equipment folder...which has the MSTS token "AirBrakesMainResVolume" then OR should use that, even though the "ORTSAirBrakeMainResVolume" is in the include files. In that specific case behavior will depend upon the values used in the MSTS file.
      Fair point. My setup doesn't operate like this (I don't include the original MSTS files at all so I have more control), so I didn't have the luxury of MSTS parameters as a backup.


      Originally posted by R. Steele
      Note to pschlik: Did you post this at Elvas to make sure the developers see it, and others.
      I'll add something to the Wishes for improvement of braking systems thread.

      Contributing to ORTS since 2023
      Find me on GitHub @SteelFill

      Like what I do? Join my Patreon to help me do more!

      Comment

      • eric
        9500 Post Veteran and Administrator



        • Dec 2002
        • 9583
        • NS MP245.4 CNO&TP South District
        • English, SQL
        • General

        #4
        Shouldn't an invalid or undeclared token name have thrown a warning or error in the logfile?.....

        Sent from my SM-G981U using Tapatalk
        If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, or items available in our library, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

        Comment

        • R. Steele
          3500 Post Veteran

          • Feb 2013
          • 3928
          • known universe
          • ORTS

          #5
          Originally posted by eric
          Shouldn't an invalid or undeclared token name have thrown a warning or error in the logfile?.....

          Sent from my SM-G981U using Tapatalk
          Good point, I been wondering about that. Not once did I see a warning in my OR log about an invalid token.
          Cheers, Gerry
          "A mind is like a parachute. It doesn't work if it is not open." Frank Zappa
          It's my railroad and I'll do what I want! Historically accurate attitude of US Railroad Barons.
          Forever, ridin' drag in railroad knowledge.
          Audi, Vide, Tace, Si Vis Vivere In Pace​

          https://www.trainsim.com/forums/filedata/fetch?filedataid=79656&type=medium​ https://www.trainsim.com/forums/filedata/fetch?filedataid=79654&type=small

          Comment

          • pschlik
            Senior Member



            • Jun 2011
            • 289
            • Missouri
            • MSOR

            #6
            Originally posted by eric
            Shouldn't an invalid or undeclared token name have thrown a warning or error in the logfile?.....

            Sent from my SM-G981U using Tapatalk
            Generally, no. There are quite a few MSTS tokens that OpenRails doesn’t use, so invalid or otherwise unneeded lines of text are just skipped. Wouldn’t be very helpful to play legacy MSTS content and get log spam about a dozen tokens being invalid when it’s not actually a problem.

            Now what might be helpful is some more warnings about when something gets set to a default value. I know with verbose logging a few tokens will log a warning about using a default value because none was specified, but main res volume doesn’t seem to be one of these.

            Contributing to ORTS since 2023
            Find me on GitHub @SteelFill

            Like what I do? Join my Patreon to help me do more!

            Comment

            • R. Steele
              3500 Post Veteran

              • Feb 2013
              • 3928
              • known universe
              • ORTS

              #7
              Originally posted by pschlik
              Generally, no. There are quite a few MSTS tokens that OpenRails doesn’t use, so invalid or otherwise unneeded lines of text are just skipped. Wouldn’t be very helpful to play legacy MSTS content and get log spam about a dozen tokens being invalid when it’s not actually a problem.

              Now what might be helpful is some more warnings about when something gets set to a default value. I know with verbose logging a few tokens will log a warning about using a default value because none was specified, but main res volume doesn’t seem to be one of these.
              It's been my experience that incorrect Open Rails tokens are noted in the log as unrecognized, especially if there is a misspelling. I have had cases when the undeclared token is not noted in log. I've been meaning to check this out, just have not gotten around to it.

              What is worrying is the inconsistency in how OR logs unrecognized tokens.
              Last edited by R. Steele; 05-25-2023, 18:40.
              Cheers, Gerry
              "A mind is like a parachute. It doesn't work if it is not open." Frank Zappa
              It's my railroad and I'll do what I want! Historically accurate attitude of US Railroad Barons.
              Forever, ridin' drag in railroad knowledge.
              Audi, Vide, Tace, Si Vis Vivere In Pace​

              https://www.trainsim.com/forums/filedata/fetch?filedataid=79656&type=medium​ https://www.trainsim.com/forums/filedata/fetch?filedataid=79654&type=small

              Comment

              • eric
                9500 Post Veteran and Administrator



                • Dec 2002
                • 9583
                • NS MP245.4 CNO&TP South District
                • English, SQL
                • General

                #8
                Originally posted by pschlik
                Generally, no. There are quite a few MSTS tokens that OpenRails doesn’t use, so invalid or otherwise unneeded lines of text are just skipped. Wouldn’t be very helpful to play legacy MSTS content and get log spam about a dozen tokens being invalid when it’s not actually a problem.
                I get skipping un-needed valid MSTS tokens, but an unknown token should still alert. We know what the full universe of MSTS tokens is, and it's not changing anytime soon.
                If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, or items available in our library, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

                Comment

                Working...