Click to See Complete Forum and Search --> : Interpolating Airplane Performance
highflight1985
Feb 13th, 2007, 04:32 PM
I'm attempting to write an application that is intended to predict airplane performance based on current atmospheric conditions and other conditions selected by the pilot (such as altitude, engine power setting, etc.). Another program already exists that does this (and more), and I'm attempting to recreate this for my own education. It's called CoPilot (http://lauriedavis9.tripod.com/copilot/).
Luckily, the author explains his methods of calculating this data to include equations. My issue is that I don't understand the math involved.
If you look at the "Aircraft" page from the link on the left, and then click on "Cirrus SR22 Example", you'll see charts describing the performance numbers of an Cirrus SR22 aircraft (small, single-engine, personal aircraft). You can view more charts by clicking on the "Gen", "Climb", and "Cruise" links at the top. These charts assume certain conditions regarding weather and the idea is that CoPilot takes this data and calculates actual performance figures the pilot can expect for the actual/current weather conditons.
Now, if you look at the "Developers" link on the left, you'll see a page that talks about how the program works. On it is an article discussing the mathematics. In the article, Mr. Davis (the author) states that he used a quadratic least squares curve fit. An excerpt from the article:
A mathematical model of the cruise performance is determined by performing a least squares curve fit to produce a quadratic equation that describes the true airspeed (knots) and fuel flow (US gallons per hour) as a function of density altitude (feet). The quadratic coefficients for true airspeed (ta, tb, tc), and fuel flow (fa, fb, fc) are stored in the aircraft database.
The actual true airspeed (t) and fuel flow (f) at a particular density altitude
(y) can then be calculated as follows:
t = ta * y2 + tb * y + tc
f = fa * y2 + fb * y + fc
The full article can be viewed at his website.
To the point: I'm a bit confused as to what values I need to plug into the equations from the performance charts to get the actual performance data (in this case, true airspeed and fuel flow).
I have never studied quadratic least squares curves that I can remember, so this concept is new to me and some explaination would be helpful.
Thanks!
highflight1985
Feb 15th, 2007, 05:27 AM
Since writing the above, I have emailed the author of the software, and he had this to say:
If I’m reading correctly, your software is capable of interpolating aircraft performance based on the performance tables in operating handbooks, and it does this by using a quadratic least squares curve. Is this correct?
Yes, that is how it works
I’m a bit rusty in my math, and I don’t think I’ve ever studied least square curves, so the concept is new to me. Could you elaborate on your article and how it makes its calculations, and/or point me in a direction where I can read up on least squares curve? I’ve done a search on Google for “least squares curve” but could only find homework assignments from various college courses or technical (almost Greek) papers on engineering.
I used a very old textbook that I used in university (over 30 years ago). There is a short description of the technique in Wikipedia: http://en.wikipedia.org/wiki/Least_squares
When you save a entry in the aircraft database, the program does a least squares curve fit on the data that you enter. The quadratic coefficients are stored in the aircraft database. The data that you entered is also stored in the database, but it is never used for anything other than determining the quadratic coefficients.
For some simple calculations, such as cruise speed, it is simply a matter of plugging the altitude into the quadratic equation and doing the calculation.
For more complicated calculations, such as climb times, the program needs to integrate a quadratic function between the two altitudes. I use a numerical integration technique <http://en.wikipedia.org/wiki/Numerical_integration> known as the Simpson's method <http://en.wikipedia.org/wiki/Composite_Simpson%27s_Method>.
I've read the two articles he mentions, but now I'm more confused than ever.
Anyone shed some more light on this?
zaza
Feb 16th, 2007, 03:47 PM
What he's doing is taking a load of actual data and coming up with an equation that seems to fit the data best. Once he's figured out what that equation is, he can then use it to calculate any other value for which he doesn't have data.
For example, let's suppose I had the following data set.
x = 1, y = 1
x = 2, y = 4
x = 4, y = 16
x = 6, y = 36
x = 8, y = 64
How could I find out the value of y when x = 3? Or any other value of x, for that matter. What he's doing is finding an equation that best fits the data, and assuming it is true for all x.
In the above example, we can easily see what the equation would be; y=x^2.
When we fit y=x^2 to the data above, we actually get a perfect fit. So we could say that having collected this data, even though we don't know what the value of y is at x=3, we're pretty confident it will be 9.
Of course, data points will very rarely lie on exactly such a convenient curve. The idea is to get as close as you can. A quadratic fit means that he is only considering powers up to x^2. i.e. his equation is ax^2 + bx + c. In the above example, we would have a=1, b=0 and c=0.
So how to find the best equation to use? This is the least-squares fit. Effectively, it works along the lines of comparing points generated by your test equation to the actual data and attempting to minimise the difference. When you've found a set of a,b,c that results in the minimum difference between your test points and the given data, you've found your best equation. It actually uses the squares of the values rather than the values themselves; hence Least Squares.
Is that starting to make some sense?
zaza
highflight1985
Feb 16th, 2007, 05:18 PM
You made perfect sense up to, "A quadratic fit means..."
Maybe if you were to use the actual aircraft data from his website in his equation? For your convienence, I've included it below. Can you plug in the numbers from this picture into the equation?
http://lauriedavis9.tripod.com/copilot/screenshots/sr22cruise.jpg
Again, the equation is:
t = ta * y^2 + tb * y + tc
and
f = fa * y^2 + fb * y + fc
where,
t = Actual/Expected True Airspeed
y = altitude
ta, tb, and tc = coefficients for true airspeed
f = Actual/Expected flow
fa, fb, and fc = coefficients for fuel flow.
...or is that not how it works?
zaza
Feb 16th, 2007, 05:36 PM
y^2 means y multiplied by y. So he has some value ta, multipled by y and then by y again. He then adds on tb multiplied by y. And then tc. This gives A Result, called t.
So he has a quadratic equation in y, where the three as yet unknown coefficients are ta, tb and tc. Compare these to a, b, c in my previous post.
Above you have shown the actual data. The idea is to use that data to fit a curve. This curve is described by three parameters, ta, tb and tc. These are not given, the idea is to figure them out. These parameters should be such that if you make y any of the altitude values, then working out the equation gives you the airspeed values. The trick is to find ta, tb and tc so that all the values in the table match up.
As I said before, they're never going to match up exactly, but the idea is to choose your ta, tb and tc so that when you consider all the points as a whole, you're as close to all of them as you can get.
Capiche?
To give an example, suppose we make ta = 1, tb = 2, tc = 3. What is t?
Well, looking at the data, let's say y = 2000, the first Altitude point.
t = (ta x y x y) + (tb x y) + tc
= (1 x 2000 x 2000) + (2 x 2000) + 3
= 4,000,000 + 8000 + 3
= 4,008,003
Clearly this is nowhere near 170. So this is not likely to be a good choice of parameters.
Let's try ta = 1, tb = 2, tc = -4007830
t = (1 x 2000 x 2000) + (2 x 2000) + (-4007830)
= 4,000,000 + 8000 - 4,007,830
= 170
Hurrah! So this choice of parameter fits exactly for the first point. But for the second, it's rubbish. The idea is to find ta, tb, tc so that we're really close for ALL the points.
This is where least squares fitting comes in. The basic premise is that you take a guess at ta, tb, tc. Work out how far away you are (based on the sum of the squares of the differences between your "predicted points" and the actual data points). Change the parameters. Work it out again. If you're further away, you've gone in the wrong direction. If you're closer, try again. Keep going until you get really close (and you define how close "really close" actually is. So you might say "find ta, tb, tc so that my "least squares" is smaller than 1,000,000". That will get you a curve that is...probably not so good but will be easy to find. Or "find ta, tb, tc so that my "least squares" is smaller than 10" That will be much better, but will take a lot longer to figure out....)
highflight1985
Feb 16th, 2007, 05:46 PM
So, how does one figure out ta, tb, and tc? If I don't know what ta, tb, and tc are, then I can't use his formula. Right?
zaza
Feb 16th, 2007, 05:54 PM
That is least squares fitting. It is to work out what the best ta, tb, tc are.
VBAhack
Feb 16th, 2007, 08:05 PM
The data appear to be very linear if you plot it, which means the quadratic coefficient will be extremely small. In any event, if you truly want to fit the data to equations:
t = tay2 + tby + tc
f = fay2 + fby + fc
then here's an explanation of least squares - the basic idea is to derive the coefficients of a desired fitting function (a quadratic one in your case) to minimize the sum of the squares of the vertical distance between the calculated values and data values. The governing equation for least squares in matrix terminolology is ATAc = ATb where T stands for matrix transpose, b the speed or fuel values, and c the unknown coefficients. The solution is c = (ATA)-1ATb where A is the coefficient matrix of the desired fitting function (in mathematical language, the terms of A are the partial derivatives of the fittings functions with respect to the unknown coefficients. In other words, whatever is multiplied by the unknown coefficient. Example: the first row of A is (20002, 2000, 1) because ta is multiplied by 20002, tb by 2000, and tc by 1. Similarly for the other rows). In this case, A is the same for both problems:
( 4000000 2000 1 ) ( 170 ) ( 19.4 )
( 16000000 4000 1 ) ( 173 ) ( 19.1 )
A = ( 36000000 6000 1 ) bspeed = ( 177 ) bfuel = ( 18.7 )
( 64000000 8000 1 ) ( 181 ) ( 18.4 )
( 100000000 10000 1 ) ( 184 ) ( 18.0 )
If you have Excel, the computations can be done using the built-in transpose, minverse, and mmult functions. Here's what I got:
ta = -5.42E-20 tb = 0.0018 tc = 166.2 ∑error2 = 0.4
fa = -1.79E-09 fb = -0.00015 fc = 19.72 ∑error2 = 0.002
As expected, the quadratic terms ta and fa are very small, especially ta. If fact, ta is so small that all you need are the linear and constant terms tb and tc. In the case of fuel, fa does play a role, but a linear fit results in a lower sum square error (0.0007 instead of 0.002). Noting the relatively large constant terms tc and fc compared to the desired values, even a linear relationship is rather weak. It's tough to force a mathematical relationship that really doesn't exist. :)
highflight1985
Feb 17th, 2007, 11:02 PM
Wow. Most of that is totally greek to me. I haven't really studied it much yet, though, so as soon as I have an afternoon to digest all of that, I'll do so. Probably Tuesday as I'm going to be preoccupied the rest of the holiday weekend. Thanks for your help so far, and I'll post back here by Tuesday evening.
MaxRaceSoftware
Feb 18th, 2007, 01:29 PM
If you look at the "Aircraft" page from the link on the left, and then click on "Cirrus SR22 Example", you'll see charts describing the performance numbers of an Cirrus SR22 aircraft (small, single-engine, personal aircraft). You can view more charts by clicking on the "Gen", "Climb", and "Cruise" links at the top. These charts assume certain conditions regarding weather and the idea is that CoPilot takes this data and calculates actual performance figures the pilot can expect for the actual/current weather conditons.
It appears that particular Quadratic Curve Fit values would only apply to that
one specific Airplane (Cirrus SR22 Example),
what will happen to Quadratic values as you change Airplanes,
Drag Coefficients, or Engine Horsepower ?
you would have to develop a Quadratic series for each different Airplane.
it would be better to use real Physics equations and move away from a series
of Quadratic equations....you would then have a Program that calculated correct
values under all circumstances...and the only time i'd use a Curve Fit Equation
along with Physics equations, would be as a very small "fudge-factor" to help
correlate your Program to real-world observable Data.
VBAhack
Feb 18th, 2007, 04:23 PM
Wow. Most of that is totally greek to me. I haven't really studied it much yet, though, so as soon as I have an afternoon to digest all of that, I'll do so. Probably Tuesday as I'm going to be preoccupied the rest of the holiday weekend. Thanks for your help so far, and I'll post back here by Tuesday evening.
If you've never had linear algebra, the explanation wouldn't make much sense. I don't know how to explain least squares w/o using linear algebra. In any case, attached is an Excel file with the calcs. Good luck.
MaxRaceSoftware
Feb 19th, 2007, 04:04 AM
i never thought about trying to Model Airplanes before
until this Thread...so i have zero experience or Data with Airplanes,
but equations should give you a direction ???
you might only need very small Curve Fits to correlate or maybe none at all ?
not sure if Speeds are MPH or Knots ?? so i used MPH
you can change that later
1-Solve Drag in Pounds
Drag in Lbs. = (Fuel / BSFC) / ( MPH * .00266667)
where
Fuel = Fuel consumed in Lbs per HP per Hour
BSFC = (UnCorrected Brake HP / Fuel Consumed)
i started off using 2000 Ft because the BSFC will probably be on the Rich side
for safety...and probably a typical .500 BSFC value
2-Solve the "combined value" of the (Projected Frontal Area * DragCoefficient)
(Fa * Cd) = DragLbs / ((( MPH * 1.46667) ^2 ) * AD * .5)
where
Fa = projected effective frontal area in sq.ft
Cd = Drag Coefficient
MPH= miles per hour speed
AD = air density
AD @ SeaLevel = .002367
AD @ 2000 ft = .002236 ??? i need to check for sure
AD @ 4000 ft = .00211 ??
AD @ 6000 ft = .001987 ??
AD @ 8000 ft = .00187 ??
AD @ 10000 ft = .001756 ??
also there may be additional factors like Lift Coefficient and Propeller Efficiency ??
to also factor in your Model....the Propeller Efficiency should likewise be affected
by Air Density value and RPM and Prop tip speed
HP = (Fuel / BSFC)
38.8 HP = (19.4 / .500)
Drag in Lbs.@ 2000Ft = (Fuel / BSFC) / ( MPH * .00266667)
85.588 Lbs. = (19.4 / .500) / ( 170 * .0026667)
(Fa * Cd) = DragLbs / ((( MPH * 1.46667) ^2 ) * AD * .5)
( 1.23144 ) = 85.588 / ((( 170 * 1.466667 ) ^2) * .002236 * .5)
now you know combined value of Fa and Cd
Solve rest of Fuel Consumed Rates @ various Altitudes and MPH
4000 Ft
DragLbs 83.641 = (173 * 1.466667)^2 * .00211 * .5 * 1.23144
18.96 Fuel = (83.641 / 85.588) * 19.4
6000 Ft
DragLbs 82.45 = (177 * 1.466667)^2 * .001987 * .5 * 1.23144
18.69 Fuel = (83.641 / 85.588) * 19.4
8000 Ft
DragLbs 81.142 = (181 * 1.466667)^2 * .00187 * .5 * 1.23144
18.39 Fuel = (81.142 / 85.588) * 19.4
10000 Ft
DragLbs 78.742 = (184 * 1.466667)^2 * .001756 * .5 * 1.23144
17.85 Fuel = (78.742 / 85.588) * 19.4
4000Ft = 19.1 -vs- 18.96 or 19.0 rounded-off
6000Ft = 18.7 -vs- 18.69 or 18.7 rounded-off
8000Ft = 18.4 -vs- 18.39 or 18.4 rounded-off
10000Ft = 18.0 -vs- 17.85 or 17.9 rounded-off
just a quick approach , not exactly all the real methods
i would probably use to solve , if i had a few more Days to
look at your Programs Data, i could figure it out better for you !
Linear Curve Fits are also pretty close
Linear Fit: y=a+bx
Coefficient Data:
a = 35.875385
b = -0.096923077
Fuel_Consumed = ( MPH * -0.096923077) + 35.875385
Linear Fit: y=a+bx
Coefficient Data:
a = 19.77
b = -0.000175
Fuel_Consumed = ( Altitude * -0.000175) + 19.77
highflight1985
Feb 20th, 2007, 08:58 AM
The data appear to be very linear if you plot it...
It may be very linear for this aircraft, but what about other aircraft with different performance data? Wouldn't that affect the forumulas used in the spreadsheet?
The governing equation for least squares in matrix terminolology is ATAc = ATb...
I remember dealing with matrices in high school Algebra, but I've forgotten what all I learned and I've never used the MMULT or TRANSPOSE functions in Excel. I could easily go read up on both of them on a web site on the internet and in the help files, but how does one deal with them in VB.NET Code?? Arrays?
Your spreadsheet looks really quite nice, but how does one use it? Suppose I wanted to fly at 15,000 feet, where do I plug in that value to find out what my airspeed and fuel flow will be? I attempted this in the blind [before asking you how to use it] already and maybe I'm doing something wrong, but the only speed I could get it to spit back out was 160.2, regardless of what altitude I entered.
MaxRace, I read over your post. It seems as if you are attempting to calculate the physics of flight for a given aircraft. I'm only attempting to calculate certain aspects of flight interpolated from already known numbers. Your method, correct me if I'm wrong, is attempting to calculate the forces and other physics related to a given aircraft as if no numbers are known. If I were designing some type of flight simulator like X-Plane (www.x-plane.com), they might be more useful, but then, I'd have to create something as complex as X-Plane's physics engine to do that. That would involve much more complicated mathematics and code than I'm prepared to deal with. Not to mention that this is intended to work on a SmartDevice that the pilot could take with him to the airport and into the airplane, so such a resource-intensive application would be undesireable.
Thanks to everyone for their support so far!! I never thought I'd get this kind of reply, or any replies at all.
VBAhack
Feb 20th, 2007, 02:46 PM
My comment about the data looking linear was specific to the data you posted. Sure, it could look different for different aircraft.
The purpose of the spreadsheet is to calculate ta, tb, tc, fa, fb, fc using a quadratic least squares fit of the specific altitude, speed, and fuel data in the upper left hand corner of the sheet. Having the parameters allows you to calculate t or f for any value of altitude (y) in the range of 2000-10000 (the calculation isn't valid outside of this range) using:
t = tay2 + tby + tc
f = fay2 + fby + fc
If you want ta, tb, tc, fa, fb, fc for the new aircraft, just enter the altitude, speed, and fuel data in the upper left hand portion of the spreadsheet and new parameters will be calculated. As long as you only have 5 pieces of data for each aircraft, the spreadsheet will work. If you have more or fewer than 5 data points, the problem needs to be re-formulated.
If you want to implement this this in VB or VB.net, I assume you don't need to perform the least squares analysis on the fly repeatedly, but just store the parameters of the polynomial equation (y = ax2 + bx + c) for each aircraft. Yeah, I'd probably store them in an array. So, if you had data for 10 aircraft, you could have a 10 x 6 array of values (or two 10 x 3 arrays, or some other scheme) that you can access when needed to make a speed or fuel calculation. You could write a simple function to perform the calculation.
If you need to do the least squares analysis on the fly (can't imagine why), you'd need to write or pick up code that will perform the matrix operations to calculate the coefficients of the quadratic equation. It would be a fair amount of work.
highflight1985
Feb 20th, 2007, 03:44 PM
My comment about the data looking linear was specific to the data you posted. Sure, it could look different for different aircraft.
...but would a non-linear set of data affect the calculation's outcome at all in a way that it would be inaccurate?
The purpose of the spreadsheet is to calculate ta, tb, tc, fa, fb, fc using a quadratic least squares fit of the specific altitude, speed, and fuel data in the upper left hand corner of the sheet.
This is what I figured. So, in a row or two below all your calculations, I wrote the following Excel equation to calculate the expected speed:
=SUM(H23*A2^2+H24+H25)
where H23 is the cell for ta, H24 is the cell for tb, H25 is the cell for tc, and A2 is the altitude (2000, in this case). Check it with your spreadsheet. You should come out to 166.2018. Now, change the altitude to A4. Calculation will be 166.2018 again. Now change the altitude to A6, or 10,000ft. It is STILL 166.2018. Just for kicks, change the altitude to 90,000ft. STILL 166.2018. Something isn't right here. It should be changing. Even the charts on the CoPilot website show that it's supposed to be changing. Another bit of evidence something isn't right: If I'm entering 2000, 4000, 6000, and so on, and we have data for those altitudes, shouldn't the calculation be coming up with the same numbers, or close? The closest we get is 4 knots off at 2000, and 18 knots difference at the worst (10,000).
As long as you only have 5 pieces of data for each aircraft, the spreadsheet will work. If you have more or fewer than 5 data points, the problem needs to be re-formulated.
By "re-formulated", you mean editing the MMULT and TRANSPOSE functions to use only those cells for which we have data for, OR, do you mean the entire spreadsheet has to be changed?
If you want to implement this this in VB or VB.net, I assume you don't need to perform the least squares analysis on the fly repeatedly...
Correct. This is just a preflight planning tool. It won't be needed by the pilot once he's left home for the airport.
highflight1985
Feb 20th, 2007, 03:48 PM
This is what I figured. So, in a row or two below all your calculations, I wrote the following Excel equation to calculate the expected speed:
=SUM(H23*A2^2+H24+H25)
I stand corrected. I messed up the formula. Here is the new one, and it appears to be working, with errors from known data +/- tenths of knot.
New Excel formula:
=Sum((H23*A2)^2+(H24*A2)+H25)
My previous questions still stand, plus one addition:
Take the fact that we only have data for the five altitudes given, but the pilot wanted to fly at 12,000 feet. Is it reasonable to believe that if we were to plug in 12,000 into the equation that the result would be fairly accurate to what he would really experience?
VBAhack
Feb 20th, 2007, 07:07 PM
...but would a non-linear set of data affect the calculation's outcome at all in a way that it would be inaccurate?
It all depends on how well the data fits a quadratic equation (i.e. parabola). One way to judge is to plot it and look a calculated curve vs original data used to create the curve. The other way is to look at the sum square error (cells F7 and I7). The smaller the better. I can't give a rule of thumb as to how small it needs to be to have a reasonable fit. That's an age old problem of data fitting and there's no universal answer I know of.
This is what I figured. So, in a row or two below all your calculations, I wrote the following Excel equation to calculate the expected speed:
Don't use sum to calculate speed and fuel for an arbitrary value of altitude. Also, if you change the values in cells A2-C6 you are changing the data and therefore ta, fa, etc. Instead, do the following:
1. Enter whatever altitude value you want in cell K2 (e.g 2500)
2. Enter the following formula in L2: =K2^2*H23+K2*H24+H25
3. Enter the following formula in M2: =K2^2*H29+K2*H30+H31
Whenever you change the value in K2 you'll get the corresponding values for speed in L2 and fuel in M2. If you enter the exact altitude for which you already have the data, the calculated value won't match exactly. That's the nature of least squares - it is a 'best fit' calculation to ALL of the data but doesn't necessary fit any of the data points exactly.
Also, extrapolation can certainly be done, but it becomes increasingly dangerous the further you are from the limits of the data used for the fitting. All you are doing is force fitting a small portion of a parabola to your data. That may not be obvious - if you plot calculated values for a wide range of altitude (even negative), you'll see the familiar parabolic shape. Departing too far from the limits of the data used to calculate the parameters can result in a situation where 2 different values for altitude can give the same values for speed or fuel - which is crazy. I really don't have any knowledge of aircraft data, so can't make any comment about extrapolation. Maybe others in this forum can.
By "re-formulated", you mean editing the MMULT and TRANSPOSE functions to use only those cells for which we have data for, OR, do you mean the entire spreadsheet has to be changed?
Basically, the entire spreadsheet needs to be changed if you have greater or less than 5 pieces of data for a particular aircraft. Example, the matrix A has 5 rows because there are 5 pieces of data. If you had 7 pieces of data, the matrix A, bspeed, and bfuel need to have 7 rows and all of the matrix formulas need to be different to accommodate the larger array sizes. Here are links to some tutorials on Excel matrix operations (they happen to be for a free Excel add-in but provide a good understanding on how matrix formulas work):
http://digidownload.libero.it/foxes/matrix/MatrixTutorial1.pdf
http://digidownload.libero.it/foxes/matrix/MatrixTutorial2.pdf
I don't like doing this, but attached is a spreadsheet with a custom function that provides a 'black box' approach. The data you want fitted are in cells A2:C6. The values of ta, etc. are in cells F2:G4. The formulas allow for any number of data points (at least 3 data points are required), just adjust the formulas. Cells F7 and G7 are calculated values of t and f for whatever value of altitude you enter into cell E7.
I really think there's nothing more I can add to this discussion. Good luck. :thumb:
.
highflight1985
Feb 21st, 2007, 02:56 PM
Wow. Holy cow.
VBAhack, the second spreadsheet you made has made my day. You've shown me that it is probably not impossible to do this in VB.NET after seeing your VBScript code. I appreciate all your help in this! Brownie points to you!
VBAhack
Feb 25th, 2007, 10:31 AM
Glad I could help. :p
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.