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

📄 perf.c

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

void main() {
	
/* Input Declarations */

double LoverD;
double Wtot; 
double Wfueltot;
double eta;
double sfc;
double Swing;
double Clmax;

/* Output Declarations */

double Wfuelcruise;
double R;
double Range;
double Vstall;
double rhosea;

FILE *fp;

/* Get Inputs */

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

fscanf(fp,"\n");
fscanf(fp," ==== Performance Analysis Input File ==== \n");
fscanf(fp,"\n");
fscanf(fp,"LoverD = %lf\n", &LoverD);
fscanf(fp,"Wtot = %lf\n", &Wtot);
fscanf(fp,"Wfueltot = %lf\n", &Wfueltot);
fscanf(fp,"eta = %lf\n", &eta);
fscanf(fp,"sfc = %lf\n", &sfc);
fscanf(fp,"Swing = %lf\n", &Swing);
fscanf(fp,"Clmax = %lf\n", &Clmax);
fclose(fp);

/* 	unit conversion for specific fuel consumption */

Wfuelcruise=0.85*Wfueltot;
R=(eta*LoverD/sfc)*log(Wtot/(Wtot-Wfuelcruise));
Range=R/5280.0;

/* sea level stall speed */

rhosea = 0.002378;
Vstall=sqrt(2.*Wtot/(rhosea*Swing*Clmax));

/* Print Outputs */

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

fprintf(fp,"\n");
fprintf(fp," ==== Performance Analysis Output File ====\n");
fprintf(fp,"\n");
fprintf(fp, "Total Weight of Fuel (lbs.)                = %15.6G \n", Wfueltot);
fprintf(fp, "Weight of Fuel Available for Cruise (lbs.) = %15.6G \n", Wfuelcruise);
fprintf(fp, "\n");
fprintf(fp, "Max. Range (miles)                         = %15.6G \n", Range);
fprintf(fp, "Stall Speed (miles/hr)                     = %15.6G \n", Vstall);
fclose(fp);

exit (0);
}

⌨️ 快捷键说明

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