Jump to content
Sign in to follow this  
Guest Ron Freimuth

Geopotential Altitude from density - xml problem

Recommended Posts

I've been trying to calculate the geopotential altitude from a given density, but I'm having trouble implementing the equation in XML, probably because I'm not familiar with how the log function works.Following is a jscript formula where:Units are SIvar g =9.80665; //gravitational constant, m/sec2var Po=101325; //sea level standard pressure, Pavar To=288.15; //sea level standard temperature, deg Kvar R =8.314320;//gas constant, J/ mol*deg K var M =28.9644; //molecular weight of dry air, gm/molvar L =6.5; //temperature lapse rate, deg K/kmvar D=d*1000; var p2=( (L*R)/(g*M-L*R) )*Math.log( (R*To*D)/(M*Po) ); var H=-(To/L)*( Math.exp(p2)-1 ); var h=H*1000;return(h)As you can see, the calculations are done in 2 parts ('p2' and 'H') for readability, so I did the same. Input is density in kg/m^3 as 'd'. Output is geopotential altitude as 'h' in meters.I've tried to convert this to XML with the following code (parens added and tags removed for clarity...)p2 = ((@L @R *) (@M @L - @g * @R *) /) ((@R @To * @Density 1000 * *) (@M @Po *)/) log *H = ((@To @L / /-/) ((@p2 exp) - 1) *) 1000 *This is just wrong:( I don't know how log and exp work in XML, and I've tried several combinations. Can anyone offer an xml equivalent of the jscript code above?Thanks,--Jon

Share this post


Link to post
Share on other sites
Guest Ian_K

Hello Jon,you don't need logs. My SS does it this way as the ISA book says.sigma=((288.2-C2/10*-L2)/288.2)^4.256C2 = FL = geopotential flight levelL2 = =-6.5*0.0254*12sigma = air density/ MSL density (= 1.2256 kg/m^3)I will send you the full SS if you mail me for it.For the other way around just do it backwards.Ian

Share this post


Link to post
Share on other sites

Hi Ian,Thanks for the reply. I'll try to implement the reciprocal of that and see how it works!--Jon>Hello Jon,>you don't need logs. My SS does it this way as the ISA book>says.>>sigma=((288.2-C2/10*-L2)/288.2)^4.256>C2 = FL = geopotential flight level>L2 = =-6.5*0.0254*12>>sigma = air density/ MSL density (= 1.2256 kg/m^3)>>I will send you the full SS if you mail me for it.>>For the other way around just do it backwards.>>Ian>>

Share this post


Link to post
Share on other sites
Guest Ron Freimuth

For one thing, you don't use "=" in XML RPN calculations. Are you familiar with HP calculators? The RPN is very similar to them. Note HP's have no "=" key. You generally end up with the calculated value at the top of the RPN stack. You then have to save it to a variable. Such as: (>L:MyVar,number) That pops the value off the stack and also places it in 'MyVar'. To do a ln: "5 ln". Enter '5', take the natural log. Result is at the top of the stack. There is also 'pi', so you don't have to enter it digitally. See the FS9 Gauges SDK on the XML stuff.Ron

Share this post


Link to post
Share on other sites

The = was just for illustrative purposes:), as were the parens. I has stuffed the constants into macros, which is why @xx was everywhere instead of (L:Whatever, number).But I was trying to use "log" not "ln", so maybe that was the reason.Anyway, Ian emailed me a SS with some good calculations which helped very much. What I ended up doing instead was just precalculating all the constants, ending up with the fomula:44.3308 42.2665 @rho 0.234969 pow * - 1000 *Where @rho is the density and the result is the geopotential altitude in meters:)--Jon

Share this post


Link to post
Share on other sites

Actually what this was all about was writing an algorithm topredict the optimum cruising altitude for several flightprofiles of a turbojet, given current weight.What I did was first find the L/D tangents for endurance andrange at the current density - this gives me the mach numbersfor best endurance and range at the current altitude.What I wanted to do next was calculate the best altitudes(somewhere over 36,000 ft, increasing with weight loss), andalso display the corresponding range and endurance machnumbers at the predicted best altitudes. In other words,provide what amounts to a dynamic step climb display of sorts. It is easy to compute the mach numbers required for range and endurance at any altitude, but how does one compute theoptimum altitude?AoA should remain constant as airspeed decreases (altitudeincreases), and velocity for best range and endurance is afunction of rho, weight, S, and Cl. So I know there answer isthere, someplace:)--Jon

