! APMonitor Modeling Language
! http://www.apmonitor.com

! Binary Distillation Column from
!
! Hahn, J. and T.F. Edgar, An improved method for nonlinear model reduction using balancing of
!   empirical gramians, Computers and Chemical Engineering, 26, pp. 1379-1397, (2002)
!
! Liquid mole fraction of component A
!   at reflux ratio = 2
!
! Condenser  0.93541941614016
! Tray 1     0.90052553715795
! Tray 2     0.86229645132283
!   .        0.82169940277993
!   .        0.77999079584355
!   .        0.73857168629759
!   .        0.69880490932694
!   .        0.66184253445732
!   .        0.62850777645505
!   .        0.59925269993058
!   .        0.57418567956453
!   .        0.55314422743545
!   .        0.53578454439850
!   .        0.52166550959767
!   .        0.51031495114413
!   .        0.50127509227528
!   .        0.49412891686784
!   .        0.48544992019184
!   .        0.47420248108803
!   .        0.45980349896163
!   .        0.44164297270225
!   .        0.41919109776836
!   .        0.39205549194059
!   .        0.36024592617390
!   .        0.32407993023343
!   .        0.28467681591738
!   .        0.24320921343484
!   .        0.20181568276528
!   .        0.16177269003094
! Tray 29    0.12514970961746
! Tray 30    0.09245832612765
! Reboiler   0.06458317697321

Model binary
  Parameters
    ! reflux ratio
    rr = 0.7

    ! Feed Flowrate (mol/min)
    Feed =  2.0 ! 24.0/60.0
    ! Mole Fraction of Feed
    x_Feed = 0.5
    ! Relative Volatility = (yA/xA)/(yB/xB) = KA/KB = alpha(A,B)
    vol=1.6
    ! Total Molar Holdup in the Condenser
    atray=0.25
    ! Total Molar Holdup on each Tray
    acond=0.5
    ! Total Molar Holdup in the Reboiler
    areb=0.1
  End Parameters

  Variables
    ! mole fraction of component A
    x[1:32] = 0.3
  End Variables

  Intermediates
    ! Distillate Flowrate (mol/min)
    D=0.5*Feed
    ! Flowrate of the Liquid in the Rectification Section (mol/min)
    L=rr*D
    ! Vapor Flowrate in the Column (mol/min)
    V=L+D
    ! Flowrate of the Liquid in the Stripping Section (mol/min)
    FL=Feed+L

    ! Vapor Mole Fractions of Component A
    ! From the equilibrium assumption and mole balances
    ! 1) vol = (yA/xA) / (yB/xB)
    ! 2) xA + xB = 1
    ! 3) yA + yB = 1
    y[1:32] = x[1:32]*vol/(1+(vol-1)*x[1:32])
  End Intermediates

  Equations
    ! condenser
    acond * $x[1] = V*(y[2]-x[1])

    ! 15 column stages
    atray * $x[2:16]  = L*(x[1:15]-x[2:16]) - V*(y[2:16]-y[3:17])

    ! feed tray
    atray * $x[17] = Feed*x_Feed + L*x[16] - FL*x[17] - V*(y[17]-y[18])

    ! 14 column stages
    atray * $x[18:31] = FL*(x[17:30]-x[18:31]) - V*(y[18:31]-y[19:32])

    ! reboiler
    areb  * $x[32] = FL*x[31] - (Feed-D)*x[32] - V*y[32]
  End Equations
End Model

