User talk:OhioBob

From Kerbal Space Program Wiki
Revision as of 14:20, 18 May 2015 by OhioBob (talk | contribs) (Scale heights)
Jump to: navigation, search

Scale heights

Hi there, I'm wondering if you've made a mistake in changing the "scale height" in Duna/Param, Laythe/Param, and Jool/Param. This has had the consequence of producing what I believe to be highly invalid atmospheric heights in Template:Infobox/Body, used on all of the celestial body pages, and a table on Science. The formula used there is "ln(1e-6) * -scale_height". Is your change erroneous, or is the formula used to calculate the atmospheric height incorrect? I'm tempted to quickly revert your changes, but hoping you'll spot this message quickly and get a chance to look at it yourself, in case there's good reason for the change. It's not a radius vs. diameter error, is it, or something like that? --Murph (talk) 07:13, 16 May 2015 (UTC)

Ok, so I've thought a little more on this. Since you didn't give any edit summary, it's impossible for me to know why you changed the numbers for scale height. It seems to me that the number which is most important to average players of the game is the atmosphere height, and that most probably won't care about the scale height. In that regard, the old numbers look like they are more "correct" than the new ones. I don't know about Jool and Laythe, but Duna's atmosphere always started around 41–42km, which matches the old numbers. Accordingly, I'm going to revert your 3 changes to the scale heights, under the assumption that there's some sort of error with them, and that the old numbers are better for now.
If the problem is actually with the way the wiki's infobox is calculating the atmospheric height, I'd be quite happy to help with any changes needed to the wiki's templates and scripting.
Here are the numbers for ease of reference, with atmosphere height calculated using the "ln(1e-6) * -scale" formula. Old is before your change. New is what you changed it to.
Body Game
Tracking Station
Old New
Scale Atmosphere Scale Atmosphere
Duna 50,000m 3000 41 447m 6000 82 893m
Jool 200,000m 10000 138 155m 30000 414 465m
Laythe 50,000m 4000 55 262m 8000 110 524m
--Murph (talk) 08:56, 16 May 2015 (UTC)
Note that Squad might have change these values but unfortunately I don't know how to access them without starting KSP and manually doing the tests (I don't trust the infobox ingame as the numbers are at least rounded or worse (aka manually added so that they can get out of sync)). Anyway if someone has the capability of testing it I guess three data points are interesting: The pressure at the surface, the pressure inside the atmosphere for a given altitude and the border at which space starts. From the first two we should be able to determine the scale height and from the latter we could verify that it's currently still a relative border (the border is not at X atm but at X*surface pressure). — xZise [talk] 22:14, 16 May 2015 (UTC)
The problem is that, starting with version 1.0, the atmospheric models have changed. The old formula of "ln(1e-6) * -scale_height" is no longer valid. The height at which an atmosphere ends is now just an arbitrary selection. The current pressure-height profile follows a curve that is defined in a configuration file. When the atmosphere reaches the arbitrary upper boundary, the pressure is forced to go to zero. Furthermore, unlike the old model, scale heights are no longer constant. The scale heights that I computed were a rough average intended to approximate the pressure when using P=Po*EXP(-z/H). I don't mind that you reverted them. I recommend that scale height be removed from the Infobox because it is no longer a constant value. I also recommend that the atmosphere height be changed to an entered value rather than calculated from scale height. The current atmosphere heights are: Eve 90 km, Kerbin 70 km, Duna 50 km, Jool 200 km, and Laythe 50 km. The body of each planet's article should also be edited to make it current with the new method. The scale height and equation P=Po*EXP(-z/H) should be removed because that is no longer how pressure is computed within the game. Since there is no longer a simple and straightforward way to compute pressure as a function of altitude, I'm thinking that the best thing may be to provide a table that gives the pressure at regular increments of altitude, say every 5 km. The article edits I'm planning to do myself. I don't know how to make the changes to the Infobox template. OhioBob (talk) 02:20, 17 May 2015 (UTC)
Thanks for getting back to us with the explanation. I'm slightly surprised that Squad changed to a more arbitrary model for this, but I guess it must have been deemed a necessary compromise for the new atmospheric physics. I'm going to go ahead and add static parameters for atmospheric height, but I won't remove scale height just yet. The more urgent part of this is to provide accurate information to users on where the atmospheric boundary lies, since that's the part which will cause confusion or problems for the majority. --Murph (talk) 02:38, 17 May 2015 (UTC)
Ok, that's atmospheric height turned into a static parameter in the most obvious of places. It's tricky to find all of the places that might have the old formula embedded, as the parameters are very widely transcluded. E.g. see Special:WhatLinksHere/Kerbin/Param, Special:WhatLinksHere/Duna/Param, etc, especially with all the translations. It's certainly done for the per-body infoboxes, and the table on the Science page. If I broke anything, or there's some required cleanup that I didn't spot, feel free to ask me to help with other parts of this issue. I have also reinstated the changes to the scale height values, on the basis that they more accurately reflect the current pressure model, which might make something somewhere more accurate. --Murph (talk) 03:48, 17 May 2015 (UTC)
Thanks for making those changes. I've further revised some of the scale heights. I used a least squares method to find the constant scale height that best matches the current pressure-height profile. OhioBob (talk) 05:42, 17 May 2015 (UTC)
Ugh okay, another thing which must be checked. Anyway, no page doesn't directly use the /Param page but only indirectly via {{Body data}}. This of course doesn't help much but primarily {{Infobox/Body}} is calculating the atmospheric height so you could use it from there. I'd also prefer a way to get the actual height and if they have put it exactly at 70 km as I don't think this is the case. I'm currently not able to play KSP but if I remember correctly the atmosphere still ends at about 69 km for Kerbin. Maybe there is a way to read some file to get that information.
Regarding the body data template, I might add something to add categories for each parameter used so it's possible to determine which sites use which parameter value? Although through all those inclusions it might get to crowded. I've also not yet checked your edits if they make sense. — xZise [talk] 09:28, 17 May 2015 (UTC)
Oh and {{Body data/alt at pressure}} won't work then anymore. — xZise [talk] 09:31, 17 May 2015 (UTC)
All the atmospheric properties are defined in a configuration file. The Kerbin atmosphere definitely ends at 70,000 m. The change in physical time warp associated with the atmosphere boundary clearly happens at 70,000 m. However, a barometer stops registering pressure somewhat lower than that, a little over 68,000 m as I recall. I don't know the reason for that, but I'm guessing the barometer rounds down to zero when the pressure drops below a certain value. Unlike before when the atmosphere just stopped when the pressure reached Po/1000000, it is now forced to go to zero pressure at the defined boundary altitude. OhioBob (talk) 16:02, 17 May 2015 (UTC)
Well my comment was more a response to Murph but nevermind. I'm interested in the configuration file however. I recently looked through the files and couldn't really find one (although that was 0.90 and I was more for a quest after all the properties of a planet and not just the atmosphere). — xZise [talk] 19:20, 17 May 2015 (UTC)
It would be great if we could get our hands on the configuration files themselves, but I think they must be embedded in the ".assets" files, as I also can't find anything in GameData which relates to it. I don't know how to open those files and examine the contents, although will poke around and see what readable text there is inside them. I'll leave it up to you if you want to go to the effort of adding hidden tracking categories. I think I did get all of the main usage of "scale height" for atmospheric height, just wanted to flag that I couldn't be 100% confident due to the wide transclusion.
As for {{Body data/alt at pressure}}, hopefully OhioBob's changes to scale height should make that at least approximately correct, but it sounds like we'll never be able to get it 100% correct without getting our hands on Squad's new parameters, and the maths used to translate them into the model. Approximation is better than nothing, as long as we know it's an approximation, and it's not wildly out for the majority of cases.
I'm going to try to make some time in-game to do some practical experimentation around the atmospheric boundaries, to confirm accuracy of the numbers, but my feeling right now is that the new static numbers probably are correct. I think they are accurate, just the scientist and engineer in me wants to personally verify them. Based on normal launching from Kerbin and re-entering, it does seem like it's exactly 70,000m when the game changes mode from space to atmospheric (the change in music and time warp bar). For now, I feel reasonably confident that the numbers are good for at least saying to players that "above this height you're ok, below it you're going to be aerobraking".
--Murph (talk) 23:34, 17 May 2015 (UTC)
I recently exchanged private correspondence with an insider who worked with Squad to develop the current atmospheric model. He gave me a copy of the config file, though I believe he intended it to be for my eyes only. I don't believe I have a right to share or distribute the file, though I feel comfortable discussing its contents. The file does not appear to be anywhere in the KSP folder, so you are probably correct that it is embedded in the .assests files. I can confirm that the atmosphere heights that I posted previously are indeed a fact. Atmospheric pressure is evaluated using a floatCurve. Each pair of points on the curve are connected by a spline with its own equation. The pressure curve for Kerbin contains 18 splines and 18 equations, though most other curves are simpler than that. Evaluating the curves to find an exact solution is way more mathematically involved then I think is appropriate to include in the Wiki articles. I was thinking about simply providing a table that gives temperature and pressure at regular altitude increments. This is something I can compute from the floatCurve data. Something else I can do is generate graphs of temperature and pressure vs. altitude (in fact, I've already done this). Using P=Po*EXP(-z/H) with a constant scale height provides only a ballpark solution. The scale heights I computed are probably about as close as we can get, but there's going to be significant error in some places. I'm sure I can derive a single equation that will be much closer, but it will still be an approximation. The equation would be in the form P=EXP(f(z)), where f(z) is a polynomial. I'm planning to rewrite sections of the Wiki articles to bring them up to date with the v1.0 changes. OhioBob (talk) 04:48, 18 May 2015 (UTC)
Here's an example equation that can be used to estimate pressure on Kerbin... P = EXP(9.8837225E-24*Z^5-2.3533019E-18*Z^4+1.7819528E-13*Z^3-5.0065555E-09*Z^2-0.00013849112*Z+11.5260885), where P is in Pa and Z is in meters. It's not pretty but it gets the job done. The equation approximates atmospheric pressure to within 1% up to about 29 km, and to within 2% to 62.3 km. Things breakdown above 62.3 km because that's were Squad begins to force the curve to go to P=0 at 70 km. I can derive similar equations for the other planets as well. OhioBob (talk) 05:16, 18 May 2015 (UTC)
Here's an example of one of the graphs I created... http://www.braeunig.us/pics/KSP/Kerbin_Atmosphere_T&P.png. I've made one for each planet and I'm thinking about using them in the Wiki articles. The graphs depict exactly the floatCurves, though I've plotted pressure on a logarithmic scale. OhioBob (talk) 05:36, 18 May 2015 (UTC)

