1 /****************************************************************** 2 * FUNCTION engine - specifies engine working space geometry * 3 * FILENAME engine.c * 4 * PROGRAMMER I.Urieli 951214 (FORTRAN) * 5 * E. Malroy 951218 (C Translation) * 6 * LAST MODIFICATION: 02/15/97 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 * myeng - determines the engine configuration * 12 * 's' (sinusoidal drive) * 13 * 'y' (ross yoke drive) * 14 * PROTOTYPE: void engine(void); * 15 * PRE: infile, outfile have been determined * 16 * POST: the engine geometry has been defined * 17 ******************************************************************/ 18 #include 19 #include 20 #include "define.h" 21 22 void sinedr(void); /* ideal sinusoidal drive */ 23 void yokedr(void); /* ross yoke drive */ 24 25 void engine(void) 26 { 27 do { 28 printf("enter engine configuration\n"); 29 printf(" s, for sinusoidal drive\n"); 30 printf(" y, for ross yoke drive\n"); 31 fflush(stdin); 32 myeng = fgetc(infile); 33 if (myeng == 's') { 34 fprintf(outfile, "%c\n", myeng); 35 sinedr(); 36 } 37 else if (myeng == 'y') { 38 fprintf(outfile,"%c\n", myeng); 39 yokedr(); 40 } 41 else { 42 printf( "Engine config. %c undefined", myeng); 43 myeng = 'u'; 44 } 45 } while(myeng =='u'); 46 } 47 48 /******************************************************************* 49 * FUNCTION sinedr - specify sinusoidal drive geometry * 50 * FILENAME: engine.c * 51 * PROGRAMMER: I. Urieli 930301 (FORTRAN) * 52 * E. Malroy 950118 (Conversion to "C") * 53 * DATE: 930301/950118 * 54 * LAST MODIFICATION: 08/16/96 by I. Urieli * 55 * INCLUDE: ,"define.h" * 56 * GLOBAL VARIABLES: * 57 * vclc,vcle: compression,expansion clearance volumes (cu.m) * 58 * vswc,vswe: compression,expansion swept volumes (cu.m) * 59 * alpha: expansion space phase angle advance (radians) * 60 * PROTOTYPE: void sinedr(void) * 61 * PRE: infile, outfile, printfile * 62 * POST: global variables vclc, vcle, vswc, vswe, alpha * 63 *******************************************************************/ 64 void sinedr() 65 { 66 printf(" Sinusoidal drive configuration:\n"); 67 fprintf(printfile," Sinusoidal drive configuration:\n"); 68 69 printf(" Enter comp. swept, clearance vols (m**3)\n"); 70 fscanf(infile,"%lf %lf", &vswc,&vclc); 71 fprintf(outfile," %.3e %.3e\n", vswc,vclc); 72 fprintf(printfile, " comp. swept, clearance vols (m**3):\n"); 73 fprintf(printfile, " %.3e %.3e\n", vswc,vclc); 74 75 printf(" Enter exp. swept, clearance vols (m**3)\n"); 76 fscanf(infile, "%lf %lf", &vswe, &vcle); 77 fprintf(outfile," %.3e %.3e\n", vswe,vcle); 78 fprintf(printfile," exp. swept, clearance vols (m**3):\n"); 79 fprintf(printfile," %.3e %.3e\n", vswe,vcle); 80 81 printf(" enter phase advance angle \"alpha\" (rads):\n"); 82 fscanf(infile,"%lf", &alpha); 83 fprintf(outfile," %.3f\n",alpha); 84 fprintf(printfile," phase advance angle \"alpha\" (rads):\n"); 85 fprintf(printfile," %.3f\n",alpha); 86 } 87 88 /****************************************************************** 89 * FUNCTION yokedr - specifies the ideal Ross yoke drive geometry * 90 * FILENAME engine.c * 91 * PROGRAMMER I. Urieli (significant revision of E. Malroy) * 92 * DATE: 01/15/97 * 93 * INCLUDE: ,"define.h" * 94 * GLOBAL VARIABLES: * 95 * FILE *infile - pointer to the input data file * 96 * FILE *outfile - pointer to the output data file * 97 * FILE *printfile - pointer to the print output file * 98 * alpha: mean phase angle advance * 99 * vclc: compression space clearance volume (m^3) * 100 * vcle: expansion space clearance volume (m^3) * 101 * vswc: compression space swept volume (m^3) * 102 * vswe: expansion space swept volume (m^3) * 103 * crank: crank radius (m) * 104 * b1: height of yoke (m) * 105 * b2: (yoke base length)/2 (m) * 106 * acomp: area of compression space piston (m^2) * 107 * aexp: area of expansion space piston (m^2) * 108 * ymin - minimum yoke vertical displacement (m) * 109 * PRE: infile, outfile, printfile * 110 * POST: the engine global variables are defined * 111 ******************************************************************/ 112 void yokedr(void) 113 { 114 115 double dcomp, dexp; /* compression, expansion piston diameters (m) */ 116 double yoke, /* yoke diagonal length (m) */ 117 ymax, /* maximum vertical displacement of yoke (m) */ 118 thmaxe, thmaxc, /* crank angles of max exp., comp. displacement */ 119 thmine, thminc; /* crank angles of min exp., comp. displacement */ 120 121 printf(" Ross yoke drive configuration:\n"); 122 fprintf(printfile," Ross yoke drive configuration:\n"); 123 124 printf("enter comp/exp clearance volumes - vclc & vcle (m^3)\n"); 125 fscanf(infile," %lf %lf", &vclc, &vcle); 126 fprintf(outfile," %f %f\n", vclc, vcle); 127 fprintf(printfile," comp clearance volume, exp clearance vol (m^3)\n"); 128 fprintf(printfile," %8.4e %8.4e\n", vclc, vcle); 129 130 printf("enter Ross yoke lengths b1, b2 & crank (m)\n"); 131 fscanf(infile,"%lf %lf %lf", &b1, &b2, &crank); 132 fprintf(outfile," %f %f %f\n", b1, b2, crank); 133 fprintf(printfile," Ross yoke lengths b1, b2 & crank (m)\n"); 134 fprintf(printfile," %8.4f %8.4f %8.4f\n", b1, b2, crank); 135 136 printf("enter compression & expansion space diameters - dcomp & dexp (m)\n"); 137 fscanf(infile,"%lf%lf", &dcomp, &dexp); 138 fprintf(outfile," %f %f\n", dcomp, dexp); 139 fprintf(printfile," compression & expansion space diameters (m)\n"); 140 fprintf(printfile," %.3f %.3f\n", dcomp, dexp); 141 142 acomp = PI * dcomp * dcomp / 4.0; 143 aexp = PI * dexp * dexp / 4.0; 144 yoke = sqrt(b1 * b1 + b2 * b2); 145 ymax = sqrt((yoke + crank) * (yoke + crank) - b2 * b2); 146 ymin = sqrt((yoke - crank) * (yoke - crank) - b2 * b2); 147 148 vswc = acomp * (ymax - ymin); 149 vswe = aexp * (ymax - ymin); 150 thmaxe = asin(ymax / (yoke + crank)); 151 thmaxc = PI - thmaxe; 152 thmine = PI + asin(ymin / (yoke - crank)); 153 thminc = 3 * PI - thmine; 154 alpha = 0.5 * (thmaxc - thmaxe) + 0.5 * (thminc - thmine); 155 156 printf(" ymin = %.3f(m), ymax = %.3f(m)\n",ymin,ymax); 157 printf(" alpha = %.3f(rad)\n",alpha); 158 printf(" vswc= %8.4e(m^3), vswe %8.4e(m^3)\n", vswc, vswe); 159 fprintf(printfile," ymin = %.3f(m), ymax = %.3f(m)\n",ymin,ymax); 160 fprintf(printfile," alpha = %.3f(rad)\n",alpha); 161 fprintf(printfile," vswc= %8.4e(m^3), vswe %8.4e(m^3)\n", vswc, vswe); 162 } 163 condor{t.gentry}4: