*DECK SEP08
      SUBROUTINE INITAL
C...
C...  STARTUP AND CONTROL OF A PLATE ABSORBER
C...
C...  A FOUR-TRAY TOWER IS BEING PLANNED TO REMOVE NH3 FROM AIR USING
C...  WATER AT A RATE OF 40 GM MOL/SEC (FN).  THE ENTERING GAS CONTAINS
C...  4 O/O NH3 AT A FLOW RATE OF 50 GM MOL/SEC (V0).
C...
C...  INITIALLY, THERE ARE 100 GM MOLS OF WATER ON EACH TRAY.  THE
C...  MOLAR LIQUID FLOW RATE, LN, FROM EACH TRAY IS GIVEN BY
C...
C...               LN = 0.2*(HN - 1200)**1.5
C...
C...  WHERE HN IS THE MOLAR LIQUID HOLDUP ON TRAY N.  THUS A MINIMUM
C...  OF 1200 GM MOLS OF LIQUID IS NEEDED ON EACH TRAY BEFORE LIQUID
C...  STARTS FLOWING FROM EACH TRAY.  THE EQUILIBRIUM RELATIONSHIP
C...  FOR THE CONDITIONS IN THE COLUMN IS
C...
C...                      Y = 0.78*X
C...
C...  PROGRAM A DYNAMIC MODEL TO CALCULATE THE EXITING GAS AND LIQUID
C...  COMPOSITIONS BASED ON THE FOLLOWING ASSUMPTIONS
C...
C...                    IDEAL TRAYS
C...
C...                    NEGLIGIBLE GAS HOLDUP
C...
C...                    ISOTHERMAL OPERATION
C...
      PARAMETER (NT=4)
      COMMON/T/      T,  NSTOP,  NORUN
     +      /Y/ HX(NT),  H(NT)
     +      /F/HXT(NT), HT(NT)
     +      /C/     V0,     FN,   HMIN,   WEIR,      Y0,      XN,
     +           Y(NT),  X(NT), FL(NT)
C...
C...  SET THE MODEL PARAMETERS
      FN=40.
      V0=50.
      HMIN=1200.
      WEIR=0.2
C...
C...  SET THE MODEL INITIAL CONDITIONS
      DO 1 N=1,NT
C...
C...  SET THE INITIAL TOTAL LIQUID HOLDUPS ON THE TRAYS
      H(N)=100.0
C...
C...  SET THE INITIAL NH3 HOLDUPS ON THE TRAYS ((TOTAL HOLDUP)*
C...  NH3 MOL FRACTION IN THE LIQUID) = HX)
       X(N)=0.
      HX(N)=H(N)*X(N)
    1 CONTINUE
C...
C...  SET THE ENTERING GAS AND LIQUID COMPOSITIONS
      Y0=0.04
      XN=0.
C...
C...  INITIALIZE THE CALCULATIONS IN DERV
      CALL DERV
      RETURN
      END
      SUBROUTINE DERV
      PARAMETER (NT=4)
      COMMON/T/      T,  NSTOP,  NORUN
     +      /Y/ HX(NT),  H(NT)
     +      /F/HXT(NT), HT(NT)
     +      /C/     V0,     FN,   HMIN,   WEIR,      Y0,      XN,
     +           Y(NT),  X(NT), FL(NT)
C...
C...  MODEL ALGEBRA
      DO 2 N=1,NT
C...
C...  LIQUID COMPOSITIONS, X(N), FROM THE PRODUCTS H(N)*X(N) (=
C...  HX(N)) AND THE LIQUID HOLDUPS, H(N)
      X(N)=HX(N)/H(N)
C...
C...  GAS COMPOSITIONS
      Y(N)=0.78*X(N)
C...
C...  LIQUID FLOW RATES
      FL(N)=0.
      IF(H(N).GT.HMIN)FL(N)=WEIR*(SQRT(H(N)-HMIN))**3
    2 CONTINUE
C...
C...  MODEL DIFFERENTIAL EQUATIONS
C...
C...     TOTAL MATERIAL BALANCE
C...
C...        DH(N)/DT = L(N+1) - L(N)
C...
C...     COMPONENT (NH3) BALANCE
C...
C...        D(H(N)*X(N))/DT = L(N+1)*X(N+1) + V0*Y(N-1)
C...
C...                        - L(N)*X(N) - V0*Y(N)
C...     N = 1, 2,..., NT
C...
C...  TRAY 1
      HT(1)=FL(2)-FL(1)
      HXT(1)=FL(2)*X(2)+V0*Y0-FL(1)*X(1)-V0*Y(1)
C...
C...  TRAY NT
      HT(NT)=FN-FL(NT)
      HXT(NT)=FN*XN+V0*Y(NT-1)-FL(NT)*X(NT)-V0*Y(NT)
C...
C...  TRAYS 2 TO NT-1
      DO 1 N=2,NT-1
      HT(N)=FL(N+1)-FL(N)
      HXT(N)=FL(N+1)*X(N+1)+V0*Y(N-1)-FL(N)*X(N)-V0*Y(N)
    1 CONTINUE
      RETURN
      END
      SUBROUTINE PRINT(NI,NO)
      PARAMETER (NT=4)
      COMMON/T/      T,  NSTOP,  NORUN
     +      /Y/ HX(NT),  H(NT)
     +      /F/HXT(NT), HT(NT)
     +      /C/     V0,     FN,   HMIN,   WEIR,      Y0,      XN,
     +           Y(NT),  X(NT), FL(NT)
C...
C...  DIMENSION THE ARRAYS FOR STORING THE PLOTTED SOLUTION
      REAL X1P(101), YNTP(101), TP(101)
C...
C...  INITIALIZE A COUNTER FOR THE PLOTTED SOLUTION
      DATA IP/0/
C...
C...  PRINT THE NUMERICAL SOLUTION EVERY TENTH CALL TO PRINT
      IP=IP+1
      IF(((IP-1)/10*10).EQ.(IP-1))THEN
         WRITE(NO,1)T,V0,(Y(I),I=1,NT),(X(I),I=1,NT),(H(I),I=1,NT)
1        FORMAT(1H ,//,5H T = ,F5.0,7X,5HV0 = ,F5.1,/,
     1              5H Y = ,4F11.5,/,
     2              5H X = ,4F11.5,/
     3              5H H = ,4F11.0,/)
      END IF
C...
C...  STORE THE NUMERICAL SOLUTION FOR PLOTTING
      X1P(IP)=X(1)
      YNTP(IP)=Y(NT)
      TP(IP)=T
C...
C...  AT THE END OF THE RUN, PLOT THE NUMERICAL SOLUTION
      IF(IP.LT.101)RETURN
C...
C...  EXITING LIQUID COMPOSITION
      CALL TPLOTS(1,IP,TP,X1P)
      WRITE(NO,11)
11    FORMAT(1H ,//,' X(1) (MOL FR) VS T (SEC)')
C...
C...  EXITING GAS COMPOSITION
      CALL TPLOTS(1,IP,TP,YNTP)
      WRITE(NO,12)
12    FORMAT(1H ,//,' Y(NT) (MOL FR) VS T (SEC)')
      IP=0
      RETURN
      END