──────────────────────────────────────────────────────────────────────────────────────────────────── Thank you for your information and if you actually got internal information then I have no objections (although I find it dull that they used hard coded exact values). I was pretty sure that the music started below 70 km, but it seems that my mind was playing tricks on me.

Now regarding your approximation: I appreciate the work you've done there and in theory we could have the formula in something like {{body data}} so you'd only do something like {{Body data/pressure approx|body|height}} and it would get you the approximated value. I believe that calculating it with the more complex approximation isn't that much more complicated to the server than with the current approximation (but I might be wrong). I'm not so good at that math so I can only guess but would it maybe possible to have an if condition that returns two different approximations depending on the height? — xZise [talk] 09:15, 18 May 2015 (UTC)

One of the reasons why you might have been fooled into thinking the atmosphere started lower is because the air pressure/density at the boundary is now equal to zero, so the immediate effects, such as drag, are less noticeable. Previously the atmosphere abruptly stopped when P=Po/1000000, so it was more obvious when the boundary was crossed. Now you have to descend all the way to 68,259 m before the pressure reaches that value. Interestingly, that is also the altitude at which I noticed that the barometer starts to read "IN VACUUM". Looks like the barometer may include code that is a relic of the old model. OhioBob (talk) 14:20, 18 May 2015 (UTC)