[net.aviation] Airfoil drawing program - here it is

jk@utastro.UUCP (John Krist) (12/12/85)

     Here is the program which draws airfoils full size on an Epson
  printer.  It was written by Robert Aymar and was listed in Sports
  Aviation, a magazine by the Experimental Aircraft Association. It was
  in the March, 1985 issue.

     The program was written for TRS-80 Model III BASIC and an Epson
  printer.  For many BASICs, I suspect that only the port addresses
  in the INP and OUT functions will need changing.  The program here
  is listed exactly as it was in the article. No modifications have been
  made, nor any bugs fixed if there are any.  I have an IBM-PC and have
  not converted it to its BASIC.  

  Here is a summary of Mr. Aymar's description of his program:

  The menu prompts you to enter the desired index number of the airfoil
  to be plotted. You are then asked for the chord length.

  Lines 140-300 initialize variables.
  A table of offsets is then printed.
  Line 470 decides if the foil thickness is wider than the paper (8 in).
  Line 460 sets the printer to 1/8 inch line feed.
  Line 510 sets up the main loop for plotting in increments of 1/8 inch.
  Line 880-920 trap division by zero.
  Lines 940 and 950 calculate the offsets using a Fourier Series curve fit.
  Lines 530-850 control the printer.

  The data at the end of the program is as follows:

  All data is in percent of chord length.
  F$ = NACA designation 
  LE = Leading edge radius
  TE = Trailing edge radius
  U0 = Upper offset at nose      U1 = Upper offset at 25% of chord
  U2 = Upper offset at 50%       U3 = Upper offset at 75%
  U4 = Upper offset at trailing edge
  L0 = Lower offset at nose      L1 = Lower offset at 25% of chord
  L2 = Lower offset at 50%       L3 = Lower offset at 75%
  L4 = Lower offset at trailing edge

 
  ** I can't answer any questions about the program. I simply typed it in.

  ** Note that the program will be rather slow.

                                              Have fun,
                                              John Krist
                                              U. Texas Astronomy Dept.
                                              (jk@utastro.UUCP)

