Homework Problems

Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Education

This is a dual-program listing containing two independent BASIC programs. The first program (starting at line 10 with REM “HT”) is a heat transfer calculator that determines the convection coefficient for fluid flow through a circular pipe, implementing multiple correlations from standard heat transfer textbooks including the Hausen, Sieder-Tate, Dittus-Boelter, Colburn, and liquid-metal equations (8.51–8.60). It guides the user through laminar, turbulent, and entry-region flow regimes, computing the Reynolds number via RE=(4*M)/(PI*D*MU) and ultimately outputting H=K*NU/D. The second program (REM “A”) uses FAST/SLOW mode switching and computes a logarithmic curve over three nested ranges, printing W against a log-scale value using the log-10 conversion constant Z=0.4342944819 multiplied by 10*LN(0.25*W²+1).


Program Overview

The listing contains two completely independent programs. The first (lines 10–1650, labelled REM "HT") is an interactive heat transfer advisor. The second (lines 1–90, labelled REM "A") is a short mathematical table generator. They are presented in a single file but have no connection to each other.

Program 1 — “HT”: Structure

The program is organised as a decision tree that walks the user through the standard textbook procedure for calculating a pipe-flow convection coefficient H. The top-level branches are:

  1. Pipe geometry check (circular vs. non-circular) — lines 40–70
  2. Average (B=1) or specific-location (B=2) value requested — lines 100–140
  3. Reynolds number calculation and laminar/turbulent split — lines 370–390
  4. Laminar sub-tree (fully developed / entry region) — lines 400–1060
  5. Turbulent sub-tree (small / large ΔT, liquid metals) — lines 1070–1605
  6. Final H calculation and output — lines 1610–1640
  7. Out-of-range catch-all — line 1650

Program 1 — Key Equations Implemented

Equation ref.CorrelationBASIC line
Eq. 8.6RE = 4M / (π D μ)370
Eq. 8.51NU = 4.36 (uniform flux, FD laminar)610
Eq. 8.53NU = 3.66 (constant Ts, FD laminar)710
Eq. 8.54 (Hausen)NU = 3.66 + (0.0668·D·Re·Pr/L) / (1 + 0.04·(D·Re·Pr/L)^(2/3))950
Eq. 8.55 (Sieder-Tate laminar)NU = 1.86·(Re·Pr/(L/D))^(1/3)·(μ/μs)^0.141030
Eq. 8.57 (Colburn)NU = 0.023·Re^0.8·Pr^(1/3)1260
Eq. 8.58 (Dittus-Boelter)NU = 0.023·Re^0.8·Pr^N (N=0.4 heating, 0.3 cooling)1340
Eq. 8.59 (Sieder-Tate turbulent)NU = 0.027·Re^0.8·Pr^(1/3)·(μ/μs)^0.141430
Eq. 8.60 (liquid metal, const flux)NU = 4.82 + 0.0185·Pe^0.8271560
— (liquid metal, const Ts)NU = 5 + 0.025·Pe^0.81600

Program 1 — Notable Techniques and Idioms

  • Input validation loops: Lines such as 60, 130, 590, 690 use the pattern IF A<>1 AND A<>2 THEN GOTO to re-prompt on invalid input — a standard Sinclair-era idiom.
  • Re-use of L: The variable L is first used as pipe length (line 90) and later reused at line 1300 as a heating/cooling flag (1 or 2). This shadows the original value and would give wrong results if L were needed afterwards — a latent bug since the Dittus-Boelter path (line 1350) goes straight to 1620 without needing the original length again, so it happens not to cause an error.
  • Reynolds number recalculated: Lines 928 and 1087 recalculate RE with a new viscosity value (average mean temperature) before entering the Hausen and turbulent correlations respectively, correctly overwriting the earlier estimate.
  • Peclet number: PE=RE*PR (line 1110) is computed once and reused for the liquid-metal correlations, avoiding redundant multiplication.
  • Dead code path for liquid metals: Line 1118 branches to line 1450 if PR is in the liquid-metal range (0.003–0.05), but line 1450 itself begins with PRINT "LIQUID METAL" — this code is reachable only from line 1118, making it a separate functional block tucked after the turbulent main path.
  • Early exit via line 1650: Many validation checks simply jump to the single out-of-range message at line 1650 rather than implementing recovery, which keeps the program compact at the cost of user guidance.
  • Line numbering gaps: Several intentional gaps (e.g. 95, 645, 845, 1055) were added later as patch-in lines, visible from the non-uniform numbering style.

Program 1 — Bugs and Anomalies

  • Line 1360 is labelled REM J=1 TEMP DIFF LARGE but the condition at line 1230 is IF J=2 THEN GOTO 1360 — so the large temperature difference path is actually taken when J=2 (user answers “NO” to “small?”). The REM comment has the logic inverted.
  • The liquid-metal path (line 1460 onwards) is never reached from the turbulent tree for B=2 because line 1084 branches to 1090 (skipping line 1088), but line 1087 is only executed for B=1. This means for a specific-location turbulent liquid-metal case the Reynolds number is never updated to the mean-temperature value — a minor inconsistency.
  • Line 1345 is used as a GOTO target from lines 1565 and 1605, but line 1345 reads PRINT "ENTER K (W/(M*K))" followed by INPUT K at line 1347 and then GOTO 1620 at line 1350 — this works correctly but the jump destination mid-sequence is easy to misread.

Program 2 — “A”: Structure and Technique

This short program prints a table of W versus a log-scaled function of W over three progressively coarser ranges.

  • Z = 0.4342944819 (line 2) is log₁₀(e), the natural-to-common-logarithm conversion factor. The expression Z*10*LN(.25*W**2+1) therefore computes 10·log₁₀(0.25W²+1).
  • The outer FOR J=1 TO 3 loop (line 10) selects three parameter pairs: range 0–1 step 0.1, range 0–10 step 1, range 0–100 step 10 — producing 11 rows each time.
  • FAST / SLOW at lines 5 and 90 suppress display refresh during computation, a standard ZX81/TS1000 speed optimisation.
  • The branching logic at lines 20–42 uses a chain of IF … GOTO to assign A and B, which is idiomatic for a platform without SELECT CASE.

Image Gallery

Source Code

  10 REM "HT"
  20 PRINT "THIS PROGRAM CALCULATES THE CONVECTION COEFFICIENT FOR FLUID FLOW THROUGH A CIRCULAR PIPE"
  30 PRINT 
  40 PRINT "IS THE PIPE CIRCULAR? (1 YES   2 NO)"
  50 INPUT A
  60 IF A<>1 AND A<>2 THEN GOTO 40
  70 IF A=2 THEN GOTO 1650
  80 PRINT "ENTER PIPE LENGTH (M)" 
  90 INPUT L
  95 PRINT "PIPE LENGTH=";L;"M"
 100 PRINT "IS AN AVERAGE (1) OR SPECIFIC (2) VALUE OF H REQUESTED?"
 120 INPUT B
 130 IF B<>1 AND B<>2 THEN GOTO 100
 140 IF B=2 THEN GOTO 230
 150 REM B=1 AVE H
 160 PRINT "BASED ON THE DATA YOU HAVE, DECIDE ON A MEAN TEMP. FOR THE FLUID CONSIDERING THE ENTIRE PIPE"
 190 PRINT "ENTER MEAN TEMP (K)"
 200 INPUT C
 210 PRINT "MEAN TEMP=";C;"K"
 220 GOTO 270
 230 REM B=2 SPEC H
 240 PRINT "INPUT TEMP. AT DESIRED LOCATION (K)"
 250 PRINT "IF NOT KNOWN EXACTLY, ENTER AN APPROX. VALUE"
 255 INPUT T
 260 PRINT "T=";T;"K"
 270 REM CALC RE
 280 PRINT "ENTER VISCOSITY AT TEMP. ABOVE (KG/(S*M))"
 290 INPUT MU
 300 PRINT "MU=";MU;" KG/(S*M)"
 310 PRINT "ENTER FLOW RATE (KG/S)"
 320 INPUT M
 330 PRINT "M=";M;" KG/S"
 340 PRINT "ENTER PIPE DIAMETER (M)"
 350 INPUT D
 360 PRINT "DIAMETER=";D;" M"
 370 LET RE=(4*M)/(PI*D*MU)
 380 PRINT "REYNOLDS NUMBER=";RE;" (EQ. 8.6)"
 390 IF RE>=2300 THEN GOTO 1070
 400 PRINT "FLOW IS LAMINAR"
 410 LET XFD=.05*RE*D
 420 PRINT "ENTRY LENGTH APPROX.=";XFD;" M"
 430 IF B=1 THEN GOTO 470
 440 PRINT "ENTER POINT OF INTEREST AS DISTANCE FROM INLET IN M"
 450 INPUT X
 460 GOTO 550
 470 REM B=1 AVG VALUE
 480 LET I=XFD/L
 490 IF I>.05 THEN GOTO 530
 500 PRINT "ENTRY REGION NOT SIGNIFICANT"
 510 PRINT "USE AVERAGE VALUES FOR VARIABLES"
 520 GOTO 560
 530 PRINT "ENTRY REGION SIGNIFICANT"
 540 GOTO 740
 550 IF X<XFD THEN GOTO 740
 560 PRINT "FLOW FULLY DEVELOPED"
 570 PRINT "IS THERE UNIFORM HEAT FLUX? (1 YES   2 NO)"
 580 INPUT E
 590 IF E<>1 AND E<>2 THEN GOTO 570
 600 IF E=2 THEN GOTO 660
 610 LET NU=4.36
 620 PRINT "EQ. 8.51  NUSSELT NO.=";NU
 630 PRINT "ENTER VALUE OF K (W/(M*K)) AT MEAN TEMP"
 640 INPUT K
 645 PRINT "K=";K;"W/(M*K)"
 650 GOTO 1620
 660 REM E=2
 670 PRINT "IS THE SURFACE TEMP. CONSTANT? (1 YES  2 NO)"
 680 INPUT F
 690 IF F<>1 AND F<>2 THEN GOTO 670
 700 IF F=2 THEN GOTO 1650
 710 LET NU=3.66
 720 PRINT "EQ. 8.53 NUSSELT NO.=";NU
 730 GOTO 630
 740 PRINT "ENTRY REGION"
 750 IF B=1 THEN GOTO 860
 760 REM B=2 SPEC VALUE
 770 PRINT "ENTER PRANDTL NO. AT POINT IN QUESTION"
 780 INPUT PR
 790 LET G=(X/D)/(RE*PR)
 800 PRINT "REFER TO FIG. 8.8 TO DETERMINE NUSSELT NO. FOR (X/D)/(RE*PR)=";G
 810 PRINT "ENTER NUSSELT NO."
 820 INPUT NU
 830 PRINT "ENTER K (W/(M*K)) AT POINT IN QUESTION"
 840 INPUT K
 845 PRINT "K=";K;"W/(M*K)"
 850 GOTO 1610
 860 REM B=1 AVG VALUE
 870 PRINT "IS SURFACE TEMP. CONSTANT? (1 YES  2 NO)"
 880 INPUT J
 890 IF J<>1 AND J<>2 THEN GOTO 870
 900 IF J=1 THEN GOTO 920
 910 GOTO 1650
 920 PRINT "ENTER ALL VALUES AT AVERAGE MEAN TEMP. (MEAN TEMP. IN+MEAN TEMP. OUT)/2"
 925 PRINT "HAUSEN EQ. 8.54"
 926 PRINT "ENTER AVG. VISCOSITY"
 927 INPUT MU
 928 LET RE=(4*M)/(PI*D*MU)
 929 PRINT "NEW REYNOLDS NO.=";RE
 930 PRINT "ENTER PRANDTL NO."
 940 INPUT PR
 950 LET NU=3.66+(.0668*D*RE*PR/L)/(1+.04*(D*RE*PR/L)**(2/3))
 960 PRINT "NUSSELT NO.=";NU
 970 PRINT "FOR IMPROVED ACCURACY: SIEDER-TATE EQ. 8.55"
 980 IF PR<.48 OR PR>16700 THEN GOTO 1650
 990 PRINT "ENTER VISCOSITY AT SURFACE TEMP"
 1000 INPUT MUS
 1010 PRINT "SURFACE VISCOSITY=";MUS;"KG/(S*M)"
 1020 IF MU/MUS<.0044 OR MU/MUS>9.75 THEN GOTO 1650
 1030 LET NU=1.86*(RE*PR/(L/D))**(1/3)*(MU/MUS)**.14
 1040 PRINT "ENTER K (W/(M*K)) AT MEAN TEMP"
 1050 INPUT K
 1055 PRINT "K=";K;"W/(M*K)"
 1060 GOTO 1610
 1070 PRINT "FLOW IS TURBULENT"
 1080 PRINT "IN THE ENTRY REGION THE RESULTS GIVEN WILL BE CRUDE APPROXIMATIONS"
 1082 IF B=1 THEN PRINT "ENTER ALL VALUES AT AVG. MEAN TEMP."
 1084 IF B=2 THEN GOTO 1090
 1085 PRINT "ENTER AVG. VISCOSITY"
 1086 INPUT MU
 1087 LET RE=(4*M)/(PI*D*MU)
 1088 PRINT "NEW REYNOLDS NO.=";RE
 1090 PRINT "ENTER PRANDTL NO."
 1100 INPUT PR
 1105 PRINT "PR=";PR
 1110 LET PE=RE*PR
 1115 PRINT "PECLET NO. (PE)=";PE
 1118 IF PR>=3E-3 AND PR<=5E-2 THEN GOTO 1450
 1120 IF PR<.7 OR PR>160 THEN GOTO 1650
 1130 IF RE<10000 THEN GOTO 1650
 1140 IF (L/D)<60 THEN GOTO 1650
 1200 PRINT "IS THE TEMP. DIFF. (SURFACE TEMP.-MEAN TEMP.) SMALL? (1 YES  2 NO)"
 1210 INPUT J
 1220 IF J<>1 AND J<>2 THEN GOTO 1200
 1230 IF J=2 THEN GOTO 1360
 1240 REM TEMP DIFF SMALL
 1250 PRINT "COBURN EQ. 8.57"
 1260 LET NU=.023*RE**.8*PR**(1/3)
 1270 PRINT "NUSSELT NO.=";NU
 1280 PRINT "PREFERRED: DITTUS-BOELTER EQ. 8.58"
 1290 PRINT "IS HEATING (1) OR COOLING (2) TAKING PLACE?"
 1300 INPUT L
 1310 IF L<>1 AND L<>2 THEN GOTO 1290
 1320 IF L=1 THEN LET N=.4
 1330 IF L=2 THEN LET N=.3
 1340 LET NU=.023*RE**.8*PR**N
 1342 PRINT "NUSSELT NO.=";NU
 1345 PRINT "ENTER K (W/(M*K))"
 1347 INPUT K
 1350 GOTO 1620
 1360 REM J=1 TEMP DIFF LARGE
 1370 IF PR<.7 OR PR>16700 THEN GOTO 1650
 1380 IF RE<10000 OR (L/D)<60 THEN GOTO 1650
 1400 PRINT "SIEDER/TATE EQ. 8.59"
 1410 PRINT "ENTER SURFACE VISCOSITY (KG/(S*M))"
 1420 INPUT MUS
 1430 LET NU=.027*RE**.8*PR**(1/3)*(MU/MUS)**.14
 1440 GOTO 1342
 1460 PRINT "LIQUID METAL"
 1480 PRINT "IS THE SURFACE HEAT FLUX CONSTANT (1), THE SURFACE TEMP. CONSTANT (2), OR NONE OF THE ABOVE?"
 1490 INPUT Q
 1500 IF Q<>1 AND Q<>2 AND Q<>3 THEN GOTO 1480
 1510 IF Q=2 OR Q=3 THEN GOTO 1570
 1520 REM HEAT FLUX CONST
 1530 IF RE<3.6E3 OR RE>9.05E5 THEN GOTO 1650
 1540 IF PE<100 OR PE>10000 THEN GOTO 1650
 1550 PRINT "EQ. 8.60"
 1560 LET NU=4.82+.0185*PE**.827
 1565 GOTO 1345
 1570 IF Q=3 THEN GOTO 1650
 1580 REM Q=2 SURF TEMP CONST
 1590 IF PE<=100 THEN GOTO 1650
 1600 LET NU=5+.025*PE**.8
 1605 GOTO 1345
 1610 PRINT "NUSSELT NO.=";NU
 1620 LET H=(K*NU)/D
 1630 PRINT "HEAT TRANSFER COEFFICIENT=";H;"W/(M**2*K)"
 1640 STOP 
 1650 PRINT "OUT OF RANGE OF PROGRAM, CONSULT LITERATURE"
 
   1 REM "A"
   2 LET Z=.4342944819
   5 FAST 
  10 FOR J=1 TO 3
  20 IF J=2 OR J=3 THEN GOTO 30
  22 LET A=1
  24 LET B=.1
  26 GOTO 50
  30 IF J=3 THEN GOTO 40
  32 LET A=10
  34 LET B=1
  36 GOTO 50
  40 LET A=100
  42 LET B=10
  50 FOR W=0 TO A STEP B
  60 LET X=Z*10*LN (.25*W**2+1)
  70 PRINT W,X
  80 NEXT W
  85 NEXT J
  90 SLOW 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.