only white spaces
This commit is contained in:
parent
d4688d206a
commit
5f78545961
1 changed files with 91 additions and 91 deletions
|
@ -33,9 +33,9 @@ static const float KTS2MPS = 0.514444444444;
|
||||||
|
|
||||||
enum Config
|
enum Config
|
||||||
{
|
{
|
||||||
CONFIG_NONE,
|
CONFIG_NONE,
|
||||||
CONFIG_APPROACH,
|
CONFIG_APPROACH,
|
||||||
CONFIG_CRUISE,
|
CONFIG_CRUISE,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generate a graph of lift, drag and L/D against AoA at the specified
|
// Generate a graph of lift, drag and L/D against AoA at the specified
|
||||||
|
@ -50,70 +50,70 @@ enum Config
|
||||||
*/
|
*/
|
||||||
void yasim_graph(Airplane* a, float alt, float kts, int cfg = CONFIG_NONE)
|
void yasim_graph(Airplane* a, float alt, float kts, int cfg = CONFIG_NONE)
|
||||||
{
|
{
|
||||||
Model* m = a->getModel();
|
Model* m = a->getModel();
|
||||||
State s;
|
State s;
|
||||||
|
|
||||||
m->setAir(Atmosphere::getStdPressure(alt),
|
m->setAir(Atmosphere::getStdPressure(alt),
|
||||||
Atmosphere::getStdTemperature(alt),
|
Atmosphere::getStdTemperature(alt),
|
||||||
Atmosphere::getStdDensity(alt));
|
Atmosphere::getStdDensity(alt));
|
||||||
|
|
||||||
switch (cfg) {
|
switch (cfg) {
|
||||||
case CONFIG_APPROACH:
|
case CONFIG_APPROACH:
|
||||||
a->loadApproachControls();
|
a->loadApproachControls();
|
||||||
break;
|
break;
|
||||||
case CONFIG_CRUISE:
|
case CONFIG_CRUISE:
|
||||||
a->loadCruiseControls();
|
a->loadCruiseControls();
|
||||||
break;
|
break;
|
||||||
case CONFIG_NONE:
|
case CONFIG_NONE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//if we fake the properties we could also use FGFDM::getExternalInput()
|
//if we fake the properties we could also use FGFDM::getExternalInput()
|
||||||
|
|
||||||
|
|
||||||
m->getBody()->recalc();
|
m->getBody()->recalc();
|
||||||
|
|
||||||
for(int deg=-179; deg<=179; deg++) {
|
for(int deg=-179; deg<=179; deg++) {
|
||||||
float aoa = deg * DEG2RAD;
|
float aoa = deg * DEG2RAD;
|
||||||
Airplane::setupState(aoa, kts * KTS2MPS, 0 ,&s);
|
Airplane::setupState(aoa, kts * KTS2MPS, 0 ,&s);
|
||||||
m->getBody()->reset();
|
m->getBody()->reset();
|
||||||
m->initIteration();
|
m->initIteration();
|
||||||
m->calcForces(&s);
|
m->calcForces(&s);
|
||||||
|
|
||||||
float acc[3];
|
float acc[3];
|
||||||
m->getBody()->getAccel(acc);
|
m->getBody()->getAccel(acc);
|
||||||
Math::tmul33(s.orient, acc, acc);
|
Math::tmul33(s.orient, acc, acc);
|
||||||
|
|
||||||
float drag = acc[0] * (-1/9.8);
|
float drag = acc[0] * (-1/9.8);
|
||||||
float lift = 1 + acc[2] * (1/9.8);
|
float lift = 1 + acc[2] * (1/9.8);
|
||||||
|
|
||||||
printf("%d %g %g %g\n", deg, lift, drag, lift/drag);
|
printf("%d %g %g %g\n", deg, lift, drag, lift/drag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void yasim_masses(Airplane* a)
|
void yasim_masses(Airplane* a)
|
||||||
{
|
{
|
||||||
RigidBody* body = a->getModel()->getBody();
|
RigidBody* body = a->getModel()->getBody();
|
||||||
int i, N = body->numMasses();
|
int i, N = body->numMasses();
|
||||||
float pos[3];
|
float pos[3];
|
||||||
float m, mass = 0;
|
float m, mass = 0;
|
||||||
printf("id posx posy posz mass\n");
|
printf("id posx posy posz mass\n");
|
||||||
for (i = 0; i < N; i++)
|
for (i = 0; i < N; i++)
|
||||||
{
|
{
|
||||||
body->getMassPosition(i, pos);
|
body->getMassPosition(i, pos);
|
||||||
m = body->getMass(i);
|
m = body->getMass(i);
|
||||||
printf("%d %.3f %.3f %.3f %.3f\n", i, pos[0], pos[1], pos[2], m);
|
printf("%d %.3f %.3f %.3f %.3f\n", i, pos[0], pos[1], pos[2], m);
|
||||||
mass += m;
|
mass += m;
|
||||||
}
|
}
|
||||||
printf("Total mass: %g", mass);
|
printf("Total mass: %g", mass);
|
||||||
}
|
}
|
||||||
|
|
||||||
int usage()
|
int usage()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: yasim <ac.xml> [-g [-a alt] [-s kts] [-approach | -cruise] ]\n");
|
fprintf(stderr, "Usage: yasim <ac.xml> [-g [-a alt] [-s kts] [-approach | -cruise] ]\n");
|
||||||
fprintf(stderr, " yasim <ac.xml> [-m]\n");
|
fprintf(stderr, " yasim <ac.xml> [-m]\n");
|
||||||
fprintf(stderr, " -g print lift/drag table: aoa, lift, drag, lift/drag \n");
|
fprintf(stderr, " -g print lift/drag table: aoa, lift, drag, lift/drag \n");
|
||||||
fprintf(stderr, " -m print mass distribution table: id, x, y, z, mass \n");
|
fprintf(stderr, " -m print mass distribution table: id, x, y, z, mass \n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,50 +137,50 @@ int main(int argc, char** argv)
|
||||||
if(a->getFailureMsg())
|
if(a->getFailureMsg())
|
||||||
printf("SOLUTION FAILURE: %s\n", a->getFailureMsg());
|
printf("SOLUTION FAILURE: %s\n", a->getFailureMsg());
|
||||||
if(!a->getFailureMsg() && argc > 2 ) {
|
if(!a->getFailureMsg() && argc > 2 ) {
|
||||||
if(strcmp(argv[2], "-g") == 0) {
|
if(strcmp(argv[2], "-g") == 0) {
|
||||||
float alt = 5000, kts = 100;
|
float alt = 5000, kts = 100;
|
||||||
int cfg = CONFIG_NONE;
|
int cfg = CONFIG_NONE;
|
||||||
for(int i=3; i<argc; i++) {
|
for(int i=3; i<argc; i++) {
|
||||||
if (std::strcmp(argv[i], "-a") == 0) {
|
if (std::strcmp(argv[i], "-a") == 0) {
|
||||||
if (i+1 < argc) alt = std::atof(argv[++i]);
|
if (i+1 < argc) alt = std::atof(argv[++i]);
|
||||||
}
|
}
|
||||||
else if(std::strcmp(argv[i], "-s") == 0) {
|
else if(std::strcmp(argv[i], "-s") == 0) {
|
||||||
if(i+1 < argc) kts = std::atof(argv[++i]);
|
if(i+1 < argc) kts = std::atof(argv[++i]);
|
||||||
}
|
}
|
||||||
else if(std::strcmp(argv[i], "-approach") == 0) cfg = CONFIG_APPROACH;
|
else if(std::strcmp(argv[i], "-approach") == 0) cfg = CONFIG_APPROACH;
|
||||||
else if(std::strcmp(argv[i], "-cruise") == 0) cfg = CONFIG_CRUISE;
|
else if(std::strcmp(argv[i], "-cruise") == 0) cfg = CONFIG_CRUISE;
|
||||||
else return usage();
|
else return usage();
|
||||||
}
|
}
|
||||||
yasim_graph(a, alt, kts, cfg);
|
yasim_graph(a, alt, kts, cfg);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[2], "-m") == 0) {
|
else if(strcmp(argv[2], "-m") == 0) {
|
||||||
yasim_masses(a);
|
yasim_masses(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Solution results:");
|
printf("Solution results:");
|
||||||
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();
|
||||||
float cg[3];
|
float cg[3];
|
||||||
a->getModel()->getBody()->getCG(cg);
|
a->getModel()->getBody()->getCG(cg);
|
||||||
a->getModel()->getBody()->recalc();
|
a->getModel()->getBody()->recalc();
|
||||||
|
|
||||||
float SI_inertia[9];
|
float SI_inertia[9];
|
||||||
a->getModel()->getBody()->getInertiaMatrix(SI_inertia);
|
a->getModel()->getBody()->getInertiaMatrix(SI_inertia);
|
||||||
|
|
||||||
printf(" Iterations: %d\n", a->getSolutionIterations());
|
printf(" Iterations: %d\n", a->getSolutionIterations());
|
||||||
printf(" Drag Coefficient: %f\n", drag);
|
printf(" Drag Coefficient: %f\n", drag);
|
||||||
printf(" Lift Ratio: %f\n", a->getLiftRatio());
|
printf(" Lift Ratio: %f\n", a->getLiftRatio());
|
||||||
printf(" Cruise AoA: %f\n", aoa);
|
printf(" Cruise AoA: %f\n", aoa);
|
||||||
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: x:%.3f, y:%.3f, z:%.3f\n\n", cg[0], cg[1], cg[2]);
|
printf(" CG: x:%.3f, y:%.3f, z:%.3f\n\n", cg[0], cg[1], cg[2]);
|
||||||
printf("Inertia tensor [kg*m^2], origo at CG:\n");
|
printf("Inertia tensor [kg*m^2], origo at CG:\n");
|
||||||
printf(" %7.3f, %7.3f, %7.3f\n", SI_inertia[0], SI_inertia[1], SI_inertia[2]);
|
printf(" %7.3f, %7.3f, %7.3f\n", SI_inertia[0], SI_inertia[1], SI_inertia[2]);
|
||||||
printf(" %7.3f, %7.3f, %7.3f\n", SI_inertia[3], SI_inertia[4], SI_inertia[5]);
|
printf(" %7.3f, %7.3f, %7.3f\n", SI_inertia[3], SI_inertia[4], SI_inertia[5]);
|
||||||
printf(" %7.3f, %7.3f, %7.3f\n", SI_inertia[6], SI_inertia[7], SI_inertia[8]);
|
printf(" %7.3f, %7.3f, %7.3f\n", SI_inertia[6], SI_inertia[7], SI_inertia[8]);
|
||||||
}
|
}
|
||||||
delete fdm;
|
delete fdm;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue