Putting It All Together: YASim Solutions
By Gary "Buckaroo" Neely
The YASim Solver
The solver is a subset of the YASim program which takes in the FDM data you've provided and constructs the relationships that generate a flyable model. It calculates total drag, thrust, lift, and weight. It determines if your aircraft can maintain sustained, level flight with the pitching moments acting on it during approach and cruise flight attitudes. The solver pre-calculates certain values and some flight surface settings and, if the results are successful, it uses these for the duration of the flight. If not, it reports that it failed to solve for the specified FDM.
The solver runs automatically when you startup Flightgear with an aircraft configured to use a YASim FDM. The solver pre-calculates settings like horizontal stabilizer incidence that are used for the entire flight, then YASim proceeds with normal interations during the flight.
Even if you aren't expecting a good solution from the solver, it can be useful in finding flaws in your FDM or positioning the center of gravity. It will flag some of the more blatant errors, and tell you when you have problems with your XML. If you are working with YASim, you will be using the solver a lot.
Running the Solver from the Command Line
The primary function of the solver is to determine if the aircraft can fly with the pitching moments that will act on it, so it's a useful tool for a developer. It would be tedious to have to start up Flightgear every time a developer wants to test the FDM. Fortunately the solver can be run independently of Flightgear as a stand-alone program. This is a great time saver.
This independent solver application is normally found in /bin directory of the Flightgear installation. On my 32-bit Windows system it is found as:
<flightgear root>/bin/Win32/yasim.exe
To run the program from the command line, you should be able to enter something like this:
"C:\Program Files\FlightGear\bin\Win32\yasim.exe" "C:\Program Files\FlightGear\data\Aircraft\Optica\Optica-yasim.xml"The exact command will vary with your operating system and installed files.
In practice, I make a copy of the yasim.exe program and place it in the same directory as the aircraft FDM file. Then all I need do is open a command prompt window and enter:
yasim.exe Optica-yasim.xml
where "Optica-yasim.xml" is the aircraft FDM I'm working with. For this to work, you may need to add the Flightgear /bin directory to your operationg system's environment path.
Working with the YASim Solver
The solver is all about pitch moments. It has two primary jobs: a) to determine if the aircraft's horizontal stabilizer can balance the pitching moments acting on it at the extremes of its flight envelope and b) to find a horizontal stabilizer incidence that allows the aircraft to cruise with neutral elevator input. The flight envelope extremes are set using the approach and cruise elements of the YASim FDM.
For the cruise calculation, the YASim solver sets the horizontal stabilizer incidence to adjust the lift produced by the tail surface in order to counter-balance the summed moments acting on the aircraft's pitch axis at cruise. Recall that you cannot set the stabilizer incidence yourself like you can the wing; the solver determines the stabilizer incidence. The solver does this using a neutral elevator, in other words, an elevator control value of 0, no elevator control input. You cannot specify an elevator control input in your cruise configuration, but you can assign a control input value for elevator trim. The solver then tries values for stabilizer incidence until it finds an incidence that enables stable level flight or gives up. The solver reports the stabilizer incidence used, along with the cruise angle of attack when using that incidence.
The solver does a similar exercise with approach settings. This time, rather than assume a neutral elevator, we're telling the solver what angle of attack to hold, and the solver tells us how much elevator control input is necessary to hold that flight attitude. Again, the elevator must be able to balance the summed pitch moments acting on the aircraft in this attitude. If your configuration doesn't have enough elevator authority to hold the approach angle, YASim will report "Insufficient elevator to trim for approach".
If the solver can find settings for tail incidence that can trim for cruise and allow an approach with maximum elevator deflection or less, then its work is done. If not, it keeps trying different values until it finds workable numbers or exceeds a maximum number of attempts and reports "Solution failed to converge after 10000 iterations".
A typical solver report looks something like this:
Solution results: Iterations: 813 Drag Coefficient: 15.855506 Lift Ratio: 110.167068 Cruise AoA: 0.600153 Tail Incidence: -0.246429 Approach Elevator: -0.683866 CG: x:-23.852, y:-0.000, z:0.539 Inertia tensor : 718058.188, -0.004, 497888.563 [kg*m^2] -0.004, 5542764.500, 0.001 Origo at CG 497888.563, 0.001, 6015855.000
These results were taken from my MD-81 model. Solution results will vary widely for various aircraft configurations, so don't expect yours to have numbers like these. This example is only for illustration.
Let's look at the solution results in detail:
Iterations
This is how many attempts the solver made to find numbers that worked. The solver isn't smart-- it simply sets trial values, looks at the results, then tries a new guess, repeating the procedure until it gets a good result or exceeds how the number of guesses it's allowed to try. Iterations is not very useful to the developer, but if iterations gets much over 1200 or so, it may indicate that your configuration isn't optimal. I wouldn't worry about it much. Most decent YASim FDM's solve in under 1500 iterations. Most that go over that fail to solve.
Drag Coefficient and Lift Ratio
These are dimensionless numbers that roughly indicate total drag and lift. Don't try to make these conform to real L/D ratios, the numbers are not equivalent. Drag values are normalized to 10, so re-examine your settings if you are getting numbers wildly beyond this range. Don't be too alarmed at high drag values-- I've configured high-lift FDM's that resulted in Drag Coefficients well above 30 that gave me the flight characteristics I wanted. Lift values are normalized to 100. Lift ratio for GA aircraft should typically not exceed 100 by much, and will often be well under 100. Numbers well over 100 and especially above 200 should be re-evaluated, as this suggests performance requirements that are too great for the engine or the altitude. It can result in an aircraft that glides forever. If drag and lift results are very close together then your aircraft will glide like a brick, but this will often be correct for many planes.
Cruise AoA
The angle of attack of the aircraft at cruise speeds in degrees. High-speed performance aircraft will usually cruise with a very small AoA. High-lift configurations with a highly cambered airfoil are likely to cruise with a pronounced negative angle of attack.
Tail Incidence
This is the solver's setting for horizontal stabilizer incidence in degrees. Using this incidence value the aircraft will cruise with neutral elevator.
Approach Elevator
This is the solver's result for the elevator deflection necessary to hold an approach. For example, a result of -0.8 indicates that an input of 80% "up" elevator control is necessary to hold the approach. A value of -1 would mean full "up" elevator is necessary to hold the approach, which would be give no margin of control.
In general cases, you will want the solver to give an approach elevator result in the range of -0.9 to -0.5, depending on the aircraft and the configured load. Values greater than -0.9 will not give much margin, but may be correct for your aircraft. Some notorious historic aircraft will approach with the stick held nearly all the way back. Beware of approach elevator values less than approximately -0.5, where small control inputs are necessary to hold an approach. This usually implies an elevator with too much authority. The aircraft may become pitch sensitive and difficult to fly, and autopilots may fail to find solutions to hold pitch. This results in porpoising or "spazzing" effects as some in the Flightgear forums have called it.
Approach configuration has a great effect on stall behavior. If the aircraft begins to stall at 12 degrees and the approach AoA is configured for 6 degrees and the solver reports an approach elevator value of -0.9, then it's telling you that you need 90% elevator to hold the approach angle of attack. But that is not stall. The aircraft won't be able to achieve a true stall (though it might achieve a kind of mushy pre-stall.) To bring the aircraft to a stall attitude, you'd need much more elevator authority, in this case something like -0.5. But be mindful that many aircraft, especially those with high-lift wings, aren't meant to fly at near stall attitudes-- that's why they're high-lift, so you can fly very slow or with very high payloads without falling out of the sky. So elevator authority for many such planes simply won't give you a stall in normal usage. The behavior depends on the specific aircraft, so be sure to study your aircraft's flight manual and pilot reports.
CG
This is where the solver has placed the aircraft's center of gravity. See YASim Weight and Balance for more information on the importance of CG placement. A solution is not necessary for the solver to place the CG. When working on weight and balance, I often use the command-line solver to show the CG result without caring about the other solver values.
Inertia tensor [kg*m^2] Origo at CG
This gives some idea of how the aircraft's mass is distributed about the center of gravity. Those new to YASim can safely ignore the inertia tensor and still obtain good results from YASim. For more information, see Inertia Tensors and YASim.
Closing Thoughts
If your YASim configuration is well thought-out, the solver may give you a flyable result on your first try. It's more likely that you will have to change and tune many settings before you get something flyable, and do much more before you get something that approaches the characteristics you want.
Here I've outlined the basics of YASim solutions and the solver. But there's a lot more to getting good solutions. For additional help, I've outlined some of the common problems and possible aids here: YASim Solution Troubleshooting
Getting a solution from the solver is only one step toward a good flight model. A successful solution will likely reward you with something that will fly, but that does not mean the flight model is realistic. That will take a lot of study, a lot of flying, a lot of FDM refinement, and a lot of patience. You will be using the command-line solver over and over as you refine your YASim FDM into something that approaches the characteristics of the real aircraft.