/************************************************************* * FUNCTION engine - specifies engine working space geometry * * FILENAME engine.c * * PROGRAMMER I.Urieli 951214 (FORTRAN) * * E. Malroy 951218 (C Translation) * * LAST MODIFICATION: 02/15/97 by I. Urieli * * INCLUDE: , , "define.h" * * GLOBAL VARIABLES: * * FILE *infile - pointer to the input data file * * FILE *outfile - pointer to the output data file * * myeng - determines the engine configuration * * 's' (sinusoidal drive) * * 'y' (ross yoke drive) * * PROTOTYPE: void engine(void); * * PRE: infile, outfile have been determined * * POST: the engine geometry has been defined * *************************************************************/ #include #include #include "define.h" void sinedr(void); /* ideal sinusoidal drive */ void yokedr(void); /* ross yoke drive */ void engine(void) { do { printf("enter engine configuration\n"); printf(" s, for sinusoidal drive\n"); printf(" y, for ross yoke drive\n"); fflush(stdin); myeng = fgetc(infile); if (myeng == 's') { fprintf(outfile, "%c\n", myeng); sinedr(); } else if (myeng == 'y') { fprintf(outfile,"%c\n", myeng); yokedr(); } else { printf( "Engine config. %c undefined", myeng); myeng = 'u'; } } while(myeng =='u'); } /************************************************************** * FUNCTION sinedr - specify sinusoidal drive geometry * * FILENAME: engine.c * * PROGRAMMER: I. Urieli 930301 (FORTRAN) * * E. Malroy 950118 (Conversion to "C") * * DATE: 930301/950118 * * LAST MODIFICATION: 08/16/96 by I. Urieli * * INCLUDE: ,"define.h" * * GLOBAL VARIABLES: * * vclc,vcle: compressn,expansion clearance volumes(cu.m)* * vswc,vswe: compression,expansion swept volumes (cu.m) * * alpha: expansion space phase angle advance (radians) * * PROTOTYPE: void sinedr(void) * * PRE: infile, outfile, printfile * * POST: global variables vclc, vcle, vswc, vswe, alpha * **************************************************************/ void sinedr() { printf(" Sinusoidal drive configuration:\n"); fprintf(printfile," Sinusoidal drive configuration:\n"); printf(" Enter comp. swept, clearance vols (m**3)\n"); fscanf(infile,"%lf %lf", &vswc,&vclc); fprintf(outfile," %.3e %.3e\n", vswc,vclc); fprintf(printfile, " comp. swept, clearance vols (m**3):\n"); fprintf(printfile, " %.3e %.3e\n", vswc,vclc); printf(" Enter exp. swept, clearance vols (m**3)\n"); fscanf(infile, "%lf %lf", &vswe, &vcle); fprintf(outfile," %.3e %.3e\n", vswe,vcle); fprintf(printfile," exp. swept, clearance vols (m**3):\n"); fprintf(printfile," %.3e %.3e\n", vswe,vcle); printf(" enter phase advance angle \"alpha\" (rads):\n"); fscanf(infile,"%lf", &alpha); fprintf(outfile," %.3f\n",alpha); fprintf(printfile," phase advance angle \"alpha\" (rads):\n"); fprintf(printfile," %.3f\n",alpha); } /****************************************************************** * FUNCTION yokedr - specifies the ideal Ross yoke drive geometry * * FILENAME engine.c * * PROGRAMMER I. Urieli (significant revision of E. Malroy) * * DATE: 01/15/97 * * INCLUDE: ,"define.h" * * GLOBAL VARIABLES: * * FILE *infile - pointer to the input data file * * FILE *outfile - pointer to the output data file * * FILE *printfile - pointer to the print output file * * alpha: mean phase angle advance * * vclc: compression space clearance volume (m^3) * * vcle: expansion space clearance volume (m^3) * * vswc: compression space swept volume (m^3) * * vswe: expansion space swept volume (m^3) * * crank: crank radius (m) * * b1: height of yoke (m) * * b2: (yoke base length)/2 (m) * * acomp: area of compression space piston (m^2) * * aexp: area of expansion space piston (m^2) * * ymin - minimum yoke vertical displacement (m) * * PRE: infile, outfile, printfile * * POST: the engine global variables are defined * ******************************************************************/ void yokedr(void) { double dcomp, dexp; /* compression, expansion piston diameters (m) */ double yoke, /* yoke diagonal length (m) */ ymax, /* maximum vertical displacement of yoke (m) */ thmaxe, thmaxc, /* crank angles of max exp., comp. displacement */ thmine, thminc; /* crank angles of min exp., comp. displacement */ printf(" Ross yoke drive configuration:\n"); fprintf(printfile," Ross yoke drive configuration:\n"); printf("enter comp/exp clearance volumes - vclc & vcle (m^3)\n"); fscanf(infile," %lf %lf", &vclc, &vcle); fprintf(outfile," %f %f\n", vclc, vcle); fprintf(printfile," comp clearance volume, exp clearance vol (m^3)\n"); fprintf(printfile," %8.4e %8.4e\n", vclc, vcle); printf("enter Ross yoke lengths b1, b2 & crank (m)\n"); fscanf(infile,"%lf %lf %lf", &b1, &b2, &crank); fprintf(outfile," %f %f %f\n", b1, b2, crank); fprintf(printfile," Ross yoke lengths b1, b2 & crank (m)\n"); fprintf(printfile," %8.4f %8.4f %8.4f\n", b1, b2, crank); printf("enter compression & expansion space diameters - dcomp & dexp (m)\n"); fscanf(infile,"%lf%lf", &dcomp, &dexp); fprintf(outfile," %f %f\n", dcomp, dexp); fprintf(printfile," compression & expansion space diameters (m)\n"); fprintf(printfile," %.3f %.3f\n", dcomp, dexp); acomp = PI * dcomp * dcomp / 4.0; aexp = PI * dexp * dexp / 4.0; yoke = sqrt(b1 * b1 + b2 * b2); ymax = sqrt((yoke + crank) * (yoke + crank) - b2 * b2); ymin = sqrt((yoke - crank) * (yoke - crank) - b2 * b2); vswc = acomp * (ymax - ymin); vswe = aexp * (ymax - ymin); thmaxe = asin(ymax / (yoke + crank)); thmaxc = PI - thmaxe; thmine = PI + asin(ymin / (yoke - crank)); thminc = 3 * PI - thmine; alpha = 0.5 * (thmaxc - thmaxe) + 0.5 * (thminc - thmine); printf(" ymin = %.3f(m), ymax = %.3f(m)\n",ymin,ymax); printf(" alpha = %.3f(rad)\n",alpha); printf(" vswc= %8.4e(m^3), vswe %8.4e(m^3)\n", vswc, vswe); fprintf(printfile," ymin = %.3f(m), ymax = %.3f(m)\n",ymin,ymax); fprintf(printfile," alpha = %.3f(rad)\n",alpha); fprintf(printfile," vswc= %8.4e(m^3), vswe %8.4e(m^3)\n", vswc, vswe); }