Volumetric Fraction of Second Phase


Language: GWBasic.

Objective: This program is part of a Quantitative Metallography Package. Given a set of data about the number of intercepts between a test grid and the grains of a second phase, it makes the necessary calculations required for the determination of the volumetric fraction of this second phase, including a simple statistical analysis of the results.


***** Begin of Program Listing *****

10  REM
12  REM  ***             QUANTITATIVE METALLOGRAPHY PACKAGE
14  REM  ***
16  REM  ***        Calculation of the Volumetric Fraction of Second Phase
18  REM  ***
20  REM  ***        References:
22  REM  ***
24  REM  ***      - UNDERWOOD, N. Quantitative Stereology. Addison-
26  REM  ***        Wesley, Reading, 1970.
28  REM  ***
30  REM  ***
32  REM  ***
34  REM  ***        Authors: Antonio Gorni & Osvaldo Branchini.
35  REM  ***                 COSIPA - I.ME - C.P. 11
36  REM  ***                 11573-900   Cubatao SP      Brazil
37  REM  ***
38  REM  ***                    October 31, 1988
40  REM  ***
100  SCREEN 1: SCREEN 0: KEY OFF: OPTION BASE 0: DIM PQT(300), VV(300), VS(300): B$ = CHR$(7): ON ERROR GOTO 1430
110  VIEW PRINT 1 TO 24: CLS : BF$ = "VOLUMETRIC FRACTION OF SECOND PHASE": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: PRINT : PRINT : LOCATE 5
120  LOCATE , 10: PRINT "<1> Data Input": PRINT
130  LOCATE , 10: PRINT "<2> Data Correction": PRINT
140  LOCATE , 10: PRINT "<3> Data Suppression": PRINT
150  LOCATE , 10: PRINT "<4> Data Output": PRINT
160  LOCATE , 10: PRINT "<5> Data Saving": PRINT
170  LOCATE , 10: PRINT "<6> Results Output"
180  PRINT : LOCATE , 10: PRINT "<7> End"
190  LOCATE 23: BF$ = "(c) 1988, by": PRINT TAB((40 - LEN(BF$)) / 2 + 1); BF$: BF$ = "ANTONIO GORNI & OSVALDO BRANCHINI": PRINT TAB((40 - LEN(BF$)) / 2 + 1); BF$;
200  LOCATE 20, 10: INPUT "Your Choice"; RR
210  IF RR > 7 OR RR < 1 THEN PRINT B$: GOTO 110
220  ON RR GOTO 230, 500, 530, 620, 880, 1000, 1240
230  CLS : BF$ = "DATA ENTRY": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: VIEW PRINT 4 TO 24: LOCATE 8
240 LOCATE , 13: PRINT "<1> New Data": LOCATE 13: LOCATE , 13: PRINT "<2> More Data": LOCATE 22: LOCATE , 13: INPUT "Your Choice"; RF: IF RF < 1 OR RF > 2 THEN PRINT B$: GOTO 230
250 R$ = ""
260  IF FS <> 0 AND RF = 1 THEN CLS : LOCATE 8: BF$ = "DATA NOT SAVED YET!": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 31, 0: PRINT B$; BF$: COLOR 7, 0 ELSE 280
270 LOCATE 20: INPUT "Do you Really Want to Enter New Data (Y/N)"; R$: IF R$ <> "Y" AND R$ <> "N" THEN PRINT B$: GOTO 260
280  IF R$ = "N" THEN 110
290  IF RF = 1 THEN NP = 0: FS = 0: AQ$ = ""
300  IF RF = 2 THEN FS = -1
310  VIEW PRINT 1 TO 24: CLS : BF$ = "INPUT OPTION": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0
320 LOCATE 8: LOCATE , 14: PRINT "<1> Keyboard": LOCATE 13: LOCATE , 14: PRINT "<2> Disk": LOCATE 20: LOCATE , 14: INPUT "Your Choice"; RE: IF RE < 1 OR RE > 2 THEN PRINT B$: GOTO 310
330  ON RE GOTO 340, 440
340  CLS : BF$ = "INPUT VIA KEYBOARD": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: VIEW PRINT 2 TO 24: LOCATE 7: FS = -1
350  IF RF = 2 THEN PRINT "Number of Points in the Grid"; GD: PRINT : PRINT "Magnification: "; M; "x": GOTO 380
360  INPUT "Number of Points in the Grid "; GD: PRINT
370  PRINT : INPUT "Magnification"; M
380  PRINT : PRINT
390  PRINT "Now Enter the number of intercepts;": PRINT "Enter END to Finish."
400 NP = NP + 1: PRINT : PRINT "----------------------------------------"
410  PRINT "V/V("; NP; ")";
420  INPUT ""; B1$: IF B1$ = "END" THEN NP = NP - 1: GOTO 110
430 PQT(NP) = VAL(B1$): VV(NP) = PQT(NP) / GD * 100: GOTO 400
440  CLS : BF$ = "INPUT VIA DISK": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0
450 VIEW PRINT 2 TO 24: LOCATE 10: PRINT "Input File (? to List Directory)?": PRINT : INPUT "", AQ$
460 IF AQ$ = "?" THEN CLS : LOCATE 6: INPUT "Directory"; DD$: PRINT : FILES DD$ + "*.FVA": PRINT : INPUT "Press  to Continue...", R$: CLS : GOTO 450
470 AQ$ = AQ$ + ".FVA"
480  LOCATE 20: COLOR 31, 0: PRINT "READING"; AQ$: COLOR 7, 0: OPEN "I", #1, AQ$: INPUT #1, NR: INPUT #1, M: INPUT #1, GD: FOR I = 1 TO NR: INPUT #1, PQT(NP + I): VV(NP + I) = PQT(NP + I) / GD * 100: NEXT I
490  CLOSE #1: NP = NP + NR: GOTO 110
500  CLS : BF$ = "DATA CORRECTION": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: PRINT : PRINT 
505  VIEW PRINT 2 TO 24: LOCATE 8: PRINT "Magnification: "; M; "x": PRINT : PRINT "Number of Points in the Grid: "; GD: PRINT : PRINT
510  PRINT "----------------------------------------": INPUT "Index of the Point (END to Finish)"; BF$: IF BF$ = "END" THEN FS = -1: GOTO 110
520 IC = VAL(BF$): PRINT : PRINT "V/V="; : PRINT " "; PQT(IC); TAB(20); : INPUT ""; PQT(IC): VV(IC) = PQT(IC) / GD * 100: PRINT : GOTO 510
530  CLS : BF$ = "DATA SUPPRESSION": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: LOCATE 10: VIEW PRINT 2 TO 24: ISA = 0
540  LOCATE 7: INPUT "Index of the Point (END to Finish)"; BF$: IF BF$ = "END" THEN 580
550 IC = VAL(BF$): PRINT : PRINT : PRINT PQT(IC): PRINT : PRINT : PRINT B$; : INPUT "Confirm (Y/N)! "; BF$: IF BF$ = "N" THEN CLS : GOTO 540
560  IF BF$ <> "Y" THEN 550
570  CLS : ISA = ISA + 1: VS(ISA) = IC: GOTO 540
580  IF ISA = 0 THEN 110
590  LOCATE 16: PRINT 31, 0: PRINT "MAKING SUPPRESIONS...": PRINT 7, 0: FOR I = 1 TO ISA - 1: FOR J = I + 1 TO ISA: IF VS(J) > VS(I) THEN IA = VS(J): VS(J) = VS(I): VS(I) = IA
600  NEXT J, I: FS = -1
610  FOR J = 1 TO ISA: FOR I = VS(J) TO NP - 1: PQT(I) = PQT(I + 1): VV(I) = VV(I + 1): NEXT I: NP = NP - 1: NEXT J: CLS : GOTO 110
620  CLS : BF$ = "DATA OUTPUT": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: CL = 0: VIEW PRINT 4 TO 24
630  LOCATE 8: LOCATE , 13: PRINT "<1> Screen": LOCATE 13, 13: PRINT "<2> Printer": LOCATE 22, 13: INPUT "Your Choice"; RE: IF RE < 1 OR RE > 2 THEN PRINT B$: GOTO 630
640  CLS
650  IF RE = 2 THEN 1450
660 LOCATE 10: PRINT "Data were Determined with:": PRINT : PRINT
670  PRINT "Magnification: "; M; "x.": IF RE = 1 THEN PRINT
680  PRINT "Grid with: "; GD; " points.": IF RE = 1 THEN LOCATE 22
690  INPUT "Press  para begin listing.", BF$: CLS : CL = 4
700  FOR I = 1 TO NP
710 PRINT : PRINT "Point #"; I: PRINT "V/V = "; PQT(I); TAB(20); VV(I); "%": CL = CL + 3
720  IF CL >= 22 AND I < NP THEN PRINT : PRINT "Press  to Continue... "; : CL = 4: INPUT "", R$: CLS
730  GOTO 740
740  NEXT
750  PRINT : INPUT "Press  to Continue...", BF$: CLS : LOCATE 12: COLOR 31, 0: PRINT "Crunching Numbers... Please Wait for a While!": COLOR 7, 0
760  FOR I = 1 TO 5: VM(I) = 0: VI(I) = 100: NEXT I
770  FOR I = 1 TO NP: IF PQT(I) > VM(5) THEN GOSUB 800
780  IF PQT(I) < VI(5) THEN GOSUB 820
790  NEXT I: GOTO 840
800 VM(5) = PQT(I): V1(5) = I: FOR K = 1 TO 4: FOR J = K + 1 TO 5: IF VM(J) > VM(K) THEN IA = VM(K): VM(K) = VM(J): VM(J) = IA: IA = V1(K): V1(K) = V1(J): V1(J) = IA
810  NEXT J, K: RETURN
820 VI(5) = PQT(I): V2(5) = I: FOR K = 1 TO 4: FOR J = K + 1 TO 5: IF VI(J) < VI(K) THEN IA = VI(K): VI(K) = VI(J): VI(J) = IA: IA = V2(K): V2(K) = V2(J): V2(J) = IA
830  NEXT J, K: RETURN
840  CLS : LOCATE 8: PRINT "The 5 Lowest Points Are:": PRINT : PRINT VI(1); TAB(8); VI(2); TAB(16); VI(3); TAB(24); VI(4); TAB(32); VI(5)
850 PRINT "("; V2(1); ")"; TAB(8); "("; V2(2); ")"; TAB(16); "("; V2(3); ")"; TAB(24); "("; V2(4); ")"; TAB(32); "("; V2(5); ")": PRINT : PRINT : PRINT
860  PRINT "The 5 Highest Points Are:": PRINT : PRINT VM(1); TAB(8); VM(2); TAB(16); VM(3); TAB(24); VM(4); TAB(32); VM(5)
870 PRINT "("; V1(1); ")"; TAB(8); "("; V1(2); ")"; TAB(16); "("; V1(3); ")"; TAB(24); "("; V1(4); ")"; TAB(32); "("; V1(5); ")": LOCATE 22: INPUT "Press  to Continue...", BF$: GOTO 110
880  CLS : BF$ = "DATA SAVING ON DISK": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: VIEW PRINT 2 TO 24
890  IF AQ$ = "" OR AQ$ = "?" THEN 940
900  LOCATE 10: PRINT "The Current File is "; LEFT$(AQ$, LEN(AQ$) - 3)
910  LOCATE 12: INPUT "Keep it (Y/N)"; R$: IF R$ <> "Y" AND R$ <> "N" THEN PRINT B$: GOTO 910
920  IF R$ = "Y" THEN 970
930  CLS
940  LOCATE 10: PRINT "File Name (? to List Directory)?": PRINT : INPUT "", AQ$
950  IF AQ$ = "?" THEN CLS : LOCATE 6: INPUT "Directory"; DD$: PRINT : FILES DD$ + "*.FVA": PRINT : PRINT : INPUT "Press  to Continue...", R$: CLS : GOTO 940
960 AQ$ = AQ$ + ".FVA"
970  LOCATE 20: COLOR 31, 0: PRINT "SAVING IN "; AQ$: COLOR 7, 0
980  OPEN "O", #1, AQ$: PRINT #1, NP: PRINT #1, M: PRINT #1, GD: FOR I = 1 TO NP: PRINT #1, PQT(I): NEXT I: CLOSE #1
990 FS = 0: GOTO 110
1000  CLS : BF$ = "RESULTS OUTPUT": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: VIEW PRINT 2 TO 24
1010  LOCATE 8, 14: PRINT "<1> Screen": LOCATE 14, 14: PRINT "<2> Printer": LOCATE 21, 14: INPUT "Your Choice"; RE: IF RE < 1 OR RE > 2 THEN PRINT B$: GOTO 1010
1020  IF RE = 2 THEN 1550
1030 CL = 6: CLS : LOCATE 4: PRINT "Volumetric Fraction Values [VV] (%):"
1040  PRINT : PRINT : FOR I = 1 TO NP STEP 8: FOR J = 0 TO 7: IF I + J > NP THEN 1090
1050  PRINT USING "##.#"; VV(I + J); : IF J < 7 THEN PRINT TAB(J * 5 + 6);
1060  NEXT J: PRINT : CL = CL + 1
1070  IF CL >= 22 AND I < NP - 5 THEN PRINT : INPUT "Press  to Continue...", R$: CL = 6: CLS : PRINT : PRINT "Volumetric Fraction Values [VV] (%):"
1080  NEXT
1090  LOCATE 24, 1: INPUT "Press  to Continue...", R$: CLS
1100  GOSUB 1280
1110 LOCATE 8: PRINT "Number of Points = "; NP: IF RE = 1 THEN PRINT : PRINT
1120  PRINT "Magnification = "; M; "x": IF RE = 1 THEN PRINT : PRINT
1130  PRINT "Number of  Points in the Grid = "; GD: PRINT : PRINT : PRINT
1140 LOCATE 22: INPUT "Press  to Continue...", BF$: CLS : LOCATE 6
1150 BF$ = "=> Statistical Analysis <=": PRINT TAB((40 - LEN(BF$)) / 2 + 1); BF$: PRINT : PRINT : LOCATE 10
1160  PRINT "Mean VV = "; MD
1170  PRINT "Standard Deviation = "; INT(DP * 100) / 100
1180  PRINT : PRINT "N(1%)= "; INT(NM(1) + .5); TAB(14); "N(3%) = "; INT(NM(3) + .5); TAB(28); "N(5%) = "; INT(NM(5) + .5): PRINT
1190  PRINT "Real Precision = "; INT(PRE * 100) / 100; " %"
1200  PRINT "Precision of the Mean = "; INT((MD * PRE / 100) * 100) / 100
1210  PRINT "Mean Amplitude = "; INT(MD * 100) / 100; " +/- "; INT((MD * PRE / 100) * 100) / 100
1220 LOCATE 22: INPUT "Press  to Continue...", BF$
1230 GOTO 110
1240 CLS : BF$ = "END OF PROGRAM RUN": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: VIEW PRINT 2 TO 24: IF FS = 0 THEN 1270
1250  LOCATE 8: BF$ = "DATA NOT SAVED YET!": PRINT TAB((40 - LEN(BF$)) / 2 + 1); : COLOR 31, 0: PRINT B$; BF$: COLOR 7, 0
1255  LOCATE 20: INPUT "Do Your Really Want to Quit (Y/N)"; R$: IF R$ <> "Y" AND R$ <> "N" THEN PRINT B$: GOTO 1250
1260  IF R$ = "N" THEN 110
1270 VIEW PRINT 1 TO 24: SCREEN 0: SCREEN 2: SCREEN 0: CLS : KEY ON: END
1280  REM  SUB-ROTINA PARA CALCULAR MEDIA, DESVIO PADRAO E ERRO DA MEDIA
1290 HP = 0: TX = 0
1300  REM  HP- SOMATORIA DE VV; TX- SOMATORIA DE VV^2; MD- MEDIA DE VV; DP- DESVIO PADRAO DE VV.
1310  FOR I = 1 TO NP
1320 HP = HP + VV(I)
1330 TX = TX + (VV(I) ^ 2)
1340  NEXT I
1350 MD = HP / NP
1360 DP = ((TX - (HP ^ 2 / NP)) / (NP - 1))
1370 DP = SQR(DP)
1380  FOR KJ = 1 TO 5 STEP 2
1390 NM(KJ) = (200 * DP / (KJ * MD)) ^ 2
1400  NEXT KJ
1410 PRE = 200 * DP / MD / SQR(NP)
1420  RETURN
1430 CLS : LOCATE 12: COLOR 31, 0: IF ERR = 53 THEN PRINT "File Not Found!" ELSE PRINT "ERROR "; ERR; " AT LINE "; ERL; "!"
1440 COLOR 7, 0: LOCATE 22: INPUT "Press  to Continue...", BF$: RESUME 110
1450 LOCATE 10: PRINT "Prepare Printer;": PRINT "Mark Start of Report.": PRINT : PRINT : PRINT
1460 PRINT "Identification Message?": PRINT : LINE INPUT "", BF$: LPRINT "DATA  FOR CALCULATION OF VOLUMETRIC FRACTION - "; BF$: CL = 5: LPRINT DATE$, TIME$: LPRINT
1470 IF RE = 1 THEN LOCATE 10: LPRINT "Measuring Conditions:": LPRINT : LPRINT
1480 LPRINT "Magnification: "; M; "x."
1490 LPRINT "Grid with "; GD; " points."
1500 LPRINT
1510  FOR I = 1 TO NP
1520  LPRINT "#"; I; TAB(10); PQT(I): CL = CL + 1
1530  IF CL >= 57 THEN LPRINT CHR$(12): CL = 0
1540  NEXT: LPRINT CHR$(12): GOTO 110
1550 CLS : LOCATE 8: PRINT "Prepare Printer!": PRINT : PRINT "Now Enter Identification Message"; : PRINT "to be Printed in the Beginning of Report.": PRINT : LINE INPUT "", BF$
1555 PRINT "VOLUMETRIC FRACTION OF SECOND PHASE - "; BF$
1560 LPRINT DATE$, TIME$: LPRINT : LPRINT :
1570 LPRINT "Number of Points = "; NP
1580 LPRINT "Magnification = "; M; "x"
1590 LPRINT "Number of Points in the Grid = "; GD
1600 LPRINT : LPRINT : LPRINT "Volumetric Fractrion [VV] Values (%):"
1610 LPRINT : FOR I = 1 TO NP STEP 15: FOR J = 0 TO 14: IF I + J > NP THEN 1650
1620  LPRINT USING "##.#"; VV(I + J); : LPRINT " "; : IF J < 14 THEN PRINT TAB(J * 5 + 6);
1630  NEXT J: LPRINT
1640  NEXT
1650  GOSUB 1280
1660 LPRINT : LPRINT : LPRINT : BF$ = "=> Statistical Analysis <=": LPRINT TAB((40 - LEN(BF$)) / 2 + 1); BF$: LPRINT : LPRINT
1670  LPRINT "Mean Volumetric Fraction = "; MD
1680  LPRINT "Standard Deviation = "; INT(DP * 100) / 100
1690  LPRINT : LPRINT "N(1%)= "; INT(NM(1) + .5); TAB(14); "N(3%) = "; INT(NM(3) + .5); TAB(28); "N(5%) = "; INT(NM(5) + .5): LPRINT
1700  LPRINT "Real Precision = "; INT(PRE * 100) / 100; " %"
1710 LPRINT "Precision of the Mean = "; INT((MD * PRE / 100) * 100) / 100
1720 LPRINT "Mean Amplitude = "; INT(MD * 100) / 100; " +/- "; INT((MD * PRE / 100) * 100) / 100
1730 LPRINT CHR$(12): GOTO 110

***** End of Program Listing ******

Return to the Software Menu.

Last Update: 25 June 1996
© Antonio Augusto Gorni