Ch produced plot /* SIMULATION OF SHUTTLE TAKE OFF & FLIGHT UP TO MAIN ENGINE SEPARATION */ /* contributed by IVOR J LEWIS for Ch users*/ #include <chplot.h> #include <math.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <time.h> time_t ltime; float z=32.2,b=16788,f=2622,po=7,t=2,w4=365000,w5=190000,r1=134,r2=494; float f1o=-32.2,h=2,t1=5800000,t2=1410000,w2=2216000,w3=1360000,w1=4410000; float x1o=0,y1o=0,c1,co,f2,f3,i,j,k,la,m1,m2,mh,n1,n2,y1a,S[255]; float r,ro,u,ug,vg,wg,x,xa,xd,xg,xl,xr,y,ya,yb,yd,yg,yt,zg; float miny,minx,maxy,maxx,to,amaxy,amaxx,fq,ds,tq,xt,xb,xk,az,yk,za,fg,bn; float aminy,aminx,ato,axo,avo,ago,xo,yo,f1a,tt1,tI,an; float x1,x2,x3,x4,zz,y2,y3,y4,t3, f1, f4,q,p; int l,hm,tm,it,id,nv; int np=255; array double D[np],E[np],G[np],GL[np],AI[np],PW[np],SI[np],AU[np],V[np],W[np]; char buffer [np]; string_t title="Shuttle Flight Parameters - Zero to 500 seconds from Lift Off", xlabel="Time - secs", ylabel="Magnitude"; class CPlot plot; main(argc, argv) /* MAIN DRIVER START ****************************** */ int argc; char *argv[]; { time(&ltime); printf("\n"); printf(" This program is the property of Ivor J Lewis\n"); printf(" CURRENT TIME %s\n", ctime (&ltime)); printf(" SIMULATED LIFT-OFF AND INITIAL LAUNCH OF THE SPACE SHUTTLE\n\n"); /* SUMMARY OF INITIAL PRE-FLIGHT CONDITIONS************************* */ printf("* INITIAL PRE¡ª FLIGHT PARAMETERS *\n\n" ); printf("* SOLID BURN RATE = %12.2f LB/SEC\n",b); printf("* G CONSTANT = %12.2f FT/SEC\n",z); printf("* DRAG COEFFICEINT = %12.2f FT/FT~2/SEC^2\n",po); printf("* LIQUID BURN RATE = %12.2f LB/SEC\n",f); printf("* SOLID ROCKET WEIGHT = %12.2f LB\n",w4); printf("* LIFT OFF TIME REFERENCE = %12.2f SEC\n",t); printf("* BOOSTER SEPARATION TIME = %12.2f SEC\n",r1); printf("* MAIN ENGINE WEIGHT = %12.2f LB\n",w5); printf("* RELATIVE ACCELERATION BATE = %12.2f FT/SEC\n",f1o); printf("* MAIN ENGINE SEPARATION TIME = %12.2f SEC\n",r2); printf("* BOOSTER THRUST = %12.2f LB\n",t1); printf("* FLIGHT TIME INCREMENT = %12.2f SEC\n",h); printf("* SOLID FUEL WEIGHT = %12.2f LB\n",w2); printf("* MAIN ENGINE THRUST = %12.2f LB\n",t2); printf("* INITIAL TOTAL WEIGHT = %12.2f LB\n",w1); printf("* LIQUID FUEL WEIGHT = %12.2f LB\n",w3); printf("* INITIAL VELOCITY REFERENCE = %12.2f FT/SEC\n",y1o); printf("* GROUND ZERO REFERENCE = %12.2f FT\n\n",x1o); printf("PRESS RETURN TO CONTINUE\n"); getchar(); printf("\n"); printf("\n"); printf("\n\n"); /* CALCULATION OF FLIGHT PARAMETERS */ int i; float y1; l_newc:; for (i=1;i<=(np);i++) { tI=q=c1=0; x1=x1o; y1=y1o; f1=f1o; p=po; W[0] = E[0]= D[0] = V[0]= AI[0] = 0.0; SI[0] = 2.0; G[0] = -32.2; r = tI; q = p; c1 = w1; nv=1; W[0]=c1; for(i=0; i <= np-1; i++) { if(r < 9) goto l_510; t3 = t1 + t2; goto l_530; l_510:; t3 = (r * (t1 + t2)) / 9.; c1 = w1; goto l_830; l_530: if(r > r1) goto l_560; c1 = w1- ((b + f) * r); zz = z / c1; goto l_610; l_560:; if(r > r2) goto l_590; c1 = (w1 - w4 - w2 - (f * r)); zz=z / c1; goto l_610; l_590:; c1 = w1 - w4 - w2 - w5 - w3; zz = z / c1; t2 = t2 * .416; l_610:; x2 = x1 + (h * y1) / 2; y2 = y1 + (h * f1) / 2; if(r > r1) goto l_650; f2 = zz * (t3 - c1 -( q * y2*y2)); goto l_660; l_650:; f2 = zz * (t2 - c1 -( q * y2*y2)); l_660: ; x3 = x1 + h * y2/2; y3 = y1 + h * f2 / 2; if( (r > r1)) goto l_700; f3 = zz * (t3 - c1 - q * y3*y3); goto l_710; l_700:; f3 = zz * (t2 - c1 - q * y3*y3); l_710:; x4=x1+h*y3; y4 = y1 + h * f3; if(r > r1) goto l_750; f4 = zz * (t3 - c1 - q * y4 * y4); goto l_760; l_750: ; f4 = zz * (t2 - c1 - q * y4 * y4); l_760:; D[(i)] = x1 + h * (y1 + 2 * y2 + 2 * y3 + y4) / 6; V[(i)] = y1 + h * (f1 + 2 * f2 + 2 * f3 + f4) / 6; if(r > r1) goto l_810; G[(i)] = zz * (t3 - c1 - q * V[(i)]*V[(i)]); goto l_930; l_810: ; G[(i)] = zz * (t2 - c1 - q * V[(i)]*V[(i)]); goto l_930; l_830:; G[(i)] = (t3 * z / w1) - z; if(G[(i)] < 0) goto l_910; V[(i)] = ((G[(i - 1)] + G[(i)]) / 2)* h; if(V[(i)] < 0) goto l_910; D[(i)] = ((V[(i - 1)] + V[(i)])/ 2)* h; if(D[(i)] < 0) goto l_910; if(r == 7) goto l_930; goto l_940; l_910: ; D[(i)] = 0; V[(i)] = 0; goto l_940; l_930: ; f1 = G[(i)]; x1 = D[(i)]; y1 = V[(i)]; l_940: ; SI[(i)] = tI + h; tI = SI[(i)]; AI[(i)] = SI[(i)] - 4; E[(i)] = q * V[(i)]*V[(i)]; if(D[(i)] > 300000.) goto l_990; goto l_1010; l_990: ; E[(i)] = 0.; l_1010:; AU[(i)] = V[(i)] / 998.96; GL[(i)] = ((G[(i)] + 32.2) / 32.2); PW[(i)] = V[(i)] * c1 / 550; mh =.68181818 * V[(i)]; W[i]=c1; r=tI +h; if((r > r2) && (D[(i)] > 300000.)) goto l_1370; if((r > r1) && (D[(i)] > 300000.)) goto l_1390; goto l_1400; l_1370:; p = .343 * p; goto l_1400; l_1390:; p = .66 * p; l_1400: ; if(D[(i)] > 300000.) goto l_1430; q = (p * 1.12 * 1 / exp(4.1865e-05 * x1)); goto l_1440; l_1430:; q = 0.; l_1440:; } for (i=0;i<np;i++) { /* start of plot routines */ AI[0]=0; G[0]=-32.2; W[0]=0; E[0]=0; V[0]=0; PW[0]=0; D[0]=0; GL[0]=0; printf("\n\n"); plot.axisRange(PLOT_AXIS_X, 0, AI[(np-1)], 25); plot.axisRange(PLOT_AXIS_Y, 0-20,100,5); plot.grid(PLOT_ON); plot.data2D(AI,(G/2)); plot.data2D(AI,(W/50000)); plot.data2D(AI,(E/25000)); plot.data2D(AI,(V/150)); plot.data2D(AI,(PW/250000)); plot.data2D(AI,((D/5280)/5)); plot.data2D(AI,(GL*20)); /* Plot data scaled to suit graphic layout*/ plot.legend("G Acceleration - ft/sec^2- Div 2",0); plot.legend("W Shuttle Flight weight - lb- Div 50000",1); plot.legend("E Drag Force - lb -Div 25000",2); plot.legend("V Shuttle Speed - m.p.h - Div 150",3); plot.legend("PW Developed HP - Div 250000",4); plot.legend("D Distance into Flight - miles -Div 5",5); plot.legend("GL G-Load -Times 20",6); plot.legendLocation(380,97); plot.title(title); plot.label(PLOT_AXIS_X, xlabel); plot.label(PLOT_AXIS_Y, ylabel); plot.grid(PLOT_ON); plot.plotting(); /* end of plot routines */ if(i=np)goto l_7000; } l_7000:; /* CALCULATE SPECIFIC TIME FRAMES */ int nimp; float sm; printf("\n"); printf("TO LIST A FLIGHT TIME SUMMARY INPUT VALUE -2 TO 500\n"); printf("ENTER TIME VALUE <= 504\t"); scanf("%d",&it); if(it > 504) goto l_tv1; it =(it/2+2); printf("* TIME INTO LAUNCH %12.2f SEC\n",AI[it]); printf("* RANGE DISTANCE %12.2f FT\n",D[it]); printf("* RANGE DISTANCE %12.2f MI\n",D[it]/5280); printf("* SHUTTLE VELOCITY %12.2f FT/SEC\n",V[it]); printf("* EQUIVILANT LAND SPEED %12.2f MPH\n",.68181818*V[it]); printf("* RELATIVE ACCELERATION %12.2f FT/SEC^2\n",G[it]); printf("* AERODYNAMIC DRAG FORCE %12.2f LB\n",E[it]); printf("* MACH NUMBER %12.2f M\n",AU[it]); printf("* G LOADING %12.2f G\n",GL[it]); printf("* DEVELOPED HORSE POWER %12.2f HP\n",PW[it]); printf("* TOTAL WEIGHT OF SHUTTLE %12.2f LB\n",W[it]); l_tv1:; /* REDO CALCULATION CHANGING PARAMETERS*/ int iq; if(it > 504) goto l_e1; printf("TO CHANGE BOOSTER THRUST INPUT VALUE 5800000 LB\n"); printf("ENTER NEW VALUE OR ZERO\t"); scanf("%f",&an); t1=an; getchar (); printf("TO CHANGE MAIN ENGINE THRUST INPUT VALUE 1410000 LB\n"); printf("ENTER NEW VALUE OR ZERO\t"); scanf("%f",&bn); t2=bn; if(bn==0 && an==0) goto l_e1; getchar(); goto l_newc; l_e1:; printf("END OF PROGRAM\n"); exit(0); } }