Share this post


Link to post
Share on other sites
Guest Ron Freimuth

>Actually what this was all about was writing an algorithm to>predict the optimum cruising altitude for several flight>profiles of a turbojet, given current weight.>>What I did was first find the L/D tangents for endurance and>range at the current density - this gives me the mach numbers>for best endurance and range at the current altitude. Yes, that's a start. >What I wanted to do next was calculate the best altitudes>(somewhere over 36,000 ft, increasing with weight loss), and>also display the corresponding range and endurance mach>numbers at the predicted best altitudes. In other words,>provide what amounts to a dynamic step climb display of sorts.>>It is easy to compute the mach numbers required for range and>endurance at any altitude, but how does one compute the>optimum altitude? Generally Mach stays virtually constant, other than in Biz Jets, etc. LRC is just past the peak of TBL 401 in MSFS (if it is set up to give good total drag) and you might note Constant Climb, then Cruise Mach numbers are common in FM's. At a constant Mach, the compressability effects stay constant. However, as one climbs CAS and dynamic pressure, q, decrease. The idea is to balance the drop in q with the decrease in W as fuel is burned. Turns out Delta_a, rather than Rho/Sigma is used when flying at constant Mach numbers. At a given weight, as one climbs AoA increases. This increases Cdi and eventually there is a balance of Cdp and Cdp that gives best range. Theoretically this occurs when Cdi = Cdo/3 and IASbest_range is at 2^1/3 = 1.26 *IAS Best_Endurance (L/D = max. My tests in MSFS show ratios more like 1.22. FS has a more complex drag model, and compressabilty comes in to change the simple results. However, this is only at low FL's. At cruise FL's, Best endurance may actually be about the same speed as Best Range. It depends on FL. What one really wants is to adjust the appropriate AIR file tables so Best Altitude at a given Weight (and Mach) is consistent with FM tables. ;) **** Jon, I suggest you email Ian and I, my email address is in my AVSIM info. Several of use have been into these things, and there is too much to post here. *********** My Jet Test XML gauges display Cdp, Cdi, L/D, Rs, Es, etc. But, not yet more than current range and endurance. Herve' Sors just worked out better Range and Endurance in his AFSD AC prediction window. He calculates current and furture fuel flow and integrates it over a flight. Which gives larger values for Range and Endurane than a simple calculaton give. However, his approach assumes FL and Speed is constant; that Cdi drops as W drops. After all, the app wouldn't know details of the future flight profile unless it were defined. Now I think one can calculate the total Range and Endurance from the current conditions if he adds a Ln (W/Wend) and perhaps other terms in his calculation. In this case, one would climb to keep Wing_loading/Delta constant as W decreased. At a constant Mach, q would decrase. CD would be constant since AoA would be constant, but q*CD*S would drop as q dropped. Thus, PPH decreases as W decreases and one climbs. That profile is approximated by Step climbs. And, I think it's tractable to fairly simple calculations. Avoiding the 'direct approach' of calculating future peformance by being able to calculate PPH, etc at any speed. I have a bunch of info in my Boeing Flight Performance Manual, but it tends to be hard to work out correctly. We also worked out most of the rest of the AIR file turbine tables. In ways consistent with the Boeing manual, but different enough to make it of limited value. It's also possible to get a varying SFC from FS, though one has to adjust TBL 1505 and find a way to make a new, calculated PPH drain the tanks. I've been experimenting with this. Turns out that a few combinatioins of Greeky stuff like Delta_a, Delta_tot, Theta, etc. can be combined to get most of the terms one needs to get all kinds of things. I calculate all that stuff in my XML Jet Test gauge, it's easier to get in XML than in C, I use FS Parmaeters directly. ------------------ Herve' Sors is working on an app that will generate FM/PoH tables for any FS AC. We still have to work out some details in the turboprop, but the general approach is pretty well known. Further, I keep suggisting other things to add to AFSD, though Herve' thinks of plenty himself. For example, AFSD now calculates CAS (not trivial) so it can be compared to FS 'IAS'. It also shows how Stall speeds change with Flaps, Weight, Bank, and even altitude. Ron PS: I think a screen shot of my two XML Jet Test gauges may be attached. I'm not sure. ;) -- yes, it's attached, but washed out.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...