Add a lift/drag vs. AoA graph option to the yasim tool, which
generates a data file of aerodynamic lift and drag (and L/D) against AoA at a specified speed and altitude through a full circle. Wrote it to track down the YF-23 superthrust issue, but it wasn't any help. All the forces look fine.
This commit is contained in:
parent
13ce1e48fb
commit
90e7c4ec43
2 changed files with 76 additions and 18 deletions
|
@ -90,6 +90,8 @@ public:
|
||||||
float getApproachElevator() { return _approachElevator.val; }
|
float getApproachElevator() { return _approachElevator.val; }
|
||||||
char* getFailureMsg();
|
char* getFailureMsg();
|
||||||
|
|
||||||
|
static void setupState(float aoa, float speed, State* s); // utility
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Tank { float pos[3]; float cap; float fill;
|
struct Tank { float pos[3]; float cap; float fill;
|
||||||
float density; int handle; };
|
float density; int handle; };
|
||||||
|
@ -104,7 +106,6 @@ private:
|
||||||
|
|
||||||
void runCruise();
|
void runCruise();
|
||||||
void runApproach();
|
void runApproach();
|
||||||
void setupState(float aoa, float speed, State* s);
|
|
||||||
void solveGear();
|
void solveGear();
|
||||||
void solve();
|
void solve();
|
||||||
void solveHelicopter();
|
void solveHelicopter();
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <simgear/xml/easyxml.hxx>
|
#include <simgear/xml/easyxml.hxx>
|
||||||
|
|
||||||
#include "FGFDM.hpp"
|
#include "FGFDM.hpp"
|
||||||
|
#include "Atmosphere.hpp"
|
||||||
#include "Airplane.hpp"
|
#include "Airplane.hpp"
|
||||||
|
|
||||||
using namespace yasim;
|
using namespace yasim;
|
||||||
|
@ -19,12 +20,61 @@ float fgGetDouble (const char * name, double defaultValue) { return 0; }
|
||||||
float fgSetDouble (const char * name, double defaultValue) { return 0; }
|
float fgSetDouble (const char * name, double defaultValue) { return 0; }
|
||||||
|
|
||||||
static const float RAD2DEG = 57.2957795131;
|
static const float RAD2DEG = 57.2957795131;
|
||||||
|
static const float DEG2RAD = 0.0174532925199;
|
||||||
|
static const float KTS2MPS = 0.514444444444;
|
||||||
|
|
||||||
|
|
||||||
|
// Generate a graph of lift, drag and L/D against AoA at the specified
|
||||||
|
// speed and altitude. The result is a space-separated file of
|
||||||
|
// numbers: "aoa lift drag LD" (aoa in degrees, lift and drag in
|
||||||
|
// G's). You can use this in gnuplot like so (assuming the output is
|
||||||
|
// in a file named "dat":
|
||||||
|
//
|
||||||
|
// plot "dat" using 1:2 with lines title 'lift', \
|
||||||
|
// "dat" using 1:3 with lines title 'drag', \
|
||||||
|
// "dat" using 1:4 with lines title 'LD'
|
||||||
|
//
|
||||||
|
void yasim_graph(Airplane* a, float alt, float kts)
|
||||||
|
{
|
||||||
|
Model* m = a->getModel();
|
||||||
|
State s;
|
||||||
|
|
||||||
|
m->setAir(Atmosphere::getStdPressure(alt),
|
||||||
|
Atmosphere::getStdTemperature(alt),
|
||||||
|
Atmosphere::getStdDensity(alt));
|
||||||
|
m->getBody()->recalc();
|
||||||
|
|
||||||
|
for(int deg=-179; deg<=179; deg++) {
|
||||||
|
float aoa = deg * DEG2RAD;
|
||||||
|
Airplane::setupState(aoa, kts * KTS2MPS, &s);
|
||||||
|
m->getBody()->reset();
|
||||||
|
m->initIteration();
|
||||||
|
m->calcForces(&s);
|
||||||
|
|
||||||
|
float acc[3];
|
||||||
|
m->getBody()->getAccel(acc);
|
||||||
|
Math::tmul33(s.orient, acc, acc);
|
||||||
|
|
||||||
|
float drag = acc[0] * (-1/9.8);
|
||||||
|
float lift = 1 + acc[2] * (1/9.8);
|
||||||
|
|
||||||
|
printf("%d %g %g %g\n", deg, lift, drag, lift/drag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int usage()
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage: yasim <ac.xml> [-g [-a alt] [-s kts]]\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
FGFDM* fdm = new FGFDM();
|
FGFDM* fdm = new FGFDM();
|
||||||
Airplane* a = fdm->getAirplane();
|
Airplane* a = fdm->getAirplane();
|
||||||
|
|
||||||
|
if(argc < 2) return usage();
|
||||||
|
|
||||||
// Read
|
// Read
|
||||||
try {
|
try {
|
||||||
string file = argv[1];
|
string file = argv[1];
|
||||||
|
@ -36,7 +86,18 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
// ... and run
|
// ... and run
|
||||||
a->compile();
|
a->compile();
|
||||||
|
if(a->getFailureMsg())
|
||||||
|
printf("SOLUTION FAILURE: %s\n", a->getFailureMsg());
|
||||||
|
|
||||||
|
if(!a->getFailureMsg() && argc > 2 && strcmp(argv[2], "-g") == 0) {
|
||||||
|
float alt = 5000, kts = 100;
|
||||||
|
for(int i=3; i<argc; i++) {
|
||||||
|
if (strcmp(argv[i], "-a") == 0) alt = atof(argv[++i]);
|
||||||
|
else if(strcmp(argv[i], "-s") == 0) kts = atof(argv[++i]);
|
||||||
|
else return usage();
|
||||||
|
}
|
||||||
|
yasim_graph(a, alt, kts);
|
||||||
|
} else {
|
||||||
float aoa = a->getCruiseAoA() * RAD2DEG;
|
float aoa = a->getCruiseAoA() * RAD2DEG;
|
||||||
float tail = -1 * a->getTailIncidence() * RAD2DEG;
|
float tail = -1 * a->getTailIncidence() * RAD2DEG;
|
||||||
float drag = 1000 * a->getDragCoefficient();
|
float drag = 1000 * a->getDragCoefficient();
|
||||||
|
@ -51,11 +112,7 @@ int main(int argc, char** argv)
|
||||||
printf(" Tail Incidence: %f\n", tail);
|
printf(" Tail Incidence: %f\n", tail);
|
||||||
printf("Approach Elevator: %f\n", a->getApproachElevator());
|
printf("Approach Elevator: %f\n", a->getApproachElevator());
|
||||||
printf(" CG: %.3f, %.3f, %.3f\n", cg[0], cg[1], cg[2]);
|
printf(" CG: %.3f, %.3f, %.3f\n", cg[0], cg[1], cg[2]);
|
||||||
|
}
|
||||||
if(a->getFailureMsg())
|
|
||||||
printf("SOLUTION FAILURE: %s\n", a->getFailureMsg());
|
|
||||||
|
|
||||||
delete fdm;
|
delete fdm;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue