-
-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
atmospheric temperature fix #4219
atmospheric temperature fix #4219
Conversation
temperature affects density. if temperature rises with altitude, density drops much more than it should, making fuel scooping harder or impossible.
Edited just so it will auto-close the related bug report :) |
its possible that the positive/negative bug also causes abnormally thin atmospheres. I just scooped a gas giant with 57,000km radius and only ~30km atmosphere. that doesnt seem right. |
@joonicks gas giants in pioneer are a bit shitty. Fine to look at, and a good implementation for technology/ability at the time, but they aren't really gas giants like you'd expect. They're rendered as a solid shell instead of layers of clouds. There's no real volume to them. So everything is a bit of a hack. |
Ok so in light of #4222 does it make sense to merge this or has it revealed that there needs to be more work? I mean I looked at all those calculations and I'd hate to guess what order all of the maths is actually being applied in. Someone really needed to bracket the hell out of those equations just for reading and sanity checking. |
src/Planet.cpp
Outdated
const double lapseRate_L = -m_surfaceGravity_g/specificHeatCp; // negative deg/m | ||
|
||
// m_surfaceGravity_g is calculated and stored as a negative number | ||
const double lapseRate_L = -m_surfaceGravity_g/specificHeatCp; // negative deg/m << wrong? -(-)/+ = +, should it be -abs(G)/hcp? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like github is warning that this line isn't indented correct? (we use tab, 4 char wide).
I'm not very comfortable as it looks to me like no one actually understands what the code should be, something that is emphasized further by the code comments. From #4216
I'm not sure it's that simple at all, as you rise density and preassure drops, giving higher speed to the molecules. For Earth temperature drops only the initial 10 km, then increases again up to 50 km: (Ideally, I'd like to see graphs of how this changes our temperature before / after this change, as that is how I understand things the best). Or does this magically make everything better for all planet and atmosphere types? |
pioneer earth atmosphere stops at 25km. so from sea level to 25km, the temperature should fall. I had to apply this fix to scoop a hot jupiter. |
stratosphere - "The increase of temperature with altitude is a result of the absorption of the Sun's ultraviolet radiation by the ozone layer." venus' atmosphere, temperature steadily declines up to 100km where pressure is 0.01, after that it slowly rises but at 200km its still only 1/5th of ground level temperature. wikip doesnt give any info about mars' atmosphere except "upper atmosphere is hot" jupiter lacks mesosphere, in troposphere temperature drops, in thermosphere (usually not considered part of the "atmosphere") temperature increases again saturn no mention of temperature |
I think I have found the formulas used. give me a bit. |
I am struggling to test this one. Think that I will need to add some more logging and info display, maybe you'll get your graphs @impaktor I've tried going over the original code as well, it's horrible. |
youre not ready to take my word for it? |
There's currently no code change in this commit and I'm pretty sure a +/- flip would be a miscorrection. As the surface gravity is stored as a negative number, lapseRate_L comes out as positive and the formulas are used correctly. If anything's wrong it's the comment, "negative deg/M". There's a separate issue that the formulas assume a fully convective (non-layered) atmosphere so the temperature falloff is constant. I'm not sure how much difference this makes given that there's a cutoff at 0.001 surface pressure anyway. For anyone trying to understand this code, lapseRate_L is the dry adiabatic lapse rate described in https://en.wikipedia.org/wiki/Lapse_rate. The final atmosphere height is calculated by inverting the height to pressure formula here at 0.001 surface pressure: https://en.wikipedia.org/wiki/Density_of_air#Altitude. |
It's not that. Changing the sign to a +/- doesn't seem to make much difference on planets like I would have expected and Gas Giants I'm struggling to scoop at any of them anyway. |
Ive read up on the various gas pages on wikipedia while looking in to this. lapserate is a change in temperature as altitude rises, its supposed to be a negative value. the formula on that page was for calculating the height z where pressure equals P0. lapserate = g/Cp where g is gravity (a positive number) and Cp is the specific heat capacity of the gas https://en.wikipedia.org/wiki/Vertical_pressure_variation#cite_note-9 thats the formula I tried. but with that formula, you can never have an atmosphere thicker than -(surfacetemperature/lapserate), or in the case of earth -(288/-0.009801649) = 29382meters. the formula will never give an answer above that value. if thats the formula used in pioneer, it would show as cool planets having a very thin atmosphere while hot planets have a very thick atmosphere. ive seen indications that that is the case. the vertical pressure variation formula can therefor not be used to determine the thickness of any atmosphere. also, if you want this: to produce temperatures that drop the higher you get, lapserate must be a negative number, which it is not right now. right now, temperature rises until it peaks at the top of the atmosphere that is twice the surface temperature. yes sure in reality atmospheric temperature varies, but on earth the hottest place is the surface. and it sure as hell is not 300C at 25km. |
jaj, the article https://en.wikipedia.org/wiki/Density_of_air#Altitude specifically states: the troposphere is only the first 10-15km on earth. |
Edit: Missed some code. Sorry, missed the second part of the commit. The single code change on line 168 is correct and a valid fix. The atmosphere height code however is working as intended. There's no dispute on the troposphere point, but unless someone wants to implement a more complex functional model of atmosphere pressure that applies to general extraterrestrial planets, it will remain academic. |
src/Planet.cpp
Outdated
*outPressure = surfaceP_p0*pow((1-lapseRate_L*height_h/surfaceTemperature_T0),(-m_surfaceGravity_g*gasMolarMass/(GAS_CONSTANT*lapseRate_L)));// in ATM since p0 was in ATM | ||
// ^^g used is abs(g) | ||
// temperature at height | ||
double temp = surfaceTemperature_T0+lapseRate_L*height_h; | ||
double temp = surfaceTemperature_T0-lapseRate_L*height_h; // << lapserate is a positive number and needs to be subtracted for temperature to drop the higher you get. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaj22 flipped sign is here
this is not intended to fix the whole issue with crappy formulas. simply a quick fix to flip the temperature gradient to its correct way. |
Atmosphere at 8000 meters, temperature = -63.4C, with + temperature (unfixed) = 93.4C top of mount everest: boiling alive. |
The line 168 fix is definitely correct. I checked all the other formulas before noticing which line was changed. Just needs the tab spacing fixed on line 148 and preferably some comment cleanup. Should make it clear on line 68 and 148 that lapseRate_L is a positive value. |
And debug output, and a new alternative way of getting atmosphere. Im starting to feel like Im writing a book.
verified output is exactly the same, except the +- fix
Ok a lot changed here since I last looked at it |
I tried to clean it up best I could, output is exactly the same as old messy function, but a bit optimized and commented up |
I don't feel comfortable enough to merge this, as I get an uneasy feeling by it (and I don't have time to get under the hood) . But if anyone else understands it, then feel free to merge. |
@impaktor do you read only the diffs, or do you watch the end result as well? |
temperature affects density. if temperature rises with altitude, density drops much more than it should, making fuel scooping harder or impossible.
comments plus a single char fix, a + to a -
EDIT: fixes #4216