Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives,...
-
Upload
jacob-h-jack-lashover -
Category
Documents
-
view
213 -
download
0
Transcript of Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives,...
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
1/56
Monte Carlo Marching Distillation: Simultaneous solution
of the MESH equations with no derivatives, no initial values,
and no doubt about completion.
Jacob H. LashoverFebruary 29, 2016 Baton Rouge, Louisiana
Abstract: The mathematical solution technique named Monte Carlo Marching
(MCM) by the author (Lashover, 2012) was previously used to solve flashvaporization and dew point problems for multicomponent, non-ideal solutions of
non-electrolytes. It was developed for chemical engineering calculations to avoidtaking the complicated calculus derivatives required for Newton-Rhapson solutions
and to guarantee convergence. This work extends use of the MCM method to thedesign of distillation towers which require significantly more model equations and
variables to describe a separation cascade or collection of contacting stages. Themodel equations which include descriptor variables such as liquid and vapor flow
rates, compositions, and equilibrium temperatures are called MESH equations andcan be solved to accomplish a given separation or to reduce the required amount of
the mass- or energy- separating agent. (Seader, 1998) The equations are put into a
linear programming form called constraint equations which are designed to be
convex. (Conley, 1984) Similar to “Maximum Likelihood” methods, the constraintequations are added to form a convex objective function which can thus be
minimized. (Banbura, 2010) Using the concept of arbitrary hyper-rectangles
(Faloutsos, 1903), the variables are placed in hyper-rectangles which are sized by the boundary values of the variables: 0 to 1 for mole fractions of
compositions, low boiler to high boiler boiling points for bubble points, etc.The values of the variables are simultaneously improved from their lower boundary values toward their higher boundary values by randomly analyzing linear
regions of the hyper-rectangles. (Eckhardt, 1987) A focus factor, FF, is used in
the calculations to reduce the rectangle widths by a power. When the power is
two, the range is bisected. Essentially, the widths of the hyper-rectangles arereduced as the objective function is minimized by better values of the variables
until the rectangles close around the final solution. Successful solutions are
demonstrated for an ideal binary column presented by Cutlip and Shacham (Cutlip,2008) , and a multicomponent, non-ideal column using the temperature and liquid
composition dependent NRTL activity coefficient model. (Renon, 1968)
Multicomponent results for methanol, 2-propanol, and water are compared to aChemSep solution. (Kooijman, 2006) Complete computer code is included.
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
2/56
Key Words: Algorithm, analytical solution, constraints, mathematical method,
optimization, mathematical modeling, QB64 computer language, calculus
derivatives, convergence, non-linear equations, convex objective function,
distillation, chemical engineering, linear programming, Monte Carlo, NRTL,
and MESH equations.
INTRODUCTION: “Newton’s method is one of the most versatile and robustmethods for solving systems of nonlinear equations. It is, in fact, the method of
choice in ChemSep. Newton’s method works extremely well if the initial estimateof the solution vector is ”near” the actual solution. Outside this ”near” region, the
method may converge slowly, oscillate, or diverge. The question to which there isno simple answer is, ‘What exactly is it near?’ Having said this it must also be
stated that Newton’s method is a much more reliable procedure than repeatedsubstitution. An important issue not addressed here is how to tell when the
problem has been solved; that is, when convergence has been obtained. A properdiscussion of this topic is beyond the scope of this work. “ (Kooijman, 2006)
The above statements in “The ChemSep Book” provide the reasons for thiswork. In addition to these problems, some designers have difficulty in performing
the calculus derivatives of the activity coefficient models required by Newton’smethod. The Monte Carlo Marching method requires no derivatives and no initial
estimates of the solution vector. In fact, the initial values of the variables may be
zeroes. It has always converged, and the value of the objective function clearly
signals when the problem has been solved by diminishing to very near zero andremaining constant at the solution. The binary column solution required 0.71
seconds while the more difficult ternary, non-ideal problem required 45 seconds asa finer solution grid was required. Results tables are included and show a
maximum 0.005 difference with Cutlip and Kooijman’s compositions, less than 0.3
degrees C on temperatures, and less than 1% on the flows. Overall mass and
energy balances close within 10-5. The computer used was a 2009 Dell Inspiron
546 Desktop with 6 GB of RAM, and an AMD Phenom™ 9650 Quad-Core
Processor operating at 2.30 GHz. VBA compatible QB64 programming
language was used. These calculation times can obviously be significantlyreduced by the newer computer processors.
Summarizing in layman’s language, if you’ve ever struggled to obtain
convergence with a Newton-Raphson method, “You’re going to love this!”
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
3/56
Development of the Monte Carlo Marching model
The Monte Carlo Marching (MCM) method presented here provides robust
convergence performance without derivatives and is insensitive to initial estimatesof the variables. Application of MCM was demonstrated in an earlier paper
(Lashover, 2012) on several non-linear models including Isaac Newton’s cubic
polynomial, y^3 – 2y -5 = 0, (Cajori, 1911) which Newton used to first
demonstrate his Newton procedure.
“Marching”, “Binary-chop”, “Interval-halving” or “Bi-section” is a simple
convergence procedure which guarantees a solution to “bounded” variables. The
MCM method is an extension of this procedure based on work by Stanislaus Ulam
(Ulam, 1991) and William Conley, both mathematicians.1 The author has
extended Ulam and Conley’s work into the field of chemical engineering. Two
examples are presented.
Example No. 1
Consider the solution for probability, Pr, when the odds are known. These
odds are calculated as (1 – Pr) / Pr. This non-linear equation is not solvable using
algebra. The following simple QB64 program using MCM easily solves for Pr.
The probability, Pr, varies from 0 to 1. When solving for O, odds, using
“Marching”, the lower limit, PL is set to zero and the upper limit, PU, is set equal
to 1.0. The initial value of Pr is calculated as Pr = (PL + PU)/ 2 = 0.50. If the first
iteration produces a negative difference, DEL, between the actual value of O, odds,
and the calculated odds, OO, PL is set equal to Pr. PU is left at 1.0. If the
difference, DEL, is positive, PU is set equal to Pr, and PL is left at 0. The next
1 Ulam is credited with invention of the Monte Carlo computation method and co-inventor with Edward Teller, atheoretical physicist, of the H-Bomb. The author was motivated early in his career by meeting Edward Teller in
1963 where they both presented papers and sat on a panel discussion at an ACS meeting in Gatlinburg, Tennessee.
William Conley, mathematics professor at the University of Wisconsin at Green Bay, first melded linear
programming and the Monte Carlo method for typical operations research problems. Conley assisted the author,
one of the original SABER (Society for American Baseball Research) statisticians, with writing a baseball game
simulator which he used to optimize the batting order for Tulane University’s Division I college baseball team. The
program was successfully used by Tulane in the 1980s.
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
4/56
value of Pr to be tried is again calculated as Pr = (PL + PU)/2 and the process is
repeated. So, if Pr is too low, the lower limit, PL, is raised to Pr as no solution
exists below Pr. Similarly, if Pr is too high, values above PU can be eliminated.
When the “correct” probability is calculated there will be no difference (within
tolerance) between the actual and calculated odds. The error or difference, DEL,eventually becomes very small, and below the acceptable tolerance, TOL. This
method always converges and eliminates one-half of the range of feasible solutions
after each iteration. This can be represented algebraically by the function f(x) = R /
(Xn) where R = the range of solutions, X = 2, and n = 1, 2, 3….n, the number of
the iteration. The limit of this function as n approaches infinity is 0 where the
entire feasible range of solutions has been examined. It does not produce an exact
solution like algebra or calculus can, however it will be shown that this
convergence procedure permits use of constraints which are not easily includedwhen using algebra or calculus.
The QB64 statements demonstrating this method follow:
REM SOLVE NONLINEAR ODDS/PROBABILITY EQUATION
INPUT " ODDS= ", O
LP = 0.0: UP = 1.0: TOL = 0.003
2 PR = (LP + UP) / 2.0
OO = (1 - PR) / PR
DEL = O - OO
IF ABS(DEL)
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
5/56
ODDS FOR WHICH PROBABILITY IS NEEDED= 2
LP UP PR OO O DEL LP UP CYCLE
0 1 0.5 1 2 +1 0 0.5 1
0 0.5 0.25 3 2 -1 0.25 0.5 2
0.25 0.5 0.375 1.667 2 +0.333 0.25 0.375 3
LP UP PR OO O DEL LP UP CYCLE
0.25 0.3750 0.3125 2.2 2 -0.200 0.3125 0.375 4
0.3125 0.3750 0.3438 1.909 2 +0.091 0.3125 0.3438 5
0.3125 0.3438 0.3281 2.048 2 -0.048 0.3281 0.3438 6
0.3281 0.3438 0.336 1.976 2 +0.024 0.3281 0.3360 7
0.3281 0.3360 0.332 2.012 2 -0.012 0.3320 0.3360 8
0.3320 0.3360 0.334 1.994 2 +0.006 0.3320 0.3340 9
0.3320 0.3340 0.333 2.000 2 0.000 10
P= .333Example No. 2 See Lashover, J. H. (2012). Monte Carlo Marching. Baton Rouge, Louisiana:"Academia.edu" for a more detailed explanation of this example.)
Consider the chemical engineering calculation of the fraction of vapor
flashed, V, from a liquid stream whose composition varies from 0 to 100 % or
from 0 to 1.0 as a fraction. The composition of the liquid stream (feed) is known
as are its temperature and pressure, however the compositions of both the vapor
and liquid streams formed are unknown. To complicate matters further, the
composition of the vapor stream formed is related to the composition of the liquidstream formed by a complex, non-linear relationship, i.e. the composition of the
vapor stream is dependent on the yet unknown liquid stream. The mass of the feed
must also equal the total mass of the resulting liquid and vapor streams
(conservation of mass). There have been many solutions presented, including the
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
6/56
author's using MCM, but others fail frequently, especially when V is close to 0 or
1.
When solving for V using “Marching”, the lower limit, VL is set to zero and
the upper limit, VU, is set equal to 1.0. The liquid and vapor concentrationsformed are also bounded between 0 and 1 when expressed as mole fractions and
the total molar concentration of each stream must also sum to unity. An overall
mass balance must be satisfied and calculation of the total pressure must equal the
pressure specified. When one mole of feed is flashed and the total pressure is
equal to one atmosphere, all variables can have a lower limit of 0 and an upper
limit of 1. Since the vapor composition is dependent on the liquid composition, the
liquid compositions become the unknown independent variables. With three
components, there are then four unknown independent variables when V is
included. Actually, there are only two unknown compositions as the third equals
1.0 minus the sum of the other two, however, all three are considered unknown to
avoid losing the constraint requiring the sum of the compositions to be unity.
In MCM, the simple marching technique shown previously is applied to the
multiple variables. These unknown variables are essentially improved from their
lower boundary values toward their higher boundary values by analyzing linear
regions which are inverse multiples of powers of two. This procedure emulates
the guaranteed conversion procedure of “Marching” and satisfies the mathematicaltheories of hyper-rectangles. (Faloutsos, 1903) Remember, after the first iteration
of marching, the region left to study has decreased by ½ or 1/ (2^1). After the
second iteration, the region left to study has decreased to ¼ or 1/ (2^2), and so
forth. The feasible region of solutions for V, after being reduced to ½ by searching
either 0.5 to 1.0 or 0 to 0.5 is next reduced to ¼ by searching either 0.75 to 1.0 or 0
to 0.25. By normalizing all independent variables to 0 to 1 or 0 to 100, no one
variable can overly influence the objective function. As shown in the distillation
examples which follow, this normalization has not always been found necessary.
Finally, the objective function is the sum of the convex constraint equations
which are crafted as the absolute differences of the constraint values from the
desired constraint values at each iteration, i.e., for the V calculation, G1 = ABS(Σ
X – 1.0) would be one constraint, G2 = ABS(ΣY – 1.0) would be the second, G3
= ABS(∑P – 1.0) would be the third, and G4 = ABS(∑Z – V*∑Y – (1 – V)*∑X).
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
7/56
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
8/56
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
9/56
Solving for V Using MCM
Computer Output
Iteration 1
V= .283724138736725
OLD OPT= 1D+30 G= 85.29139956077
NEW OPT= 85.29139956077
SUMX= .8772386085987092
SUMY= .9174543451798476
SUMPT= 92.96106152534807
SUMZX= .9911135121617614
G1= 8.363938474651931 G2= 12.2761391401291 G3= 8.254565482015238 G4=
56.3967564639
7374 G= 85.29139956077
X(1)= .2280518072843552 X(2)= .3864084398746491 X(3)= .262778361439705
Y(1)= .3562745191479074 Y(2)= .3508095455125981 Y(3)= .2103702805193421
LL(1)= 1 LL(2)= 1 LL(3)= 1 LL(4)= 1
UL(1)= 100 UL(2)= 100 UL(3)= 100 UL(4)= 100
R(1)= 49 R(2)= 49 R(3)= 49 R(4)= 49
ZX(1)= .4973556831422566 ZX(2)= .146236918257682 ZX(3)= .3475209107618227
PP(1)= 36.09951565266172 PP(2)= 35.54577719906401 PP(3)= 21.31576867362234
COUNTI= 1 COUNTJ= 1
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
10/56
Final Iteration
V= .9451196705718721
OLD OPT= .108056010212107 G= 8.869474744795088D-02
NEW OPT= 8.869474744795088D-02
SUMX= .9991877469223368
SUMY= .9999986734315671
SUMPT= 101.3248655854536
SUMZX= .990000458304824
G1= 1.344145464514668D-04 G2= .0812253077663172 G3= 1.326568432915565D-04 G4= 7.20236829189065D-03 G= 8.869474744795088D-02
X(1)= .254672596779671 X(2)= 6.184798915739828D-02 X(3)= .6826671609852676
Y(1)= .514203322045091 Y(2)= .1550985014029116 Y(3)= .3306968499835646
LL(1)= 25.43944087766766 LL(2)= 6.15487926417003 LL(3)= 68.2508029011053 LL(4)=
94.5072167416216
UL(1)= 100 UL(2)= 100 UL(3)= 100 UL(4)= 100
R(1)= .048828125 R(2)= .048828125 R(3)= .048828125 R(4)= .048828125
ZX(1)= .495000398096542 ZX(2)= .1485001911742847 ZX(3)= .3464998690339974
PP(1)= 52.10165160621884 PP(2)= 15.71535565465002 PP(3)= 33.50785832458468
COUNTI= 5505 COUNTJ= 12
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
11/56
Table 2. Calculation of V, fraction of vapor flashed, for a 50, 15, 35 mole % mixtureof MeOH, IPA, & H2O, respectively, at 78 C and 101.325 kPa. using
MCM.
LL(1), LL(2), AND LL(3) are lower limits of liq. phase mole%, LL(4) is lower limit of V.
R()'s are ranges of variables to be searched for feasible solutions.
OPT is last optimum value of objective function.G is new optimum found during present iteration.
X's and Y's are liquid and vapor compositions in mole fraction, respectively.
∑X's and ∑Y's are sums of liquid and vapor compositions.
∑kPa and ∑moles are the sums of the vapor pressures and total moles fed.
Total feed is 100 moles while total pressure is 101.325 kPa.
Iteration I 1 2 32 1034 1408 1638 1680 6224
Iteration J 1 1 1 3 3 4 4 13
LL(1) 1 1 1 22.02 22.18 25.61 20.93 25.45
LL(2) 1 1 3.804 1 1 4.79 1.1775 6.175LL(3) 1 1 1 34.15 33.43 44.16 56.58 68.25
LL(4) 1 1 18.08 24.33 1 66.47 76.95 94.5
R(1) 49 71.81 68.7 25 25 12.5 1.25E+01 2.44E-02
R(2) 49 87.64 96.2 20.61 24.07 12.5 1.25E+01 2.44E-02
R(3) 49 75.28 81.72 25 25 12.5 1.25E+01 2.44E-02
R(4) 49 77.37 12.5 25 25 12.5 1.25E+01 2.44E-02
OPT 1.00E+30 85.29 77.93 25.37 15.58 10.87 6.62E+00 8.87E-02
G 85.29 77.93 29.86 19.04 11.82 10.29 6.33E+00 8.75E-02
V 28.37 68.08 37.54 46.69 67.27 78.16 8.86E+01 9.45E+01
X(1) 0.2281 0.197 0.3865 0.3327 0.326 0.3074 2.64E-01 2.55E-01X(2) 0.3864 0.538 0.1309 0.148 0.1111 0.08579 8.26E-02 6.18E-02
X(3) 0.2628 0.3272 0.3112 0.4206 0.4865 0.5548 6.34E-01 6.83E-01
ƩX"S 0.8773 1.0622 0.8285 0.9012 0.9236 0.9421 9.81E-01 9.99E-01
Y(1) 0.3563 0.2928 0.6558 0.5656 0.5769 0.5687 5.06E-01 5.14E-01
Y(2) 0.3508 0.4568 0.1432 0.1867 0.1644 0.1499 1.76E-01 1.55E-01
Y(3) 0.2104 0.304 0.1926 0.2521 0.2712 0.2887 3.19E-01 3.31E-01
ƩY'S 0.9175 1.0536 0.9916 1.0044 1.0126 1.0073 1.00E+00 1.00E+00
ƩkPa 92.96 106.76 100.47 101.77 102.6 102.07 1.01E+02 1.01E+02
Ʃmoles 99.91 98.94 99.11 99.05 99.01 99 9.90E+01 1.00E+02
Redlich-Kister model for activity coefficients; Raoult's Law for vapor phase
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
12/56
V X1 X2 X3 Y1 Y2 Y3
Derivative 94.34 0.2579 0.06269 0.6794 0.5145 0.1552 0.3302
MCM 94.56 0.2545 0.06175 0.6831 0.5141 0.1551 0.3308
Δ -0.22 0.0034 0.00094 -0.0037 0.0004 0.0001 -0.0006
Table 3. Comparison of MCM results with results using derivatives
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
13/56
Figure 2. MCM Logic Diagram
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
14/56
Figure 3. MCM Solution of Flash Vaporization
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
15/56
Figure 4. MCM Constraint Values vs. Iteration Number
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
16/56
USING MCM TO SOLVE DISTILLATION
The distillation column to be specified in the two demonstration problems is
shown below. For MCM, the stages are numbered from top to bottom but with
the condenser being Stage# 0 and the bottom stage being Stage# 3 for both problems. The condenser is assumed to condense all of the vapor that enters it thus
being defined as a “total condenser.” Since the condenser is not an equilibrium
stage, no further enrichment takes place there, the composition of the Distillate, D,
and the Reflux stream, L(0), will be the same as that of the vapor, V(1) leaving
Stage# 1. The feed will enter Stage# 2 which will be numbered Stage# 4 for
purposes of determining its temperature and enthalpy. The Feed, F, the Distillate,
D, and the Bottoms stream, BTMS, are all liquids at their boiling points, therefore
the Heat added to the Reboiler, QR , will be equal to the heat removed by the
Condenser, QC. Thus QR – QC = 0 and the Feed enthalpy, QF, will equal the total
heat removed from the column by the Distillate, QD and the BTMS, QBTMS. Thus
QF - QD - QBTMS = 0 = DELQ. The column will be considered to be at constant
atmospheric pressure with no heat loss and an efficiency of 100 %.
The stage numbers will be represented by S% (% designating an integer)
and the components by I% thus the component liquid compositions will be X(S%,
I%) and their vapor compositions will be Y(S%, I%). The enthalpy of the liquid
streams will be labelled hL (S%) while that of the vapor will named HV(S%).Activity coefficients will be named GAM(S%, I%), while pure component vapor
pressures will be called VP(S%, I%), equilibrium constants = VP(S%, I%) / P will
be named K(S%, I%), and temperatures will be T(S%). Vapor and liquid molar
flows will be V(S%) and L(S%), respectively. Reflux ratio will be RR and Boil-up
ratio will be BR.
The Cutlip problem was selected because it had been solved and would
provide confirmation of the MCM method. Likewise, a multi-component problem
was designed that could be corroborated by comparison with a ChemSep solution.The Cutlip problem was done in English units for direct comparison to the Cutlip
problem while Metric units were used for the ternary non-ideal problem.
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
17/56
Figure 5. Three Equilibrium Stage Tower
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
18/56
The Algorithm:
As noted in the examples already shown, the first step in the MCM
method is to define the unknown variables to be solved. Per the Gibbs
phase rule, the following must be specified for each column:
(The numbers in parentheses are the number of degrees of freedom, i.e.,
the number of stages = 3, but it is considered only one degree of
freedom.)
1) The number of stages. (1) There are 3 stages but one is the
reboiler leaving technically 2.
2)
The location of all feeds. (1)
3) The location of all side streams. (0)
4)
For each feed stream, the three component flows (3), and the
pressure and vapor fraction. (2) Remember that there are
two component flows for the binary column.
5) The pressure in each stage. (2) The reboiler and condenser are
counted separately.
6) The heat duty of each stage except condensers and reboilers.
(2) Set at zero—no heat loss.
7) The pressure in the condenser. (1)
8) The pressure in the reboiler. (1)
9)
Specify one variable at the top (condenser). (1) Distillate
flow is given here.
10) Specify one variable at the bottom (reboiler). (1) Heat duty
is given here.
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
19/56
Therefore, the total number of degrees of freedom is 14 for the
binary column and 15 for the ternary column. For a total
condenser, the liquid phase composition of the condenser, and
hence the reflux and distillate, are equal to the composition ofthe vapor leaving the first stage. The bottoms flow, L(3) leaving
the reboiler is calculated from an overall material balance as
BTMS = F – D, and once the bottoms compositions are known,
the distillate compositions can be calculated from overall
component balances as the feed composition is given. The liquid
and vapor flows from each stage are also related by material
balance thus only one of the liquid and vapor flow set need be
specified. Units of the flows are g-moles/hour. Compositions
are mole fraction, temperatures are in Centigrade, and pressure
is mm Hg. Enthalpies are in calories/g-mole.
Finally, the following variables are selected as the unknowns to
be simultaneously solved:
Vapor flows: V(1), V(2), and V(3) There is no vapor flow,
V(0), from the condenser.
Liquid compositions: For each stage there will be 3 for the
ternary system. Just 2 for the binary column, and in both cases
since they must sum to 1.0 when expressed as mole fractions,
there is one less composition needed after the first one or two
are selected.
X(0, 1), X(0, 2), X(0, 3) Stage# 0Calculated by material balance.2
2 F * Z(1) = XD(1) * D + XB(1) * BTMS
XD(1) = (F * Z(1) - XB(1) * BTMS) / D
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
20/56
X(1, 1), X(1 ,2), X(1, 3) Stage# 1
X(2, 1), X(2, 2), X(2, 3) Stage# 2
X(3, 1), X(3, 2), X(3, 3) Stage# 3
Liquid flows: L(0), L(1), L(2), and L(3) As noted above L(3)
= BTMS leaving only 3. These are calculated from material
balances once the vapor flows are selected. This leaves 9
unknowns for the binary and 12 for the ternary system when the
bottoms compositions are selected first.
Temperatures: T(0), T(1), T(2), T(3) can be calculated as
the bubble point temperature of each stage once the liquid
compositions are selected. The feed temperature can easily be
calculated from it’s known composition and pressure. It is
designated as T(4) here and along with the given composition is
used to calculate the feed enthalpy, hL. There is no vapor phase
in the feed. T(0) can be calculated as the bubble point of the
vapor compositions from V(1) which are the same as the liquid
compositions in the condenser. MCM is also used to calculatethe bubble points so no temperature guesses or derivatives are
required.
Bounds on these variables are 0 to 1.0 for composition
and low boiler temperature to high boiler temperatures for
boiling points. Since V(1) = L(0) + D and L(0) = RR x D,
selecting a high reflux rate like 20 for the ternary leads to a high
for L(0) of 20 x 30 = 600 moles/hr. or 600 + 30 = 630 for
V(S%) max. The minimum V(1) must be at least 30+ in order
for there to be liquid for reflux. We can then proceed to begin
selecting values for the unknowns and calculating constraints
for the objective function to be minimized.
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
21/56
CONSTRAINT EQUATIONS
REM STAGE 0 (CONDENSER)G0 = ABS(V(1) - D - L!(0))
G01 = ABS(V(1) * Y(1, 1) - L!(0) * X(0, 1) - D * X(0, 1))
G02 = ABS(V(1) * Y(1, 2) - L!(0) * X(0, 2) - D * X(0, 2))
G03 = ABS(V(1) * Y(1, 3) - l!(0) * X(0, 3) - D * X(0, 3))
H0 = ABS(V(1) * SUMHV(1) - L!(0) * SUMHL(0) - D * SUMHL(0) - QC)
H0 = H0 / 1000
REM STAGE 1
G1 =ABS(L!(0) + V(2) - L!(1) - V(1)) 'OVERALL MOLE BALANCE
G11=ABS(-V(1) * Y(1,1)-L!(1) * X(1,1)+V(2) * Y(2,1)+L!(0) * X(0,1))
G12=ABS(-V(1) * Y(1,2)-L!(1) * X(1,2)+V(2) * Y(2,2)+L!(0) * X(0,2))
G13=ABS(-V(1) * Y(1,3)-L!(1) * X(1,3)+V(2) * Y(2,3)+L!(0) * X(0,3))SUMY(1) = Y(1, 1) + Y(1, 2) + Y(1, 3)
SUMY(1) = ABS(1. - SUMY(1))
H1=ABS(-V(1)*SUMHV(1)+V(2)*SUMHV(2)-L!(1)*SUMHL(1)+L!(0)*SUMHL(0))
H1 = H1 / 1000
REM STAGE 2
G2 = ABS(L!(1) + F + V(3) - L!(2) - V(2))
G21=ABS(L!(1)*X(1,1)-V(2)*Y(2,1)-L!(2)*X(2,1)+V(3)*Y(3,1)+ZF(1)*F)
G22=ABS(L!(1)*X(1,2)-V(2)*Y(2,2)-L!(2)*X(2,2)+V(3)*Y(3,2)+ZF(2)*F)
G23=ABS(L!(1)*X(1,3)-V(2)*Y(2,3)-L!(2)*X(2,3)+V(3)*Y(3,3)+ZF(3)*F)
SUMY(2) = Y(2, 1) + Y(2, 2) + Y(2,3)
SUMY(2) = ABS(1. - SUMY(2))
H2=ABS(-V(2)*SUMHV(2)+V(3)*SUMHV(3)+SUMHL(4)*F+L!(1)*SUMHL(1)-
L!(2)*SUMHL(2))
H2 = H2 / 1000
REM STAGE 3
G3 = ABS(L!(2) - L!(3) - V(3))
G31 = ABS(L!(2) * X(2, 1) - V(3) * Y(3, 1) - BTMS * X(3, 1))
G32 = ABS(L!(2) * X(2, 2) - V(3) * Y(3, 2) - BTMS * X(3, 2))
G33 = ABS(L!(2) * X(2, 3) - V(3) * Y(3, 3) - BTMS * X(3, 3))
SUMY(3) = Y(3, 1) + Y(3, 2) + Y(3, 3)
SUMY(3) = ABS(1. - SUMY(3))
H3 = ABS(-V(3) * SUMHV(3) + QR + L!(2) * SUMHL(2) - L!(3) * SUMHL(3))
H3 = H3 / 1000
GOSUB ENERGY
100 G = G01 + G02 + G03 + G11 + G12 + G13 + G21 + G22 + G23 + G31 +
G32 + G33
G = G + H0 + H1 + H2 + H3 + SUMY(0) + SUMY(1) + SUMY(2) + SUMY(3) +
DELQ
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
22/56
DISCUSSION
Note that the constraint equations are of the convex form
where the right hand side of the equation is subtracted from theleft hand side to result in 0 when all of the variables are correct.
The absolute value of these differences is used and these values
are added to form a convex objective function which can be
minimized. These constrain equations are MESH equations in
convex form.
There are three component material balances and one
energy balance equation for each stage, a total of 12 equationsfor the ternary system, 9 equations for the binary system
matching the number of unknowns. Note that the energy
differences (errors) have been scaled by dividing each of them
by 1000 to make the values more closely match the other errors.
The equations for G0, G1, G2, and G3 are the overall material
balances for each stage, but are redundant as they have already
been used to relate the vapor and liquid flows. An overallenergy balance relating the energy input by the feed and reboiler
to that removed by the distillate, bottoms, and condenser is also
included as are the Sum of the Y’s. Note that the Y’s are used in
the mass balances incorporating all of the unknown variables
into these equations. Experienced distillation simulator users
know that with non-linear equations there are multiple solutions
possible so it is extremely important that the overall mass andenergy balances close. The overall component mass balances
have been forced to close by calculating the distillate
compositions from the bottoms’ compositions using the overall
mass balance, F = D + B, broken into individual component
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
23/56
balances. The overall energy balance is also redundant to the
stage energy balances but was included for insurance.
The vapor compositions for each stage, except for the
feed and condenser which create no vapor, are calculated duringthe bubble point calculations. The sum of these Y’s must also
be equal to 1.0 and are included in the objective function
calculated during each iteration for the subscript, I. When an
infeasible value such as 0 or (-) for any of the unknown
variables is encountered, the algorithm returns to its start and
tries another solution with I incremented by 1. The subscript ,
J, remains the same until all I’s are tried, then is incremented by1 to tighten the hyper-rectangles around the best solution so far.
J is used as a power of the focus factor, FF, which has been
selected as 2.0 for the n-butane-n-pentane problem, and selected
as 1.3 for the ternary problem to provide a finer grid for
searching. Selection of the proper focus factor is learned from
experience with various problems. The author has solved all
problems so far with FF = 1.3 or FF = 2.0. Computer code for each problem is included in the
Appendices and contains comments to guide the reader.
Intermediate calculation output is also provided so that the
reader can follow the paths of the objective function values as
they are reduced to a minimum and remain constant signifying
the completion of the solution. The PRINT statements can be
bypassed by placing an apostrophe in front of the statement.The intermediate output provided by the PRINT statements is
essential until code debugging and certainty of the correct
MESH equations are completed.
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
24/56
RESULTS:
I. n-butane & n-pentane from Cutlip & Shacham
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
25/56
Convergence of n-butane & n-pentane solution
WELCOME TO RIGDIS14.BAS
THE TIME IS 18:05:13 AND THE DATE IS 02-23-2016
COMPONENTS ARE USED IN ORDER OF BOILING POINTS, LOWEST TO HIGHEST
BP'S IN F ARE 31.129 AND 96.87 F, RESPECTIVELY
IST SUBSCRIPT IS STAGE NO., 2ND SUBSCRIPT IS COMPONENT NO.
NEW OPT= 13.56237 I= 2 J= 1
NEW OPT= 8.60752 I= 117 J= 1
NEW OPT= 7.099331 I= 272 J= 1
NEW OPT= 6.90924 I= 8 J= 2
NEW OPT= 6.548571 I= 32 J= 2
NEW OPT= 6.342526 I= 163 J= 2NEW OPT= 2.496014 I= 221 J= 2
NEW OPT= 1.376465 I= 467 J= 3
NEW OPT= 1.261207 I= 294 J= 4
NEW OPT= 1.129066 I= 215 J= 5
NEW OPT= 1.100345 I= 228 J= 5
NEW OPT= .9700624 I= 462 J= 5
NEW OPT= .53333 I= 562 J= 5
NEW OPT= .5306512 I= 106 J= 6
NEW OPT= .4136833 I= 115 J= 6
NEW OPT= .3883325 I= 100 J= 7
NEW OPT= .3694802 I= 126 J= 7
NEW OPT= .3689947 I= 158 J= 7NEW OPT= .3177557 I= 164 J= 7
NEW OPT= .3021875 I= 227 J= 8
NEW OPT= .2983455 I= 484 J= 8
NEW OPT= .2756652 I= 523 J= 8
NEW OPT= .2595588 I= 694 J= 8
NEW OPT= .2451617 I= 717 J= 8
NEW OPT= .240488 I= 7 J= 9
NEW OPT= .2306435 I= 18 J= 9
NEW OPT= .2234408 I= 21 J= 9
NEW OPT= .2156426 I= 68 J= 9
NEW OPT= .2144745 I= 77 J= 9
NEW OPT= .2067866 I= 83 J= 9
NEW OPT= .2043912 I= 87 J= 9
NEW OPT= .2017308 I= 226 J= 9
NEW OPT= .2000239 I= 310 J= 9
NEW OPT= .1970954 I= 311 J= 9
NEW OPT= .1866049 I= 351 J= 9
NEW OPT= .1760544 I= 383 J= 9
NEW OPT= .170598 I= 427 J= 9
NEW OPT= .168051 I= 598 J= 9
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
26/56
NEW OPT= .1592648 I= 717 J= 9
NEW OPT= .1579064 I= 777 J= 9
NEW OPT= .1510153 I= 884 J= 9
NEW OPT= .1504792 I= 13 J= 10
NEW OPT= .1491413 I= 19 J= 10
NEW OPT= .1469339 I= 44 J= 10NEW OPT= .1423655 I= 59 J= 10
NEW OPT= .1417301 I= 76 J= 10
NEW OPT= .1386222 I= 97 J= 10
NEW OPT= .1362681 I= 124 J= 10
NEW OPT= .1357231 I= 186 J= 10
NEW OPT= .1347106 I= 215 J= 10
NEW OPT= .1327947 I= 234 J= 10
NEW OPT= .1302254 I= 281 J= 10
NEW OPT= .12947 I= 395 J= 10
NEW OPT= .1279244 I= 398 J= 10
NEW OPT= .126572 I= 420 J= 10
NEW OPT= .1258504 I= 428 J= 10NEW OPT= .1237936 I= 442 J= 10
NEW OPT= .1212975 I= 445 J= 10
NEW OPT= .1199046 I= 447 J= 10
NEW OPT= .11675 I= 475 J= 10
NEW OPT= .1163187 I= 485 J= 10
NEW OPT= .1113952 I= 492 J= 10
NEW OPT= .1082548 I= 493 J= 10
NEW OPT= .1063951 I= 511 J= 10
NEW OPT= .1050479 I= 577 J= 10
NEW OPT= .1043972 I= 599 J= 10
NEW OPT= .1023048 I= 603 J= 10
NEW OPT= .102284 I= 612 J= 10
NEW OPT= .098626 I= 638 J= 10
NEW OPT= 9.856462E-02 I= 970 J= 10
NEW OPT= 9.705922E-02 I= 2 J= 11
NEW OPT= 9.659583E-02 I= 7 J= 11
NEW OPT= 9.657159E-02 I= 40 J= 11
NEW OPT= 9.640448E-02 I= 96 J= 11
NEW OPT= 9.626424E-02 I= 255 J= 11
NEW OPT= 9.609228E-02 I= 473 J= 11
NEW OPT= 9.586024E-02 I= 522 J= 11
NEW OPT= 9.585699E-02 I= 757 J= 11
NEW OPT= 9.571949E-02 I= 17 J= 12
NEW OPT= 9.571089E-02 I= 139 J= 12
NEW OPT= 9.552763E-02 I= 193 J= 12NEW OPT= 9.543725E-02 I= 628 J= 12
NEW OPT= 9.543505E-02 I= 756 J= 12
NEW OPT= 9.529868E-02 I= 816 J= 12
NEW OPT= .0952848 I= 220 J= 13
NEW OPT= 9.524148E-02 I= 340 J= 13
NEW OPT= 9.522845E-02 I= 429 J= 13
NEW OPT= 9.515925E-02 I= 124 J= 14
NEW OPT= 9.514897E-02 I= 483 J= 14
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
27/56
NEW OPT= 9.513015E-02 I= 602 J= 14
NEW OPT= .0951127 I= 787 J= 14
NEW OPT= 9.509851E-02 I= 96 J= 15
NEW OPT= 9.509684E-02 I= 269 J= 15
NEW OPT= 9.509414E-02 I= 348 J= 15
NEW OPT= 9.506063E-02 I= 360 J= 15
NEW OPT= 9.505975E-02 I= 498 J= 15NEW OPT= 9.505945E-02 I= 991 J= 15
ELAPSED TIME= .71484375 SECONDS
OPT= 9.505945E-02 I= 1001 J= 16
G01= 3.439188E-05 G02= 3.308803E-05 H0= 8.758545E-03
G11= 9.143346E-05 G12= 5.759504E-05 H1= .0274367
G21= 1.297146E-04 G22= 9.071827E-05 H2= 3.665925E-03
G31= 4.639508E-05 G32= 4.095277E-05 H3= 4.650269E-02
SUMY1= 1.192093E-06 SUMY2= 3.20673E-05 SUMY3= 5.245209E-06
DELQ= 8.636401E-03 QQC= 9913.636
OVERALL COUNT= 15000
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
28/56
II. MeOH-IPA-H2O comparison with ChemSep
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
29/56
Convergence of MeOH-IPA-H2O SolutionWELCOME TO DISMCM07.BAS
THE TIME IS 17:16:50 AND THE DATE IS 02-23-2016
COMPONENTS ARE USED IN ORDER OF BOILING POINTS,LOW TO HIGH
COMPONENTS ARE METHANOL, 2-PROPANOL, AND WATER
BP'S IN C ARE 64.55, 82.25, AND 100. C, RESPECTIVELY1ST SUBSCRIPT IS STAGE NO., 2ND SUBSCRIPT IS COMPONENT NO.
G= 7817.1500676441 I= 7 J= 1 NEW OPT= 7817.1500676441
G= 4690.94383561659 I= 63 J= 1 NEW OPT= 4690.94383561659
G= 4489.91825568842 I= 312 J= 1 NEW OPT= 4489.91825568842
G= 4488.71401505321 I= 1046 J= 1 NEW OPT= 4488.71401505321
G= 4120.66780269603 I= 1579 J= 1 NEW OPT= 4120.66780269603
G= 3503.64139490078 I= 2163 J= 1 NEW OPT= 3503.64139490078
G= 2809.98256802775 I= 2213 J= 1 NEW OPT= 2809.98256802775
G= 2800.4278138952 I= 1242 J= 2 NEW OPT= 2800.4278138952
G= 2618.44267113462 I= 1992 J= 2 NEW OPT= 2618.44267113462
G= 2219.54018317678 I= 56 J= 3 NEW OPT= 2219.54018317678
G= 1802.42512445764 I= 870 J= 3 NEW OPT= 1802.42512445764
G= 1740.23882593035 I= 739 J= 5 NEW OPT= 1740.23882593035
G= 1272.68609459433 I= 976 J= 5 NEW OPT= 1272.68609459433
G= 1252.6357041528 I= 126 J= 6 NEW OPT= 1252.6357041528
G= 948.059635421107 I= 1481 J= 6 NEW OPT= 948.059635421107
G= 883.574640018997 I= 2637 J= 6 NEW OPT= 883.574640018997
G= 551.308735366156 I= 1252 J= 7 NEW OPT= 551.308735366156
G= 491.337852186098 I= 1855 J= 8 NEW OPT= 491.337852186098
G= 452.39434903912 I= 2363 J= 9 NEW OPT= 452.39434903912
G= 433.495599014635 I= 1673 J= 11 NEW OPT= 433.495599014635
G= 426.428005765711 I= 346 J= 12 NEW OPT= 426.428005765711
G= 408.438109011682 I= 880 J= 12 NEW OPT= 408.438109011682
G= 406.267188700355 I= 1456 J= 12 NEW OPT= 406.267188700355G= 378.664312716753 I= 2984 J= 12 NEW OPT= 378.664312716753
G= 365.279482749328 I= 30 J= 13 NEW OPT= 365.279482749328
G= 341.764777434676 I= 43 J= 13 NEW OPT= 341.764777434676
G= 320.079789475042 I= 1136 J= 14 NEW OPT= 320.079789475042
G= 319.010077856613 I= 1194 J= 14 NEW OPT= 319.010077856613
G= 309.465691626442 I= 1340 J= 14 NEW OPT= 309.465691626442
G= 307.754102992359 I= 1459 J= 14 NEW OPT= 307.754102992359
G= 305.209950805526 I= 1534 J= 14 NEW OPT= 305.209950805526
G= 305.014917929711 I= 1654 J= 14 NEW OPT= 305.014917929711
G= 228.027517057871 I= 1674 J= 14 NEW OPT= 228.027517057871
G= 211.250747879507 I= 1714 J= 14 NEW OPT= 211.250747879507
G= 194.002389509369 I= 2063 J= 14 NEW OPT= 194.002389509369G= 190.376120967065 I= 2382 J= 14 NEW OPT= 190.376120967065
G= 182.030781498348 I= 77 J= 15 NEW OPT= 182.030781498348
G= 177.026329358877 I= 213 J= 15 NEW OPT= 177.026329358877
G= 170.412827068251 I= 282 J= 15 NEW OPT= 170.412827068251
G= 153.022912002767 I= 443 J= 15 NEW OPT= 153.022912002767
G= 149.914258130783 I= 750 J= 15 NEW OPT= 149.914258130783
G= 123.355499115842 I= 828 J= 15 NEW OPT= 123.355499115842
G= 97.0841176441661 I= 994 J= 15 NEW OPT= 97.0841176441661
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
30/56
G= 92.5949724676948 I= 2494 J= 15 NEW OPT= 92.5949724676948
G= 88.626361937812 I= 2553 J= 15 NEW OPT= 88.626361937812
G= 85.4843395120787 I= 1207 J= 17 NEW OPT= 85.4843395120787
G= 76.0364313360713 I= 1426 J= 17 NEW OPT= 76.0364313360713
G= 74.752070185055 I= 1903 J= 17 NEW OPT= 74.752070185055
G= 72.5733577096555 I= 2334 J= 17 NEW OPT= 72.5733577096555G= 64.6857015349761 I= 174 J= 18 NEW OPT= 64.6857015349761
G= 57.9305197370146 I= 276 J= 18 NEW OPT= 57.9305197370146
G= 57.3130779750471 I= 467 J= 18 NEW OPT= 57.3130779750471
G= 50.6595563661554 I= 824 J= 18 NEW OPT= 50.6595563661554
G= 46.9185777883877 I= 1600 J= 18 NEW OPT= 46.9185777883877
G= 33.2190849109639 I= 1659 J= 18 NEW OPT= 33.2190849109639
G= 31.1479108366452 I= 10 J= 20 NEW OPT= 31.1479108366452
G= 28.935906815921 I= 916 J= 20 NEW OPT= 28.935906815921
G= 27.2964246584842 I= 292 J= 21 NEW OPT= 27.2964246584842
G= 24.9289176676958 I= 242 J= 22 NEW OPT= 24.9289176676958
G= 16.5797175097385 I= 530 J= 22 NEW OPT= 16.5797175097385
G= 14.807742154669 I= 1984 J= 22 NEW OPT= 14.807742154669G= 13.3948645966694 I= 1037 J= 23 NEW OPT= 13.3948645966694
G= 11.0069629989503 I= 1988 J= 23 NEW OPT= 11.0069629989503
G= 10.9773741166885 I= 91 J= 26 NEW OPT= 10.9773741166885
G= 10.4083736231255 I= 708 J= 26 NEW OPT= 10.4083736231255
G= 9.88356578393092 I= 124 J= 27 NEW OPT= 9.88356578393092
G= 9.55697291947769 I= 513 J= 27 NEW OPT= 9.55697291947769
G= 9.38718723385838 I= 531 J= 27 NEW OPT= 9.38718723385838
G= 9.1753945773423 I= 752 J= 27 NEW OPT= 9.1753945773423
G= 7.88019362329578 I= 849 J= 27 NEW OPT= 7.88019362329578
G= 7.78279143030387 I= 984 J= 27 NEW OPT= 7.78279143030387
G= 5.78818000950896 I= 1238 J= 27 NEW OPT= 5.78818000950896
G= 5.11384103056108 I= 352 J= 28 NEW OPT= 5.11384103056108
G= 4.87377960666485 I= 43 J= 29 NEW OPT= 4.87377960666485
G= 4.2463866159891 I= 627 J= 29 NEW OPT= 4.2463866159891
G= 4.23637468512125 I= 829 J= 29 NEW OPT= 4.23637468512125
G= 3.78995470641092 I= 1069 J= 29 NEW OPT= 3.78995470641092
G= 3.4808251707264 I= 2876 J= 30 NEW OPT= 3.4808251707264
G= 3.21750748648925 I= 1572 J= 31 NEW OPT= 3.21750748648925
G= 3.20179204716282 I= 1717 J= 31 NEW OPT= 3.20179204716282
G= 2.95679615413781 I= 829 J= 33 NEW OPT= 2.95679615413781
G= 2.74296629896886 I= 1011 J= 33 NEW OPT= 2.74296629896886
G= 2.59972413597935 I= 1177 J= 33 NEW OPT= 2.59972413597935
G= 2.56564719793815 I= 1907 J= 33 NEW OPT= 2.56564719793815
G= 2.32391873128655 I= 2735 J= 33 NEW OPT= 2.32391873128655
G= 2.07088882622648 I= 13 J= 34 NEW OPT= 2.07088882622648G= 1.93853037829832 I= 417 J= 34 NEW OPT= 1.93853037829832
G= 1.90124469792828 I= 2766 J= 34 NEW OPT= 1.90124469792828
G= 1.76062834546378 I= 2994 J= 34 NEW OPT= 1.76062834546378
G= 1.65499579147665 I= 1987 J= 35 NEW OPT= 1.65499579147665
G= 1.62096088133278 I= 2628 J= 36 NEW OPT= 1.62096088133278
G= 1.602354350631 I= 707 J= 37 NEW OPT= 1.602354350631
G= 1.59817529380331 I= 1329 J= 37 NEW OPT= 1.59817529380331
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
31/56
G= 1.53654006743516 I= 1484 J= 37 NEW OPT= 1.53654006743516
G= 1.51941892914619 I= 1995 J= 37 NEW OPT= 1.51941892914619
G= 1.46356249523146 I= 2261 J= 37 NEW OPT= 1.46356249523146
G= 1.43737712725776 I= 311 J= 38 NEW OPT= 1.43737712725776
G= 1.43263431568158 I= 720 J= 38 NEW OPT= 1.43263431568158
G= 1.38874991664128 I= 731 J= 38 NEW OPT= 1.38874991664128
G= 1.31912200825086 I= 918 J= 38 NEW OPT= 1.31912200825086G= 1.3159313669239 I= 1756 J= 38 NEW OPT= 1.3159313669239
G= 1.30606393629554 I= 2333 J= 39 NEW OPT= 1.30606393629554
G= 1.26377169552792 I= 269 J= 40 NEW OPT= 1.26377169552792
G= 1.25723129977059 I= 2377 J= 40 NEW OPT= 1.25723129977059
G= 1.25714159610264 I= 1003 J= 42 NEW OPT= 1.25714159610264
G= 1.24925519226137 I= 1107 J= 42 NEW OPT= 1.24925519226137
G= 1.24708315569576 I= 1124 J= 43 NEW OPT= 1.24708315569576
G= 1.2425015332705 I= 1428 J= 43 NEW OPT= 1.2425015332705
G= 1.23720890838308 I= 1190 J= 44 NEW OPT= 1.23720890838308
G= 1.23701853612049 I= 3000 J= 45 NEW OPT= 1.23701853612049
G= 1.23603633525977 I= 43 J= 46 NEW OPT= 1.23603633525977
G= 1.23332132789085 I= 1298 J= 46 NEW OPT= 1.23332132789085G= 1.23187965206951 I= 2189 J= 46 NEW OPT= 1.23187965206951
G= 1.23136432390398 I= 141 J= 48 NEW OPT= 1.23136432390398
G= 1.22926242284027 I= 562 J= 48 NEW OPT= 1.22926242284027
G= 1.22802072811206 I= 2001 J= 50 NEW OPT= 1.22802072811206
START TIME= 62210.903 FINISH TIME= 62256.234
ELAPSED TIME= 45.3309999999983 SECONDS
FINAL RESULTS
BOTTOM,STAGE= 3 X1= .375998126966507 X2= .231066869116218 X3=
.392935003917275
STAGE= 2 X1= .507903390190903 X2= .232151477558479 X3=
.259945132250618
STAGE= 1 X1= .652298339650017 X2= .190642120616716 X3=
.157059539733267
COND., STAGE= 0 X1= .789338879214408 X2= .127507156548963 X3=
8.31540139071657E-2
V(1)= 391.207429289046
V(2)= 385.279448536624
V(3)= 381.237768763931
CONDENSER TEMP., T(0)= 67.689453125
T(1)= 70.046875
T(2)= 72.54296875
T(3)= 75.0390625
FEED TEMP., T(4)= 72.8203125
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
32/56
REFLUX, L(0)= 361.2086
L(1)= 355.2796
L(2)= 451.2384
BOTTOMS,L(3)= 70
REFLUX RATIO= 12.0402862548828
BOIL-UP RATIO= 5.44626349545249
LAST OBJ. CALC., MAY NOT BE MIN.VALUE.
G= 1.2411560748514 I= 3001 J= 51 OPT= 1.22802072811206
OVERALL COUNT= 150000
G01= 8.3375987467782E-4 G02= 1.6611736015954E-3 G03=
8.35323018942208E-4 H0= 3.44388386601645E-2
G11= 8.03936258425952E-4 G12= 1.78070623340435E-3 G13=
9.93409256316916E-4 H1= 4.78141324082159E-2G21= 4.13536897028624E-4 G22= 1.49741325416551E-3 G23=
1.90883635664135E-3 H2= 9.27941712609439E-2
G31= 3.8371328077566E-4 G32= 1.37788062235628E-3 G33=
1.7507501192665E-3 H3= 5.14147309300448E-2
SUMY0= 1.00037700167585 SUMY1= 0 SUMY2= 0
SUMY3= 0
DELQ= 5.24692882990787E-5 QQC= 3439200.53812674
OVERALL COUNT= 150000
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
33/56
REFERENCES:
Banbura, M. (2010). "Maximum Likelihood Estimation of Factor Models on Data Sets with Arbitrary,
Pattern of Missing Data". Social Science Research Network . Retrieved September 1, 2012, from
SSRN Electronic Library (Working Paper Series No. 1189/May 2010,: h.
Conley, W. C. (1984). Computer Optimization Techniques Revised Edition. Princeton, N. J.: Petrocelli
Books, Inc.
Cutlip, M. B. (2008). Problem Solving in Chemical and Biochemical Engineering with POLYMATH, EXCEL,
and MATLAB, 2nd Ed. Upper Saddle River, N. J.: Prentice Hall.
Eckhardt, R. (1987). "Stan Ulam, John von Neumann, and the Monte Carlo method". Los Alamos Science,
Special Issue (15),, 131-137.
Faloutsos, C. (1903). Analysis of the n-dimensional quadtree decomposition for arbitrary hyper-
rectangles. Retrieved September 15, 2012, from
http://drum.lib.umd.edu/bitstream/1903/678/2/CS-TR-3381.pdf .
Kooijman, H. a. and Ross Taylor (2006). Modeling Separation Processes, Version 7.04 [2100/6] LITE free
license at http://www.chemsep.com.
Lashover, J. H. (2012). "Monte Carlo Marching". Academia.edu, ResearchGate.com, and Scribd.com.
Renon, H. &. (1968). "Local Compositions in Thermodynamic Excess Functions for Liquid Mixtures", NRTL
(non-random, two liquid). AIChE Journal , 135-144.
Seader, J. D. (1998). Separation Process Principles. New York, N. Y.: John Wiley & Sons, Inc.
Ulam, S. M. (1991). Adventures of a Mathematician. Berkeley, CA: U. of California Press.
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
34/56
APPENDIX A COMPUTER CODE FOR N-BUTANE & N-
PENTANE PROBLEM
REM RIGDIS14.BAS (Remove apostrophe (') in front of PRINT statements to print
intermediate output.)
REM 12.8 RIGOROUS DISTILLATION CALCULATIONS FOR A SIMPLE SEPARATIONTOWER REV. 02/23/16
REM PAGE 551 OF PROBLEM SOLVING IN CHEMICAL AND BIOCHEMICAL
ENGINEERING 2ND ED.
REM BY MICHAEL B. CUTLIP AND MORDECHAI SHACHAM
REM PRENTICE HALL 1999
DECLARE SUB BUBBLE
DECLARE SUB CONSTRAINT
DECLARE SUB ENTHALPY
DECLARE SUB ENERGY
DECLARE SUB PHASE
1 CLS: ON ERROR GOTO 1000
DEFSNG A-Z
DIM BP(10), VP(10, 10), L(10)
DIM V(10), TC(10), X(10, 10), Y(10, 10)
DIM K(10, 10), HL(10, 10), HV(10, 10)
DIM Z(10), A(10), B(10), C(10)
DIM SUMHL(10), SUMHV(10)
DIM AA(10), LL(10), UL(10), AAV(10), LLV(10), ULV(10), XX(10), TF(10),
SUMY(10)
PRINT: PRINT " WELCOME TO RIGDIS14.BAS "
PRINT " THE TIME IS " + TIME$ + " AND THE DATE IS " + DATE$PRINT " COMPONENTS ARE USED IN ORDER OF BOILING POINTS, LOWEST TO
HIGHEST"
PRINT " BP'S IN F ARE 31.129 AND 96.87 F, RESPECTIVELY"
PRINT " IST SUBSCRIPT IS STAGE NO., 2ND SUBSCRIPT IS COMPONENT NO."
INPUT " NAME OF FILE TO STORE OUTPUT= ", FI$
OPEN "C:\QB64\" + FI$ + ".TXT" FOR OUTPUT AS #1
PRINT #1,: PRINT #1, " WELCOME TO RIGDIS14.BAS "
PRINT #1, " THE TIME IS " + TIME$ + " AND THE DATE IS " + DATE$
PRINT #1, " COMPONENTS ARE USED IN ORDER OF BOILING POINTS, LOWEST TO
HIGHEST"PRINT #1, " BP'S IN F ARE 31.129 AND 96.87 F, RESPECTIVELY"
PRINT #1, " IST SUBSCRIPT IS STAGE NO., 2ND SUBSCRIPT IS COMPONENT
NO."
REM SPECS
N% = 2 'NO. OF COMPONENTS
F = 1.0 'MOLES/HR
Z(1) = 0.23 'MOLES/HR
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
35/56
Z(2) = 1.0 - Z(1)
BTMS = 0.75 'MOLES/HR
D = F - BTMS
PT = 120 'PSI
QR = 10000 'BTU/HR
QC = 10000
BP(1) = 71.554 'AT 120 PSI = 160.8 FBP(2) = 115.67 'AT 120 PSI = 240.21 F
NT% = 3 'NUMBER OF STAGES
REM ANTOINE CONSTANTS
A(1) = 11.7324: B(1) = 2154.9: C(1) = 238.7 'TEMPERATURE IN CENTIGRADE
AND PRESSURE IN PSI
A(2) = 11.8875: B(2) = 2477.07: C(2) = 233.2
REM TEST ANTOINE CONSTANTS USING PURE COMPONENT BOILING TEMPERATURES
REM BP'S IN C AT 120 PSI ARE 71.554 AND 115.67, RESPECTIVELY
REM BP'S IN F AT 120 PSI ARE 160.8 AND 240.21, RESPECTIVELY
REM FOR SCALING PURPOSES, TEMPERATURES WILL BE CALCULATED IN C ANDCONVERTED TO F FOR ENTHALPY EQUATIONS
REM F = 1.8 * C + 32
VAP1! = EXP(A(1) - B(1) / (71.554 + C(1)))
VAP2! = EXP(A(2) - B(2) / (115.67 + C(2)))
PRINT: PRINT " VAPOR PRESSURE OF PURE COMPONENTS AT THEIR BOILING
POINTS SHOULD BE 120 PSIA"
PRINT " PRESSURE AT BP FOR N-BUTANE= "; VAP1!; " PSI"
PRINT " PRESSURE AT BP FOR N-PENTANE= "; VAP2!; " PSI"
INPUT " PRESS ENTER TO CONTINUE", YES
S% = 4: X(4, 1) = Z(1): X(4, 2) = Z(2) ' CHECK WHETHER FEED IS ONE OR
TWO PHASES
GOSUB BUBBLE
GOSUB PHASE
REM FOR THIS 3 STAGE BINARY COLUMN, THERE ARE 9 UNKNOWNS:
REM COMPOSITION OF ONE COMPONENT ON EACH STAGE = 3
REM TEMPERATURE (BP) OF EACH STAGE = 3
REM VAPOR FLOW LEAVING EACH STAGE = 3
REM ALL OTHER VARIABLES ARE DEPENDENT ON THESE INDEPENDENT VARIABLES
REM TEMPERATURE IS DETERMINED IN C WHICH WILL RANGE FROM THE LOWEST
BP TO THE HIGHEST
OPT = 1E+30: TS# = TIMER: RANDOMIZE (-2222)
COUNTI% = 0: COUNTJ% = 0: COUNT& = 0
FOR II = 1 TO 10
AA(II) = 0.: LL(II) = 0.: UL(II) = 0.: AAV(II) = 0.: LLV(II) = 0.:
ULV(II) = 0.
NEXT II
FF = 2
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
36/56
FOR J = 1 TO 15
ZZZ = 1000
FOR I = 1 TO ZZZ
COUNT& = COUNT& + 1
REM GET COMPOSITION VALUES FOR STAGES 3 & 2. FOR A BINARY X2
= 1.0 - X1 SO X1 DETERMINES X2REM SINCE F, D, AND B ARE KNOWN, SELECTING X(3, 1) SETS X(0,
1) BY OVERALL MATERIAL BALANCE
REM X(0, 1) ALSO SETS Y(1, 1) SINCE FOR A TOTAL CONDENSER X(0,
1) = Y(1, 1)
FOR S% = 3 TO 1 STEP -1
IF AA(S%) - 100! / FF ^ J < 0 THEN GOTO 15
GOTO 17
15 LL(S%) = 0!
GOTO 16
17 LL(S%) = AA(S%) - 100! / FF ^ J
16 IF AA(S%) + 100! / FF ^ J > 100 THEN GOTO 18GOTO 19
18 UL(S%) = 100! - LL(S%)
GOTO 20
19 UL(S%) = AA(S%) + 100! / FF ^ J - LL(S%)
20 XX(S%) = LL(S%) + RND * UL(S%)
NEXT S%
'PRINT: PRINT " LIQUID COMPOSITIONS ON STAGES 1 - 3"
FOR S% = 3 TO 1 STEP -1
X(S%, 1) = XX(S%) / 100!: X(S%, 2) = 1.0 - X(S%, 1)
'PRINT " S%= "; S%; " X1= "; X(S%, 1); " X2= "; X(S%, 2)
NEXT S%
X(4, 1) = 0.23: X(4, 2) = 0.77 'FEED STAGE GIVEN DATA
'INPUT " PRESS ENTER TO CONTINUE", YES
REM CALCULATE DISTILLATE COMPOSITION BY OVERALL MATERIAL
BALANCE
REM F * Z(1) = XD(1) * D + XB(1) * BTMS
REM XD(1) = (F * Z(1) - XB(1) * BTMS) / D
X(0, 1) = (F * Z(1) - X(3, 1) * BTMS) / D
IF X(0, 1) 3. THEN GOTO 188
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
37/56
GOTO 199
188 ULV(S%) = 3! - LLV(S%)
GOTO 200
199 ULV(S%) = AAV(S%) + 3! / FF ^ J - LLV(S%)
200 V(S%) = LLV(S%) + RND * ULV(S%)
'PRINT " S= "; S%; " V(S%)= "; V(S%)
NEXT S%
IF V(1)
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
38/56
'PRINT " DELQ= "; DELQ; " QQC= "; QQC
'PRINT " OVERALL COUNT= "; COUNT&
PRINT #1,: PRINT #1, " NEW OPT= "; OPT; " I= "; I; " J= "; J
'PRINT #1,: PRINT #1, " G= "; G; " I= "; I; " J= "; J
'PRINT #1, " G01= "; G01; " G02= "; G02; " H0= "; H0
'PRINT #1, " G11= "; G11; " G12= "; G12; " H1= "; H1'PRINT #1, " G21= "; G21; " G22= "; G22; " H2= "; H2
'PRINT #1, " G31= "; G31; " G32= "; G32; " H3= "; H3
'PRINT #1, " SUMY1= "; SUMY(1); " SUMY2= "; SUMY(2); " SUMY3=
"; SUMY(3)
'PRINT #1, " DELQ= "; DELQ; " QQC= "; QQC
'PRINT #1, " OVERALL COUNT= "; COUNT&
FOR S% = 3 TO 1 STEP -1
AA(S%) = X(S%, 1) * 100! ': PRINT " STAGE= "; S%; " X1= ";
X(S%, 1); " X2= "; X(S%, 2)
'PRINT #1, " STAGE= "; S%; " X1= "; X(S%, 1); " X2= ";
X(S%, 2)NEXT S%
FOR S% = 1 TO 3
AAV(S%) = V(S%) ': PRINT " V(S%)= "; V(S%)
'PRINT #1, " V(S%)= "; V(S%)
NEXT S%
COUNTI% = COUNTI% + 1 ': PRINT: PRINT " COUNTI= "; COUNTI%
'INPUT " PRESS ENTER TO CONTINUE", YES
450 NEXT I
COUNTI% = 0
COUNTJ% = COUNTJ% + 1 ': PRINT: PRINT " COUNTJ= "; COUNTJ%
NEXT J
TFF# = TIMER
PRINT: PRINT " START TIME= "; TS#; " FINISH TIME= "; TFF#
ELAPSE# = (TFF# - TS#): PRINT " ELAPSED TIME= "; ELAPSE#; " SECONDS"
PRINT #1, " ELAPSED TIME= "; ELAPSE#; " SECONDS"
PRINT " FINAL COMPOSITIONS"
PRINT: PRINT " X(0, 1)= "; X(0, 1); " X(0, 2)= "; X(0, 2)
PRINT: PRINT " X(1, 1)= "; AA(1) / 100.; " X(1, 2)= "; (1.0 - AA(1) /
100.)
PRINT: PRINT " X(2, 1)= "; AA(2) / 100.; " X(2, 2)= "; (1.0 - AA(2) /100.)
PRINT: PRINT " X(3, 1)= "; AA(3) / 100.; " X(3, 2)= "; (1.0 - AA(3) /
100.)
PRINT: PRINT " V(1)= "; AAV(1)
PRINT: PRINT " V(2)= "; AAV(2)
PRINT: PRINT " V(3)= "; AAV(3)
INPUT " PRESS ENTER TO CONTINUE", YES
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
39/56
PRINT: PRINT " TF(0)= "; TF(0)
PRINT: PRINT " TF(1)= "; TF(1)
PRINT: PRINT " TF(2)= "; TF(2)
PRINT: PRINT " TF(3)= "; TF(3)
PRINT: PRINT " L(0)= "; L(0)PRINT: PRINT " L(1)= "; L(1)
PRINT: PRINT " L(2)= "; L(2)
PRINT: PRINT " L(3)= "; L(3)
PRINT: PRINT " REFLUX RATIO= "; RR
PRINT: PRINT " BOIL-UP RATIO= "; BR
INPUT " PRESS ENTER TO CONTINUE", YES
GOSUB CONSTRAINT
PRINT: PRINT " OPT= "; OPT; " I= "; I; " J= "; J
PRINT " G01= "; G01; " G02= "; G02; " H0= "; H0PRINT " G11= "; G11; " G12= "; G12; " H1= "; H1
PRINT " G21= "; G21; " G22= "; G22; " H2= "; H2
PRINT " G31= "; G31; " G32= "; G32; " H3= "; H3
PRINT " SUMY1= "; SUMY(1); " SUMY2= "; SUMY(2); " SUMY3= "; SUMY(3)
PRINT " DELQ= "; DELQ; " QQC= "; QQC
PRINT " OVERALL COUNT= "; COUNT&
PRINT #1,: PRINT #1, " OPT= "; OPT; " I= "; I; " J= "; J
PRINT #1, " G01= "; G01; " G02= "; G02; " H0= "; H0
PRINT #1, " G11= "; G11; " G12= "; G12; " H1= "; H1
PRINT #1, " G21= "; G21; " G22= "; G22; " H2= "; H2
PRINT #1, " G31= "; G31; " G32= "; G32; " H3= "; H3
PRINT #1, " SUMY1= "; SUMY(1); " SUMY2= "; SUMY(2); " SUMY3= ";
SUMY(3)
PRINT #1, " DELQ= "; DELQ; " QQC= "; QQC
PRINT #1, " OVERALL COUNT= "; COUNT&
995 INPUT " PRESS ENTER TO CONTINUE", YES
CLOSE #1
GOTO 999
1000 PRINT "**********"; CHR$(7)
PRINT " ERROR NUMBER "; ERR; " HAS OCCURRED! ON LINE#= "; ERL
PRINT " PRESS ENTER TO ABORT OR ANY OTHER KEY TO CONTINUE: "CHOICE$ = INPUT$(1)
IF ASC(CHOICE$) = 13 THEN
ON ERROR GOTO 0
ELSE
RESUME NEXT
END IF
CLS
GOTO 1
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
40/56
999 END
ENTHALPY:
'PRINT #1,: PRINT #1, " CALCULATE LIQUID AND VAPOR ENTHALPIES FOR EACH
STAGE."
'PRINT: PRINT " CALCULATE LIQUID AND VAPOR ENTHALPIES FOR EACH STAGE."FOR S% = 0 TO 4: SUMHL(S%) = 0.: SUMHV(S%) = 0.: NEXT S%
FOR S% = 0 TO 4
HL(S%, 1) = (29.6 * TF(S%) + 0.04 * TF(S%) ^ 2) * X(S%, 1) ':
PRINT " STAGE= "; S%; " HL(S%, 1)= "; HL(S%, 1)
HL(S%, 2) = (38.5 * TF(S%) + 0.025 * TF(S%) ^ 2) * X(S%, 2) ':
PRINT " STAGE= "; S%; " HL(S%, 2)= "; HL(S%, 2)
SUMHL(S%) = HL(S%, 1) + HL(S%, 2) ': PRINT " STAGE#= "; S%; "
SUMHL(S%)= "; SUMHL(S%)
IF S% = 0 OR S% = 4 THEN SUMHV(S%) = 0.: GOTO 80 'NO VAPOR FROM
CONDENSER AND FEED TRAY
HV(S%, 1) = (8003 + 43.8 * TF(S%) - 0.04 * TF(S%) ^ 2) * Y(S%, 1)': PRINT " STAGE= "; S%; " HV(S%, 1)= "; HV(S%, 1)
HV(S%, 2) = (12004 + 31.7 * TF(S%) + 0.007 * TF(S%) ^ 2) * Y(S%,
2) ': PRINT " STAGE= "; S%; " HV(S%, 2)= "; HV(S%, 2)
SUMHV(S%) = HV(S%, 1) + HV(S%, 2) ': PRINT " STAGE#= "; S%; "
SUMHV(S%)= "; SUMHV(S%)
80 NEXT S%
'INPUT " PRESS ENTER TO CONTINUE", YES
RETURN
BUBBLE:
TL = BP(1)
TU = BP(2)
TC(S%) = (TL + TU) / 2: TF(S%) = 1.8 * TC(S%) + 32
COUNTD% = 0: LMAX% = 1000
50 REM CHECK ITERATIONS VS LMAX%
IF COUNTD% > LMAX% THEN PRINT " COUNTD >= MAX IN BUBBLE SUB"; COUNTD%:
GOTO 60 'INPUT " PRESS ENTER TO CONTINUE", YES
VP(S%, 1) = EXP(A(1) - B(1) / (TC(S%) + C(1))): VP(S%, 2) = EXP(A(2) -
B(2) / (TC(S%) + C(2)))
K(S%, 1) = VP(S%, 1) / PT: K(S%, 2) = VP(S%, 2) / PT
PTT = X(S%, 1) * VP(S%, 1) + X(S%, 2) * VP(S%, 2) ': PRINT " PTT= ";
PTT; " TC= "; TC(S%)DELP = ABS(PT - PTT)
IF DELP
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
41/56
111 'PRINT: PRINT " FOR STAGE NO.= "; S%; " BUBBLE TEMP.= "; TC(S%); "
ITER. CT. = "; COUNTD%
'PRINT #1,: PRINT #1, " FOR STAGE NO.= "; S%; " BUBBLE TEMP.= ";
TC(S%); " ITER. CT. = "; COUNTD%
TF(S%) = 1.8 * TC(S%) + 32 ': PRINT " BUBBLE TEMP. IN F= "; TF(S%)
Y(S%, 1) = (VP(S%, 1) * X(S%, 1)) / PT ': PRINT " Y(S%, 1)= "; Y(S%,
1)Y(S%, 2) = (VP(S%, 2) * X(S%, 2)) / PT ': PRINT " Y(S%, 2)= "; Y(S%,
2)
SUMY(S%) = Y(S%, 1) + Y(S%, 2)
'PRINT " S%= "; S%; " SUMY= "; SUMY(S%)
'PRINT #1, " SUMY= "; SUMY(S%)
60 'INPUT "PRESS ENTER TO CONTINUE", YES
RETURN
CONSTRAINT:
REM STAGE 0 (CONDENSER'G0 = ABS(V(1) - D - L(0))
G01 = ABS(V(1) * K(1, 1) * X(1, 1) - L(0) * X(0, 1) - D * X(0, 1))
G02 = ABS(V(1) * K(1, 2) * X(1, 2) - L(0) * X(0, 2) - D * X(0, 2))
H0 = ABS(V(1) * SUMHV(1) - L(0) * SUMHL(0) - D * SUMHL(0) - QC)
H0 = H0 / 1000
REM STAGE 1
'G1 = ABS(L(0) + V(2) - L(1) - V(1)) 'OVERALL MOLE BALANCE
G11 = ABS(-((V(1) - L(0)) * K(1, 1) + L(1)) * X(1, 1) + V(2) * K(2, 1)
* X(2, 1))
G12 = ABS(-((V(1) - L(0)) * K(1, 2) + L(1)) * X(1, 2) + V(2) * K(2, 2)
* X(2, 2))
SUMY(1) = Y(1, 1) + Y(1, 2)
SUMY(1) = ABS(1. - SUMY(1))
H1 = ABS(-V(1) * SUMHV(1) + V(2) * SUMHV(2) - L(1) * SUMHL(1) + L(0) *
SUMHL(0))
H1 = H1 / 1000
REM STAGE 2
'G2 = ABS(L(1) + F + V(3) - L(2) - V(2))
G21 = ABS(L(1) * X(1, 1) - (V(2) * K(2, 1) + L(2)) * X(2, 1) + V(3) *
K(3, 1) * X(3, 1) + Z(1) * F)
G22 = ABS(L(1) * X(1, 2) - (V(2) * K(2, 2) + L(2)) * X(2, 2) + V(3) *
K(3, 2) * X(3, 2) + Z(2) * F)
SUMY(2) = Y(2, 1) + Y(2, 2)SUMY(2) = ABS(1. - SUMY(2))
H2 = ABS(-V(2) * SUMHV(2) + V(3) * SUMHV(3) + SUMHL(4) + L(1) *
SUMHL(1) - L(2) * SUMHL(2))
H2 = H2 / 1000
REM STAGE 3
'G3 = ABS(L(2) - L(3) - V(3))
G31 = ABS(L(2) * X(2, 1) - (V(3) * K(3, 1) + BTMS) * X(3, 1))
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
42/56
G32 = ABS(L(2) * X(2, 2) - (V(3) * K(3, 2) + BTMS) * X(3, 2))
SUMY(3) = Y(3, 1) + Y(3, 2)
SUMY(3) = ABS(1. - SUMY(3))
H3 = ABS(-V(3) * SUMHV(3) + QR + L(2) * SUMHL(2) - L(3) * SUMHL(3))
H3 = H3 / 1000
GOSUB ENERGY 'GET DELQ
100 G = G01 + G02 + G11 + G12 + G21 + G22 + G31 + G32 + H0 + H1 + H2 +
H3 + SUMY(1) + SUMY(2) + SUMY(3) + DELQ
'PRINT: PRINT " G= "; G; " I= "; I; " J= "; J; " OPT= "; OPT; "
OVERALL COUNT= "; COUNT&
'PRINT " G01= "; G01; " G02= "; G02; " H0= "; H0
'PRINT " G11= "; G11; " G12= "; G12; " H1= "; H1
'PRINT " G21= "; G21; " G22= "; G22; " H2= "; H2
'PRINT " G31= "; G31; " G32= "; G32; " H3= "; H3
'PRINT " SUMY1= "; SUMY(1); " SUMY2= "; SUMY(2); " SUMY3= "; SUMY(3)
'PRINT " DELQ= "; DELQ'PRINT #1,: PRINT #1, " G= "; G; " I= "; I; " J= "; J; " OPT= "; OPT;
" OVERALL COUNT= "; COUNT&
'PRINT #1, " G01= "; G01; " G02= "; G02; " H0= "; H0
'PRINT #1, " G11= "; G11; " G12= "; G12; " H1= "; H1
'PRINT #1, " G21= "; G21; " G22= "; G22; " H2= "; H2
'PRINT #1, " G31= "; G31; " G32= "; G32; " H3= "; H3
'PRINT #1, " SUMY1= "; SUMY(1); " SUMY2= "; SUMY(2); " SUMY3= ";
SUMY(3)
'PRINT #1, " DELQ= "; DELQ
'INPUT " PRESS ENTER TO CONTINUE", YES
RETURN
PHASE: 'CHECK TO SEE IF FEED IS ONE OR TWO PHASES
PRINT: PRINT " CHECK TO SEE IF FEED IS ONE OR TWO PHASES "
PRINT #1,: PRINT #1, " CHECK TO SEE IF FEED IS ONE OR TWO PHASES "
REM CALCULATE BUBBLE PRESSURE OF FEED
PBUBL = Z(1) * VP(S%, 1) + Z(2) * VP(S%, 2)
REM CALCULATE DEW PRESSURE OF FEED
PDEW = 1 / ((Z(1) / VP(S%, 1)) + (Z(2) / VP(S%, 2)))
PRINT " BUBBLE PRESSURE OF FEED= "; PBUBL; " DEW PRESSURE OF FEED= ";
PDEW
PRINT #1, " BUBBLE PRESSURE OF FEED= "; PBUBL; " DEW PRESSURE OF FEED=
"; PDEW
REM ESTIMATE FRACTION VAPOR BY INTERPOLATIONVB = (PBUBL - PT) / (PBUBL - PDEW)
PRINT " ESTIMATE VB FOR PT= "; PT; " VB ESTIMATE= "; VB
PRINT #1, " ESTIMATE VB FOR PT= "; PT; " VB ESTIMATE= "; VB
IF VB
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
43/56
ENERGY:
'PRINT: PRINT " TEST OVERALL ENERGY BALANCE"
'PRINT " QF + QR = QD + QBTMS + QC "
'PRINT #1,: PRINT #1, " TEST OVERALL ENERGY BALANCE"
'PRINT #1, " QF + QR = QD + QBTMS + QC "
QD = D * SUMHL(0): QBTMS = BTMS * SUMHL(3): QF = F * SUMHL(4): QR =
10000'PRINT " QD= "; QD; " QBTMS= "; QBTMS; " QF= "; QF; " QR= "; QR
'PRINT #1, " QD= "; QD; " QBTMS= "; QBTMS; " QF= "; QF; " QR= "; QR
DELQ = ABS((QF - QBTMS - QD) / 10000)
'PRINT " DELQ= "; DELQ
'PRINT #1,: PRINT #1, " DELQ= "; DELQ
QQC = QF + QR - QD - QBTMS
'PRINT " QQC= "; QQC: PRINT #1, " QQC= "; QQC
BR = V(3) / BTMS
RR = L(0) / D
'PRINT " BR= "; BR; " RR= "; RR;: PRINT #1, " BR= "; BR; " RR= "; RR;
" QQC= "; QQC
'INPUT " PRESS ENTER TO CONTINUE", YESRETURN
APPENDIX B COMPUTER CODE FOR MEOH-IPA-H2O
PROBLEM
REM DISMCM07.BAS (Remove apostrophe (') in front of PRINT statements to print
intermediate output.)
#COMPILE EXE
#BREAK ON#DEBUG ERROR ON
#DEBUG DISPLAY ON
FUNCTION PBMAIN () AS LONG
REM RIGOROUS MULTICOMPONENT NONIDEAL DISTILLATION CALCULATIONS
REM USING MONTE CARLO MARCHING REV. 02/23/16 C
1 CLS: ON ERROR GOTO 1000
DEFDBL A-Z
DEFINT i, j, l, n
DIM BP(10), VP(10, 10), L!(10), MW(10)DIM V(10), TC(10), X(10, 10), Y(10, 10)
DIM K!(10, 10), HL(10, 10), HV(10, 10), XX(10)
DIM ZF(10), EA(10), EB(10), EC(10), PC(10), SUMY(10)
DIM SUMHL(10), SUMHV(10), W(10, 10), COMPONENT$(10)
DIM AAC(10), LL!(10), UL(10), AAV(10), LLV!(10), ULV(10)
DIM AA(10), BB(10), CC(10), AAA(10), BBB(10), CCC(10)
DIM AV(10), BV(10), CV(10), T(10), GAM(10, 10)
DIM HLF(10), ENTHFL(10)
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
44/56
DIM A(3, 3), tau(3, 3), G(3, 3), Alph(3, 3)
DIM Term1(3), Term2(3, 3), Sum3(3), alpha(3)
DIM lngam!(3), Aij(3), Aji(3), Ap(3), Bp(3), Cp(3)
PRINT: PRINT " WELCOME TO DISMCM07.BAS "PRINT " THE TIME IS " + TIME$ + " AND THE DATE IS " + DATE$
PRINT " COMPONENTS ARE USED IN ORDER OF BOILING POINTS, LOW TO HIGH"
PRINT " COMPONENTS ARE METHANOL, 2-PROPANOL, AND WATER"
PRINT " BP'S IN C ARE 64.47. 82.52, AND 100. C, RESPECTIVELY"
PRINT " 1ST SUBSCRIPT IS STAGE NO., 2ND SUBSCRIPT IS COMPONENT NO."
INPUT " NAME OF FILE TO STORE OUTPUT= ", FI$
OPEN "C:\QB64\" + FI$ + ".TXT" FOR OUTPUT AS #1
PRINT #1,: PRINT #1, " WELCOME TO DISMCM07.BAS "
PRINT #1, " THE TIME IS " + TIME$ + " AND THE DATE IS " + DATE$
PRINT #1, " COMPONENTS ARE USED IN ORDER OF BOILING POINTS,LOW TOHIGH"
PRINT #1, " COMPONENTS ARE METHANOL, 2-PROPANOL, AND WATER"
PRINT #1, " BP'S IN C ARE 64.55, 82.25, AND 100. C, RESPECTIVELY"
PRINT #1, " 1ST SUBSCRIPT IS STAGE NO., 2ND SUBSCRIPT IS COMPONENT
NO."
REM FOR SYSTEM MEOH/IPA/H2O UNITS ARE MOLE/HR, CAL/HR, DEG.C,
REM AND MOLE FRACTION, MM HG
COMPONENT$(1)=" METHANOL": COMPONENT$(2)= " IPA":COMPONENT$(3)= " H2O"
'PRINT: PRINT COMPONENT$(1); COMPONENT$(2); COMPONENT$(3)
REM SPECS
N% = 3 'NO. OF COMPONENTS
F = 100.0 'MOLES/HR
NF% = 2
TF = 73.26
ZF(1) = 0.50 'MOLE FRACTION
ZF(2) = 0.20
ZF(3) = 0.30
BTMS = 70. 'MOLES/HR 50
D = F - BTMS
PT = 760 'MM HG
QR = 3439427
QC = QR
BP(1) = 64.55 'AT 760 MM HGBP(2) = 82.25 'AT 760 MM HG
BP(3) = 100.00 'AT 760 MM HG
NT% = 3 'NUMBER OF STAGES
X(4, 1)= ZF(1): X(4, 2) = ZF(2): X(4, 3)= ZF(3)'FEED STAGE GIVEN DATA
REM ENERGY DATA FOR MEOH, IPA, AND H2O
MW(1) = 32.0422: MW(2) = 60.0959: MW(3) = 18.0153
REM MULTIPLY J/G BY 0.238846 TO GET CALORIES AND BY MW TO GET CAL/MOLE
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
45/56
AA(1)= 2.33: BB(1)= 0.00782: CC(1)= 0.0000377 'MEOH LIQ.CP J/G @T(C)
AA(2)= 2.320857: BB(2)= 0.01242953: CC(2)= 0.0 'IPA LIQ CP J/G @T(C)
AA(3)= 4.188: BB(3)= -0.000569: CC(3)= 0.00000849 'H2O LIQ CP J/G
@T(C)
AAA(1)= 1218.4: BBB(1)= -1.3849: CCC(1)= -0.006402 'HVAP MEOH J/G
@T(C)
AAA(2)= 801.13: BBB(2)= -1.767583: CCC(2)= 0.0 'HVAP IPA J/G @T(C)AAA(3)= 2481.1: BBB(3)= -1.821: CCC(3)= -0.004236 'HVAP H2O J/G @ T(C)
AV(1)= 42.63215:BV(1)= 0.07690246: CV(1)= 0.0/32.0422'MEOH VAP CP
J/G@T(C)
AV(2)= 1.40664: BV(2)= 0.00353197: CV(2)= 0.0 'IPA VAP CP J/G @T(C)
AV(3)= 1.813: BV(3)= 0.0007439: CV(3)= 0.0000001123 'H2O VAP CP J/G
@T(C)
TC(1)= 512.64: TC(2)= 508.3: TC(3)= 647.13: H= .238846# 'JOULES TO
CAL.
PC(1)= 79.9112 * 760: PC(2)= 46.9973 * 760: PC(3)= 217.666 * 760
REM LIQ. CP'S = AA + BB*TC + CC*TC^2
REM HVAP'S = AAA + BBB*TC + CCC*TC^2REM VAP. CP'S = AV + BV*TC + CV*TC^2
REM REDUCED TEMPERATURE, TR = T/TC WITH T AND TC IN KELVIN
REM ANTOINE VAPOR PRESSURE CONSTANTS--MM Hg and T, C AND LOGe
EA(1) = 18.5875: EB(1) = 3626.55: EC(1) = -34.29 'MEOH
EA(2) = 18.6929: EB(2) = 3640.2: EC(2) = -53.54 'IPA
EA(3) = 18.3036: EB(3) = 3816.44: EC(3) = -46.13 'H2O
'PRINT: PRINT " CHECK FOR PT = 760 MM HG AT BPT."
FOR I% = 1 TO N%
VP(1, I%)= EXP(EA(I%) - EB(I%) / (BP(I%) + 273.15 + EC(I%)))
'PRINT: PRINT " COMPONENT= "; COMPONENT$(I%)
'PRINT " BOILING POINT PRESSURE CHECK= "; VP(1, I%)
'PRINT " DELTA P= "; 760 - VP(1, I%)
'PRINT " PCT ERROR= "; 100 * (760 - VP(1, I%)) / VP(1, I%)
'PRINT " A= "; EA(I%); " B= "; EB(I%); " C= "; EC(I%)
NEXT I%
REM FOR THIS 3 STAGE COLUMN, THERE ARE 12 UNKNOWNS:
REM COMPOSITION OF TWO COMPONENTS ON EACH STAGE = 6
REM TEMPERATURE (BP) OF EACH STAGE = 3
REM VAPOR FLOW LEAVING EACH STAGE = 3
REM ALL OTHER VARIABLES ARE DEPENDENT ON THESE INDEPENDENT VARIABLES
REM TEMP. IS DETERMINED IN C WHICH WILL RANGE FROM THE LOW BP TO HIGH
BP
OPT = 1E+30: TS# = TIMER: RANDOMIZE (-2222)
COUNTI% = 0: COUNTJ% = 0: COUNT& = 0
FOR II = 1 TO 10
AAC(II) = 0.: LL!(II) = 0.: UL(II) = 0.: AAV(II) = 0.: LLV!(II) =
0.
ULV(II) = 0.
NEXT II
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
46/56
FF = 1.3
FOR J = 1 TO 50
ZZZ = 3000
FOR I = 1 TO ZZZ
COUNT& = COUNT& + 1
REM GET COMPOSITION VALUES FOR STAGES 3 & 2.
REM SINCE F, D, AND B ARE KNOWN, SELECTING X(3, 1) SETS X(0,
1),
REM X(0, 2) AND X(0, 3) BY OVERALL MATERIAL BALANCE
FOR S% = 6 TO 1 STEP -1
IF AAC(S%) - 100! / FF ^ J < 0 THEN GOTO 15
GOTO 17
15 LL!(S%) = 0!
GOTO 16
17 LL!(S%) = AAC(S%) - 100! / FF ^ J
16 IF AAC(S%) + 100! / FF ^ J > 100 THEN GOTO 18GOTO 19
18 UL(S%) = 100! - LL!(S%)
GOTO 20
19 UL(S%) = AAC(S%) + 100! / FF ^ J - LL!(S%)
20 XX(S%) = LL!(S%) + RND * UL(S%)
NEXT S%
'PRINT: PRINT " LIQUID COMPOSITIONS ON STAGES 3 - 1"
X(3, 1) = XX(6) / 100!
X(3, 2) = XX(5) / 100!: X(3, 3) = 1.0 - X(3, 1) - X(3, 2)
IF X(3, 3)
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
47/56
IF X(0, 2)
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
48/56
'PRINT : PRINT " CALC. LIQ. AND VAP. ENTHALPIES PER STAGE."
GOSUB ENTHALPY
GOSUB CONSTRAINT
IF G < OPT THEN GOTO 350
GOTO 450
350 OPT = G': PRINT: PRINT " NEW OPT= "; OPT; " I= "; I; " J=
"; J
'PRINT: PRINT " G= "; G; " I= "; I; " J= "; J; " OPT= "; OPT
'PRINT " OVERALL COUNT= "; COUNT&
'PRINT " G01= "; G01; " G02= "; G02; " G03= "; G03; " H0= ";
H0
'PRINT " G11= "; G11; " G12= "; G12; " G13= "; G13; " H1= ";
H1
'PRINT " G21= "; G21; " G22= "; G22; " G23= "; G23; " H2= ";
H2
'PRINT " G31= "; G31; " G32= "; G32; " G33= "; G33; " H3= ";H3
'PRINT " SUMY0= "; SUMY(0); " SUMY1= "; SUMY(1); " SUMY2=
";SUMY(2)
'PRINT " SUMY3= "; SUMY(3)
'PRINT " DELQ= "; DELQ ; " QQC= "; QQC
PRINT #1,: PRINT #1, " G= "; G;" I= "; I;" J= "; J;" NEW OPT=
";OPT
'PRINT #1, " OVERALL COUNT= "; COUNT&
'PRINT #1, " G01= "; G01; " G02= "; G02; " G03= "; G03; " H0=
"; H0
'PRINT #1, " G11= "; G11; " G12= "; G12; " G13= "; G13; " H1=
"; H1
'PRINT #1, " G21= "; G21; " G22= "; G22; " G23= "; G23; " H2=
"; H2
'PRINT #1, " G31= "; G31; " G32= "; G32; " G33= "; G33; " H3=
"; H3
'PRINT #1, " SUMY0= ";SUMY(0);" SUMY1= ";SUMY(1);" SUMY2=
";SUMY(2)
'PRINT #1, " SUMY3= ";SUMY(3)
'PRINT #1, " DELQ= "; DELQ; " QQC= "; QQC
'INPUT " PRESS ENTER TO CONTINUE", YES
'PRINT #1, " OVERALL COUNT= "; COUNT&
AAC(6) = X(3, 1) * 100!: AAC(5) = X(3, 2) * 100!AAC(4) = X(2, 1) * 100!: AAC(3) = X(2, 2) * 100!
AAC(2) = X(1, 1) * 100!: AAC(1) = X(1, 2) * 100!
X(3, 3) = 1.0 - X(3, 1) - X(3, 2)
X(2, 3) = 1.0 - X(2, 1) - X(2, 2)
X(1, 3) = 1.0 - X(1, 1) - X(1, 2)
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
49/56
'PRINT " STAGE= ";3;" X1= ";X(3,1);" X2= ";X(3,2);" X3=
";X(3,3)
'PRINT " STAGE= ";2;" X1= ";X(2,1);" X2= ";X(2,2);" X3=
";X(2,3)
'PRINT " STAGE= ";1;" X1= ";X(1,1);" X2= ";X(1,2);" X3=
";X(1,3)
'PRINT " STAGE= ";0;" X1= ";X(0,1);" X2= ";X(0,2);" X3=";X(0,3)
FOR S% = 1 TO 3
AAV(S%) = V(S%)': PRINT " V(S%)= "; V(S%)
NEXT S%
COUNTI% = COUNTI% + 1 ': PRINT: PRINT " COUNTI= "; COUNTI%
'INPUT " PRESS ENTER TO CONTINUE", YES
450 NEXT I
COUNTI% = 0
COUNTJ% = COUNTJ% + 1 ': PRINT: PRINT " COUNTJ= "; COUNTJ%
NEXT J
TFF# = TIMER
PRINT: PRINT " START TIME= "; TS#; " FINISH TIME= "; TFF#
PRINT #1, : PRINT #1, " START TIME= "; TS#; " FINISH TIME= ";TFF#
ELAPSE# = (TFF# - TS#): PRINT " ELAPSED TIME= "; ELAPSE#;" SEC."
PRINT #1, " ELAPSED TIME= "; ELAPSE#; " SECONDS"
INPUT " PRESS ENTER TO CONTINUE", YES
PRINT #1, " FINAL RESULTS"
PRINT " FINAL RESULTS"
X(0, 1)=X(0, 1): X(0, 2)=X(0, 2): X(0, 3)= X(0, 3)
X(1, 1)=AAC(2)/100.:X(1,2)=AAC(1)/100.:X(1,3)=(1.0-X(1,1)-X(1,2))
X(2, 1)=AAC(4)/100.:X(2,2)=AAC(3)/100.:X(2,3)=(1.0-X(2,1)-X(2,2))
X(3, 1)=AAC(6)/100.:X(3,2)=AAC(5)/100.:X(3,3)=(1.0-X(3,1)-X(3,2))
PRINT " STAGE= "; 3;" X1= ";X(3,1);" X2= ";X(3,2);" X3= ";X(3,3)
PRINT " STAGE= "; 2;" X1= ";X(2,1);" X2= ";X(2,2);" X3= ";X(2,3)
PRINT " STAGE= "; 1;" X1= ";X(1,1);" X2= ";X(1,2);" X3= ";X(1,3)
PRINT " STAGE= "; 0;" X1= ";X(0,1);" X2= ";X(0,2);" X3= ";X(0,3)
PRINT: PRINT " V(1)= "; AAV(1)
PRINT: PRINT " V(2)= "; AAV(2)
PRINT: PRINT " V(3)= "; AAV(3)
INPUT " PRESS ENTER TO CONTINUE", YES
PRINT: PRINT " T(0)= "; T(0)
PRINT: PRINT " T(1)= "; T(1)
PRINT: PRINT " T(2)= "; T(2)
PRINT: PRINT " T(3)= "; T(3)
PRINT: PRINT " T(4)= "; T(4)
PRINT: PRINT " L(0)= "; L!(0)
PRINT: PRINT " L(1)= "; L!(1)
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
50/56
PRINT: PRINT " L(2)= "; L!(2)
PRINT: PRINT " L(3)= "; L!(3)
PRINT: PRINT " REFLUX RATIO= "; RR
PRINT: PRINT " BOIL-UP RATIO= "; BR
INPUT " PRESS ENTER TO CONTINUE", YES
PRINT #1, " BOTTOM,STAGE= ";3;" X1= ";X(3,1);" X2= ";X(3,2);" X3=
";X(3,3)
PRINT #1, " STAGE= ";2;" X1= ";X(2,1);" X2= ";X(2,2);" X3=
";X(2,3)
PRINT #1, " STAGE= ";1;" X1= ";X(1,1);" X2= ";X(1,2);" X3=
";X(1,3)
PRINT #1, " COND., STAGE= ";0;" X1= ";X(0,1);" X2= ";X(0,2);" X3=
";X(0,3)
PRINT #1, : PRINT #1, " V(1)= "; AAV(1)
PRINT #1, : PRINT #1, " V(2)= "; AAV(2)
PRINT #1, : PRINT #1, " V(3)= "; AAV(3)
PRINT #1, : PRINT #1, " CONDENSER TEMP., T(0)= "; T(0)
PRINT #1, : PRINT #1, " T(1)= "; T(1)
PRINT #1, : PRINT #1, " T(2)= "; T(2)
PRINT #1, : PRINT #1, " T(3)= "; T(3)
PRINT #1, : PRINT #1, " FEED TEMP., T(4)= "; T(4)
PRINT #1, : PRINT #1, " REFLUX, L(0)= "; L!(0)
PRINT #1, : PRINT #1, " L(1)= "; L!(1)
PRINT #1, : PRINT #1, " L(2)= "; L!(2)
PRINT #1, : PRINT #1, " BOTTOMS,L(3)= "; L!(3)
PRINT #1, : PRINT #1, " REFLUX RATIO= "; RR
PRINT #1, : PRINT #1, " BOIL-UP RATIO="; BR
PRINT: PRINT " G= "; G; " I= "; I; " J= "; J; " OPT= "; OPT
PRINT " OVERALL COUNT= "; COUNT&
PRINT " G01= "; G01; " G02= "; G02; " G03= "; G03; " H0= "; H0
PRINT " G11= "; G11; " G12= "; G12; " G13= "; G13; " H1= "; H1
PRINT " G21= "; G21; " G22= "; G22; " G23= "; G23; " H2= "; H2
PRINT " G31= "; G31; " G32= "; G32; " G33= "; G33; " H3= "; H3
PRINT " SUMY0= "; SUMY(0); " SUMY1= "; SUMY(1); " SUMY2= "; SUMY(2)
PRINT " SUMY3= "; SUMY(3)
PRINT " DELQ= "; DELQ; " QQC= "; QQC
PRINT #1, : PRINT #1, " LAST OBJ. CALC., MAY NOT BE MIN.VALUE."PRINT #1, " G= "; G; " I= "; I; " J= "; J; " OPT= "; OPT
PRINT #1, " OVERALL COUNT= "; COUNT&
PRINT #1, " G01= "; G01; " G02= "; G02; " G03= "; G03; " H0= "; H0
PRINT #1, " G11= "; G11; " G12= "; G12; " G13= "; G13; " H1= "; H1
PRINT #1, " G21= "; G21; " G22= "; G22; " G23= "; G23; " H2= "; H2
PRINT #1, " G31= "; G31; " G32= "; G32; " G33= "; G33; " H3= "; H3
PRINT #1, " SUMY0= ";SUMY(0);" SUMY1= ";SUMY(1);" SUMY2= ";SUMY(2)
PRINT #1, " SUMY3= "; SUMY(3)
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
51/56
PRINT #1, " DELQ= "; DELQ; " QQC= "; QQC
PRINT #1, " OVERALL COUNT= "; COUNT&
995 INPUT " PRESS ENTER TO CONTINUE", YES
CLOSE #1
GOTO 999
1000 PRINT "**********"; CHR$(7)
PRINT " ERROR NUMBER "; ERR; " HAS OCCURRED ON LINE#= "; ERL
RESUME NEXT
999 END
BUBBLE:
TL = 64.5
TU = 100.T(S%) = (TL + TU) / 2
COUNTD% = 0: LMAX% = 1000
50 REM CHECK ITERATIONS VS LMAX%
IF COUNTD% > LMAX% THEN GOTO 60'INPUT "PRESS ENTER TO CONTINUE",YES
GOSUB NRTL
VP(S%, 1) = EXP(EA(1) - EB(1) / (T(S%) + 273.15 + EC(1)))
VP(S%, 2) = EXP(EA(2) - EB(2) / (T(S%) + 273.15 + EC(2)))
VP(S%, 3) = EXP(EA(3) - EB(3) / (T(S%) + 273.15 + EC(3)))
K!(S%, 1)=VP(S%, 1)/PT: K!(S%,2)=VP(S%,2)/PT: K!(S%,3)=VP(S%,3)/PT
PTT=GAM(S%,1)*X(S%,1)*VP(S%,1)+GAM(S%,2)*X(S%,2)*VP(S%,2)
PTT = PTT + GAM(S%,3)*X(S%,3)*VP(S%,3)
'PRINT " PTT= "; PTT; " T= "; T(S%)
DELP = ABS(PT - PTT)
IF DELP
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
52/56
RETURN
CONSTRAINT:
REM STAGE 0 (CONDENSER)
G0 = ABS(V(1) - D - L!(0))G01 = ABS(V(1) * Y(1, 1) - L!(0) * X(0, 1) - D * X(0, 1))
G02 = ABS(V(1) * Y(1, 2) - L!(0) * X(0, 2) - D * X(0, 2))
G03 = ABS(V(1) * Y(1, 3) - l!(0) * X(0, 3) - D * X(0, 3))
H0 = ABS(V(1) * SUMHV(1) - L!(0) * SUMHL(0) - D * SUMHL(0) - QC)
H0 = H0 / 1000
REM STAGE 1
G1 =ABS(L!(0) + V(2) - L!(1) - V(1)) 'OVERALL MOLE BALANCE
G11=ABS(-V(1) * Y(1,1)-L!(1) * X(1,1)+V(2) * Y(2,1)+L!(0) * X(0,1))
G12=ABS(-V(1) * Y(1,2)-L!(1) * X(1,2)+V(2) * Y(2,2)+L!(0) * X(0,2))
G13=ABS(-V(1) * Y(1,3)-L!(1) * X(1,3)+V(2) * Y(2,3)+L!(0) * X(0,3))
SUMY(1) = Y(1, 1) + Y(1, 2) + Y(1, 3)SUMY(1) = ABS(1. - SUMY(1))
H1=ABS(-V(1)*SUMHV(1)+V(2)*SUMHV(2)-L!(1)*SUMHL(1)+L!(0)*SUMHL(0))
H1 = H1 / 1000
REM STAGE 2
G2 = ABS(L!(1) + F + V(3) - L!(2) - V(2))
G21=ABS(L!(1)*X(1,1)-V(2)*Y(2,1)-L!(2)*X(2,1)+V(3)*Y(3,1)+ZF(1)*F)
G22=ABS(L!(1)*X(1,2)-V(2)*Y(2,2)-L!(2)*X(2,2)+V(3)*Y(3,2)+ZF(2)*F)
G23=ABS(L!(1)*X(1,3)-V(2)*Y(2,3)-L!(2)*X(2,3)+V(3)*Y(3,3)+ZF(3)*F)
SUMY(2) = Y(2, 1) + Y(2, 2) + Y(2,3)
SUMY(2) = ABS(1. - SUMY(2))
H2=ABS(-V(2)*SUMHV(2)+V(3)*SUMHV(3)+SUMHL(4)*F+L!(1)*SUMHL(1)-
L!(2)*SUMHL(2))
H2 = H2 / 1000
REM STAGE 3
G3 = ABS(L!(2) - L!(3) - V(3))
G31 = ABS(L!(2) * X(2, 1) - V(3) * Y(3, 1) - BTMS * X(3, 1))
G32 = ABS(L!(2) * X(2, 2) - V(3) * Y(3, 2) - BTMS * X(3, 2))
G33 = ABS(L!(2) * X(2, 3) - V(3) * Y(3, 3) - BTMS * X(3, 3))
SUMY(3) = Y(3, 1) + Y(3, 2) + Y(3, 3)
SUMY(3) = ABS(1. - SUMY(3))
H3 = ABS(-V(3) * SUMHV(3) + QR + L!(2) * SUMHL(2) - L!(3) * SUMHL(3))
H3 = H3 / 1000
GOSUB ENERGY
100 G = G01 + G02 + G03 + G11 + G12 + G13 + G21 + G22 + G23 + G31 +
G32 + G33
G = G + H0 + H1 + H2 + H3 + SUMY(0) + SUMY(1) + SUMY(2) + SUMY(3) +
DELQ
G = G + G0 + G1 + G2 + G3
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
53/56
'PRINT: PRINT " G= "; G; " I= "; I; " J= "; J; " OPT= "; OPT
'PRINT " OVERALL COUNT= "; COUNT&
'PRINT " G0= "; G0; " G1= "; G1; " G2= "; G2; " G3= "; G3
'PRINT " G01= "; G01; " G02= "; G02; " G03= "; G03; " H0= "; H0
'PRINT " G11= "; G11; " G12= "; G12; " G13= "; G13; " H1= "; H1
'PRINT " G21= "; G21; " G22= "; G22; " G23= "; G23; " H2= "; H2
'PRINT " G31= "; G31; " G32= "; G32; " G33= "; G33; " H3= "; H3'PRINT " SUMY0= "; SUMY(0);" SUMY1= "; SUMY(1); " SUMY2= "; SUMY(2)
'PRINT " SUMY3= "; SUMY(3)
'PRINT " DELQ= "; DELQ; " QQC= "; QQC
'PRINT #1,: PRINT #1, " G= "; G; " I= "; I; " J= "; J; " OPT= "; OPT
'PRINT #1, " OVERALL COUNT= "; COUNT&
'PRINT #1, " G0= "; G0; " G1= "; G1; " G2= "; G2; " G3= "; G3
'PRINT #1, " G01= "; G01; " G02= "; G02; " G03= "; G03; " H0= "; H0
'PRINT #1, " G11= "; G11; " G12= "; G12; " G13= "; G13; " H1= "; H1
'PRINT #1, " G21= "; G21; " G22= "; G22; " G23= "; G23; " H2= "; H2
'PRINT #1, " G31= "; G31; " G32= "; G32; " G33= "; G33; " H3= "; H3
'PRINT #1, " SUMY0= ";SUMY(0);" SUMY1= ";SUMY(1);" SUMY2= ";SUMY(2)
'PRINT " SUMY3= "; SUMY(3)'PRINT #1, " DELQ= "; DELQ; " QQC= "; QQC
'INPUT " PRESS ENTER TO CONTINUE", YES
RETURN
ENERGY:
'PRINT: PRINT " TEST OVERALL ENERGY BALANCE"
'PRINT " QF + QR = QD + QBTMS + QC "
'PRINT #1,: PRINT #1, " TEST OVERALL ENERGY BALANCE"
'PRINT #1, " QF + QR = QD + QBTMS + QC "
QD = D * SUMHL(0): QBTMS = BTMS * SUMHL(3): QF = F * SUMHL(4)
QR = 3439381
'PRINT " QD= "; QD; " QBTMS= "; QBTMS; " QF= "; QF; " QR= "; QR
'PRINT #1, " QD= ";QD; " QBTMS= ";QBTMS; " QF= ";QF; " QR= ";QR
DELQ = ABS((QF - QBTMS - QD) / QR)
'PRINT " DELQ= "; DELQ
'PRINT #1,: PRINT #1, " DELQ= "; DELQ
QQC = QF + QR - QD - QBTMS
'PRINT " QQC= "; QQC: PRINT #1, " QQC= "; QQC
BR = V(3) / BTMS
RR = L!(0) / D
'PRINT " BR= ";BR;" RR= ";RR;: PRINT #1, " BR= ";BR;" RR= ";RR
'PRINT " QQC= "; QQC
'INPUT " PRESS ENTER TO CONTINUE", YES
RETURN
WILSON:
'PRINT:PRINT " CALCULATE WILSON ACTIVITY COEFFS. FOR STAGE= ";S%"
VW = 18.07: VM = 40.73: VI = 76.92 'CM^3/MOL
W(1, 1) = 1: W(2, 2) = 1: W(3, 3) = 1
W(1, 2) = 1.03116: W(2, 1) = 1.08036
W(1, 3) = 0.60703: W(3, 1) = 0.92588
W(2, 3) = 0.1258: W(3, 2) = 0.7292
-
8/20/2019 Monte Carlo Marching Distillation: Simultaneous solution of the MESH equations with no derivatives, no initial valu…
54/56
FOR KK% = 1 TO N%
Q1 = 0
FOR C% = 1 TO N%
Q1 = Q1 + X(S%, C%) * W(KK%, C%)
NEXT C%
Q2 = 0FOR II% = 1 TO N%
Q3 = 0
FOR C% = 1 TO N%
Q3 = Q3 + X(S%, C%) * W(II%, C%)
NEXT C%
Q2 = Q2 + (X(S%, II%) * W(II%, KK%)) / Q3
NEXT II%
GAM(S%, KK%) = EXP(1. - LOG(Q1) - Q2)
'PRINT: PRINT " S= "; S%; " KK= "; KK%
'PRINT " GAM(S%, KK)= "; GAM(S%, KK%)
NEXT KK%
'INPUT " PRESS ENTER TO CONTINUE", YESRETURN
ENTHALPY:
FOR S% = 0 TO 4
SUMHL(S%) = 0: SUMHV(S%) = 0
FOR II% = 1 TO N%
HL(S%,II%)=(AA(II%)*T(S%))+((BB(II%)/2.0)*(T(S%)^2))+((CC(II%)/3.0)*(T
(S%)^3))
HL(S%, II%) = HL(S%, II%) * H * MW(II%) 'CAL/MOLE
SUMHL(S%) = SUMHL(S%) + HL(S%, II%) * X(S%, II%)
IF S% = 0 THEN GOTO 77
IF S% = 4 THEN GOTO 77
HV(S%, II%) = AAA(II%) + BBB(II%) * T(S%)