** NOTE: Be sure to edit out all the html text before running this!!**

**AUTHOR: Billy Abernathy DATE: 4/28/96
*-------------------------------------------------------------------------
* 1 2 3 4 5 6 7
*23456789012345678901234567890123456789012345678901234567890123456789012
*-------------------------------------------------------------------------
C Program phaseb.for
C$ NOEXTENSIONS NOWARNINGS
CHARACTER*50 IMMISC, MISC
REAL XB, DELHA, DELHB, TSTARA, TSTARB, TB, TA, R, TE, T, DT, XE
DOUBLE PRECISION DELGAM, DELGBM, XBS, XBL
PARAMETER (R = 8.31451)
** The program will generate two data files, the names of which are
** inputted by the user. The immiscible solids data output assumes the
** two substances are completely miscible (soluble) as liquids and
** completely immiscible as solids. This data (when plotted T vs. Xb)
** will generate a simple binary phase diagram, showing if there is a
** possible eutectic point.
** The second data file does not assume complete solid immiscibility and
** will calculate liquidus and solidus lines. It does assume an ideal
** solution.
WRITE (*,*) 'Enter the name of the immiscible solids data output f
Gile.'
READ '(A)', IMMISC
WRITE (*,*) 'Enter the name of the miscible solids data output fil
Ge.'
READ '(A)', MISC
OPEN (3, FILE = MISC)
OPEN (4, FILE = IMMISC)
WRITE (*,*) 'Now enter the melting temperatures of pure A and B (i
Gn Kelvin), followed by the heats of fusion of pure A and B (in jou
Gles per mole).'
WRITE (*,*) 'NOTE: For simplicity, enter the data so Ta > Tb'
READ *, TSTARA,TSTARB,DELHA,DELHB
WRITE (4,*) ' Xb T '
WRITE (4,10) 0., TSTARA
** Here all the temperature-composition data for the immiscible data
** set is calculated. For each mole fraction of species B, the higher
** melting point is chosen for the plot. If the two melting point
** lines intersect, the program notes it that point as a eutectic
** point and will write in a whole string of compositions at that
** temperature.
DT = .02
TE = 0.
DO N = 1,199,1
XB = REAL(N)/200
TA = (TSTARA*DELHA)/(DELHA - R*TSTARA*LOG(1-XB))
TB = (TSTARB*DELHB)/(DELHB - R*TSTARB*LOG(XB))
IF (TA.GT.TB) THEN
T = TA
ELSE
T = TB
END IF
** Here the two melting points are compared to see if we're at a eutectic
** point. The tolerance level right now is set at 2 percent.
IF (DT.GT.(ABS((TA-TB)/TA))) THEN
DT = ABS((TA - TB)/TA)
IF (DT.LT..02) THEN
TE = (TA + TB)/2
XE = XB
END IF
ELSE
END IF
WRITE (4,10) XB, T
END DO
WRITE (4,10) 1.,TSTARB
** If a eutectic point was found, the program will now store a series of
** compositions at that temperature for your plot.
IF (TE.GT.1.) THEN
WRITE (4,'(// A /)') 'Eutectic data:'
WRITE (4,*) ' Xb T '
DO N = 1,101,1
XB = REAL(N)/100 - 0.01
T = TE
WRITE (4,10) XB,T
END DO
ELSE
WRITE (4,*) 'No eutectiod detected.'
END IF
** Whew! One set of data down. Now a similar process is used to produce the
** other set of data, except now since we cannot solve these equations
** explicitly for T, we are finding mole fractions corresponding to
** temperatures lower than the higher melting point.
WRITE (3,*) ' T Xbs
G Xbl '
DO N = 75,INT(TSTARA),1
T = REAL(N)
DELGAM = DELHA*(1 - T/TSTARA)
DELGBM = DELHB*(1 - T/TSTARB)
XBS = (1 - DEXP(-DBLE(DELGAM)/(R*T)))/(DEXP(-DBLE(DELGBM)/(R*T))
G- DEXP(-DBLE(DELGAM)/(R*T)))
XBL = XBS*DEXP(-DBLE(DELGAM)/(R*T))
IF (XBS.GT.0.0.AND.XBS.LT.1.0) THEN
IF (XBL.GT.0.0.AND.XBL.LT.1.0) THEN
WRITE (3,*) T,XBS,XBL
ELSE
WRITE (3,*) T,XBS,0.0
END IF
ELSE IF (XBS.GT.1.0.AND.XBL.LT.1.0.AND.XBL.GT.0.0) THEN
WRITE (3,*) T,1.0,XBL
ELSE IF (XBS.LT.0.0.AND.XBL.LT.1.0.AND.XBL.GT.0.0) THEN
WRITE (3,*) T,0.0,XBL
END IF
END DO

10 FORMAT (1X,F6.4,2X,F6.2)
END



Billy Abernathy 5/1/96


Project Hompage | Experimental Page
URL=http://www.eng.vt.edu/eng/materials/classes/MSE2094_NoteBook/96ClassProj/ experimental/fortran.html