1 /**************************************************************** 2 * FUNCTION gas - specifies the working gas properties * 3 * FILENAME: gas.c * 4 * PROGRAMMER: izzi urieli * 5 * DATE: 95/12/02 * 6 * LAST MODIFICATION: 96/08/16 by I Urieli * 7 * INCLUDE: , , "define.h" * 8 * GLOBAL VARIABLES: * 9 * FILE *infile - pointer to the input data file * 10 * FILE *outfile - pointer to the output data file * 11 * FILE *printfile - pointer to the print output file * 12 * double rgas - gas constant (Joules/kg.K) * 13 * double cp - specific heat at const pressure (J/kg.K) * 14 * double cv - specific heat at const volume (J/kg.K) * 15 * double gama - ratio (cp / cv) * 16 * double mu0 - dynamic viscosity at ref temp t0 (kg.m/s) * 17 * double t0 - reference temperature (273 K) * 18 * double t_suth - Sutherland constant for dynamic viscosity * 19 * double prandtl - Prandtl number (0.71) * 20 * PROTOTYPE: void gas(void); * 21 * PRE: global variables infile, outfile and printfile have * 22 * been specified * 23 * POST: global variables rgas, cp, cv, gama, mu0, t0, t_suth, * 24 * and Prandtl have been specified * 25 ****************************************************************/ 26 #include 27 #include 28 #include "define.h" 29 30 void gas() 31 { 32 char mygas[3]; 33 34 fgetc(infile); /* remove "return" char from input buffer */ 35 do { 36 printf("enter gas type: h2 (hydrogen), he (helium),ai (air): "); 37 fflush(stdin); 38 fgets(mygas, 3, infile); 39 if (strcmp(mygas, "h2") == 0) { 40 fprintf(outfile, "\n%s\n", mygas); 41 printf(" gastype is hydrogen\n"); 42 fprintf(printfile, "\n gastype is hydrogen\n"); 43 gama = 1.4; 44 rgas = 4157.2; 45 mu0 = 8.35e-6; 46 t_suth = 84.4; 47 } 48 else if (strcmp(mygas, "he") == 0) { 49 fprintf(outfile, "\n%s\n", mygas); 50 printf("\n gastype is helium\n"); 51 fprintf(printfile, " gastype is helium\n"); 52 gama = 1.67; 53 rgas = 2078.6; 54 mu0 = 18.85e-6; 55 t_suth = 80.0; 56 } 57 else if (strcmp(mygas, "ai") == 0) { 58 fprintf(outfile, "\n%s\n", mygas); 59 printf(" gastype is air\n"); 60 fprintf(printfile, "\n gastype is air\n"); 61 gama = 1.4; 62 rgas = 287.0; 63 mu0 = 17.08e-6; 64 t_suth = 112.0; 65 } 66 else { 67 printf(" gastype %s is undefined\n", mygas); 68 strcpy(mygas, "un"); 69 } 70 } while (strcmp(mygas, "un") == 0); 71 cv = rgas / (gama - 1.0); 72 cp = gama * cv; 73 t0 = 273.0; 74 prandtl = 0.71; 75 } condor{t.gentry}14: