Computers Educ. Vol. 14, No. 6, pp. 525-536, Printed in Great Britain. All rights reserved
1990 Copyright
0
COMPUTERIZED, INTERACTIVE CALCULATION DIMENSIONLESS VARIABLES
Department
0360-1315190 $3.00 + 0.00 1990 Pergamon Press plc
OF
S. M. CALISAL and H. L. WONG of Mechanical Engineering, University of British Columbia, Vancouver, B.C., Canada V6T lW5 (Received 12 February 1990)
Abstract-A method for the calculation of dimensionless variables is given by the direct application of the proof of the Pi Theorem. The method requires the inversion of a small matrix. The procedure leads to a very efficient computerized calculation of dimensionless variables. Three applications from fluid mechanics are given as illustrations. The proof of the Pi Theorem and the fundamental assumptions used are included to explain the methodology.
1. INTRODUCTION
In daily life, physical quantities are measured or expressed in different forms. Sometimes, the accepted dimension is not precise. The time taken to reach a destination is often used to refer to the distance from one point to another although it is obvious that the assumed speed is an important parameter. Of course, sometimes this is implied. When a sign expresses the distance to a lodge in hiking as ‘five minutes’ there is the assumption that the person will be hiking rather than running. Similarly, in engineering length is used as a measure of pressure, which is of practical importance to design engineers. Strictly speaking, this term is dimensionally incorrect as implied in this expression is the assumption of a gravitational acceleration and a density. There are different standard systems for measurement. One such system is the Metric System (meter, kilogram, second). Any system that can measure all of the physical quantities or categories of interest can be used successfully. Roman System and Ottoman System were complete systems even though they are not popular now. Each system has fundamental units necessary to measure direct and derived measurements. A direct measurement is a measurement with one fundamental unit such as ‘meter’ in a length measurement in the metric system. A derived measurement such as measurement of velocity in terms of meter and second in the metric system requires more than a single fundamental unit. Physical laws can be very good examples of derived units. One example is Newton’s law, F = mu, i.e. force is equal to mass times acceleration. The unit of force is then defined in terms of a relationship between the fundamental units of mass, length and time. While dimensions based on arbitrary standards are necessary for practical reasons, they are also often confusing and complicate the problem. In engineering, non-dimensional variables can be used to design and simplify experiments and for the presentation of the results. In the following paragraphs, we develop a method to calculate all of the dimensionless quantities in a physical problem. For this we need to use a methodology, some theorems and assumptions. The theorems invoked and assumptions used have been included in the Appendix for completeness. 2. DIMENSIONAL
INDEPENDENCE
The idea of dimensional independence is of importance in the derivation of physical relationships using dimensional analysis. This concept is presented first in the hope of achieving a more logical development of the method used in later sections. We assume here that the reader is familiar with the algebra of units. If measurements are made for a set of measurement categories Qi for i=l,..., n, it is then possible to find a certain combination of these categories to have the dimension of a category Q, for j < n in the original set. To illustrate the process and to find a method to identify the category Q,, we can assume that we have k fundamental units U,, such as meter, kilogram and second, and n physical systems Q(‘) possibly in different physical categories. 525
526
S. M. CALISALand H. L. WONG
A set Qi is dimensionally independent if there does not exist a set of real numbers aj so that the product of the units of the physical systems Q(‘)alQ(2)a2.. . Q(“@nis dimensionless. Let us assume that the dimensions of the physical system, in terms of fundamental units, has the following form: Q(l)
=
4,
Q’“’
=
4
~(UPII
~V)PIZ,
u(l)Pn,
,5@)Pn2
. . . , ,yWm
to n
U(k)Pnk
,..*,
where qi and pii are real numbers while U’ is a fundamental more compact form as: Q(l) = qi
forj=l..
. k. One can then write the product
The condition
unit. The above can be rewritten in
,olu(jh
(1)
of the categories as:
that the above product be dimensionless is that !, Pijai = O.
Theorem: The quantities Q(l). . . Q(“) cannot be dimensionless, i.e. dimensionally independent if n >k. 3. THE METHOD The following result is based on the proof of the Pi Theorem[ 1] and the Homogeneity Theorem. Using equation (18) in Appendix C and keeping the same notation, we can write: Qk+j=~i[q;“.
. .q$k]
fi
U(i)zi=Ph,‘~
~q~+~u(‘)~iI..
. U(k)s,t.
j=l
Comparing the above relationships, 7cj =
Sij=
(3)
one can obtain the following equations for xi and sii
qk+l
q;‘1. . . q>’ i
i
j=l
h=l
=qk+i
fi h=l
dh
(5)
Yihphj.
In matrix notation, the above relationships can be written as [SJ = [R][P]. By post multiplying by [PI-’ we can rewrite the above equation [s][P]-’
= [RI.
In the above equation, the matrix [P] contains the powers of the fundamental units for selected independent variables. In the application of the PI Theorem, it is necessary to make a list of all of the variables considered important in the problem. Then the fundamental units are chosen and confirmed to be dimensionally independent, i.e. the elements of the [P] matrix are defined and the value of the determinant of [P] is checked to be non-zero. The rest of the variables are called dependent and define the elements of the matrix [S]. The inverse of [P] can be calculated and hence [R] obtained. The matrix [R] then contains the powers of the independent variables defined in [PI. Therefore, the dimensionless variables, rts, can be found as a relationship between each dependent variable and the independent ones. Two applications of the above process are given in Section 5.
Computerized, interactive calculation of dimensionless variables ?
1
“Analysis.Bea”
Run
>
521
Input Variables (n)
V Write in VAR
array
Find Determinant IPI
<
Data From Unite.Dat
4
V
YES
_ Det [P]=O? NO
Find
[PI-l
r” output
to Screen
cl5 END
Fig. 1. Flow chart of program Analysis.bas.
4. USE
OF A MICROCOMPUTER
A computer program, Analysisbas been written in Quick BASIC for the calculation of the matrix [R] as defined in the previous section. The flow chart of this program is given in Fig. 1. A listing of this program is given in Appendix E. This program is fully interactive. In addition an output file is also created to print a hardcopy of the results. It should be noted, however, that companion data files (Units.dat and Namedat.dat) are required to run the main program Analysis.bas. The first data file contains information on the physical type of variables and definition of their units in terms of the powers of fundamental units. The second data file contains the names of the corresponding variables recorded in the first data file. For example, if we use three fundamental units only, namely Length, Mass and Time (L, M, T), then in Units.dat, for velocity we would have: the velocity variable identification number, 1, 0,- 1 (representing L' MO T-' ) and CAE W.-E*
S. M. CALISAL and H. L. WONG
528
the word ‘Velocity’ in the file Namedat.dat. Similarly for density we have: variable identification number, -3, 1, 0 in Unitsdat and the word ‘Density’ in Namedat.dat. When run, the main program asks for the total number of variables. The user then identifies these variables from a menu displayed on screen. If a variable to be used is not currently resident in the datafiles, the program prompts the user to input the necessary particulars for this ‘new’ variable. The program is able to learn the ‘new’ variables and interactively increase its database. Note that although the total number of independent variables is fixed at three, the program Analysis.bas can be modified to accommodate more. It should be mentioned, however, that three independent variables will normally be adequate for most applications in mechanics. It can be observed from the above that [P] will be a 3 x 3 square matrix while the size of [S] is n x 3. This will give the solution [R] as a n x 3 matrix. Variable codes given by the user are read into an n x 4 array called VAR. These are then compared with the data file (subroutine PSMATRIX) to find the powers a, b, c of the fundamental units L”Mb T’. The integers a, 6, c are then inserted into VAR(I,2), VAR(1, 3), VAR(I,4) respectively. The element VAR(1, 1) contains the variable identification code number assigned to the named variable and I = 1 . . . 3 is reserved for the independent variables. The rest of the array VAR records the dependent variables. These two categories are then read into matrices [P] and [S] by a subroutine (PSMATRIX) in program Analysis.bas. Another subroutine (INVERSE) calculates the determinant of [PI. If the determinant is non-zero, then the program calculates the inverse [PI-‘; otherwise, a message “Please try again . . .” is printed on the screen. A subroutine (RESULTS) writes the results of the calculations: on the screen as well as into an user designated output file. The data files, Units.dat and Namedat.dat, are updated automatically with usage. This means that the size of these data files will increase through repeated updating. The advantage of this self learning feature is that any variable needs to be defined only once by the user. 5. EXAMPLE 5.1.
APPLICATIONS
Ship resistance
The resistance (R) of a moving ship depends on five variables, namely: the length of the ship (L), ship velocity (V), water density (p), kinematic viscosity of the water (v), and the gravitational acceleration (g). With the choice of L, V and p as independent variables, the matrices [P] and [S] will be as follows.
After the calculation of [R] in Analysis.bas, the rcs can be found. Figure 2 gives the output file for this application. Resistance =I =
L2yZp
Hence, using the Pi Theorem, we can conclude that the drag coefficient is a function of it* and rc3, which are the inverse of the well known Reynold’s number and the inverse of the square of the Froude number respectively. 5.2. Turbomachinery testing The available head (energy per unit mass), H, and required power, P, for a turbomachinery is dependent on the quantity Q/C&’ where Q is the volume flow rate, o the angular velocity of the
Computerized, interactive calculation ofdimensionless variables NAME OF RUN:
529
Ship Resistance Problem
VARIABLES ARE:
Ship Length Ship Velocity Water Density Resistance Kine Visco g
Powers of: Dependent Resistance: Dependent Kine Visco: Dependent g:
Ship Length 2 1 -1
Ship Velocity Water Density 2 1 1 0 2 0
Fig.2.Outputfile forshipresistance problem.
impeller and B a significant diameter. This non-dimensional relationship can be derived using the present method. Generally, two other parameters: the fluid density, p, and the fluid dynamic viscosity, ~1,are also considered important in this problem. Hence, with the seven variables given above, running the program Analysis.bas produces the output as shown in Fig. 3. From the above. the zs can be found n, =--y
Q
WD
H 7rj = 2 w2D P
7c4=3.
WDP
If viscosity p is neglected, then both the non-dimensional
head and power are related to Q/wD' .
5.3. Radar back-scattered returns from the sea surface Radar can be used to survey the sea surface by the comparison of the emitted power EE to the reflected return power E, . It was experimentally observed [2] that the ratio ER /EE (CT,,)for breaking waves is given by: oo=f
1
uk “2 - v2 [ B
(6)
where u is the friction velocity, k the wave number and g the gravitational acceleration. This result can actually be derived using the present computer program. The variables considered to be important in the ratio ER/EE are listed overleaf: NAME OF RUN:
Turbomachinery Problem
VARIABLES ARE:
Ang velocity Diameter Fluid density Volume rate Dyn viscosity Head Power
Powers of: Dependent Dependent Dependent Dependent
Volume rate: Dyn viscosity: Head: Power:
Ang velocity 1 1 2 3
Diameter 3 2 2 5
Fig.3.Outputfile turbomachinery problem.
Fluid density 0 1 0 1
S. M. CALISALand H. L. WONG
530
(1) Radar wavelength I,, and angle of incidence 4. (2) Surface wave wavelength 1, wave height h, and wave number (3) (4) (5) (6) (7)
k.
Wind direction 8. Surface shear stress r. Water density p. Surface tension of the water (T. Gravitational acceleration g.
The independent variables can be taken to be k, g and r. Running the program Analysis.bas produces the following results
From the above, the relationship between ER/EE as a function of the ns can be expressed as:
Phillips[2] suggested that some of these variables can be eliminated by making appropriate assumptions. Surface tension is negligible (a, x 0). For breaking waves h z 1. k = 2x/l, so ;Ik = constant. 1,<<11, so 1,/A w 0. For a simplified relationship, we can assume that the readings are taken in the direction of the wind so that 8 = 0. We can further assume that 4 = 0, i.e. the angle of incidence of the radar energy to the water surface is very small (glancing). Equation (7) now becomes:
(8)
gqg]. E
For Newtonian fluids, the shear stress t = $u/@. Hence, the shear stress (7) has order of magnitude of pu2. If kinematic viscosity of the sea water is assumed constant, equation (8) then becomes:
$.
$=f E
[
1
(9)
6. CONCLUSION An effective and robust computer program to calculate the non-dimensional variables for problems in mechanics is presented. The program is interactive and of the self-learning type (increasing a data base as used) and allows the use of a series of fundamental units. The program checks for the linear independence of the set of fundamental units used, then calculates the
Computerized, interactive calculation of dimensionless variables
531
non-dimensional variables. Such a program can be used for educational or research purposes. The formulation presented has recently been used on a spread-sheet program (Lotus l-2-3) with success. The computerized calculation of non-dimensional variables permits users to try different sets of fundamental variables and use the most suitable results for the design of experiments, presentation of data or for theoretical studies as shown by the second application on radar back scattering from the sea surface. REFERENCES 1. Sedov L. I., Similarity and Dimensional Methods in Mechanics. Academic Press, New York (1959). 2. Phillips 0. M., On radar returns from the sea surface-Bragg scattering and breaking waves. 17th Symposium on Naval Hydrodynamics, pp. l-l 1 (1988). APPENDIX The following information is supplied for completeness and to explain the methodology used in the computer program. (A) Fundamental Assumption
For any dimensional category, the ratio of measurements before and after a change of scale in the set of fundamental units is the same for all physical systems in the length category. Let us assume that we need u length measurements, v time measurements and w mass measurements for the measurement of a physical category 4 ..,l+t ,,..., t,;m ,,..., m,). 4 =f(l,, As an example we consider a speed measurement: we normally need a = 1, u = 1 and w = 0. I,;1 ,,...,
q=f(I,,...,
t,;m ,,...,
m,).
(10) (11)
After a change in scale, we expect that the functional relationship will be identical in form but the numbers in the measurements will change by scale factors, a, j3, y for length, time and mass respectively as: q’ =f(l{,
.
, I;;?; ,...,
t;;m; ,...,
m;)
(12)
where 1: = al,; t; = DC,;rn; = ym,. One can assume that another set of measurements is done in the same category as: q=rG,.
..,r,,<
,...)
+l
I,...,
fi,)
.J;,r;
,..., c,Sl,; ,..., *;I:)
(13)
and that after the change of scale one obtains: $=f(C,.
(14)
where ~=a[;<=/?i:;m~=y%~. The fundamental assumption can then be expressed in the following equation 4’ Q’ -=-. 4 4
(15)
(B) Homogeneity Theorem
If the fundamental assumption is valid then any function involved in the derived measurement must satisfy the following condition f(a[ ,... Here a, b, c are real constants. of the fundamental assumption.
;/It ,... ;ymr...)=a”jbyCf(I
,...
;t,...;m
,...
).
(16)
The proof of the theorem can be done using successive scale changes and by the use
(C) Second Fundamental Assumption We assume that the physical functional relationships are independent of the particular units used as long as the dimensional categories are not changed. If qn +, = F(q,, , q.) then after a scale change so that q: = (I/a,) q, the functional relationships retain the same form: 4;+,=F(q:,,...,q;).
(17)
This is equivalent to saying that the form of physical laws do not depend on the choice of the system of units. (0) Proof of the Pi Theorem
The Pi Theorem enables the use of some of the physical units as fundamental units. This then gives the set of dimensionless quantities one can work with which are independent of the standards used for measurements. This, of course, is very important in engineering as the number of variables are reduced. The Pi Theorem can be formally written as follows. Any physical law expressing a relationship invariant under a scale change between n + 1 physical quantities q = F(q, , , q”) can be expressed as a relation between n - k + 1 dimensionless variables (RS). The law takes the form n = +(n,, . , x, _k). To prove the Pi Theorem, let us assume that m quantities Q”‘. . Q (m)form a set of physical categories in a physical problem. We assume that q, q,,, are the m real numbers corresponding to the set of m measurements. Then one can claim that there exist a functional relationship of the form: q = F(q, , , qm_ ,) or G(q,, , q,,,) = 0.
S. M. CALISALand H. L. WONG
532
Let us assume that k fundamental units k < n are used and that the first kQ’)s are dimensionally independent. In fact, we may take these Q% as the k fundamental units. The other physical categories can be expressed in terms of the first k categories. Explicitly, if U’ are the fundamental units in a system of measurement, the first k physical quantities can be written as: Q, = q, lJ”‘P”
U”‘p,,
Q2 = q2 U(“m . . . U”‘p,
through to Q, = qt U(“ph’
U”‘p,
and the rest of the (dependent) quantities can be written down in terms of the fundamental units or the first physical quantities as:
through to Q
n
=
4
n
UWn.l
.
u(k)sn,r
=
nn_kQ(lkn-k,,
QWn-r.x.
We can now express the Q% for i > k and write the expressions for Qs as:
through to
Or in a more compact form we obtain the following equation k
Qk+, =n,[q;“.
. . q;‘] fl
U(j)Ti-lPhlr* =qk+,U(I)s,~.
.
U(kb,r,
(18)
In equation (18), one should notice that the subscripts of s are renumbered. Comparing the above relationships, one can obtain the following equations for fI and sV. qk+t n =-=qk+i I 4;“. qy
,=I
fi qp i h=l
(19 (20)
h-l
or in terms of matrix notation [S] = [R][P]. Now define a matrix [A ] = [PI-’ and introduce a special change in scale as
q9’ I/(J),
U(J)’ = &I’ For 1
(21) But aszahkp)h
=
zp@#ahk
=
6)k where S,, = 0 for j
#
k and S,, = I for j = k, one can write: k
Q”’
n
=
,rJjhh,
II=,
For n > j > k, however, one can write: (p,h
QJ=qJkfi, I [qyl
q/
I-I tPhh
Eah,s”~.‘. .q,Za,,s,’ . . . qny]s’L=q k J
I
(22)
But as Ea,,s,, = Zs,,,a,,, = r,, we obtain:
q,nu’“h”,
Q, = 41’.
q2k
From these results we can have the following conclusions. Any function of the form F(q, of scales can be written in the following way. l...1,4t+l4;“’ 9;““. ( The second result is that the physical quantities 71, units of I[ values are given by: F
(23) qn) = 0 with the above change
Qfl
= F(1 1,n, n,_,) = 0. , qp > n,_, have no dimensions, i.e. they are independent of scales. The
n,=
Qk+, Q;“,
Qr
but from the definitions of rV, they are dimensionless. The proof outlined above gives a convenient way to calculate the dimensionless coefficients of any problem once the independent units are elected. The matrix manipulation can be done easily in a small computer.
Computerized,interactive calculation of dimensionlessvariables
533
(E) Program Listing of Analysisbas
REM PROGRAM FOR DIMENSIONAL ANALYSIS (ANALYSIS.BAS) REM IN QUICK BASIC WRITTEN BY HAW L WONG (1988) DECLARE SUB READATA (MAXVAR, DAT, NAMEDAT) DECLARE SUB UPDATE (I, UAXVAR. VARNAME. VAR. DAT) DECLARE SUB INFOTABLE.(MAXVAR; NAMEDATj DECLARE SUB PSMATRIX (V, MAXVAR, VAR, DAT, P. S) DECLARE SUB INVERSE (P;C, IN, D) DECLARE SUB RESULTS (V, VARNAME, R, DEST$) OPTION BASE 1 DIM SHARED P(3, 3) AS INTEGER, C(3, 3) AS INTEGER, IN(3, 3) AS INTEGER DIM SHARED S(9, 3) AS INTEGER, R(9, 3) AS INTEGER DIM SHARED VAR(12, 4) AS INTEGER, DAT(lOO, 4) AS INTEGER AS STRING, NAMEDAT(lOO) AS STRING DIM SHARED VARNAME(12) COMMON DEST$, N$, V, D, MAXVAR CALL READATA(MAXVAR, DAT, NAMEDAT) CLS START: PRINT "PROGRAM FOR DIMENSIONAL ANALYSIS" LOCATE 4, 1 PRINT "Note. 3 independent variables ONLY" PRINT "(Suitable for most common problems encountered.)" PRINT "You can use a Maximum of 9 Dependent variables.t' PRINT "More than the allowed number of variables can be" PRINT "used with a slight alteration of the program." LOCATE 16, 1 INPUT "Type in Name of Output File: 'I, DEST$ OPEN "O", #l, DEST$ LOCATE 22, 1: PRINT "Type any key to continue...." DO LOOP WHILE INKEY$ = II1 RESTART: CLS CALL INFOTABLE(MAXVAR, NAMEDAT) LOCATE 18, 1 INPUT "Type in Name of this Run: It, N$ INPUT "Type in the Total Number of Variables: 'I, V FOR I = 1 TO 3 LOCATE 20, 1 INPUT "Tvne Independent VAR Name: II, VARNAME(1) INPUT "Type Code-for Independent Variable: II;VAR(1, 1) IF VARfI. 1) > MAXVAR THEN CALL UPDATEII. MAXVAR. VARNAME, VAR, DAT) II LOCATE'Z~, i: PRINT 11 PRINT II NEXT I FOR I = 4 TO V LOCATE 20, 1 INPUT "Type Dependent Variable Name: 'I, VARNAME(1) INPUT "Type Code for Dependent Variable: 'I, VAR(1, 1) IF VAR(1, 1) > MAXVAR THEN CALL UPDATE(1, MAXVAR, VARNAME, VAR, DAT) LOCATE 20, 1: PRINT It II PRINT II NEXT I LOCATE 23, 1: PRINT "Press any key to continue...." DO LOOP WHILE INKEY$ = Itu CLS PRINT ItP Matrix is : ‘I CALL PSMATRIX(V, MAXVAR, VAR, DAT, P, S) CALL INVERSE(P, C, IN, D) IF D = 0 THEN PRINT "First 3 var NOT independent" PRINT "Please try again......." LOCATE 23, 1: PRINT "Press any key to continue...." DO LOOP WHILE INKEY$ = u)1 GOT0 RESTART END IF II: PRINT PRINT : PRINT "S Matrix is : FOR I = lTOV-3 PRINT S(1, l), S(1, 2), S(1, 3) FOR J = 1 TO 3 R(1, J) = S(1, 1) * IN(l, J) + S(1, 2) * IN(2, J) + S(1, 3) * IN(3, NEXT J NEXT I PRINT
534
S. M.CALISAL~~~ H.L.
WC)NG
PRINT "R Matrix is : II FOR K = 1 TO V - 3 PRINT R(K, l), R(K, 2), R(K, 3) NEXT K LOCATE 23, 1: PRINT "Press any key to continue...." DO LOOP WHILE INKEY$ = m11 CLS LOCATE 3, 15: PRINT "*******X*******X*****X***X**R***~********ll LOCATE 4, 15: PRINT II* RESULTS OF DIMENSIONAL ANALYSIS *II LOCATE 5, 15: PRINT "****************X*************x********ll PRINT LOCATE 8, 1 PRINT "NAME OF RUN: II; N$ "; N$ PRINT #l, "NAME OF RUN: CALL RESULTS(V, VARNAME, R, DEST$) LOCATE 23, 1 PRINT "More Runs? (Y to proceed, Any Key to End): 'I DO LOOP WHILE INKEY$ = 1111 IF INKEY$ = "Y" OR INKEY$ = "y" THEN GOT0 START CLS END SUB INFOTABLE (MAXVAR, NAMEDAT) REM Subroutine: Printing Information Table PRINT PRINT "Choose the variables from this list by code # when prompted" PRINT "****IF Variable is not in this list then use a new code # ONE" PRINT II greater than the last and answer the questions when prompted.tl PRINT PRINT "Code Variable Code Variable Code Variable" PRINT FOR J = 1 TO MAXVAR STEP 3 PRINT J; TAB(7); NAMEDAT( IF J + 1 <= MAXVAR THEN PRINT TAB(21); J + 1; TAB(27); NAMEDAT(J + 1); END IF IF J + 2 <= MAXVAR THEN PRINT TAB(43); J + 2; TAB(49); NAMEDAT(J + 2) END IF NEXT J END SUB SUB INVERSE (P, C, 1N;D) REM Subroutine: Finding Determinant and Inverse Matrix D=O FOR J = 1 TO 3 IF J = 3 THEN R = 1 ELSE R = J + 1 IF J > 1 THEN S = J - 1 ELSE S = J + 2 D = D + P(2, R) * P(l, J) * P(3, S) - P(l, S) * P(3, J) * P(2, R) C(1, J) = P(2, R) * P(3, S) - P(2, S) * P(3, R) C(2, J) = P(l, S) * P(3, R) - P(l, R) * P(3, S) C(3, J) = P(l, R) * P(2, S) - P(l, S) * P(2, R) NEXT J PRINT "Determinant is : If; D IF D <> 0 THEN FOR I = 1 TO 3 FOR J = 1 TO 3 IN(1, J) = C(J, I) / D NEXT J NEXT I PRINT PRINT "Inverse Matrix is : I* FOR I = 1 TO 3 PRINT IN(1, l), IN(1, 2), IN(1, 3) NEXT I END IF END SUB SUB PSMATRIX (V, NAXVAR, VAR, DAT, P, S) REM Subroutine: Filling in the P and S Matrices
535
Computerized, interactive calculation of dimensionless variables FOR K = 1 TO V FOR L = 1 TO MAXVAR IF DAT(L, 1) = VAR(K,
NEXT L IF K <= 3 THEN P(K, 1) = VAR(K, 2) P(K, 2) = VAR(K, 3) P(K, 3) = VAR(K, 4) PRINT P(K, l), P(K, END IF IF K > 3 THEN S(K - 3, 1) = VAR(K, S(K - 3, 2) = VAR(K, S(K - 3, 3) = VAR(K, END IF
1) THEN VAR(K, 2) = DAT(L, VAR(K, 3) = DAT(L, VAR(K, 4) = DAT(L, END IF
2) 3) 4)
21, P(K, 3) 2) 3) 4)
NEXT K END SUB SUB READATA (MAXVAR, DAT, NAMEDAT) REM Subroutine: Reading from Data File OPEN "I", #2, "A:UNITS.DAT" INPUT #2, MAXVAR FOR I = 1 TO MAXVAR INPUT #2, DAT(1, l), DAT(1, NEXT I CLOSE #2 OPEN "I", #3, "A:NAMEDAT.DAT" FOR I = 1 TO MAXVAR INPUT #3, NAMEDAT(1) NEXT I CLOSE #3 END SUB
2), DAT(1,
3), DAT(1,
4)
SUB RESULTS (V, VARNAME, R, DEST$) REM Subroutine: Writing out the results PRINT : PRINT "VARIABLES ARE: "; PRINT #l, n ": PRINT #l, "VARIABLES ARE: ": FOR I = 1 TO V PRINT VARNAME(1); ", "; PRINT #l, TAB(17); , VARNAME(1) NEXT I PRINT LOCATE 12, 1 PRINT PRINT "Powers of: “, VARNAME(l), VARNAME(Z), VARNAME(3) PRINT #l, "Powers of: “; TAB(17); , VARNAME(l), VARNAME(2), VARNAME(3) PRINT FOR I = 1 TO V - 3 PRINT "Dependent II; VARNAME(1 + 3); ll:ll;TAB(25); R(I, l), R(I, 2), R( PRINT #1, "Dependent I*; VARNAME(1 + 3); “:“; TAB(2;); , R(I, 11, R(I, 2) NEXT I CLOSE #1 LOCATE 20, 1: PRINT "OUTPUT FOR THIS RUN IS SAVED ON: "; DEST$ END SUB SUB UPDATE (I, MAXVAR, VARNAME, VAR, DAT) REM Subroutine: Updating the Data files PRINT "THIS IS A NEW VARIABLE TO BE APPENDED IN DATA FILE" LOCATE 23, 1 INPUT "Enter Fundamental Units L,M,T :I',VAR(1, 2), VAR(1, 3), VAR(1, I, LOCATE 23, 1: PRINT II LOCATE 22, 1: PRINT It OPEN "O", #2, "A:UNITS.DAT" MAXVAR = MAXVAR + 1 WRITE #2, MAXVAR FOR Q = 1 TO MAXVAR - 1 WRITE 62, DAT(Q, l), 4) 2), DAT(Q, 3), DAT(Q, NEXT Q FL;;", ",;, VAR(I, 1), VAR(I, (I, 3), VAR (II 4)
4) II
536
S. M. CALISALand H. L. WONG
OPEN "A:NAMEDAT.DAT" FOR APPEND AS #3 WRITE #3, VARNAME(1) CLOSE #3 FOR Q = 1 TO 4 DAT(MAXVAR, Q) = VAR(1, Q) NEXT Q END SUB