Skip to content

Commit

Permalink
Merge pull request #81 from dkavolis/#75
Browse files Browse the repository at this point in the history
Revert NaN stability derivates if stable AoA is not found
  • Loading branch information
dkavolis authored Oct 24, 2019
2 parents f47fc98 + b84b4a3 commit b6cc8ee
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,20 @@ double phi
1e-4,
minLimit: -90,
maxLimit: 90);
alpha = optResult.Result;
int calls = optResult.FunctionCalls;

// if stable AoA doesn't exist, calculate derivatives at 0 incidence
if (!optResult.Converged)
{
FARLogger.Info("Stable angle of attack not found, calculating derivatives at 0 incidence instead");
alpha = 0;
_instantCondition.FunctionIterateForAlpha(alpha);
calls += 1;
}
else
{
alpha = optResult.Result;
}

input.alpha = alpha;
nominalOutput = _instantCondition.iterationOutput;
Expand All @@ -269,9 +282,9 @@ double phi

stabDerivOutput.stableCl = neededCl;
stabDerivOutput.stableCd = nominalOutput.Cd;
stabDerivOutput.stableAoA = optResult.Converged ? alpha : double.NaN;
stabDerivOutput.stableAoA = alpha;
stabDerivOutput.stableAoAState = "";
if (optResult.Converged && Math.Abs((nominalOutput.Cl - neededCl) / neededCl) > 0.1)
if (Math.Abs((nominalOutput.Cl - neededCl) / neededCl) > 0.1)
stabDerivOutput.stableAoAState = nominalOutput.Cl > neededCl ? "<" : ">";

FARLogger.Info("Cl needed: " +
Expand All @@ -283,15 +296,7 @@ double phi
", Cd: " +
nominalOutput.Cd.ToString(CultureInfo.InvariantCulture) +
", function calls: " +
optResult.FunctionCalls.ToString());

if (!optResult.Converged)
{
// couldn't find stable AoA, no reason to compute invalid stability derivatives
for (int i = 3; i < 24; i++)
stabDerivOutput.stabDerivs[i] = double.NaN;
return stabDerivOutput;
}
calls.ToString());

//vert vel derivs
pertOutput.Cl = (pertOutput.Cl - nominalOutput.Cl) / (2 * FARMathUtil.deg2rad);
Expand Down
Binary file not shown.
Binary file modified GameData/FerramAerospaceResearch/Plugins/ferramGraph.dll
Binary file not shown.
Binary file modified bin/Debug/FerramAerospaceResearch.dll
Binary file not shown.
Binary file modified bin/Debug/ferramGraph.dll
Binary file not shown.

0 comments on commit b6cc8ee

Please sign in to comment.