-------------- Cut here -------------------   
1 REM *****************************************************************
2 REM   PROGRAM: COMPUTER DRAWN AIRFOILS
3 REM        BY: ROBERT H. AYMAR
4 REM            2888 ROUTE 97
5 REM            GLENWOOD, MD   21738
6 REM   PROGRAM LISTED IN THE MARCH, 1985 ISSUE OF SPORTS AVIATION, THE
7 REM   MAGAZINE OF THE EXPERIMENTAL AIRCRAFT ASSOCIATION
8 REM *****************************************************************
9 REM
10 CLEAR 400:CLS
20 LPRINT CHR$(27)"E"
30 REM THIS IS THE MENU, ADD FOILS AS REQUIRED
40 '
50 PRINT "(1) 0010,(2) 0012,(3) 0015,(4) 1408,(5) 1410, (6) 1412,(7) 2410,(8) 2412,(9) 2415,(10) 4412,(11) 4415,(12) 23012,(13) 2418,(14) 4418,(15) GA(W)-1"
60 '
70 '
80 PRINT:INPUT"ENTER INDEX NUMBER FOR FOIL REQ'D ";NU
90 ON NU GOTO 1000,1010,1020,1030,1040,1050,1060,1070,1080,1090,1100,1110,1120,1130,1140
100 '
110 '
120 PRINT:INPUT"ENTER CHORD LENGTH IN INCHES";CL
130 CLS:PRINT " PRINTING TABLE OF OFFSETS"
140 C=1:R0=LE/C:R4=TE/C   'C=SCALING FACTOR
150 P0=U0/C:P1=U1/C:P2=U2/C:P3=U3/C:P4=U4/C
160 W0=L0/C:W1=L1/C:W2=L2/C:W3=L3/C:W4=L4/C
170 PU=P0+P4:MU=P0-P4
180 PL=W0+W4:ML=W0-W4
190 AU=(SQR(2)/4)*(SQR(R0)+SQR(R4)):BU=(.5*SQR(2)/4)*(SQR(R0)-SQR(R4))
200 AL=-AU:BL=-BU
210 C0=(1/3)*((1/2)*PU+P1+P3-SQR(3)*AU)
220 C1=(1/3)*(MU+P1-P3-SQR(3)*BU)
230 C2=(1/2)*((1/2)*PU-P2+AU)
240 C3=(1/2)*MU-C1
250 C4=(1/2)*PU-C0-C2
260 D0=(1/3)*((1/2)*PL+W1+W3-SQR(3)*AL)
270 D1=(1/3)*(ML+W1-W3*SQR(3)*BL)
280 D2=(1/2)*((1/2)*PL-W2+AL)
290 D3=(1/2)*ML-D1
300 D4=(1/2)*PL-D0-D2
310 LPRINT TAB(25)"AIRFOIL ";F$;" LAYOUT"
320 LPRINT TAB(25) STRING$(20,"-")
330 LPRINT TAB(25) "(ALL DIMS. IN INCHES)"
340 LPRINT " ":LPRINT" "
350 LPRINT TAB(26) "CHORD LENGTH IS ";CL
360 LPRINT TAB(26) "LE RADIUS IS ";LE*CL:LPRINT " "
370 LPRINT TAB(17) "STATION";TAB(30) "Y UPPER";TAB(44) "Y LOWER"
380 LPRINT " "
390 READ XC
400 DATA .0125,.025,.05,.075,.1,.2,.3,.4,.5,.6,.7,.8,.9,.95,1
410 GOSUB 870
420 LPRINT TAB(17) XC*CL;TAB(30) YU*CL;TAB(44) YL*CL
430 LPRINT " "
440 IF YU>UU THEN UU=YU:IF ABS(YL)>LL THEN LL=ABS(YL) 'FIND MAX OFFSETS
450 IF XC=1 THEN 460 ELSE GOTO 390
460 LPRINT CHR$(27)"0"
470 IF (LL+UU)*CL>7.75 THEN PRINT"THIS SIZE FOIL EXCEEDS THE PAPER WIDTH":GOTO 970
480 CLS:PRINT "DRAWING FULL SIZE FOIL  ";F$;" ";CL;" INCHES LONG"
490 PRINT:PRINT TAB(10) "PLEASE BE PATIENT, I'M WORKING AS FAST AS I CAN"
500 LPRINT" ":LPRINT" ":LPRINT" "
510 FOR XC=0 TO 1 STEP(1/(CL*8))
520 GOSUB 870
530 S=INT((YL*CL)/.0167):Q=INT((YU*CL)/.0167)
540 R=INT(ABS((LL*CL)/.0167))+15   'CENTER LINE
550 N=R+Q:N2=INT(N/256):N1=N-256*N2  'NO. OF COLUMNS
560 IF N2>=1 THEN R=R-1
570 F=0
580 IF N1=10 OR N1=11 OR N1=12 OR N1=13 THEN N1=N1+10:GOTO 600
590 GOTO 610
600 F=10
610 A=R-1+S:B=8:C=127:D=ABS(S+1):E=Q-1
620 IF Q<=0 THEN E=0
630 LPRINT CHR$(27)"K"CHR$(N1)CHR$(N2);
640 FOR I=0 TO A
650 OUT 251,0
660 IF INP(251)<>61 THEN 660
670 NEXT I
680 LPRINT CHR$(C);
690 IF S=0 THEN GOTO 740
700 FOR I=1 TO D
710 OUT 251,0
720 IF INP(251)<>61 THEN 720
730 NEXT I
740 IF E=0 THEN LPRINT CHR$(C):GOTO 860
750 LPRINT CHR$(C);
760 FOR I=1 TO E
770 OUT 251,0
780 IF INP(251)<>61 THEN 780
790 NEXT I
800 OUT 251,127
810 IF F=10 THEN 820 ELSE 850
820 FOR I=1 TO F
830 OUT 251,0
840 NEXT I
850 OUT 251,10
860 IF XC>1 THEN GOTO 970 ELSE NEXT XC
870 X=1-2*XC
880 IF (1-X*X)<0 THEN 970
890 Y=SQR(1-X*X)
900 IF XC<.14645 OR XC>.85355 THEN 910 ELSE 920
910 AT=ATN(Y/X):GOTO 930
920 AT=1.5708-ATN(X/Y)
930 IF XC>.85355 THEN AT=AT+3.14159
940 YU=C0+C1*COS(AT)+C2*COS(2*AT)+C3*COS(3*AT)+C4*COS(4*AT)+AU*SIN(AT)+BU*SIN(2*AT)
950 YL=D0+D1*COS(AT)+D2*COS(2*AT)+D3*COS(3*AT)+D4*COS(4*AT)+AL*SIN(AT)+BL*SIN(2*AT)
960 RETURN
970 INPUT "WOULD YOU LIKE TO TRY IT AGAIN, Y/N ";E$
980 IF E$="Y" THEN 10 ELSE LPRINT CHR$(27)CHR$(64):END
990 REM DATA FOR AIRFOILS AS FOUND IN "THEORY OF WING SECTIONS"
1000 F$="0010":LE=.011:TE=0:U0=0:U1=.04456:U2=.03971:U3=.02357:U4=.00095:L0=0:L1=-.04456:L2=-.03971:L3=-.02357:L4=-.00095:GOTO 120
1010 F$="0012":LE=.0158:TE=0:U0=0:U1=.05941:U2=.05294:U3=.03143:U4=.00126:L0=0:L1=-.05941:L2=-.05294:L3=-.03143:L4=-.00126:GOTO 120
1020 F$="0015":LE=.0248:TE=0:U0=0:U1=.07427:U2=.06617:U3=.03929:U4=.00158:L0=0:L1=-.07427:L2=-.06617:L3=-.03929:L4=-.00158:GOTO 120
1030 F$="1408":LE=.007:TE=0:U0=0:U1=.04819:U2=.04502:U3=.02749:U4=.00084:L0=0:L1=-.03101:L2=-.02556:L3=-.01443:L4=-.00084:GOTO 120
1040 F$="1410":LE=.011:TE=0:U0=0:U1=.05809:U2=.05385:U3=.03272:U4=.00105:L0=0:L1=-.04091:L2=-.03439:L3=-.01966:L4=-.00105:GOTO 120
1050 F$="1412":LE=.0158:TE=0:U0=0:U1=.06799:U2=.06267:U3=.03795:U4=.00126:L0=0:L1=-.0508:L2=-.04321:L3=-.02489:L4=-.00216:GOTO 120
1060 F$="2410":LE=.011:TE=0:U0=0:U1=.06668:U2=.06356:U3=.03923:U4=.00105:L0=0:L1=-.0323:L2=-.02468:L3=-.01312:L4=-.00105:GOTO 120
1070 F$="2412":LE=.0158:TE=0:U0=0:U1=.0767:U2=7.240001E-02:U3=.0446:U4=.0013:L0=0:L1=-.0422:L2=-.0334:L3=-.0182:L4=-.0013:GOTO 120
1080 F$="2415":LE=.0248:TE=0:U0=0:U1=.0917:U2=.0857:U3=.0526:U4=.0015:L0=0:L1=-.057:L2=-.0467:L3=-.026:L4=-.0016:GOTO 120
1090 F$="4412":LE=.0158:TE=0:U0=0:U1=.0941:U2=.0919:U3=.0579:U4=.0013:L0=0:L1=-.025:L2=-.014:L3=-.0052:L4=-.0013:GOTO 120
1100 F$="4415":LE=.0248:TE=0:U0=0:U1=.1092:U2=.1053:U3=.0659:U4=.0016:L0=0:L1=-.0398:L2=-.0272:L3=-.0129:L4=-.0016:GOTO 120
1110 F$="23012":LE=.0158:TE=0:U0=0:U1=.076:U2=.0641:U3=.0372:U4=.0013:L0=0:L1=-.0428:L2=-.0417:L3=-.0258:L4=-.0013:GOTO 120
1120 F$="2418":LE=.0356:TE=0:U0=0:U1=.1065:U2=.0989:U3=.0605:U4=.0019:L0=0:L1=-.0718:L2=-.0599:L3=-.0339:L4=-.0019:GOTO 120
1130 F$="4418":LE=.0356:TE=0:U0=0:U1=.124:U2=.1185:U3=.0739:U4=.0019:L0=0:L1=-.0549:L2=-.0402:L3=-.0206:L4=-.0019:GOTO 120
1140 F$="GA(W)-1":LE=.033:TE=0:U0=0:U1=9.777999E-02:U2=.10269:U3=.06517:U4=0:L0=0:L1=-.06265:L2=-.06091:L3=-.02461:L4=-.00783:GOTO 120