⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aero.c

📁 多学科优化软件isight培训教程初级pdf有很详细的例子讲解
💻 C
字号:
#include <stdio.h>
#include <math.h>

void main() {
	
double b;
double AR; 
double Swing;
double Lfuse;
double Dfuse;
double Afuse;
double Swetted;
double LoverD;
double pi;
double tail;
double cone;
double cyl;
int i=1;

FILE *fp;

/*GetInputs */

if ((fp = fopen("AeroIn.txt","r"))==NULL) {
        printf("\n");
        printf("*** ERROR ***\n");
        printf("Cannot open input file AeroIn.txt. \n");
        printf("\n");
        exit (1);
    }

fscanf(fp,"\n");
fscanf(fp," ==== Aerodynamic Analysis Input File ==== \n");
fscanf(fp,"\n");
fscanf(fp, "Wing Span (ft)              b     = %lf\n", &b);
fscanf(fp, "Surface Area of the Wing    Swing = %lf ft^2\n", &Swing);
fscanf(fp, "Length of Fuselage          Lfuse = %lf ft\n", &Lfuse);
fscanf(fp, "Diameter of Fuselage        Dfuse = %lf ft\n", &Dfuse);
fclose(fp);


/* wetted area calculation */

AR=(b*b)/Swing; 
pi=4.0*atan(1.0);

cyl = (pi * Dfuse * 0.6*Lfuse);
cone = (pi * pow((Dfuse/2.0),2) * 0.4*Lfuse) / 3.0;

Afuse= cyl + cone + pi*pow((Dfuse/2.0),2);
tail= 4*(1.25*Dfuse)*(0.125*Lfuse) + 2*(1.5*Dfuse)*(0.15*Lfuse);
Swetted=Afuse + 2.0*Swing - 2.0*Dfuse*(Swing/b) + tail;

/* estimate lift to drag ratio at cruise */

LoverD= 10.0 + 4.0*(AR/(Swetted/Swing)-1.0);

if (LoverD > 16 ) { 
   LoverD=16.0; 
}

/* Print Outputs */

if ((fp = fopen("AeroOut.txt","w"))==NULL) {
        printf("\n");
        printf("*** ERROR ***\n");
        printf("Cannot open output file AeroOut.txt. \n");
        printf("\n");
        exit(1);
    }

fprintf(fp,"\n");
fprintf(fp," ==== Aerodynamic Analysis Output File ==== \n");
fprintf(fp,"\n");
/* fprintf(fp, "Aspect Ratio of the Wing     = %15.6G\n", AR); */
fprintf(fp, "Surface Area of the Fuselage = %15.6G  ft^2\n", Afuse);
fprintf(fp, "Wetted Area of the Aircraft  = %15.6G  ft^2\n", Swetted);
fprintf(fp, "Lift/Drag of the Aircraft    = %15.6G\n", LoverD);
fclose(fp);

/* Lines to Slow Down the Code to Demo Parallel Feature in iSIGHT */

/* while (i < 1500) {

    if ((fp = fopen("AeroLoop.txt","w"))==NULL) {
        printf("\n");
        printf("*** ERROR ***\n");
        printf("Cannot open temporary file AeroLoop.txt. \n");
        printf("\n");
        exit (1);
    }
    fprintf(fp,"%d",i);
    fclose(fp);
    i++;
  
};*/

exit (0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -